上周5的时候跟同事他们一起讨论DG环境的数据库的升级方式,原主库使用shutdown abort后,由broker自动切换备库,由备库变成主库,在做升级,升级前做一次restore point。随后就说到了,shutdown abort可能会导致出现一次坏块的情况(概率是很少),备库同时升级失败,导致shutdown abort的数据库不能通过flashback到restore point,但是这次出现了分歧。
下次就是用bbed这个来模拟一下。测试环境是11gr2,在11gr2中安装bbed这个工具比10要复杂一些。安装步骤见:
ORACLE 编译/安装bbed工具
http://luoping.blog.51cto.com/534596/985911
下面开始测试:
1.启动flashback
- SQL> select open_mode,log_mode,flashback_on from V$database;
- OPEN_MODE LOG_MODE FLASHBACK_ON
- -------------------- ------------ ------------------
- READ WRITE ARCHIVELOG NO
- #注意restore point可以不用开启flashback,也可以开启flashback .
- #normal restore point要开启flashback.
- #guaranteed restore point不用开启flashback
- SQL> alter database flashback on;
- Database altered.
- SQL> select open_mode,log_mode,flashback_on from V$database;
- OPEN_MODE LOG_MODE FLASHBACK_ON
- -------------------- ------------ ------------------
- READ WRITE ARCHIVELOG YES
2,建测试数据表空间与数据
- SQL> create tablespace test datafile '/u01/app/oracle/oradata/luo/test.dbf' size 20M autoextend off;
- Tablespace created.
- SQL> alter user scott identified by oracle account unlock default tablespace test;
- User altered.
- SQL> create table scott.test as select * from dba_objects;
- Table created.
- SQL>
3,创建restore point
- SQL> create restore point bbed_test guarantee flashback database;
- Restore point created.
- SQL> col name for a20
- SQL> set lines 175
- SQL> select scn,to_char(time,'YYYY-MM-DD HH24:MI:SS') ctime,name from v$restore_point;
- SCN CTIME NAME
- ---------- ------------------- --------------------
- 1037086 2012-09-08 04:46:39 BBED_TEST
4,通过bbed工具损坏一个block。
5,查询内容报坏块错误。
- SQL> select owner,object_name from test where object_name='TEST';
- select owner,object_name from test where object_name='TEST'
- *
- ERROR at line 1:
- ORA-01578: ORACLE data block corrupted (file # 5, block # 1183)
- ORA-01110: data file 5: '/u01/app/oracle/oradata/luo/test.dbf'
6,flashback数据库bbed_test
- SQL> shutdown abort;
- ORACLE instance shut down.
- SQL> startup mount;
- ORACLE instance started.
- Total System Global Area 313159680 bytes
- Fixed Size 2226072 bytes
- Variable Size 243271784 bytes
- Database Buffers 62914560 bytes
- Redo Buffers 4747264 bytes
- Database mounted.
- #这个显示了flashback成功
- SQL> flashback database to restore point bbed_test;
- Flashback complete.
- SQL> alter database open;
- alter database open
- *
- ERROR at line 1:
- ORA-01589: must use RESETLOGS or NORESETLOGS option for database open
- SQL> alter database open resetlogs;
- Database altered.
7,查询指定数据。
- SQL> conn scott/oracle
- Connected.
- SQL> select owner,object_name from test where object_name='TEST';
- select owner,object_name from test where object_name='TEST'
- *
- ERROR at line 1:
- ORA-01578: ORACLE data block corrupted (file # 5, block # 1183)
- ORA-01110: data file 5: '/u01/app/oracle/oradata/luo/test.dbf'
这里还是报块的错误。
想想为什么不能成功。因为数据库的restore point,只能flash数据库自己修改的块,而像shutdown abort这样强制关闭ORACLE时,并不会记录flash log日志的,所以就会出现上面的情况。但是如果坏的块出现在system表空间,那样恢复起来可能就会很惨了。
本文转自7343696 51CTO博客,原文链接:http://blog.51cto.com/luoping/985975,如需转载请自行联系原作者