歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
您现在的位置: Linux教程網 >> UnixLinux >  >> Unix知識 >> 關於Unix

linux命令的oracle運用

1 dd 模擬物理壞塊 [sql] view plaincopySQL> select * from v$database_block_corruption; no rows selected

  1 dd

  模擬物理壞塊

  [sql] view plaincopySQL> select * from v$database_block_corruption;

  no rows selected

  SQL> select * from v$backup_corruption;

  no rows selected

  SQL> select * from v$copy_corruption;

  no rows selected

  SQL> create tablespace physical_corrupt datafile size 10m autoextend on;

  Tablespace created.

  SQL> conn hr/hr

  Connected.

  SQL> create table tt (i int) tablespace physical_corrupt;

  Table created.

  SQL> insert into tt values(1);

  1 row created.

  SQL> insert into tt values(2);

  1 row created.

  SQL> commit;

  Commit complete.

  SQL> select tt.*,dbms_rowid.rowid_block_number(rowid) from tt;

  I DBMS_ROWID.ROWID_BLOCK_NUMBER(ROWID)

  ---------- ------------------------------------

  1 15

  2 15

  SQL> select tablespace_name,file_name from dba_data_files where tablespace_name='PHYSICAL_CORRUPT';

  TABLESPACE_NAME

  ------------------------------

  FILE_NAME

  --------------------------------------------------------------------------------

  PHYSICAL_CORRUPT

  /u01/app/oracle/oradata/ORCL/datafile/o1_mf_physical_88gkb4l9_.dbf

  [oracle@Think ~]$ dd of=/u01/app/oracle/oradata/ORCL/datafile/o1_mf_physical_88gkb4l9_.dbf bs=8192 conv=notrunc seek=15 <

  > my name is think

  > !

  0+1 records in

  0+1 records out

  17 bytes (17 B) copied, 9.9193e-05 s, 171 kB/s

  用rman向oracle注冊,報告填充v$database_block_corruption

  RMAN> backup validate tablespace physical_corrupt;

  Starting backup at 24-OCT-12

  using target database control file instead of recovery catalog

  allocated channel: ORA_DISK_1

  channel ORA_DISK_1: sid=140 devtype=DISK

  channel ORA_DISK_1: starting full datafile backupset

  channel ORA_DISK_1: specifying datafile(s) in backupset

  input datafile fno=00006 name=/u01/app/oracle/oradata/ORCL/datafile/o1_mf_physical_88gkb4l9_.dbf

  channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01

  Finished backup at 24-OCT-12

  SQL> select * from v$database_block_corruption;

  FILE# BLOCK# BLOCKS CORRUPTION_CHANGE# CORRUPTIO

  ---------- ---------- ---------- ------------------ ---------

  6 15 1 0 CORRUPT

  SQL> select * from tt;

  select * from tt

  *

  ERROR at line 1:

  ORA-01578: ORACLE data block corrupted (file # 6, block # 15)

  ORA-01110: data file 6:

  '/u01/app/oracle/oradata/ORCL/datafile/o1_mf_physical_88gkb4l9_.dbf'

  2 diff

  逐行比較兩個文本文件,列出差異行

  通常的輸出格式:

  n1 a n2

  n1 c n2

  n1 d n2

  字母(a、d和c)之前的行號(n1)是針對file1的,其後面的行號(n2)是針對file2的。

  字母a、d和c分別表示附加、刪除和修改操作。

  以”<”打頭的行屬於第一個文件,以”>”打頭的行屬於第二個文件。

  例如:

  [plain] view plaincopy[oracle@Think udump]$ diff orcl_ora_18900.trc orcl_ora_19032.trc

  1c1

  < /u01/app/oracle/admin/orcl/udump/orcl_ora_18900.trc

  ---

  > /u01/app/oracle/admin/orcl/udump/orcl_ora_19032.trc

  11,13c11,13

  < Redo thread mounted by this instance: 0

  < Oracle process number: 0

  < Unix process pid: 18900, image: oracle@Think

  ---

  > Redo thread mounted by this instance: 1

  > Oracle process number: 17

  > Unix process pid: 19032, image: oracle@Think (TNS V1-V3)

  15,17c15,19

  < KCCDEBUG_LEVEL = 0

  < Dynamic strand is set to TRUE

  < Running with 2 shared and 18 private strand(s). Zero-copy redo is FALSE

  ---

  > *** 2012-10-23 20:37:12.033

  > *** SERVICE NAME:(SYS$USERS) 2012-10-23 20:37:12.033

  > *** SESSION ID:(155.108) 2012-10-23 20:37:12.033

  > kwqalqt2: Warning !! queue table IX.ORDERS_QUEUETABLE exits, entry in system.aq$_queue_tables missing

  > kwqalqt2: Warning !! queue table IX.STREAMS_QUEUE_TABLE exits, entry in system.aq$_queue_tables missing

  3 watch

  監測一個命令的運行結果,並且動態刷新

  -n:指定時間間隔,缺省是2秒

  -d:高亮顯示變化的區域

ctrl+c退出 例如: [oracle@Think udump]$ watch -n 1 -d du -sh /u01/app/oracle/admin 4 tail tail -f filename 文件最尾部的內容顯示在屏幕上,並且不斷刷新,是你看到最新的內

  ctrl+c退出

  例如:

  [oracle@Think udump]$ watch -n 1 -d du -sh /u01/app/oracle/admin

  4 tail

  tail -f filename

  文件最尾部的內容顯示在屏幕上,並且不斷刷新,是你看到最新的內容。

  未完待續......

Copyright © Linux教程網 All Rights Reserved