oracle資料庫服務切換

tangyunoracle發表於2012-05-13
oracle資料庫的服務切換其實也是一個很簡單的過程,不過因為很多地方都不使用服務,所以很多剛開始接觸oracle的兄弟都對這個東西不是很熟悉,前以前還有一個開發商的同事問起這個東西。所以這裡就把之前做的一個實際例子貼一下供一些剛接觸的朋友參考。[@more@]

-------節點1
bash-2.05$ crs_stat -t
Name Type Target State Host
------------------------------------------------------------
ora....SM1.asm application ONLINE ONLINE gddb21
ora.gddb21.gsd application ONLINE ONLINE gddb21
ora.gddb21.ons application ONLINE ONLINE gddb21
ora.gddb21.vip application ONLINE ONLINE gddb21
ora....SM2.asm application ONLINE ONLINE gddb22
ora.gddb22.gsd application ONLINE ONLINE gddb22
ora.gddb22.ons application ONLINE ONLINE gddb22
ora.gddb22.vip application ONLINE ONLINE gddb22
ora.uwnms2.db application ONLINE ONLINE gddb22
ora....nms2.cs application ONLINE ONLINE gddb22
ora....s21.srv application ONLINE ONLINE gddb21
ora....s22.srv application ONLINE ONLINE gddb22
ora....ms21.cs application ONLINE ONLINE gddb22
ora....21.inst application ONLINE ONLINE gddb21
ora....s21.srv application ONLINE ONLINE gddb21
ora....ms22.cs application ONLINE ONLINE gddb22
ora....22.inst application ONLINE ONLINE gddb22
ora....s22.srv application ONLINE ONLINE gddb22

SQL> show parameter service
NAME TYPE VALUE
------------------------------------ -----------
service_names string uwnms21, suwnms2, uwnms2
SQL>
------------節點2----
bash-2.05$ crs_stat -t
Name Type Target State Host
------------------------------------------------------------
ora....SM1.asm application ONLINE ONLINE gddb21
ora.gddb21.gsd application ONLINE ONLINE gddb21
ora.gddb21.ons application ONLINE ONLINE gddb21
ora.gddb21.vip application ONLINE ONLINE gddb21
ora....SM2.asm application ONLINE ONLINE gddb22
ora.gddb22.gsd application ONLINE ONLINE gddb22
ora.gddb22.ons application ONLINE ONLINE gddb22
ora.gddb22.vip application ONLINE ONLINE gddb22
ora.uwnms2.db application ONLINE ONLINE gddb22
ora....nms2.cs application ONLINE ONLINE gddb22
ora....s21.srv application ONLINE ONLINE gddb21
ora....s22.srv application ONLINE ONLINE gddb22
ora....ms21.cs application ONLINE ONLINE gddb22
ora....21.inst application ONLINE ONLINE gddb21
ora....s21.srv application ONLINE ONLINE gddb21
ora....ms22.cs application ONLINE ONLINE gddb22
ora....22.inst application ONLINE ONLINE gddb22
ora....s22.srv application ONLINE ONLINE gddb22

SQL> show parameter service

NAME TYPE VALUE
------------------------------------ -----------
service_names string uwnms2, suwnms2, uwnms22
------把服務切到節點1上
bash-2.05$srvctl relocate service -d uwnms2 -s uwnms22 -i uwnms22 -t uwnms21
-------------節點1-------
SQL> show parameter service
NAME TYPE VALUE
------------------------------------ -----------
service_names string uwnms21, suwnms2, uwnms2, uwnms22
----------節點2-------------
---接著先停掉agent
---接著停掉監聽
---殺掉LOCAL=NO的程式
---停掉例項
---停掉ASM
---停掉其他資源
---停掉CRS
bash-2.05$ crs_stat -t
Name Type Target State Host
------------------------------------------------------------
ora....SM1.asm application ONLINE ONLINE gddb21
ora.gddb21.gsd application ONLINE ONLINE gddb21
ora.gddb21.ons application ONLINE ONLINE gddb21
ora.gddb21.vip application ONLINE ONLINE gddb21
ora....SM2.asm application OFFLINE OFFLINE
ora.gddb22.gsd application OFFLINE OFFLINE
ora.gddb22.ons application OFFLINE OFFLINE
ora.gddb22.vip application OFFLINE OFFLINE
ora.uwnms2.db application ONLINE ONLINE gddb21
ora....nms2.cs application ONLINE ONLINE gddb21
ora....s21.srv application ONLINE ONLINE gddb21
ora....s22.srv application ONLINE OFFLINE
ora....ms21.cs application ONLINE ONLINE gddb21
ora....21.inst application ONLINE ONLINE gddb21
ora....s21.srv application ONLINE ONLINE gddb21
ora....ms22.cs application ONLINE ONLINE gddb21
ora....22.inst application OFFLINE OFFLINE
ora....s22.srv application ONLINE ONLINE gddb21
-------啟動CRS,其他資源會自動啟動
bash-2.05$ crs_stat -t
Name Type Target State Host
------------------------------------------------------------
ora....SM1.asm application ONLINE ONLINE gddb21
ora.gddb21.gsd application ONLINE ONLINE gddb21
ora.gddb21.ons application ONLINE ONLINE gddb21
ora.gddb21.vip application ONLINE ONLINE gddb21
ora....SM2.asm application ONLINE ONLINE gddb22
ora.gddb22.gsd application ONLINE ONLINE gddb22
ora.gddb22.ons application ONLINE ONLINE gddb22
ora.gddb22.vip application ONLINE ONLINE gddb22
ora.uwnms2.db application ONLINE ONLINE gddb21
ora....nms2.cs application ONLINE ONLINE gddb21
ora....s21.srv application ONLINE ONLINE gddb21
ora....s22.srv application ONLINE OFFLINE
ora....ms21.cs application ONLINE ONLINE gddb21
ora....21.inst application ONLINE ONLINE gddb21
ora....s21.srv application ONLINE ONLINE gddb21
ora....ms22.cs application ONLINE ONLINE gddb21
ora....22.inst application ONLINE ONLINE gddb22
ora....s22.srv application ONLINE ONLINE gddb22
-------在節點1上把服務切回來
bash-2.05$ srvctl relocate service -d uwnms2 -s uwnms22 -i uwnms21 -t uwnms22
SQL> show parameter service
NAME TYPE VALUE
------------------------------------ -----------
service_names string uwnms2, suwnms2, uwnms22
bash-2.05$ crs_stat -t
Name Type Target State Host
------------------------------------------------------------
ora....SM1.asm application ONLINE ONLINE gddb21
ora.gddb21.gsd application ONLINE ONLINE gddb21
ora.gddb21.ons application ONLINE ONLINE gddb21
ora.gddb21.vip application ONLINE ONLINE gddb21
ora....SM2.asm application ONLINE ONLINE gddb22
ora.gddb22.gsd application ONLINE ONLINE gddb22
ora.gddb22.ons application ONLINE ONLINE gddb22
ora.gddb22.vip application ONLINE ONLINE gddb22
ora.uwnms2.db application ONLINE ONLINE gddb21
ora....nms2.cs application ONLINE ONLINE gddb21
ora....s21.srv application ONLINE ONLINE gddb21
ora....s22.srv application ONLINE ONLINE gddb22
ora....ms21.cs application ONLINE ONLINE gddb21
ora....21.inst application ONLINE ONLINE gddb21
ora....s21.srv application ONLINE ONLINE gddb21
ora....ms22.cs application ONLINE ONLINE gddb21
ora....22.inst application ONLINE ONLINE gddb22
ora....s22.srv application ONLINE ONLINE gddb22
---------檢查監聽是否正常
---------啟動agent
---------檢查gc狀態
srvctl relocate service -d -s -I -t
將當前執行在DGDB2的SDG服務切換回DGDB1例項
srvctl relocate service -d dgdb -s sdg -i dgdb2 -t dgdb1(如沒有使用者連線,可在30秒內完成操作)
執行該操作會自動中止使用者連線,建議服務切換時,先通知開發商停止使用者,同時使用以下服務啟停方式進行切換。
啟動服務:srvctl start service -d dgdb -s sdg -i dgdb1
停止服務:srvctl stop service -d dgdb -s sdg

其實執行一下 srvctl -help 一切操作都很清楚了。

---------End-----------------------------------------

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

相關文章