节点1
grid@node1:~> srvctl config database -d ORACLE
Database unique name: ORACLE
Database name: ORACLE
Oracle home: /u01/app/oracle/product/11.2.0/dbhome_1
Oracle user: oracle
Spfile: +DATA/ORACLE/spfileORACLE.ora
Domain:
Start options: open
Stop options: immediate
Database role:PRIMARY
Management policy: AUTOMATIC
Server pools: ORACLE
Database instances:
Disk Groups: DATA,FRA
Mount point paths:
Services: ORACLESER
Type: RACOneNode
Online relocation timeout: 30
Instance name prefix: ORACLE
Candidate servers:node1,node2
Database is administrator managed
grid@node1:~> crsctl stat res -t
--------------------------------------------------------------------------------
NAME TARGET STATE SERVER STATE_DETAILS
--------------------------------------------------------------------------------
Local Resources
--------------------------------------------------------------------------------
ora.DATA.dg
ONLINE ONLINE node1
ONLINE ONLINE node2
ora.FRA.dg
ONLINE ONLINE node1
ONLINE ONLINE node2
ora.LISTENER.lsnr
ONLINE ONLINE node1
ONLINE ONLINE node2
ora.OCR_VOTE.dg
ONLINE ONLINE node1
ONLINE ONLINE node2
ora.asm
ONLINE ONLINE node1 Started
ONLINE ONLINE node2 Started
ora.gsd
OFFLINEOFFLINE node1
OFFLINEOFFLINE node2
ora.net1.network
ONLINE ONLINE node1
ONLINE ONLINE node2
ora.ons
ONLINE ONLINE node1
ONLINE ONLINE node2
ora.registry.acfs
ONLINE ONLINE node1
ONLINE ONLINE node2
--------------------------------------------------------------------------------
Cluster Resources
--------------------------------------------------------------------------------
ora.LISTENER_SCAN1.lsnr
1 ONLINE ONLINE node2
ora.cvu
1 ONLINE ONLINE node2
ora.node1.vip
1 ONLINE ONLINE node1
ora.node2.vip
1 ONLINE ONLINE node2
ora.oc4j
1 ONLINE ONLINE node2
ora.oracle.db
1 ONLINE ONLINE node1 Open
ora.oracle.oracleser.svc
1 ONLINE ONLINE node1
ora.scan1.vip
1 ONLINE ONLINE node2
grid@node1:~> srvctl status database -d ORACLE
Instance ORACLE_1 is running on node node1
Online relocation: INACTIVE
grid@node1:~>
oracle@node1:~> sqlplus /nolog
SQL*Plus: Release 11.2.0.4.0 Production on Mon May 25 18:01:492015
Copyright (c) 1982, 2013, Oracle. All rights reserved.
SQL> conn /as sysdba
Connected.
SQL> show parameter cluster_database;
NAME TYPE VALUE
------------------------------------ -----------------------------------------
cluster_database boolean TRUE
cluster_database_instances integer 2
SQL> show parameter name
NAME TYPE VALUE
------------------------------------ -----------------------------------------
cell_offloadgroup_name string
db_file_name_convert string
db_name string ORACLE
db_unique_name string ORACLE
global_names boolean FALSE
instance_name string ORACLE_1
lock_name_space string
log_file_name_convert string
processor_group_name string
service_names string ORACLESER
SQL>
节点2
grid@node2:~> srvctl config database -d ORACLE
Database unique name: ORACLE
Database name: ORACLE
Oracle home: /u01/app/oracle/product/11.2.0/dbhome_1
Oracle user: oracle
Spfile: +DATA/ORACLE/spfileORACLE.ora
Domain:
Start options: open
Stop options: immediate
Database role: PRIMARY
Management policy: AUTOMATIC
Server pools: ORACLE
Database instances:
Disk Groups: DATA,FRA
Mount point paths:
Services: ORACLESER
Type: RACOneNode
Online relocation timeout: 30
Instance name prefix: ORACLE
Candidate servers:node1,node2
Database is administrator managed
grid@node2:~> crsctl stat res -t
--------------------------------------------------------------------------------
NAME TARGET STATE SERVER STATE_DETAILS
--------------------------------------------------------------------------------
Local Resources
--------------------------------------------------------------------------------
ora.DATA.dg
ONLINE ONLINE node1
ONLINE ONLINE node2
ora.FRA.dg
ONLINE ONLINE node1
ONLINE ONLINE node2
ora.LISTENER.lsnr
ONLINE ONLINE node1
ONLINE ONLINE node2
ora.OCR_VOTE.dg
ONLINE ONLINE node1
ONLINE ONLINE node2
ora.asm
ONLINE ONLINE node1 Started
ONLINE ONLINE node2 Started
ora.gsd
OFFLINEOFFLINE node1
OFFLINEOFFLINE node2
ora.net1.network
ONLINE ONLINE node1
ONLINE ONLINE node2
ora.ons
ONLINE ONLINE node1
ONLINE ONLINE node2
ora.registry.acfs
ONLINE ONLINE node1
ONLINE ONLINE node2
--------------------------------------------------------------------------------
Cluster Resources
--------------------------------------------------------------------------------
ora.LISTENER_SCAN1.lsnr
1 ONLINE ONLINE node2
ora.cvu
1 ONLINE ONLINE node2
ora.node1.vip
1 ONLINE ONLINE node1
ora.node2.vip
1 ONLINE ONLINE node2
ora.oc4j
1 ONLINE ONLINE node2
ora.oracle.db
1 ONLINE ONLINE node1 Open
ora.oracle.oracleser.svc
1 ONLINE ONLINE node1
ora.scan1.vip
1 ONLINE ONLINE node2
grid@node2:~> srvctl status database -d ORACLE
Instance ORACLE_1 is running on node node1
Online relocation: INACTIVE
grid@node2:~>
此时,实例ORACLE_1运行于节点1上。
在节点1杀死pmon进程,查看数据库状态。
node1:~ # ps -ef|grep pmon
grid 4452 1 0 17:56 ? 00:00:00asm_pmon_+ASM1
oracle 5282 1 0 17:57 ? 00:00:00ora_pmon_ORACLE_1
root 6741 4259 0 18:03 pts/0 00:00:00 greppmon
node1:~ # kill -9 5282
node1:~ # su - grid
grid@node1:~> crsctl stat res -t
--------------------------------------------------------------------------------
NAME TARGET STATE SERVER STATE_DETAILS
--------------------------------------------------------------------------------
Local Resources
--------------------------------------------------------------------------------
ora.DATA.dg
ONLINE ONLINE node1
ONLINE ONLINE node2
ora.FRA.dg
ONLINE ONLINE node1
ONLINE ONLINE node2
ora.LISTENER.lsnr
ONLINE ONLINE node1
ONLINE ONLINE node2
ora.OCR_VOTE.dg
ONLINE ONLINE node1
ONLINE ONLINE node2
ora.asm
ONLINE ONLINE node1 Started
ONLINE ONLINE node2 Started
ora.gsd
OFFLINEOFFLINE node1
OFFLINEOFFLINE node2
ora.net1.network
ONLINE ONLINE node1
ONLINE ONLINE node2
ora.ons
ONLINE ONLINE node1
ONLINE ONLINE node2
ora.registry.acfs
ONLINE ONLINE node1
ONLINE ONLINE node2
--------------------------------------------------------------------------------
Cluster Resources
--------------------------------------------------------------------------------
ora.LISTENER_SCAN1.lsnr
1 ONLINE ONLINE node2
ora.cvu
1 ONLINE ONLINE node2
ora.node1.vip
1 ONLINE ONLINE node1
ora.node2.vip
1 ONLINE ONLINE node2
ora.oc4j
1 ONLINE ONLINE node2
ora.oracle.db
1 ONLINE OFFLINE Abnormal Terminatio
n,CLEANING
ora.oracle.oracleser.svc
1 ONLINE OFFLINE
ora.scan1.vip
1 ONLINE ONLINE node2
grid@node1:~>
等待一分钟再次查看
grid@node1:~> crsctl stat res -t
--------------------------------------------------------------------------------
NAME TARGET STATE SERVER STATE_DETAILS
--------------------------------------------------------------------------------
Local Resources
--------------------------------------------------------------------------------
ora.DATA.dg
ONLINE ONLINE node1
ONLINE ONLINE node2
ora.FRA.dg
ONLINE ONLINE node1
ONLINE ONLINE node2
ora.LISTENER.lsnr
ONLINE ONLINE node1
ONLINE ONLINE node2
ora.OCR_VOTE.dg
ONLINE ONLINE node1
ONLINE ONLINE node2
ora.asm
ONLINE ONLINE node1 Started
ONLINE ONLINE node2 Started
ora.gsd
OFFLINEOFFLINE node1
OFFLINEOFFLINE node2
ora.net1.network
ONLINE ONLINE node1
ONLINE ONLINE node2
ora.ons
ONLINE ONLINE node1
ONLINE ONLINE node2
ora.registry.acfs
ONLINE ONLINE node1
ONLINE ONLINE node2
--------------------------------------------------------------------------------
Cluster Resources
--------------------------------------------------------------------------------
ora.LISTENER_SCAN1.lsnr
1 ONLINE ONLINE node2
ora.cvu
1 ONLINE ONLINE node2
ora.node1.vip
1 ONLINE ONLINE node1
ora.node2.vip
1 ONLINE ONLINE node2
ora.oc4j
1 ONLINE ONLINE node2
ora.oracle.db
1 ONLINE ONLINE node1 Open
ora.oracle.oracleser.svc
1 ONLINE ONLINE node1
ora.scan1.vip
1 ONLINE ONLINE node2
grid@node1:~>
杀死PMON进程后,不发生切换,将会在本机重启进程。
node1:/u01/app/11.2.0/grid/bin # ./srvctl relocate database -dORACLE -n node2
grid@node1:~> srvctl status database -d oracle
Instance ORACLE_1is running on node node1
Online relocation:ACTIVE
Source instance:ORACLE_1 on node1
Destinationinstance: ORACLE_2 on node2
grid@node1:~> crsctl stat res -t
--------------------------------------------------------------------------------
NAME TARGET STATE SERVER STATE_DETAILS
--------------------------------------------------------------------------------
Local Resources
--------------------------------------------------------------------------------
ora.DATA.dg
ONLINE ONLINE node1
ONLINE ONLINE node2
ora.FRA.dg
ONLINE ONLINE node1
ONLINE ONLINE node2
ora.LISTENER.lsnr
ONLINE ONLINE node1
ONLINE ONLINE node2
ora.OCR_VOTE.dg
ONLINE ONLINE node1
ONLINE ONLINE node2
ora.asm
ONLINE ONLINE node1 Started
ONLINE ONLINE node2 Started
ora.gsd
OFFLINE OFFLINE node1
OFFLINEOFFLINE node2
ora.net1.network
ONLINE ONLINE node1
ONLINE ONLINE node2
ora.ons
ONLINE ONLINE node1
ONLINE ONLINE node2
ora.registry.acfs
ONLINE ONLINE node1
ONLINE ONLINE node2
--------------------------------------------------------------------------------
Cluster Resources
--------------------------------------------------------------------------------
ora.LISTENER_SCAN1.lsnr
1 ONLINE ONLINE node2
ora.cvu
1 ONLINE ONLINE node2
ora.node1.vip
1 ONLINE ONLINE node1
ora.node2.vip
1 ONLINE ONLINE node2
ora.oc4j
1 ONLINE ONLINE node2
ora.oracle.db
1 ONLINE ONLINE node1 Open
2 ONLINE OFFLINE STARTING
ora.oracle.oracleser.svc
1 ONLINE ONLINE node1
ora.scan1.vip
1 ONLINE ONLINE node2
再次查看
grid@node1:~> crsctl stat res -t
--------------------------------------------------------------------------------
NAME TARGET STATE SERVER STATE_DETAILS
--------------------------------------------------------------------------------
Local Resources
--------------------------------------------------------------------------------
ora.DATA.dg
ONLINE ONLINE node1
ONLINE ONLINE node2
ora.FRA.dg
ONLINE ONLINE node1
ONLINE ONLINE node2
ora.LISTENER.lsnr
ONLINE ONLINE node1
ONLINE ONLINE node2
ora.OCR_VOTE.dg
ONLINE ONLINE node1
ONLINE ONLINE node2
ora.asm
ONLINE ONLINE node1 Started
ONLINE ONLINE node2 Started
ora.gsd
OFFLINEOFFLINE node1
OFFLINEOFFLINE node2
ora.net1.network
ONLINE ONLINE node1
ONLINE ONLINE node2
ora.ons
ONLINE ONLINE node1
ONLINE ONLINE node2
ora.registry.acfs
ONLINE ONLINE node1
ONLINE ONLINE node2
--------------------------------------------------------------------------------
Cluster Resources
--------------------------------------------------------------------------------
ora.LISTENER_SCAN1.lsnr
1 ONLINE ONLINE node2
ora.cvu
1 ONLINE ONLINE node2
ora.node1.vip
1 ONLINE ONLINE node1
ora.node2.vip
1 ONLINE ONLINE node2
ora.oc4j
1 ONLINE ONLINE node2
ora.oracle.db
1 ONLINE ONLINE node1 Open
2 ONLINE OFFLINE STARTING
ora.oracle.oracleser.svc
1 ONLINE ONLINE node1
ora.scan1.vip
1 ONLINE ONLINE node2
再次查看
grid@node1:~> crsctl stat res -t
--------------------------------------------------------------------------------
NAME TARGET STATE SERVER STATE_DETAILS
--------------------------------------------------------------------------------
Local Resources
--------------------------------------------------------------------------------
ora.DATA.dg
ONLINE ONLINE node1
ONLINE ONLINE node2
ora.FRA.dg
ONLINE ONLINE node1
ONLINE ONLINE node2
ora.LISTENER.lsnr
ONLINE ONLINE node1
ONLINE ONLINE node2
ora.OCR_VOTE.dg
ONLINE ONLINE node1
ONLINE ONLINE node2
ora.asm
ONLINE ONLINE node1 Started
ONLINE ONLINE node2 Started
ora.gsd
OFFLINEOFFLINE node1
OFFLINEOFFLINE node2
ora.net1.network
ONLINE ONLINE node1
ONLINE ONLINE node2
ora.ons
ONLINE ONLINE node1
ONLINE ONLINE node2
ora.registry.acfs
ONLINE ONLINE node1
ONLINE ONLINE node2
--------------------------------------------------------------------------------
Cluster Resources
--------------------------------------------------------------------------------
ora.LISTENER_SCAN1.lsnr
1 ONLINE ONLINE node2
ora.cvu
1 ONLINE ONLINE node2
ora.node1.vip
1 ONLINE ONLINE node1
ora.node2.vip
1 ONLINE ONLINE node2
ora.oc4j
1 ONLINE ONLINE node2
ora.oracle.db
1 OFFLINE ONLINE node1 Open,STOPPING
2 ONLINE ONLINE node2 Open
ora.oracle.oracleser.svc
1 ONLINE ONLINE node2
ora.scan1.vip
1 ONLINE ONLINE node2
再次查看
grid@node1:~> crsctl stat res -t
--------------------------------------------------------------------------------
NAME TARGET STATE SERVER STATE_DETAILS
--------------------------------------------------------------------------------
Local Resources
--------------------------------------------------------------------------------
ora.DATA.dg
ONLINE ONLINE node1
ONLINE ONLINE node2
ora.FRA.dg
ONLINE ONLINE node1
ONLINE ONLINE node2
ora.LISTENER.lsnr
ONLINE ONLINE node1
ONLINE ONLINE node2
ora.OCR_VOTE.dg
ONLINE ONLINE node1
ONLINE ONLINE node2
ora.asm
ONLINE ONLINE node1 Started
ONLINE ONLINE node2 Started
ora.gsd
OFFLINEOFFLINE node1
OFFLINEOFFLINE node2
ora.net1.network
ONLINE ONLINE node1
ONLINE ONLINE node2
ora.ons
ONLINE ONLINE node1
ONLINE ONLINE node2
ora.registry.acfs
ONLINE ONLINE node1
ONLINE ONLINE node2
--------------------------------------------------------------------------------
Cluster Resources
--------------------------------------------------------------------------------
ora.LISTENER_SCAN1.lsnr
1 ONLINE ONLINE node2
ora.cvu
1 ONLINE ONLINE node2
ora.node1.vip
1 ONLINE ONLINE node1
ora.node2.vip
1 ONLINE ONLINE node2
ora.oc4j
1 ONLINE ONLINE node2
ora.oracle.db
2 ONLINE ONLINE node2 Open
ora.oracle.oracleser.svc
1 ONLINE ONLINE node2
ora.scan1.vip
1 ONLINE ONLINE node2
grid@node1:~>
此时在节点2进行查看
grid@node2:~> srvctl config database -d ORACLE
HDatabase unique name: ORACLE
Database name: ORACLE
Oracle home: /u01/app/oracle/product/11.2.0/dbhome_1
Oracle user: oracle
Spfile: +DATA/ORACLE/spfileORACLE.ora
Domain:
Start options: open
Stop options: immediate
Database role: PRIMARY
Management policy: AUTOMATIC
Server pools: ORACLE
Database instances:
Disk Groups: DATA,FRA
Mount point paths:
Services: ORACLESER
Type: RACOneNode
Online relocation timeout: 30
Instance name prefix: ORACLE
Candidate servers: node1,node2
Database is administrator managed
grid@node2:~> srvctl status database -d ORACLE
Instance ORACLE_2is running on node node2
Online relocation:INACTIVE
grid@node2:~> crsctl stat res -t
--------------------------------------------------------------------------------
NAME TARGET STATE SERVER STATE_DETAILS
--------------------------------------------------------------------------------
Local Resources
--------------------------------------------------------------------------------
ora.DATA.dg
ONLINE ONLINE node1
ONLINE ONLINE node2
ora.FRA.dg
ONLINE ONLINE node1
ONLINE ONLINE node2
ora.LISTENER.lsnr
ONLINE ONLINE node1
ONLINE ONLINE node2
ora.OCR_VOTE.dg
ONLINE ONLINE node1
ONLINE ONLINE node2
ora.asm
ONLINE ONLINE node1 Started
ONLINE ONLINE node2 Started
ora.gsd
OFFLINE OFFLINE node1
OFFLINEOFFLINE node2
ora.net1.network
ONLINE ONLINE node1
ONLINE ONLINE node2
ora.ons
ONLINE ONLINE node1
ONLINE ONLINE node2
ora.registry.acfs
ONLINE ONLINE node1
ONLINE ONLINE node2
--------------------------------------------------------------------------------
Cluster Resources
--------------------------------------------------------------------------------
ora.LISTENER_SCAN1.lsnr
1 ONLINE ONLINE node2
ora.cvu
1 ONLINE ONLINE node2
ora.node1.vip
1 ONLINE ONLINE node1
ora.node2.vip
1 ONLINE ONLINE node2
ora.oc4j
1 ONLINE ONLINE node2
ora.oracle.db
2 ONLINE ONLINE node2 Open
ora.oracle.oracleser.svc
1 ONLINE ONLINE node2
ora.scan1.vip
1 ONLINE ONLINE node2
grid@node2:~>
发生切换后实例ORACLE_1变为ORACLE_2运行于节点2上运行。