Oracle資料庫(DataGuard)遷移方案(下)

龍山游龍發表於2023-04-19

第一部分 主備資料庫切換 

1.1  檢查D G 同步情況

檢查DG同步程式狀態:

SQL> select  process, status,sequence#,block#,blocks, delay_mins from v$managed_standby;

檢查DG日誌同步延時情況:

SQL> select thread#,max(sequence#) from gv$archived_log group by thread#;

SQL> select thread#,max(sequence#) from gv$archived_log where applied='YES' group by thread#;

 

1.2  關閉主備庫 2 節點

SQL> shutdown immediate;

 

1.3  源端生產庫主切從

SQL> select name,database_role,switchover_status from v$database;

SQL> alter database commit to switchover to physical standby with session shutdown;

 

1.4  目標D G 庫從切主

SQL> select name,database_role,switchover_status from v$database;

SQL> alter database commit to switchover to primary;

SQL> alter database open;

如果是switchover_status 列時"NOT ALLOWED"表示歸檔還沒有應用完成,可以等待一段時間;如果日誌全部應用了再檢視角色轉換狀態;如果角色轉換狀態是TO PRIMARY,那麼表示可以進行角色轉換。執行從轉主的命令,命令執行成功後,資料庫的狀態會變為mount。

 

1.5  目標端啟動2節點

Shell> su – oracle

Shell> sqlplus / as sysdba

SQL> startup

 

1.6  新主新備重新同步

在節點1上開啟MRP

SQL> startup

SQL> alter database recover managed standby database using current logfile disconnect from session;

在節點2直接啟動

SQL> startup

 

1.7  檢查D G 同步情況

檢查DG同步程式狀態:

SQL> select  process, status,sequence#,block#,blocks, delay_mins from v$managed_standby;

檢查DG日誌同步延時情況:

SQL> select thread#,max(sequence#) from gv$archived_log group by thread#;

SQL> select thread#,max(sequence#) from gv$archived_log where applied='YES' group by thread#;


第二部分 RAC叢集IP修改

第2部分 

2.1  修改R AC 兩節點/ etc/ hosts

1節點:

Vi /etc/hosts

192.168.17.101 racdb1

192.168.17.13 racdb1-vip

10.253.253.101 racdb1-priv

192.168.17.102 racdb2

192.168.17.14 racdb2-vip

10.253.253.102 racdb2-priv

192.168.17.15 orcl-scan

2節點:

Vi /etc/hosts

192.168.17.101 racdb1

192.168.17.13 racdb1-vip

10.253.253.101 racdb1-priv

192.168.17.102 racdb2

192.168.17.14 racdb2-vip

10.253.253.102 racdb2-priv

192.168.17.15 orcl-scan

2.2  先停SCAN監聽,再停SCAN VIP

[grid@racdb2 ~]$/u01/app/12.2/grid/bin/srvctl stop scan_listener

[grid@racdb2 ~]$/u01/app/12.2/grid/bin/srvctl stop scan

[grid@racdb2 ~]$/u01/app/12.2/grid/bin/srvctl status scan

 

2.3  先停本地監聽,再停本地VIP

[grid@racdb2 ~]$ srvctl stop listener

[grid@racdb2 ~]$ srvctl stop vip -n racdb1

[grid@racdb2 ~]$ srvctl stop vip -n racdb2

 

2.4  修改R AC 兩節點 PUBLIC   IP

[root@racdb1 ~]# vi /etc/sysconfig/network-scripts/ifcfg-eth0

IPADDR=192.168.17.101

GATEWAY=192.168.17.254

[root@racdb1 ~]# ifdown eth0

[root@racdb1 ~]# ifup eth0

[root@racdb1 ~]# ip a

 

[root@racdb2 ~]# vi /etc/sysconfig/network-scripts/ifcfg-eth0

IPADDR=192.168.17.102

GATEWAY=192.168.17.254

[root@racdb2 ~]# ifdown eth0

[root@racdb2 ~]# ifup eth0

[root@racdb2 ~]# ip a

 

2.5  修改R AC 叢集 PUBLIC 註冊資訊

[root@racdb1 ~]# /u01/app/12.2/grid/bin/oifcfg delif -global eth0

[root@racdb1 ~]# /u01/app/12.2/grid/bin/oifcfg setif -global eth0/192.168.17.0:public

 

2.6  修改R AC 兩節點V IP

[root@racdb1 ~]# /u01/app/12.2/grid/bin/srvctl modify nodeapps -n racdb1 -A 192.168.17.13/255.255.255.0/eth0

[root@racdb1 ~]# /u01/app/12.2/grid/bin/srvctl modify nodeapps -n racdb2 -A 192.168.17.14/255.255.255.0/eth0

 

[root@racdb1 ~]# /u01/app/12.2/grid/bin/srvctl config vip -n racdb1

VIP exists: /racdb1-vip/192.168.17.13/192.168.0.0/255.255.255.0/eth0, hosting node racdb1

[root@racdb1 ~]# /u01/app/12.2/grid/bin/srvctl config vip -n racdb2

VIP exists: /racdb2-vip/192.168.17.14/192.168.0.0/255.255.255.0/eth0, hosting node racdb2

 

2.7  修改R AC 叢集 SCAN VIP

[root@racdb1 ~]# /u01/app/12.2/grid/bin/srvctl modify scan -n 192.168.17.15

 

2.8  先啟本地VIP,再啟本地監聽

[root@racdb1 ~]# /u01/app/12.2/grid/bin/srvctl start vip -n racdb1

[root@racdb1 ~]# /u01/app/12.2/grid/bin/srvctl start vip -n racdb2

[root@racdb1 ~]# /u01/app/12.2/grid/bin/srvctl start listener

 

2.9  先啟SCAN VIP,再啟SCAN監聽

[root@racdb1 ~]#/u01/app/12.2/grid/bin/srvctl start scan

[root@racdb1 ~]#/u01/app/12.2/grid/bin/srvctl start scan_listener

 

第三部分 遷移失敗回退方案

第3部分 

3.1  關閉目標端資料庫或主機

SQL> shutdown immediate

或者

Shell> shutdown -h now

 

3.2  啟動老生產資料庫和監聽

Shell> sqlplus / as sysdba

SQL> alter database activate standby database;

注:由於老生產庫環境處於備庫角色,因此在極端情況下,可以直接強制開啟,恢復業務。


來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/30310891/viewspace-2946969/,如需轉載,請註明出處,否則將追究法律責任。

相關文章