Oracle11g的dataguard創建中ORA-01665解決過程
Oracle 11g在創建data guard時,恢復standby控制文件不成功。在mount standby database時告訴我,控制文件不是standby控制文件,具體信息為“ORA-01665: control file is not a standby control file”。
控制文件我在主庫中,使用rman生成的。
backup current controlfile for standby format 'xxxxxx/ctl.stdy';
拷貝到備庫上恢復。按照10g的操作習慣,使用rman工具進行恢復操作。
在11g的RMAN工具做了不少改動,如加了set功能直接修改生成適用於standby的spfile文件,個人覺得是雞肋。我手工編輯修改比這裡敲命令操作爽多了。
還有這裡恢復standby controlfile時,要手工指定,我恢復的控制文件是用於standby,否則就不行了。
restore controlfile from '/u01/backup/db7881/ctl.stdy';
恢復是恢復了,但在mount standby database時,出錯。
SQL> alter database mount standby database;
alter database mount standby database
*
ERROR at line 1:
ORA-01665: control file is not a standby control file
如果不做standby database的mount,那麼則可以mount成功。
SQL> alter database mount;
Database altered.
這點證明我的備份介質是沒有問題的。檢查一下控制文件的類型,不是我需要的standby類型。
SQL> select controlfile_type from v$database;
CONTROL
-------
BACKUP
好,再回到11g rman的恢復控制文件的操作上來。
RMAN 工具的restore 的restoreobject,有一項是standby controlfile.
STANDBY CONTROLFILE Restores a control file for a standby database. RMAN can transparently restore a normal control file backup and make it usable for a standby database.
RMAN restores either a normal or standby control file as appropriate, depending on the most recent database role known to the recovery catalog (RC_SITE.DATABASE_ROLE) for the target database. The purpose of this option to override the default
setting in cases where the most recent database role is out-of-date. Assume that you perform a switchover from primary database dgny to standby database dgsf, so that dgsf is the new primary database. Later, you make dgny a standby database for dgsf. You want
to restore a control file on dgny, but the recovery catalog was not resynchronized and still shows dgny as a primary database. In this case, you can specify STANDBY CONTROLFILE to override the default RMAN behavior and restore a standby control file.
If you restore the control file of a database whose DB_UNIQUE_NAME is known to the recovery catalog, then RMAN updates all filenames in the control file to filenames known to the recovery catalog. Any filenames explicitly renamed with ALTER DATABASE
RENAME FILE take precedence over the filenames in the recovery catalog.
See Also: Table 2-36 for restrictions and usage notes
Note: You must always run the RECOVER command after mounting a restored control file, and must also always open the database with the RESETLOGS option.
使用”restore standby controlfile“ 進行恢復操作,成功。
RMAN> restore standby controlfile from '/u01/backup/db7881/ctl.stdy';
Starting restore at 07-JAN-15
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=62 device type=DISK
channel ORA_DISK_1: restoring control file
channel ORA_DISK_1: restore complete, elapsed time: 00:00:02
output file name=+VG1/db7881dg/controlfile/current.447.868357987
output file name=+VG1/db7881dg/controlfile/current.507.868357987
Finished restore at 07-JAN-15
數據庫可以恢復控制文件後,檢查v$database的controlfile_type,已經是我們需要的類型了。
SQL> alter database mount standby database;
Database altered.
SQL> select controlfile_type from v$database;
CONTROL
-------
STANDBY
--end.