8.3.4Renaming a Datafile in the Primary Database8.3.4 在主庫中重命令資料檔案(即手動在備庫修改相等的變化)
When you rename one or more datafiles in the primary database, the change is not propagated to the standby database. Therefore, if you want to rename the same datafiles on the standby database, you must manually make the equivalent modifications on the standby database because the modifications are not performed automatically, even if theSTANDBY_FILE_MANAGEMENTinitialization parameter is set toAUTO.
當你在主庫中重新命名一個或多個資料檔案時,備庫是不會發生相應的變化的。因此,如果你想在備庫重新命名相同的資料檔案,你必須手動在備庫中做相等的修改。因為這些改變不是自動的,甚至STANDBY_FILE_MANAGEMENT設定為AUTO也不會發生改變的。
The following steps describe how to rename a datafile in the primary database and manually propagate the changes to the standby database.
按照以下描述來在主庫重新命名資料檔案,而手動將這些改變傳播到備庫中去。
Torename the datafile in the primary database, take the tablespace offline:
1.在主庫中重新命名資料檔案,先將資料表空間離線:
SQL> ALTER TABLESPACE tbs_4 OFFLINE;
Exit from the SQL prompt and issue an operating system command, such as the following UNIXmvcommand, to rename the datafile on the primary system:
退出SQL提示符,使用作業系統命令,像unix的mv命令,在主庫作業系統上重新命名資料檔案:
% mv /disk1/Oracle/oradata/payroll/tbs_4.dbf/disk1/oracle/oradata/payroll/tbs_x.dbf
Rename the datafile in the primary database and bring the tablespace back online:
在主庫上發出以下命令來重新命名資料檔案,然後將資料表空間聯機:
SQL> ALTER TABLESPACE tbs_4RENAMEDATAFILE 2> '/disk1/oracle/oradata/payroll/tbs_4.dbf'3> TO'/disk1/oracle/oradata/payroll/tbs_x.dbf';SQL> ALTER TABLESPACE tbs_4 ONLINE;
Connect to the standby database, query theV$ARCHIVED_LOGview to verify all of the archived redo log files are applied, and then stop Redo Apply:
串連備庫,查詢V$ARCHIVED_LOG 視圖來驗證所有的歸檔日誌已經應用,然後停止重做應用:
SQL> SELECT SEQUENCE#,APPLIED FROM V$ARCHIVED_LOG ORDER BY SEQUENCE#;SEQUENCE# APP--------- ---8 YES9 YES10 YES11 YES4 rows selected. SQL>ALTER DATABASE RECOVER MANAGED STANDBY DATABASE CANCEL;
Shut down the standby database:
5.關閉備庫
SQL> SHUTDOWN;
Rename the datafile at the standby site using an operating system command, such as the UNIXmvcommand:
6.在備庫的作業環境使用作業系統命令,如UNIX的mv命令,來重新命名資料檔案:
% mv /disk1/oracle/oradata/payroll/tbs_4.dbf /disk1/oracle/oradata/payroll/tbs_x.dbf
Start and mount the standby database:
7.啟動並裝載備庫:
SQL> STARTUP MOUNT;
Rename the datafile in the standby control file. Note that theSTANDBY_FILE_MANAGEMENTinitialization parameter must be set toMANUAL.
在備庫上重新命名資料檔案到控制檔案裡,注意:STANDBY_FILE_MANAGEMENT初始化參數必須設定為MANUAL
SQL> ALTER DATABASE RENAME FILE '/disk1/oracle/oradata/payroll/tbs_4.dbf'2> TO '/disk1/oracle/oradata/payroll/tbs_x.dbf';
On the standby database, restart Redo Apply:
9.在備庫重新啟動重做應用:
SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE2> DISCONNECT FROM SESSION;
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 errorsORA-01157: cannot identify/lock datafile 4 - see DBWR trace fileORA-01110: datafile 4: '/Disk1/oracle/oradata/payroll/tbs_x.dbf'
相關參考:
Oracle Data Guard 重要配置參數
基於同一主機配置 Oracle 11g Data Guard
探索Oracle之11g DataGuard
Oracle Data Guard (RAC+DG) 歸檔刪除策略及指令碼
Oracle Data Guard 的角色轉換
Oracle Data Guard的日誌FAL gap問題
Oracle 11g Data Guard Error 16143 Heartbeat failed to connect to standby 處理方法