Chinaunix首页 | 论坛 | 博客
  • 博客访问: 96785
  • 博文数量: 20
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 202
  • 用 户 组: 普通用户
  • 注册时间: 2013-09-07 01:56
个人简介

数据库技术爱好者

文章分类

全部博文(20)

文章存档

2016年(11)

2015年(9)

我的朋友

分类: Oracle

2016-10-23 22:12:07

1.prepare

点击(此处)折叠或打开

  1. [oracle@master ~]$ cat par.txt
  2. blocksize=8192
  3. listfile=filelist.txt
  4. mode=edit
  5. [oracle@master ~]$ cat filelist.txt
  6. 1 /u01/oracle/oradata/edus/system01.dbf 1121976320
  7. 2 /u01/oracle/oradata/edus/sysaux01.dbf 1698693120
  8. 3 /u01/oracle/oradata/edus/undotbs01.dbf 1048576000
  9. 4 /u01/oracle/oradata/edus/users01.dbf 5242880
  10. 5 /u01/oracle/oradata/edus/edus01.dbf 532283392
  11. [oracle@master ~]$ bbed parfile=par.txt
  12. Password:
  13. BBED: Release 2.0.0.0.0 - Limited Production on Sun Oct 23 07:09:40 2016
  14. Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.
  15. ************* !!! For Oracle Internal Use only !!! ***************

2.利用BBED查看第1号文第520块,bootstrap$段头块内容

点击(此处)折叠或打开

  1. BBED> show all
  2. FILE# 1
  3. BLOCK# 520
  4. OFFSET 20
  5. DBA 0x00400208 (4194824 1,520)
  6. FILENAME /u01/oracle/oradata/edus/system01.dbf
  7. BIFILE bifile.bbd
  8. LISTFILE filelist.txt
  9. BLOCKSIZE 8192
  10. MODE Edit
  11. EDIT Unrecoverable
  12. IBASE Dec
  13. OBASE Dec
  14. WIDTH 80
  15. COUNT 512
  16. LOGFILE log.bbd
  17. SPOOL No
  18. BBED> map /v
  19. File: /u01/oracle/oradata/edus/system01.dbf (1)
  20. Block: 520 Dba:0x00400208
  21. ------------------------------------------------------------
  22. Unlimited Data Segment Header
  23. struct kcbh, 20 bytes @0
  24. ub1 type_kcbh @0
  25. ub1 frmt_kcbh @1
  26. ub1 spare1_kcbh @2
  27. ub1 spare2_kcbh @3
  28. ub4 rdba_kcbh @4
  29. ub4 bas_kcbh @8
  30. ub2 wrp_kcbh @12
  31. ub1 seq_kcbh @14
  32. ub1 flg_kcbh @15
  33. ub2 chkval_kcbh @16
  34. ub2 spare3_kcbh @18
  35. struct ktech, 72 bytes @20
  36. ub4 spare1_ktech @20
  37. sword tsn_ktech @24
  38. ub4 lastmap_ktech @28
  39. ub4 mapcount_ktech @32
  40. ub4 extents_ktech @36
  41. ub4 blocks_ktech @40
  42. ub2 mapend_ktech @44
  43. struct hwmark_ktech, 32 bytes @48
  44. struct locker_ktech, 8 bytes @80
  45. ub4 flag_ktech @88
  46. struct ktemh, 16 bytes @92
  47. ub4 count_ktemh @92
  48. ub4 next_ktemh @96
  49. ub4 obj_ktemh @100
  50. ub4 flag_ktemh @104
  51. struct ktetb[1], 8 bytes @108
  52. ub4 ktetbdba @108
  53. ub4 ktetbnbk @112
  54. struct ktshc, 8 bytes @4148
  55. ub2 ktshcnxf @4148
  56. ub2 ktshcnfl @4150
  57. ub2 ktshcnfb @4152
  58. ub1 ktshctyp @4154
  59. struct ktsfs_seg[1], 20 bytes @4156
  60. ub2 ktsfsflg @4156
  61. struct ktsfsxid, 8 bytes @4160
  62. ub4 ktsfslhd @4168
  63. ub4 ktsfsltl @4172
  64. struct ktsfs_txn[16], 320 bytes @4176
  65. ub2 ktsfsflg @4176
  66. struct ktsfsxid, 8 bytes @4180
  67. ub4 ktsfslhd @4188
  68. ub4 ktsfsltl @4192
  69. ub4 tailchk @8188
  70. BBED> p ktech
  71. struct ktech, 72 bytes @20
  72. ub4 spare1_ktech @20 0x00000000
  73. sword tsn_ktech @24 0
  74. ub4 lastmap_ktech @28 0x00000000
  75. ub4 mapcount_ktech @32 0x00000000
  76. ub4 extents_ktech @36 0x00000001
  77. ub4 blocks_ktech @40 0x00000007
  78. ub2 mapend_ktech @44 0x1020
  79. struct hwmark_ktech, 32 bytes @48
  80. ub4 extno_ktehw @48 0x00000000
  81. ub4 blkno_ktehw @52 0x00000003
  82. ub4 extsize_ktehw @56 0x00000007
  83. ub4 blkaddr_ktehw @60 0x0040020c
  84. ub4 mapblk_ktehw @64 0x00000000
  85. ub4 offset_ktehw @68 0x00000000
  86. ub4 flblks_ktehw @72 0x00000001
  87. ub4 blkcnt_ktehw @76 0x00000003
  88. struct locker_ktech, 8 bytes @80
  89. ub2 kxidusn @80 0x0000
  90. ub2 kxidslt @82 0x0000
  91. ub4 kxidsqn @84 0x00000000
  92. ub4 flag_ktech @88 0x00000000 (NONE)
  93. BBED> set file 1 block 521;
  94. FILE# 1
  95. BLOCK# 521
  96. BBED> map /v
  97. File: /u01/oracle/oradata/edus/system01.dbf (1)
  98. Block: 521 Dba:0x00400209
  99. ------------------------------------------------------------
  100. KTB Data Block (Table/Cluster)
  101. struct kcbh, 20 bytes @0
  102. ub1 type_kcbh @0
  103. ub1 frmt_kcbh @1
  104. ub1 spare1_kcbh @2
  105. ub1 spare2_kcbh @3
  106. ub4 rdba_kcbh @4
  107. ub4 bas_kcbh @8
  108. ub2 wrp_kcbh @12
  109. ub1 seq_kcbh @14
  110. ub1 flg_kcbh @15
  111. ub2 chkval_kcbh @16
  112. ub2 spare3_kcbh @18
  113. struct ktbbh, 48 bytes @20
  114. ub1 ktbbhtyp @20
  115. union ktbbhsid, 4 bytes @24
  116. struct ktbbhcsc, 8 bytes @28
  117. sb2 ktbbhict @36
  118. ub1 ktbbhflg @38
  119. ub1 ktbbhfsl @39
  120. ub4 ktbbhfnx @40
  121. struct ktbbhitl[1], 24 bytes @44
  122. struct kdbh, 14 bytes @68
  123. ub1 kdbhflag @68
  124. sb1 kdbhntab @69
  125. sb2 kdbhnrow @70
  126. sb2 kdbhfrre @72
  127. sb2 kdbhfsbo @74
  128. sb2 kdbhfseo @76
  129. sb2 kdbhavsp @78
  130. sb2 kdbhtosp @80
  131. struct kdbt[1], 4 bytes @82
  132. sb2 kdbtoffs @82
  133. sb2 kdbtnrow @84
  134. sb2 kdbr[24] @86
  135. ub1 freespace[1156] @134
  136. ub1 rowdata[6898] @1290
  137. ub4 tailchk @8188
  138. BBED> p kdbr
  139. sb2 kdbr[0] @86 8099
  140. sb2 kdbr[1] @88 7962
  141. sb2 kdbr[2] @90 7573
  142. sb2 kdbr[3] @92 7373
  143. sb2 kdbr[4] @94 6990
  144. sb2 kdbr[5] @96 6778
  145. sb2 kdbr[6] @98 6573
  146. sb2 kdbr[7] @100 5961
  147. sb2 kdbr[8] @102 5755
  148. sb2 kdbr[9] @104 5555
  149. sb2 kdbr[10] @106 5334
  150. sb2 kdbr[11] @108 5130
  151. sb2 kdbr[12] @110 4847
  152. sb2 kdbr[13] @112 4613
  153. sb2 kdbr[14] @114 4366
  154. sb2 kdbr[15] @116 3896
  155. sb2 kdbr[16] @118 3688
  156. sb2 kdbr[17] @120 3473
  157. sb2 kdbr[18] @122 3193
  158. sb2 kdbr[19] @124 2409
  159. sb2 kdbr[20] @126 2204
  160. sb2 kdbr[21] @128 1630
  161. sb2 kdbr[22] @130 1421
  162. sb2 kdbr[23] @132 1222
  163. BBED> p *kdbr[0]
  164. rowdata[6877]
  165. -------------
  166. ub1 rowdata[6877] @8167 0x2c
  167. BBED> x /rnnccccccccccccccccccccccccccc
  168. rowdata[6877] @8167
  169. -------------
  170. flag@8167: 0x2c (KDRHFL, KDRHFF, KDRHFH)
  171. lock@8168: 0x01
  172. cols@8169: 3
  173. col 0[3] @8170: -1
  174. col 1[3] @8174: -1
  175. col 2[9] @8178: 8.0.0.0.0
  176. BBED> p *kdbr[1]
  177. rowdata[6740]
  178. -------------
  179. ub1 rowdata[6740] @8030 0x2c
  180. BBED> x /rnnccccccccccccccccccccccccccc
  181. rowdata[6740] @8030
  182. -------------
  183. flag@8030: 0x2c (KDRHFL, KDRHFF, KDRHFH)
  184. lock@8031: 0x01
  185. cols@8032: 3
  186. col 0[1] @8033: 0
  187. col 1[1] @8035: 0
  188. col 2[129] @8037: CREATE ROLLBACK SEGMENT SYSTEM STORAGE ( INITIAL 112K
  189. NEXT 56K MINEXTENTS 1 MAXEXTENTS 32765 OBJNO 0 EXTENTS (FILE 1 BLOCK 128))

3.例子:直接操作数据块,模拟数据块损坏

点击(此处)折叠或打开

  1. BBED> set file 1 block 520;
  2. FILE# 1
  3. BLOCK# 520
  4. BBED> show all;
  5. FILE# 1
  6. BLOCK# 520
  7. OFFSET 0
  8. DBA 0x00400208 (4194824 1,520)
  9. FILENAME /u01/oracle/oradata/edus/system01.dbf
  10. BIFILE bifile.bbd
  11. LISTFILE filelist.txt
  12. BLOCKSIZE 8192
  13. MODE Edit
  14. EDIT Unrecoverable
  15. IBASE Dec
  16. OBASE Dec
  17. WIDTH 80
  18. COUNT 512
  19. LOGFILE log.bbd
  20. SPOOL No
  21. BBED> copy file 2 block 20 to file 1 block 520;
  22. File: /u01/oracle/oradata/edus/system01.dbf (1)
  23. Block: 520 Offsets: 0 to 511 Dba:0x00400208
  24. ------------------------------------------------------------------------
  25. 1ea20000 14008000 81080000 00000104 8b800000 02000000 80c08300 00000000
  26. 00000000 00f80000 00000000 00000000 00000000 00000000 00000000 00000000
  27. 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
  28. 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
  29. 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
  30. 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
  31. 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
  32. 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
  33. 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
  34. 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
  35. 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
  36. 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
  37. 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
  38. 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
  39. 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
  40. 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
  41. <32 bytes per line>
  42. 关闭数据库后,重新启动数据库,报错了
  43. SQL> shutdown
  44. Database closed.
  45. Database dismounted.
  46. ORACLE instance shut down.
  47. SQL> startup
  48. ORACLE instance started.
  49. Total System Global Area 1043886080 bytes
  50. Fixed Size 2219952 bytes
  51. Variable Size 788529232 bytes
  52. Database Buffers 247463936 bytes
  53. Redo Buffers 5672960 bytes
  54. Database mounted.
  55. ORA-01092: ORACLE instance terminated. Disconnection forced
  56. ORA-00704: bootstrap process failure
  57. ORA-01578: ORACLE data block corrupted (file # 1, block # 520)
  58. ORA-01110: data file 1: '/u01/oracle/oradata/edus/system01.dbf'
  59. Process ID: 5493
  60. Session ID: 1512 Serial number: 5
  61. SQL> shutdown abort
  62. ORA-24324: service handle not initialized
  63. ORA-01041: internal error. hostdef extension doesn't exist
  64. SQL> exit
  65. Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
  66. With the Partitioning, OLAP, Data Mining and Real Application Testing options
  67. [oracle@master ~]$ sq
  68. SQL*Plus: Release 11.2.0.1.0 Production on Sun Oct 23 07:00:45 2016
  69. Copyright (c) 1982, 2009, Oracle. All rights reserved.
  70. Connected to an idle instance.
  71. SQL> alter database mount;
  72. alter database mount
  73. *
  74. ERROR at line 1:
  75. ORA-01034: ORACLE not available
  76. Process ID: 0
  77. Session ID: 0 Serial number: 0
  78. SQL> exit
  79. Disconnected
  80. [oracle@master ~]$ sq
  81. SQL*Plus: Release 11.2.0.1.0 Production on Sun Oct 23 07:00:58 2016
  82. Copyright (c) 1982, 2009, Oracle. All rights reserved.
  83. Connected to an idle instance.
  84. SQL> startup nomount; //之所以重新关闭启,在于RMAN RESTORE DATAFILE 分配CHANNEL报错
  85. ORACLE instance started.
  86. Total System Global Area 1043886080 bytes
  87. Fixed Size 2219952 bytes
  88. Variable Size 788529232 bytes
  89. Database Buffers 247463936 bytes
  90. Redo Buffers 5672960 bytes
  91. SQL> alter database mount;
  92. Database altered.
  93. RMAN恢复
  94. RMAN> restore datafile 1;
  95. Starting restore at 23-OCT-16
  96. released channel: ORA_DISK_1
  97. allocated channel: ORA_DISK_1
  98. channel ORA_DISK_1: SID=10 device type=DISK
  99. channel ORA_DISK_1: starting datafile backup set restore
  100. channel ORA_DISK_1: specifying datafile(s) to restore from backup set
  101. channel ORA_DISK_1: restoring datafile 00001 to /u01/oracle/oradata/edus/system01.dbf
  102. channel ORA_DISK_1: reading from backup piece /oraBackup/backupSet/EDUS/backupset/2016_10_23/o1_mf_nnndf_TAG20161023T063316_d0sh0x81_.bkp
  103. channel ORA_DISK_1: piece handle=/oraBackup/backupSet/EDUS/backupset/2016_10_23/o1_mf_nnndf_TAG20161023T063316_d0sh0x81_.bkp tag=TAG20161023T063316
  104. channel ORA_DISK_1: restored backup piece 1
  105. channel ORA_DISK_1: restore complete, elapsed time: 00:03:07
  106. Finished restore at 23-OCT-16
  107. RMAN> recover database;
  108. Starting recover at 23-OCT-16
  109. using channel ORA_DISK_1
  110. starting media recovery
  111. media recovery complete, elapsed time: 00:00:03
  112. Finished recover at 23-OCT-16
  113. 打开数据库:
  114. SQL> alter database open;
  115. Database altered.




阅读(1912) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~