linux命令的oracle运用(一) .

1 dd

    模拟物理坏块


  1. <SPAN xmlns="http://www.w3.org/1999/xhtml">SQL> select * from v$database_block_corruption;  
  2.   
  3. no rows selected  
  4.   
  5. SQL> select * from v$backup_corruption;  
  6.   
  7. no rows selected  
  8.   
  9. SQL> select * from v$copy_corruption;  
  10.   
  11. no rows selected  
  12.   
  13. SQL> create tablespace physical_corrupt datafile size 10m autoextend on;  
  14.   
  15. Tablespace created.  
  16.   
  17. SQL> conn hr/hr  
  18. Connected.  
  19. SQL> create table tt (i int)  tablespace physical_corrupt;  
  20.   
  21. Table created.  
  22. SQL> insert into tt values(1);  
  23.   
  24. 1 row created.  
  25.   
  26. SQL> insert into tt values(2);  
  27.   
  28. 1 row created.  
  29.   
  30. SQL> commit;  
  31.   
  32. Commit complete.  
  33. SQL> select tt.*,dbms_rowid.rowid_block_number(rowid) from tt;  
  34.   
  35.      I DBMS_ROWID.ROWID_BLOCK_NUMBER(ROWID)  
  36. ---------- ------------------------------------   
  37.      1                   15  
  38.      2                   15  
  39.   
  40. SQL> select tablespace_name,file_name from dba_data_files where tablespace_name='PHYSICAL_CORRUPT';  
  41.   
  42. TABLESPACE_NAME  
  43. ------------------------------   
  44. FILE_NAME  
  45. --------------------------------------------------------------------------------   
  46. PHYSICAL_CORRUPT  
  47. /u01/app/oracle/oradata/ORCL/datafile/o1_mf_physical_88gkb4l9_.dbf  
  48.   
  49. [oracle@Think ~]$ dd of=/u01/app/oracle/oradata/ORCL/datafile/o1_mf_physical_88gkb4l9_.dbf bs=8192 conv=notrunc seek=15 <<!  
  50. > my name is think  
  51. > !  
  52. 0+1 records in  
  53. 0+1 records out  
  54. 17 bytes (17 B) copied, 9.9193e-05 s, 171 kB/s  
  55.   
  56. 用rman向oracle注册,报告填充v$database_block_corruption  
  57. RMAN> backup validate tablespace physical_corrupt;  
  58.   
  59. Starting backup at 24-OCT-12  
  60. using target database control file instead of recovery catalog  
  61. allocated channel: ORA_DISK_1  
  62. channel ORA_DISK_1: sid=140 devtype=DISK  
  63. channel ORA_DISK_1: starting full datafile backupset  
  64. channel ORA_DISK_1: specifying datafile(s) in backupset  
  65. input datafile fno=00006 name=/u01/app/oracle/oradata/ORCL/datafile/o1_mf_physical_88gkb4l9_.dbf  
  66. channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01  
  67. Finished backup at 24-OCT-12  
  68.   
  69. SQL> select * from v$database_block_corruption;  
  70.   
  71.      FILE#     BLOCK#     BLOCKS CORRUPTION_CHANGE# CORRUPTIO  
  72. ---------- ---------- ---------- ------------------ ---------   
  73.      6     15          1          0 CORRUPT  
  74.   
  75. SQL> select * from tt;  
  76. select * from tt  
  77. *  
  78. ERROR at line 1:  
  79. ORA-01578: ORACLE data block corrupted (file # 6, block # 15)  
  80. ORA-01110: data file 6:  
  81. '/u01/app/oracle/oradata/ORCL/datafile/o1_mf_physical_88gkb4l9_.dbf'</SPAN>  
SQL> 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分别表示附加、删除和修改操作。
       以”<”打头的行属于第一个文件,以”>”打头的行属于第二个文件。
       例如:

  1. <SPAN xmlns="http://www.w3.org/1999/xhtml">[oracle@Think udump]$ diff orcl_ora_18900.trc orcl_ora_19032.trc  
  2. 1c1  
  3. < /u01/app/oracle/admin/orcl/udump/orcl_ora_18900.trc  
  4. ---  
  5. > /u01/app/oracle/admin/orcl/udump/orcl_ora_19032.trc  
  6. 11,13c11,13  
  7. < Redo thread mounted by this instance: 0 <none>  
  8. < Oracle process number: 0  
  9. < Unix process pid: 18900, image: oracle@Think  
  10. ---  
  11. > Redo thread mounted by this instance: 1  
  12. > Oracle process number: 17  
  13. > Unix process pid: 19032, image: oracle@Think (TNS V1-V3)  
  14. 15,17c15,19  
  15. < KCCDEBUG_LEVEL = 0  
  16. < Dynamic strand is set to TRUE  
  17. < Running with 2 shared and 18 private strand(s). Zero-copy redo is FALSE  
  18. ---  
  19. > *** 2012-10-23 20:37:12.033  
  20. > *** SERVICE NAME:(SYS$USERS) 2012-10-23 20:37:12.033  
  21. > *** SESSION ID:(155.108) 2012-10-23 20:37:12.033  
  22. > kwqalqt2: Warning !! queue table IX.ORDERS_QUEUETABLE exits, entry in system.aq$_queue_tables missing   
  23. > kwqalqt2: Warning !! queue table IX.STREAMS_QUEUE_TABLE exits, entry in system.aq$_queue_tables missing </SPAN>  
[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 <none>
< 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
       文件最尾部的内容显示在屏幕上,并且不断刷新,是你看到最新的内容。

转自: http://blog.csdn.net/linwaterbin/article/details/8102333
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值