码迷,mamicode.com
首页 > 其他好文 > 详细

分享:bbed修改数据文件头推进scn与其他数据文件相同

时间:2015-06-18 17:30:22      阅读:113      评论:0      收藏:0      [点我收藏+]

标签:

场景简介:

         物理copy表空间数据文件,数据库发生完全检查点,删除该表空间下的数据文件,使该表空间数据文件头的scn与其他数据文件不一致。

场景构造:

1、  创建测试表空间

SYS@orser> create tablespace bbed datafile ‘/u01/app/oracle/oradata/orser/bbed01.dbf‘ size 10M autoextend on;

 

Tablespace created

2、  物理cp数据文件(最好先做备份)

[oracle@orser orser]$ cp bbed01.dbf bbed01.dbf.bak

3、  数据库发生检查点这

SYS@orser> alter system checkpoint;

 

System altered.

4、  删除数据文件

[oracle@orser orser]$ rm -rf bbed01.dbf

5、  cp之间备份的数据文件

[oracle@orser orser]$ cp bbed01.dbf.bak bbed01.dbf

6、  一致性关闭数据库报错

SYS@orser> shutdown immediate

ORA-01122: database file 7 failed verification check

ORA-01110: data file 7: ‘/u01/app/oracle/oradata/orser/bbed01.dbf‘

ORA-01208: data file is an old version - not accessing current version

解决方案:

         查询各个数据文件头scn,该数据文件头scn会低于其他数据文件scn,使用bbed修改数据文件头中的scn使该文件头scn与其他文件相同。

解决方法:

1、  数据库启动到mount状态

SYS@orser> startup mount

ORACLE instance started.

 

Total System Global Area  640286720 bytes

Fixed Size                  1346840 bytes

Variable Size             566231784 bytes

Database Buffers           67108864 bytes

Redo Buffers                5599232 bytes

Database mounted.

2、  查看各个数据文件的scn

SYS@orser> select file#,checkpoint_change#,name from v$datafile_header;

 

     FILE# CHECKPOINT_CHANGE# NAME

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

         1            5206894 /u01/app/oracle/oradata/orser/system01.dbf

         2            5206894 /u01/app/oracle/oradata/orser/sysaux01.dbf

         3            5206894 /u01/app/oracle/oradata/orser/undotbs01.dbf

         4            5206894 /u01/app/oracle/oradata/orser/users01.dbf

         5            5206894 /u01/app/oracle/oradata/orser/index01.dbf

         6            5206894 /u01/app/oracle/oradata/orser/orser01.dbf

         7            5205966 /u01/app/oracle/oradata/orser/bbed01.dbf

         9            5206894 /u01/app/oracle/oradata/orser/iot01.dbf

        10            5206894 /u01/app/oracle/oradata/orser/example01.dbf

 

9 rows selected.

可以看出bbed01数据文件头scn要小于其他数据文件头scn所以现在无法启动数据库。

3、  更新bbedlistfile文件

可以通过 select file#,name,bytes from v$datafile; 获取listfile信息

[oracle@orser lib]$ vim filelist.txt

1  /u01/app/oracle/oradata/orser/system01.dbf          786432000

2  /u01/app/oracle/oradata/orser/sysaux01.dbf          796917760

3  /u01/app/oracle/oradata/orser/undotbs01.dbf         791674880

4  /u01/app/oracle/oradata/orser/users01.dbf             5242880

5  /u01/app/oracle/oradata/orser/index01.dbf            52428800

6  /u01/app/oracle/oradata/orser/orser01.dbf           209715200

7  /u01/app/oracle/oradata/orser/bbed01.dbf             10485760

9  /u01/app/oracle/oradata/orser/iot01.dbf             104857600
10 /u01/app/oracle/oradata/orser/example01.dbf         104857600

4、  bbed查询bbed01数据文件结构信息

BBED> set dba 7,1

        DBA             0x01c00001 (29360129 7,1)

BBED> map     

 File: /u01/app/oracle/oradata/orser/bbed01.dbf (7)

 Block: 1                                     Dba:0x01c00001

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

 Data File Header

 

 struct kcvfh, 860 bytes                        @0      

 

         ub4 tailchk                                @8188

 

 

5、  Bbed查看kcvfh信息

BBED> p kcvfh

struct kcvfh, 860 bytes                     @0      

   ……………………………………………省略部分信息………………………………………………

(KCVFHOFZ)

   struct kcvfhckp, 36 bytes                @484    

      struct kcvcpscn, 8 bytes              @484    

         ub4 kscnbas                        @484      0x004f6fce

         ub2 kscnwrp                        @488      0x0000

      ub4 kcvcptim                          @492      0x32c5916c

      ub2 kcvcpthr                          @496      0x0001

      union u, 12 bytes                     @500    

         struct kcvcprba, 12 bytes          @500    

            ub4 kcrbaseq                    @500      0x00000093

            ub4 kcrbabno                    @504      0x00000045

            ub2 kcrbabof                    @508      0x0010

      ub1 kcvcpetb[0]                       @512      0x02

      ub1 kcvcpetb[1]                       @513      0x00

      ub1 kcvcpetb[2]                       @514      0x00

      ub1 kcvcpetb[3]                       @515      0x00

      ub1 kcvcpetb[4]                       @516      0x00

      ub1 kcvcpetb[5]                       @517      0x00

      ub1 kcvcpetb[6]                       @518      0x00

      ub1 kcvcpetb[7]                       @519      0x00

   ub4 kcvfhcpc                             @140      0x00000004

   ub4 kcvfhrts                             @144      0x00000000

   ub4 kcvfhccc                             @148      0x00000003

   struct kcvfhbcp, 36 bytes                @152    

      struct kcvcpscn, 8 bytes              @152    

         ub4 kscnbas                        @152      0x00000000

         ub2 kscnwrp                        @156      0x0000

      ub4 kcvcptim                          @160      0x00000000

      ub2 kcvcpthr                          @164      0x0000

      …………………………………省略部分信息………………………………………..

   struct kcvfhprs, 8 bytes                 @420    

      ub4 kscnbas                           @420      0x003a40e3

      ub2 kscnwrp                           @424      0x0000

   struct kcvfhprfs, 8 bytes                @428    

      ub4 kscnbas                           @428      0x00000000

      ub2 kscnwrp                           @432      0x0000

   ub4 kcvfhtrt                             @444      0x00000000

6、  bbed查看其他正常数据文件头kcvfh信息

 

BBED> set dba 1,1

        DBA             0x00400001 (4194305 1,1)

 

BBED> map

 File: /u01/app/oracle/oradata/orser/system01.dbf (1)

 Block: 1                                     Dba:0x00400001

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

 Data File Header

 

 struct kcvfh, 860 bytes                      @0      

 ub4 tailchk                                @8188   

 

 

BBED> p kcvfh

struct kcvfh, 860 bytes                     @0      

    ……………………………………………省略部分信息………………………………………………

(KCVFHOFZ)

   struct kcvfhckp, 36 bytes                @484    

      struct kcvcpscn, 8 bytes              @484    

         ub4 kscnbas                        @484      0x004f736e

         ub2 kscnwrp                        @488      0x0000

      ub4 kcvcptim                          @492      0x32c59266

      ub2 kcvcpthr                          @496      0x0001

      union u, 12 bytes                     @500    

         struct kcvcprba, 12 bytes          @500    

            ub4 kcrbaseq                    @500      0x00000097

            ub4 kcrbabno                    @504      0x00000002

            ub2 kcrbabof                    @508      0x0010

      ub1 kcvcpetb[0]                       @512      0x02

      ub1 kcvcpetb[1]                       @513      0x00

      ub1 kcvcpetb[2]                       @514      0x00

      ub1 kcvcpetb[3]                       @515      0x00

      ub1 kcvcpetb[4]                       @516      0x00

      ub1 kcvcpetb[5]                       @517      0x00

      ub1 kcvcpetb[6]                       @518      0x00

      ub1 kcvcpetb[7]                       @519      0x00

   ub4 kcvfhcpc                             @140      0x0000026b

   ub4 kcvfhrts                             @144      0x32c58dd9

   ub4 kcvfhccc                             @148      0x0000026a

   struct kcvfhbcp, 36 bytes                @152    

      struct kcvcpscn, 8 bytes              @152    

         ub4 kscnbas                        @152      0x00000000

         ub2 kscnwrp                        @156      0x0000

      ub4 kcvcptim                          @160      0x00000000

      ub2 kcvcpthr                          @164      0x0000

      union u, 12 bytes                     @168    

       ……………………………………………省略部分信息………………………………………………  

   struct kcvfhprs, 8 bytes                 @420    

      ub4 kscnbas                           @420      0x003a40e3

      ub2 kscnwrp                           @424      0x0000

   struct kcvfhprfs, 8 bytes                @428    

      ub4 kscnbas                           @428      0x00000000

      ub2 kscnwrp                           @432      0x0000

   ub4 kcvfhtrt                             @444      0x00000000

7、  查看正常数据文件头(1system01数据文件头)scn转码前的值

BBED> dump offset 484 count 4

 File: /u01/app/oracle/oradata/orser/system01.dbf (1)

 Block: 1                Offsets:  484 to  487           Dba:0x00400001

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

 6e734f00

 

 <32 bytes per line>

8、  修改旧数据文件头(7bbed01数据文件头)scn的值

BBED> m /x 6e734f00 offset 484

Warning: contents of previous BIFILE will be lost. Proceed? (Y/N) y

 File: /u01/app/oracle/oradata/orser/bbed01.dbf (7)

 Block: 1                Offsets:  484 to  995           Dba:0x01c00001

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

 6e734f00 00000800 6c91c532 01000000 93000000 45000000 10000000 02000000

……………………………省略部分信息………………………………………………

 <32 bytes per line>

9、  查看正常数据文件头(1system01数据文件头)chckpoint_time的值

BBED> dump offset 492 count 4

 File: /u01/app/oracle/oradata/orser/system01.dbf (1)

 Block: 1                Offsets:  492 to  495           Dba:0x00400001

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

 6692c532

 

 <32 bytes per line>

10、修改旧数据文件头(7bbed01数据文件头)checkpoint_time的值

BBED> m /x 6692c532 offset 492

 File: /u01/app/oracle/oradata/orser/bbed01.dbf (7)

 Block: 1                Offsets:  492 to 1003           Dba:0x01c00001

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

 6692c532 01000000 93000000 45000000 10000000 02000000 00000000

……………………………省略部分信息………………………………………………

 <32 bytes per line>

11、查看正常数据文件头中检查点计数器(kcvfhcpc)的值

BBED> dump offset 140 count 4

 File: /u01/app/oracle/oradata/orser/system01.dbf (1)

 Block: 1                Offsets:  140 to  143           Dba:0x00400001

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

 6b020000

 

 <32 bytes per line>

12、修改旧数据文件头中检查点计数器(kcvfhcpc

 

BBED> m /x 6b020000 offset 140

 File: /u01/app/oracle/oradata/orser/bbed01.dbf (7)

 Block: 1                Offsets:  140 to  651           Dba:0x01c00001

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

 6b020000 00000000 03000000 00000000 00000000 00000000 00000000

……………………………省略部分信息………………………………………………

 <32 bytes per line>

13、查看正常数据文件头中控制文件备份的计数器(kcvfhccc)的值

BBED> dump offset 148 count 4

 File: /u01/app/oracle/oradata/orser/system01.dbf (1)

 Block: 1                Offsets:  148 to  151           Dba:0x00400001

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

 6a020000

 

 <32 bytes per line>

14、修改旧数据文件头中控制文件备份的计数器(kcvfhccc)的值

BBED> m /x 6a020000 offset 148

 File: /u01/app/oracle/oradata/orser/bbed01.dbf (7)

 Block: 1                Offsets:  148 to  659           Dba:0x01c00001

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

 6a020000 00000000 00000000 00000000 00000000 00000000 00000000

……………………………省略部分信息………………………………………………

 <32 bytes per line>

15、重新生成sum

BBED> sum apply

Check value for File 7, Block 1:

current = 0x953d, required = 0x953d

16、查询各个数据文件头scn

SYS@orser>  select file#,checkpoint_change#,name from v$datafile_header;

 

     FILE# CHECKPOINT_CHANGE# NAME

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

         1            5206894 /u01/app/oracle/oradata/orser/system01.dbf

         2            5206894 /u01/app/oracle/oradata/orser/sysaux01.dbf

         3            5206894 /u01/app/oracle/oradata/orser/undotbs01.dbf

         4            5206894 /u01/app/oracle/oradata/orser/users01.dbf

         5            5206894 /u01/app/oracle/oradata/orser/index01.dbf

         6            5206894 /u01/app/oracle/oradata/orser/orser01.dbf

         7            5206894 /u01/app/oracle/oradata/orser/bbed01.dbf

         9            5206894 /u01/app/oracle/oradata/orser/iot01.dbf

        10            5206894 /u01/app/oracle/oradata/orser/example01.dbf

 

9 rows selected.

可以看到与其他数据文件scn已经相同

17、尝试启动数据库

SYS@orser> alter database open;

alter database open

*

ERROR at line 1:

ORA-01122: database file 7 failed verification check

ORA-01110: data file 7: ‘/u01/app/oracle/oradata/orser/bbed01.dbf‘

   ORA-01207: file is more recent than control file - old control file

18、查看控制文件中关于bbed数据文件的信息

SYS@orser> alter session set events ‘immediate trace name controlf level 8‘; 

 

Session altered.

 

SYS@orser> select value from v$diag_info where name=‘Default Trace File‘;

 

VALUE

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

/u01/app/oracle/diag/rdbms/orser/orser/trace/orser_ora_3558.trc

部分内容:

name #11: /u01/app/oracle/oradata/orser/bbed01.dbf

creation size=1280 block size=8192 status=0xe head=11 tail=11 dup=1

 tablespace 20, index=8 krfil=7 prev_file=0

 unrecoverable scn: 0x0000.00000000 01/01/1988 00:00:00

 Checkpoint cnt:7 scn: 0x0000.004f736e 07/01/2014 21:34:30

19、 修改旧数据文件头中检查点计数器(kcvfhcpc)为控制文件记录的值

BBED> m /x 07000000 offset 140

 File: /u01/app/oracle/oradata/orser/bbed01.dbf (7)

 Block: 1                Offsets:  140 to  651           Dba:0x01c00001

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

 07000000 00000000 6a020000 00000000 00000000 00000000 00000000

 

 <32 bytes per line>

20、 修改旧数据文件头中控制文件备份的计数器(kcvfhccc)的值

BBED> m /x 06000000 offset 148

 File: /u01/app/oracle/oradata/orser/bbed01.dbf (7)

 Block: 1                Offsets:  148 to  659           Dba:0x01c00001

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

 06000000 00000000 00000000 00000000 00000000 00000000 00000000

 

 <32 bytes per line>

21、重新生成sum

BBED> sum apply

Check value for File 7, Block 1:

current = 0x953d, required = 0x953d

22、 尝试启动数据库

SYS@orser> alter database open;

 

Database altered.

23、  启动成功

分享:bbed修改数据文件头推进scn与其他数据文件相同

标签:

原文地址:http://my.oschina.net/1590538xiaokai/blog/468464

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!