自己做的工作一直涉及的是單實例數據庫
創建主庫
創建備庫
在主庫上創建備庫的控制文件
關閉主庫
拷貝主庫的密碼文件到備庫的相應文件中
修改主庫的spfile 文件
*
*
*
*
*
*
*
*
*
*
修改主庫的tns
PRIMARY =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST =
)
(CONNECT_DATA =
(SERVICE_NAME = orcl)
)
)
STANDBY =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST =
)
(CONNECT_DATA =
(SERVICE_NAME = orcl)
)
)
當然備庫的spfile也得修改
*
*
*
*
*
*
*
*
*
*
修改備庫的tns
PRIMARY =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST =
)
(CONNECT_DATA =
(SERVICE_NAME = orcl)
)
)
STANDBY =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST =
)
(CONNECT_DATA =
(SERVICE_NAME = standby)
)
)
由於備庫沒有實力服務
oradim
oradim
其實到這裡配置基本上就結束了
啟動及關閉順序
在備庫將實例啟動到mount 狀態
SQL> startup nomount;
SQL>alter database mount standby database ;
SQL>alter database recover managed standby database disconnect from session;
SQL>alter database recover managed standby database cancel;
備庫啟監聽
$lsnrctl start
主庫啟實例
SQL> startup;
主庫啟監聽
$lsnrctl start
在主庫驗證歸檔目錄是否有效
SQL> SELECT STATUS
如果有錯誤
SQL> alter system switch logfile;
SQL> select max(sequence#) from v$archived_log;
主備切換
SQL> select switchover_status fromv$database;
SWITCHOVER_STATUS
TO STANDBY
SQL> alter database commit to switchoverto physical standby with session shutdown ;
數據庫已更改
SQL> alter database commit to switchoverto physical standby;
alter database commit to switchover tophysical standby
*
第
ORA
SQL> shutdown immediate;
ORA
ORACLE 例程已經關閉
SQL> startup
ORACLE 例程已經啟動
Total System Global Area
Fixed Size
Variable Size
Database Buffers
Redo Buffers
數據庫裝載完畢
數據庫已經打開
SQL> alter database commit to switchoverto physical standby;
數據庫已更改
SQL> select switchover_status fromv$database;
SWITCHOVER_STATUS
TO PRIMARY
SQL> shutdown immediate;
數據庫已經關閉
已經卸載數據庫
ORACLE 例程已經關閉
SQL> startup nomount;
ORACLE 例程已經啟動
Total System Global Area
Fixed Size
Variable Size
Database Buffers
Redo Buffers
SQL> alter database mount standbydatabase;
數據庫已更改
SQL> alter database recover managedstandby database disconnect from session;
數據庫已更改
SQL> select switchover_status fromv$database;
SWITCHOVER_STATUS
SWITCHOVER PENDING
SQL> alter database commit to switchoverto primary;
alter database commit to switchover toprimary
*
ERROR at line
ORA
開始介質恢復
SQL> alter database recover managedstandby database finish;
Database altered
SQL> alter database commit to switchoverto primary;
Database altered
SQL> shutdown immediate;
ORA
Database dismounted
ORACLE instance shut down
SQL> startup;
ORACLE instance started
Total System Global Area
Fixed Size
Variable Size
Database Buffers
Redo Buffers
Database mounted
Database opened
SQL> alter system switch logfile;
System altered
SQL> select switchover_status fromv$database;
SWITCHOVER_STATUS
TO STANDBY
以下是介質恢復時的alert 日志
alterdatabase commit to switchover to primary
Maximumwait for role transition is
Databasenot available for switchover
End
End
Archived log files detected beyondEnd
Incomplete recovery SCN:
Databasenot available for switchover
End
End
Archived log files detected beyondEnd
Incomplete recovery SCN:
Switchover:Media recovery required
ORA
WedSep
alterdatabase recover managed standby database finish
SerialMedia Recovery started
ManagedStandby Recovery not using Real Time Apply
WARNING!Recovering data file
itmight be an online backup taken without entering the begin backup command
WARNING!Recovering data file
itmight be an online backup taken without entering the begin backup command
MediaRecovery Log F:\FLASH_RECOVER_AREA\ORCL\ARCHIVELOG\
MediaRecovery Log F:\FLASH_RECOVER_AREA\ORCL\ARCHIVELOG\
WedSep
MediaRecovery Log F:\FLASH_RECOVER_AREA\ORCL\ARCHIVELOG\
WedSep
MediaRecovery Log F:\FLASH_RECOVER_AREA\ORCL\ARCHIVELOG\
MediaRecovery Log F:\FLASH_RECOVER_AREA\ORCL\ARCHIVELOG\
MediaRecovery Log F:\FLASH_RECOVER_AREA\ORCL\ARCHIVELOG\
MediaRecovery Log F:\FLASH_RECOVER_AREA\ORCL\ARCHIVELOG\
WedSep
MediaRecovery Log F:\FLASH_RECOVER_AREA\ORCL\ARCHIVELOG\
WedSep
MediaRecovery Log F:\FLASH_RECOVER_AREA\ORCL\ARCHIVELOG\
MediaRecovery Log F:\FLASH_RECOVER_AREA\ORCL\ARCHIVELOG\
IdentifiedEnd
Resettingstandby activation ID
MediaRecovery End
MediaRecovery Applied through change
Completed:alter database recover managed standby database finish
好像是當時主庫傳過來的歸檔日志都沒有應用
From:http://tw.wingwit.com/Article/program/Oracle/201311/18923.html