数据库版本:11.2.0.4
操作系统: primary:redhat linux 5.9
standby:redhat linux 5.6
primary DB: rac + ASM
standby DB: 单节点 + 文件系统
因为主库使用了asm 文件系统,asm下创建表空间和添加数据文件,文件名默认后缀为会话线程号,而这些以线程号命名的文件,
在通过日志传输到standby 数据库时,备库不能正常创建同名的文件,因此备库在应用主库传输过来的文件时会出错,并进一步倒是备库的recover 进程中断。
下面命令的输出结果中,以数字命名的文件时通过duplicate 的方式复制到备库的,文件6为备库通过主库新增数据库文件的sql 进行recover 生成,
由于备库使用文件系统存储,因此备库无法正常创建数据文件,查询v$datafile查询出来的文件名,在操作系统中实际上并未生成,oracle 只是修改了数据字典而已。
standby@ SYS> select file#,name from v$datafile;
FILE# NAME
---------- ------------------------------------------------------------
1 /oradata1/oracle/oradata/system.256.852462171
2 /oradata1/oracle/oradata/sysaux.257.852462171
3 /oradata1/oracle/oradata/undotbs1.258.852462171
4 /oradata1/oracle/oradata/users.259.852462173
5 /oradata1/oracle/oradata/undotbs2.264.852462315
6 /home/oracle/app/product/11.1/db_1/dbs/UNNAMED00006
6 rows selected.
Elapsed: 00:00:00.00
standby@ SYS> alter system set standby_file_management = manual;
System altered.
Elapsed: 00:00:00.00
standby@ SYS> alter database create datafile 6 as '/home/oracle/app/product/11.1/db_1/dbs/UNNAMED00006.dbf';
Database altered.
Elapsed: 00:00:00.05
standby@ SYS> select file#,name from v$datafile;
FILE# NAME
---------- ------------------------------------------------------------
1 /oradata1/oracle/oradata/system.256.852462171
2 /oradata1/oracle/oradata/sysaux.257.852462171
3 /oradata1/oracle/oradata/undotbs1.258.852462171
4 /oradata1/oracle/oradata/users.259.852462173
5 /oradata1/oracle/oradata/undotbs2.264.852462315
6 /home/oracle/app/product/11.1/db_1/dbs/UNNAMED00006.dbf
6 rows selected.
Elapsed: 00:00:00.00
----------------
在操作系统中执行以下命令,将create的datafile复制为规范的文件名――与主库文件同名(asm除外)
[oracle@standby01 oradata]$ cp /home/oracle/app/product/11.1/db_1/dbs/UNNAMED00006.dbf /oradata1/oracle/oradata/users_01.dbf
-----------
standby@ SYS> alter database rename file '/home/oracle/app/product/11.1/db_1/dbs/UNNAMED00006.dbf' to '/oradata1/oracle/oradata/users_01.dbf';
Database altered.
Elapsed: 00:00:00.01
standby@ SYS> select file#,name from v$datafile;
FILE# NAME
---------- ------------------------------------------------------------
1 /oradata1/oracle/oradata/system.256.852462171
2 /oradata1/oracle/oradata/sysaux.257.852462171
3 /oradata1/oracle/oradata/undotbs1.258.852462171
4 /oradata1/oracle/oradata/users.259.852462173
5 /oradata1/oracle/oradata/undotbs2.264.852462315
6 /oradata1/oracle/oradata/users_01.dbf
6 rows selected.
Elapsed: 00:00:00.00
至此数据文件在名称和格式上已经和主库一致了,但由于数据文件是create出来的没有数据,需要利用归档日志进行recover
standby@ SYS> recover automatic standby database ;
ORA-00279: change 11876832 generated at 08/13/2014 18:05:51 needed for thread 1
ORA-00289: suggestion : /oradata1/arch/1_328_852462251.dbf
ORA-00280: change 11876832 for thread 1 is in sequence #328
ORA-00278: log file '/oradata1/arch/1_328_852462251.dbf' no longer needed for this recovery
ORA-16145: archival for thread# 1 sequence# 328 in progress
Specify log: {<RET>=suggested | filename | AUTO | CANCEL}
AUTO
ORA-16145: archival for thread# 1 sequence# 328 in progress
standby@ SYS>
standby@ SYS> alter database recover managed standby database disconnect;
Database altered.
最后记得将standby_file_management参数值改回auto。
standby@ SYS> alter system set standby_file_management = auto;
System altered.
Elapsed: 00:00:00.00
问题解决。
在恢复过程中可能遇到的问题:
问题一、
ORA-01275: Operation CREATE DATAFILE is not allowed if standby file management is automatic.
此问题是由于standby 数据库中standby_file_management参数设置为auto,修改为manual 就可。
alter system set standby_file_management = manual;
问题二、
ORA-01511: error in renaming log/data files
ORA-01121: cannot rename database file 15 - file is in use or recovery
此问题是由于需要rename的文件正在被使用,在rac系统中可以将rac 的另一个实例停掉, 当前实例如果在open 状态下的话,可重启到mount状态下。
本文出自 “狂奔的蜗牛” 博客,谢绝转载!