什么时候会刷新备库控制文件refresh the standby database control file?

通过合理的设置,对于Primary的绝大数操作,都是可以传递到Physical Standby,datafile的操作是通过STANDBY_FILE_MANAGEMENT参数来控制的,但是即使STANDBY_FILE_MANAGEMENT设置为auto,对于rename操作,standby还是忽略的。

If you do not rename the corresponding datafile at the standby system, and then try to
refresh the standby database control file, the standby database will attempt to use the
renamed datafile, but it will not find it. Consequently, you will see error messages
similar to the following in the alert log:
ORA-00283: recovery session canceled due to errors
ORA-01157: cannot identify/lock datafile 4 - see DBWR trace file
ORA-01110: datafile 4: '/Disk1/oracle/oradata/payroll/tbs_x.dbf'

从中可以看出,如果没有刷新standby的控制文件,日志中也不会有错误信息,那么在什么情况下会刷新控制文件呢?

先来来看看控制文件记录了什么信息?

■ The database name and database unique identifier (DBID)
■ The time stamp of database creation
■ Information about data files, online redo log files, and archived redo log files
■ Tablespace information
■ RMAN backups

事实上standby一直在应用主库传过来的日志,归档信息也一直在更新,也就是说一直在更新控制文件,但是控制文件并没有因此

觉察数据字典中的数据文件位置和自己的不一样。也就是说归档信息的改变不会导致refresh the standby database control file,下面做个实验看看数据文件的变化会不会导致refresh the standby database control file

1、更改主库google表空间的数据文件名称

SQL> select name from v$tablespace;

NAME
------------------------------
SYSTEM
UNDOTBS1
SYSAUX
USERS
TEMP
GOOGLE

6 rows selected.

SQL> select name from v$datafile;

NAME
--------------------------------------------------------------------------------
/u01/oracle/product/10.2.0/oradata/orcl/system01.dbf
/u01/oracle/product/10.2.0/oradata/orcl/undotbs01.dbf
/u01/oracle/product/10.2.0/oradata/orcl/sysaux01.dbf
/u01/oracle/product/10.2.0/oradata/orcl/users01.dbf
/u01/oracle/product/10.2.0/oradata/orcl/google.dbf

SQL> alter tablespace google offline normal;

SQL> ! mv /u01/oracle/product/10.2.0/oradata/orcl/google.dbf /u01/oracle/product/10.2.0/oradata/orcl/google1.dbf

SQL> alter database rename file '/u01/oracle/product/10.2.0/oradata/orcl/google.dbf' to '/u01/oracle/product/10.2.0/oradata/orcl/google1.dbf';


SQL> alter tablespace GOOGLE online;

SQL> alter system archive log current;

此时查看备库日志正常,无异常信息。

2、为主库google表空间在添加个数据文件,同样standby也会为google表空间添加数据文件。

SQL> alter tablespace google add datafile '/u01/oracle/product/10.2.0/oradata/orcl/google2.dbf' size 10m;

Tablespace altered.

SQL> alter system archive log current;

此时查看备库仍然没有异常信息。

SQL> select name from v$datafile;

NAME
--------------------------------------------------------------------------------
/u01/oracle/product/10.2.0/oradata/iptv/system01.dbf
/u01/oracle/product/10.2.0/oradata/iptv/undotbs01.dbf
/u01/oracle/product/10.2.0/oradata/iptv/sysaux01.dbf
/u01/oracle/product/10.2.0/oradata/iptv/users01.dbf
/u01/oracle/product/10.2.0/oradata/iptv/google.dbf
/u01/oracle/product/10.2.0/oradata/iptv/google2.dbf
--从备用库上可以看出控制文件中的信息还没有和数据字典中的信息同步。

什么时候才会刷新控制文件呢?这时我们再主库为google表空间添加个google.dbf文件看会出现什么情况?

---主库添加数据文件
SQL>alter tablespace google add datafile '/u01/oracle/product/10.2.0/oradata/orcl/google.dbf' size 10m;
SQL> alter system archive log current;

这时备用库终于出现异常

File #7 added to control file as 'UNNAMED00007' because it was
created under name already used in this database. Creation name:
'/u01/oracle/product/10.2.0/oradata/orcl/google.dbf'
Errors with log /u01/arch/1_61_724530650.dbf
MRP0: Background Media Recovery terminated with error 1537

说明添加同名的datafile会导致standby的控制文件refresh,但除此之外还有什么情况会导致standby的控制文件refresh呢?

出现此问题的处理相对简单,步骤如下:

1、备库修改standby_file_management参数
SQL> alter system set standby_file_management='manual';   
2、OS层面移动google.dbf为google1.dbf
[oracle@dg002 iptv]$ mv google.dbf  google1.dbf
3、修改DB层面修改google.dbf为google1.dbf
SQL> alter database rename file '/u01/oracle/product/10.2.0/oradata/iptv/google.dbf' to '/u01/oracle/product/10.2.0/oradata/iptv/google1.dbf';
4、DB层面修改修改UNNAMED00007为google.dbf
SQL>  alter database create datafile  '/u01/oracle/product/10.2.0/db_1/dbs/UNNAMED00007' as '/u01/oracle/product/10.2.0/oradata/iptv/google.dbf';
5、备库修改standby_file_management参数
SQL> alter system set standby_file_management='auto'; 
6、开启日志应用
SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE  DISCONNECT FROM SESSION;

不明白的是仅仅修改下控制文件,添加数据文件、删除数据文件都可以,为什么rename datafile不可以呢,对oracle来说有什么难度吗? 

posted @ 2013-10-14 16:04  My Data Support  阅读(545)  评论(0编辑  收藏  举报