dataguard 切換後更換IP,service_name
本帖最後由 selectshen 於 2014-10-28 16:55 編輯
測試DB資訊:
--DB1
os:rhel5.6 ip:123.0.0.52 oracle version:10.2.0.4 sid:rh10g03 db_role:primary
--DB2
os:rhel5.6 ip:123.0.0.54 oracle version:10.2.0.4 sid:rh10g02 db_role:standby
先做一個簡單的switchover
-----------------DB1
SQL> select switchover_status from v$database;
SWITCHOVER_STATUS
--------------------
SESSIONS ACTIVE
----上條語句的結果如果是to_standby,切換就不需要加with session shutdown
SQL> alter database commit to switchover to physical standby with session shutdown;
Database altered.
SQL> shutdown immediate;
ORA-01507: database not mounted
ORACLE instance shut down.
SQL> startup mount;
ORACLE instance started.
Total System Global Area 599785472 bytes
Fixed Size 2085776 bytes
Variable Size 293604464 bytes
Database Buffers 297795584 bytes
Redo Buffers 6299648 bytes
Database mounted.
SQL> alter database recover managed standby database disconnect from session ;
Database altered.
---------------DB2
SQL> select switchover_status from v$database;
SWITCHOVER_STATUS
--------------------
TO PRIMARY
SQL> alter database commit to switchover to primary;
Database altered.
SQL> alter database open;
Database altered.
SQL> alter system switch logfile;
System altered.
SQL> /
System altered.
--如果你的沒有出什麼錯的話,應該可以看到,就表示已經switchover成功了.
---------------DB2
SQL> select process,thread#,sequence#,status from v$managed_standby;
PROCESS THREAD# SEQUENCE# STATUS
--------- ---------- ---------- ------------
ARCH 1 281 CLOSING
ARCH 1 282 CLOSING
LNS 1 283 WRITING
---------------DB1
SQL> select process,thread#,sequence#,status from v$managed_standby;
PROCESS THREAD# SEQUENCE# STATUS
--------- ---------- ---------- ------------
ARCH 0 0 CONNECTED
ARCH 1 280 CLOSING
MRP0 1 283 WAIT_FOR_LOG
RFS 1 283 IDLE
RFS 0 0 IDLE
順便說一下failover,failover時是不用管DB1了,因為假設或事實DB1已經掛了,
只需在DB2上alter database recover managed standby database finish force;應用日誌,
然後alter database commit to switchover to primary;就行了.
上面的很簡單,但生產環境可能就不只是這樣了.如果我們只是簡單的switchover,客戶端的
tnsnames裡存的可是之前的IP和service_name,此時客戶端就需要修改tnsnames裡對應的IP和
service_name,如果是B/s程式還好,直接的C/S程式每個客戶端都要修,有時甚至已經不現實.
所以常常會在switchover之後,還要修改對應的IP和service_name.最近產生了一個個人覺得比較好
的方案,就是我們只需要修改IP就可以了,不需要修改service_name,而是在建dataguard時就加
一個共有的service_name,客戶端連線都透過這個service_name,而主從之間的傳輸可用原本預設
的service_name(常常就是各自的sid).新加的service_name可以透過靜態註冊或動態註冊都可以.
這樣可以有效避免,常規方式中,客戶端連線的service_name就是primary預設的service_name,
當switchover後,如果在要在新的primary上能讓使用者連線,就要加這個service_name.但如果加了這個
service_name,原有的主從就會因為名稱的衝突無法傳輸.這時的解決辦法可以是重建standby或是修改
sid等,就比較複雜了.
以下測試修改IP:
--假設客戶端連線的IP:123.0.0.52 service_name:rh10g 這裡的service_name已經是兩邊有加的service_name
透過DB1和DB2在 listener.ora中加入:
(SID_DESC =
(SID_NAME = rh10g03)
(ORACLE_HOME = /u01/app/oracle/product/10.2.0/db_1)
(global_dbname = rh10g)
用於靜態註冊.或是透過在DB1和DB2中執行:
SQL> alter system set service_names=rh10g;
用於動態註冊.
--------------------DB1
--需要先把DB1的IP改為一箇中間IP:123.0.0.55,避免修改IP後衝突
--修改裡面IP對應的主機名
vi /etc/hosts
123.0.0.55 srhel10g03
--修改IP為中間IP123.0.0.55
vi /etc/sysconfig/network-scripts/ifcfg-eth0
--修改tnsnames.ora
RH10G02 =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 123.0.0.52)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = rh10g02)
)
)
RH10G03 =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 123.0.0.54)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = rh10g03)
)
)
--重啟網路
service network restart
---------------------------DB2
--修改裡面IP對應的主機名
vi /etc/hosts
123.0.0.52 srhel10g02
--修改IP
vi /etc/sysconfig/network-scripts/ifcfg-eth0
--修改tnsnames.ora
RH10G02 =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 123.0.0.52)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = rh10g02)
)
)
RH10G03 =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 123.0.0.54)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = rh10g03)
)
)
--重啟網路
service network restart
-------------------------DB1
--修改裡面IP對應的主機名
vi /etc/hosts
123.0.0.54 srhel10g03
----修改正確IP 123.0.0.54
vi /etc/sysconfig/network-scripts/ifcfg-eth0
--重啟網路
service network restart
-------------------------DB2
--網路修改完後,在DB2上切幾次日誌檢測是否正常
上面是switchover的方法,如果是failover那就簡單了,直接透過靜態或動態註冊加入原primary的service_name,
然後修改IP就可以了.
--dataguard的幾個引數:
log_archive_config='DG_CONFIG=(orcl01,orcl02)'
log_archive_dest_1='LOCATION=/u09/archivelog/orcl01 VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=orcl01'
LOG_ARCHIVE_DEST_2='SERVICE=orcl02 LGWR ASYNC VALID_FOR=(ONLINE_LOGFILES,primary_ROLE) DB_UNIQUE_NAME=orcl02'
LOG_ARCHIVE_DEST_STATE_1=ENABLE
LOG_ARCHIVE_DEST_STATE_2=defer
FAL_SERVER=orcl02
FAL_CLIENT=orcl01
db_file_name_convert='orcl02','orcl01' scope=spfile;
log_file_name_convert='orcl02','orcl01' scope=spfile;
standby_file_management=auto
測試DB資訊:
--DB1
os:rhel5.6 ip:123.0.0.52 oracle version:10.2.0.4 sid:rh10g03 db_role:primary
--DB2
os:rhel5.6 ip:123.0.0.54 oracle version:10.2.0.4 sid:rh10g02 db_role:standby
先做一個簡單的switchover
-----------------DB1
SQL> select switchover_status from v$database;
SWITCHOVER_STATUS
--------------------
SESSIONS ACTIVE
----上條語句的結果如果是to_standby,切換就不需要加with session shutdown
SQL> alter database commit to switchover to physical standby with session shutdown;
Database altered.
SQL> shutdown immediate;
ORA-01507: database not mounted
ORACLE instance shut down.
SQL> startup mount;
ORACLE instance started.
Total System Global Area 599785472 bytes
Fixed Size 2085776 bytes
Variable Size 293604464 bytes
Database Buffers 297795584 bytes
Redo Buffers 6299648 bytes
Database mounted.
SQL> alter database recover managed standby database disconnect from session ;
Database altered.
---------------DB2
SQL> select switchover_status from v$database;
SWITCHOVER_STATUS
--------------------
TO PRIMARY
SQL> alter database commit to switchover to primary;
Database altered.
SQL> alter database open;
Database altered.
SQL> alter system switch logfile;
System altered.
SQL> /
System altered.
--如果你的沒有出什麼錯的話,應該可以看到,就表示已經switchover成功了.
---------------DB2
SQL> select process,thread#,sequence#,status from v$managed_standby;
PROCESS THREAD# SEQUENCE# STATUS
--------- ---------- ---------- ------------
ARCH 1 281 CLOSING
ARCH 1 282 CLOSING
LNS 1 283 WRITING
---------------DB1
SQL> select process,thread#,sequence#,status from v$managed_standby;
PROCESS THREAD# SEQUENCE# STATUS
--------- ---------- ---------- ------------
ARCH 0 0 CONNECTED
ARCH 1 280 CLOSING
MRP0 1 283 WAIT_FOR_LOG
RFS 1 283 IDLE
RFS 0 0 IDLE
順便說一下failover,failover時是不用管DB1了,因為假設或事實DB1已經掛了,
只需在DB2上alter database recover managed standby database finish force;應用日誌,
然後alter database commit to switchover to primary;就行了.
上面的很簡單,但生產環境可能就不只是這樣了.如果我們只是簡單的switchover,客戶端的
tnsnames裡存的可是之前的IP和service_name,此時客戶端就需要修改tnsnames裡對應的IP和
service_name,如果是B/s程式還好,直接的C/S程式每個客戶端都要修,有時甚至已經不現實.
所以常常會在switchover之後,還要修改對應的IP和service_name.最近產生了一個個人覺得比較好
的方案,就是我們只需要修改IP就可以了,不需要修改service_name,而是在建dataguard時就加
一個共有的service_name,客戶端連線都透過這個service_name,而主從之間的傳輸可用原本預設
的service_name(常常就是各自的sid).新加的service_name可以透過靜態註冊或動態註冊都可以.
這樣可以有效避免,常規方式中,客戶端連線的service_name就是primary預設的service_name,
當switchover後,如果在要在新的primary上能讓使用者連線,就要加這個service_name.但如果加了這個
service_name,原有的主從就會因為名稱的衝突無法傳輸.這時的解決辦法可以是重建standby或是修改
sid等,就比較複雜了.
以下測試修改IP:
--假設客戶端連線的IP:123.0.0.52 service_name:rh10g 這裡的service_name已經是兩邊有加的service_name
透過DB1和DB2在 listener.ora中加入:
(SID_DESC =
(SID_NAME = rh10g03)
(ORACLE_HOME = /u01/app/oracle/product/10.2.0/db_1)
(global_dbname = rh10g)
用於靜態註冊.或是透過在DB1和DB2中執行:
SQL> alter system set service_names=rh10g;
用於動態註冊.
--------------------DB1
--需要先把DB1的IP改為一箇中間IP:123.0.0.55,避免修改IP後衝突
--修改裡面IP對應的主機名
vi /etc/hosts
123.0.0.55 srhel10g03
--修改IP為中間IP123.0.0.55
vi /etc/sysconfig/network-scripts/ifcfg-eth0
--修改tnsnames.ora
RH10G02 =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 123.0.0.52)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = rh10g02)
)
)
RH10G03 =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 123.0.0.54)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = rh10g03)
)
)
--重啟網路
service network restart
---------------------------DB2
--修改裡面IP對應的主機名
vi /etc/hosts
123.0.0.52 srhel10g02
--修改IP
vi /etc/sysconfig/network-scripts/ifcfg-eth0
--修改tnsnames.ora
RH10G02 =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 123.0.0.52)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = rh10g02)
)
)
RH10G03 =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 123.0.0.54)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = rh10g03)
)
)
--重啟網路
service network restart
-------------------------DB1
--修改裡面IP對應的主機名
vi /etc/hosts
123.0.0.54 srhel10g03
----修改正確IP 123.0.0.54
vi /etc/sysconfig/network-scripts/ifcfg-eth0
--重啟網路
service network restart
-------------------------DB2
--網路修改完後,在DB2上切幾次日誌檢測是否正常
上面是switchover的方法,如果是failover那就簡單了,直接透過靜態或動態註冊加入原primary的service_name,
然後修改IP就可以了.
--dataguard的幾個引數:
log_archive_config='DG_CONFIG=(orcl01,orcl02)'
log_archive_dest_1='LOCATION=/u09/archivelog/orcl01 VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=orcl01'
LOG_ARCHIVE_DEST_2='SERVICE=orcl02 LGWR ASYNC VALID_FOR=(ONLINE_LOGFILES,primary_ROLE) DB_UNIQUE_NAME=orcl02'
LOG_ARCHIVE_DEST_STATE_1=ENABLE
LOG_ARCHIVE_DEST_STATE_2=defer
FAL_SERVER=orcl02
FAL_CLIENT=orcl01
db_file_name_convert='orcl02','orcl01' scope=spfile;
log_file_name_convert='orcl02','orcl01' scope=spfile;
standby_file_management=auto
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/28539951/viewspace-1312403/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- dataguard 更換IP,service_name(二)
- oracle dataguard 切換Oracle
- 切換IP地址
- Oracle DataGuard切換步驟Oracle
- DataGuard切換保護模式模式
- oracle 之dataguard standby 切換Oracle
- oracle11g dataguard切換Oracle
- Dataguard failover切換實驗AI
- 實戰dataguard主從切換
- IP地址切換工具
- 【DataGuard】Oracle DataGuard 資料保護模式切換Oracle模式
- Oracle 11.2.0.4 physical dataguard和snapshot dataguard切換Oracle
- Oracle DataGuard switchover切換一例Oracle
- DataGuard主備庫切換步驟
- dataguard之物理standby 日誌切換
- 【DATAGUARD】物理dg的switchover切換(五)
- 如何更換動態IP?
- dataguard 手動切換,檢查指令碼指令碼
- dataguard之物理standby庫failover 切換AI
- 【DATAGUARD】物理dg的failover切換(六)AI
- 切換代理IP時如何檢查IP?
- scan ip的手動切換
- DataGuard---->物理StandBy的角色切換之switchover
- 基於多種場景DataGuard切換方案
- Oracle物理DG自動切換——Dataguard Broker配置Oracle
- 物理dataguard 正常切換 角色轉換,switchover_status 狀態改變
- 切換IP批處理檔案
- 【DATAGUARD】Oracle Dataguard物理備庫切換最佳實踐(sqlplus)OracleSQL
- 物理dataguard 正常切換 腳色轉換,switchover_status 狀態改變
- 帝國cms更換域名後圖片地址更換的方法
- Oracle DataGuard 主備切換 (switchover) oracle11gOracle
- DATAGUARD在做SWITCHOVER切換時遇到問題總結
- ORACLE 11g dataguard系列,手工切換測試Oracle
- 如何更優雅地切換 Git 分支Git
- 備庫的切換狀態為SWITCHOVER PENDING時進行dataguard主備庫角色切換
- 程式切換(上下文切換)
- DataGuard切換(主庫為Rac+備庫為Rac)
- 爬蟲為什麼要用IP代理更換IP地址爬蟲