hcwzwx 发表于 2018-9-14 06:07:27

linux命令的oracle运用(一)

  1 dd
  模拟物理坏块
  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>  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
  $ dd of=/u01/app/oracle/oradata/ORCL/datafile/o1_mf_physical_88gkb4l9_.dbf bs=8192 conv=notrunc seek=15!
  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分别表示附加、删除和修改操作。
  以””打头的行属于第二个文件。
  例如:
  $ 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>  > 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退出
  例如:
  $ watch -n 1 -d du -sh /u01/app/oracle/admin
  4 tail
  tail -f filename
  文件最尾部的内容显示在屏幕上,并且不断刷新,是你看到最新的内容。
  oracle视频教程请关注:http://u.youku.com/user_video/id_UMzAzMjkxMjE2.html

页: [1]
查看完整版本: linux命令的oracle运用(一)