在同一台機器上搭建物理備用數據庫的步驟
主庫
備庫
sqlplus "/as sysdba"
create pfile=
cp /home/oracle/initprim
vi /home/oracle/initprim
orcl
orcl
orcl
orcl
orcl
orcl
orcl
orcl
orcl
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
編輯備庫的參數文件
vi /home/oracle/initstby
stby
stby
stby
stby
stby
stby
stby
stby
stby
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
備份主庫
rman target /
backup database format
創建備庫控制文件
export ORACLE_SID=orcl
sqlplus "/as sysdba"
alter database create standby controlfile as
cp /oradata/stby/stbycontrol
cp /oradata/stby/stbycontrol
處理備庫
export ORACLE_SID=stby
orapwd file=/oracle/product/
sqlplus "/as sysdba"
startup nomount
alter database mount;
rman target /
restore database;
重啟主庫
export ORACLE_SID=orcl
sqlplus "/as sysdba"
shutdown immediate
startup pfile=
配置tnsnames
orcl =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT =
)
(CONNECT_DATA =
(SID = orcl)
(SERVER = DEDICATED)
)
)
stby =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT =
)
(CONNECT_DATA =
(SID = stby)
(SERVER = DEDICATED)
)
)
將備庫置於接收歸檔日志狀態
export ORACLE_SID=stby
sqlplus "/as sysdba"
alter database recover managed standby database disconnect from session;
過一會兒檢查是否收到日志
export ORACLE_SID=orcl
sqlplus "/as sysdba"
select max(sequence#) from v$archived_log;
alter system switch logfile;
alter system switch logfile;
export ORACLE_SID=stby
sqlplus "/as sysdba"
select sequence#
主備庫角色切換
角色切換
步驟
SQL> SELECT SWITCHOVER_STATUS FROM V$DATABASE;
SWITCHOVER_STATUS
TO STANDBY
步驟
SQL> ALTER DATABASE COMMIT TO SWITCHOVER TO PHYSICAL STANDBY;
步驟
SQL> SHUTDOWN IMMEDIATE
SQL> STARTUP MOUNT
步驟
SQL> SELECT SWITCHOVER_STATUS FROM V$DATABASE;
SWITCHOVER_STATUS
TO_PRIMARY
步驟
SQL> ALTER DATABASE COMMIT TO SWITCHOVER TO PRIMARY;
步驟
SQL> ALTER DATABASE OPEN;
SQL> SHUTDOWN IMMEDIATE;
SQL> STARTUP;
步驟
SQL> alter database recover managed standby database disconnect from session;
(注
步驟
Issue the following statement on the new primary database:
SQL> ALTER SYSTEM SWITCH LOGFILE;
備注
ALTER DATABASE RECOVER MANAGED STANDBY DATABASE USING CURRENT LOGFILE;
如果有缺失的歸檔日志文件
ALTER DATABASE REGISTER PHYSICAL LOGFILE
FORCE 關鍵詞終止目標物理備數據庫上活動的RFS 進程
ALTER DATABASE RECOVER MANAGED STANDBY DATABASE FINISH FORCE;
From:http://tw.wingwit.com/Article/program/Oracle/201311/19074.html