oracle rac service学习

1.添加服务,添加完成服务之后默认服务不会启动,需要手工启动:

[oracle@suq1 ~]$srvctl add service -d suq -s srv1 -r suq1,suq2
[grid@suq1 admin]$ crsctl stat res -t
--------------------------------------------------------------------------------
NAME           TARGET  STATE        SERVER                   STATE_DETAILS       
--------------------------------------------------------------------------------
Local Resources
--------------------------------------------------------------------------------
ora.BACKUP.dg
               ONLINE  ONLINE       suq1                                         
               ONLINE  ONLINE       suq2                                         
ora.DATADG.dg
               ONLINE  ONLINE       suq1                                         
               ONLINE  ONLINE       suq2                                         
ora.LISTENER.lsnr
               ONLINE  ONLINE       suq1                                         
               ONLINE  ONLINE       suq2                                         
ora.SYSTEMDG.dg
               ONLINE  ONLINE       suq1                                         
               ONLINE  ONLINE       suq2                                         
ora.asm
               ONLINE  ONLINE       suq1                     Started             
               ONLINE  ONLINE       suq2                     Started             
ora.gsd
               OFFLINE OFFLINE      suq1                                         
               OFFLINE OFFLINE      suq2                                         
ora.net1.network
               ONLINE  ONLINE       suq1                                         
               ONLINE  ONLINE       suq2                                         
ora.ons
               ONLINE  ONLINE       suq1                                         
               ONLINE  ONLINE       suq2                                         
ora.registry.acfs
               ONLINE  ONLINE       suq1                                         
               ONLINE  ONLINE       suq2                                         
--------------------------------------------------------------------------------
Cluster Resources
--------------------------------------------------------------------------------
ora.LISTENER_SCAN1.lsnr
      1        ONLINE  ONLINE       suq2                                         
ora.cvu
      1        ONLINE  ONLINE       suq2                                         
ora.oc4j
      1        ONLINE  ONLINE       suq2                                         
ora.scan1.vip
      1        ONLINE  ONLINE       suq2                                         
ora.suq.db
      1        ONLINE  ONLINE       suq1                     Open                
      2        ONLINE  ONLINE       suq2                     Open                
ora.suq.srv1.svc
      1        OFFLINE OFFLINE                                                   
      2        OFFLINE OFFLINE                                                   
ora.suq1.vip
      1        ONLINE  ONLINE       suq1                                         
ora.suq2.vip
      1        ONLINE  ONLINE       suq2 


2.查看服务信息,并且手工启动服务:

[oracle@suq1 ~]$ srvctl config service -d suq -s srv1
Service name: srv1
Service is enabled
Server pool: suq_srv1
Cardinality: 2
Disconnect: false
Service role: PRIMARY
Management policy: AUTOMATIC
DTP transaction: false
AQ HA notifications: false
Failover type: NONE
Failover method: NONE
TAF failover retries: 0
TAF failover delay: 0
Connection Load Balancing Goal: LONG
Runtime Load Balancing Goal: NONE
TAF policy specification: NONE
Edition: 
Preferred instances: suq1,suq2
Available instances: 
[grid@suq1 admin]$ srvctl start service -d suq -s srv1
[grid@suq1 admin]$ crsctl stat res -t
--------------------------------------------------------------------------------
NAME           TARGET  STATE        SERVER                   STATE_DETAILS       
--------------------------------------------------------------------------------
Local Resources
--------------------------------------------------------------------------------
ora.BACKUP.dg
               ONLINE  ONLINE       suq1                                         
               ONLINE  ONLINE       suq2                                         
ora.DATADG.dg
               ONLINE  ONLINE       suq1                                         
               ONLINE  ONLINE       suq2                                         
ora.LISTENER.lsnr
               ONLINE  ONLINE       suq1                                         
               ONLINE  ONLINE       suq2                                         
ora.SYSTEMDG.dg
               ONLINE  ONLINE       suq1                                         
               ONLINE  ONLINE       suq2                                         
ora.asm
               ONLINE  ONLINE       suq1                     Started             
               ONLINE  ONLINE       suq2                     Started             
ora.gsd
               OFFLINE OFFLINE      suq1                                         
               OFFLINE OFFLINE      suq2                                         
ora.net1.network
               ONLINE  ONLINE       suq1                                         
               ONLINE  ONLINE       suq2                                         
ora.ons
               ONLINE  ONLINE       suq1                                         
               ONLINE  ONLINE       suq2                                         
ora.registry.acfs
               ONLINE  ONLINE       suq1                                         
               ONLINE  ONLINE       suq2                                         
--------------------------------------------------------------------------------
Cluster Resources
--------------------------------------------------------------------------------
ora.LISTENER_SCAN1.lsnr
      1        ONLINE  ONLINE       suq2                                         
ora.cvu
      1        ONLINE  ONLINE       suq2                                         
ora.oc4j
      1        ONLINE  ONLINE       suq2                                         
ora.scan1.vip
      1        ONLINE  ONLINE       suq2                                         
ora.suq.db
      1        ONLINE  ONLINE       suq1                     Open                
      2        ONLINE  ONLINE       suq2                     Open                
ora.suq.srv1.svc
      1        ONLINE  ONLINE       suq1                                         
      2        ONLINE  ONLINE       suq2                                         
ora.suq1.vip
      1        ONLINE  ONLINE       suq1                                         
ora.suq2.vip
      1        ONLINE  ONLINE       suq2  

3.修改服务,让服务只可运行在实力1上:

[oracle@suq1 ~]$  srvctl modify service -d suq -s srv1 -i suq1 -n

[grid@suq1 admin]$ crsctl stat res -t
--------------------------------------------------------------------------------
NAME           TARGET  STATE        SERVER                   STATE_DETAILS       
--------------------------------------------------------------------------------
Local Resources
--------------------------------------------------------------------------------
ora.BACKUP.dg
               ONLINE  ONLINE       suq1                                         
               ONLINE  ONLINE       suq2                                         
ora.DATADG.dg
               ONLINE  ONLINE       suq1                                         
               ONLINE  ONLINE       suq2                                         
ora.LISTENER.lsnr
               ONLINE  ONLINE       suq1                                         
               ONLINE  ONLINE       suq2                                         
ora.SYSTEMDG.dg
               ONLINE  ONLINE       suq1                                         
               ONLINE  ONLINE       suq2                                         
ora.asm
               ONLINE  ONLINE       suq1                     Started             
               ONLINE  ONLINE       suq2                     Started             
ora.gsd
               OFFLINE OFFLINE      suq1                                         
               OFFLINE OFFLINE      suq2                                         
ora.net1.network
               ONLINE  ONLINE       suq1                                         
               ONLINE  ONLINE       suq2                                         
ora.ons
               ONLINE  ONLINE       suq1                                         
               ONLINE  ONLINE       suq2                                         
ora.registry.acfs
               ONLINE  ONLINE       suq1                                         
               ONLINE  ONLINE       suq2                                         
--------------------------------------------------------------------------------
Cluster Resources
--------------------------------------------------------------------------------
ora.LISTENER_SCAN1.lsnr
      1        ONLINE  ONLINE       suq2                                         
ora.cvu
      1        ONLINE  ONLINE       suq2                                         
ora.oc4j
      1        ONLINE  ONLINE       suq2                                         
ora.scan1.vip
      1        ONLINE  ONLINE       suq2                                         
ora.suq.db
      1        ONLINE  ONLINE       suq1                     Open                
      2        ONLINE  ONLINE       suq2                     Open                
ora.suq.srv1.svc
      1        ONLINE  ONLINE       suq1                                         
ora.suq1.vip
      1        ONLINE  ONLINE       suq1                                         
ora.suq2.vip
      1        ONLINE  ONLINE       suq2  

4.先将可用实例添加上实例2,然后手工将服务从实例1 relocate到实例2上:

      
[oracle@suq1 ~]$ srvctl stop service -d suq -s srv1 -i suq1
[grid@suq1 admin]$ crsctl stat res -t
--------------------------------------------------------------------------------
NAME           TARGET  STATE        SERVER                   STATE_DETAILS       
--------------------------------------------------------------------------------
Local Resources
--------------------------------------------------------------------------------
ora.BACKUP.dg
               ONLINE  ONLINE       suq1                                         
               ONLINE  ONLINE       suq2                                         
ora.DATADG.dg
               ONLINE  ONLINE       suq1                                         
               ONLINE  ONLINE       suq2                                         
ora.LISTENER.lsnr
               ONLINE  ONLINE       suq1                                         
               ONLINE  ONLINE       suq2                                         
ora.SYSTEMDG.dg
               ONLINE  ONLINE       suq1                                         
               ONLINE  ONLINE       suq2                                         
ora.asm
               ONLINE  ONLINE       suq1                     Started             
               ONLINE  ONLINE       suq2                     Started             
ora.gsd
               OFFLINE OFFLINE      suq1                                         
               OFFLINE OFFLINE      suq2                                         
ora.net1.network
               ONLINE  ONLINE       suq1                                         
               ONLINE  ONLINE       suq2                                         
ora.ons
               ONLINE  ONLINE       suq1                                         
               ONLINE  ONLINE       suq2                                         
ora.registry.acfs
               ONLINE  ONLINE       suq1                                         
               ONLINE  ONLINE       suq2                                         
--------------------------------------------------------------------------------
Cluster Resources
--------------------------------------------------------------------------------
ora.LISTENER_SCAN1.lsnr
      1        ONLINE  ONLINE       suq2                                         
ora.cvu
      1        ONLINE  ONLINE       suq2                                         
ora.oc4j
      1        ONLINE  ONLINE       suq2                                         
ora.scan1.vip
      1        ONLINE  ONLINE       suq2                                         
ora.suq.db
      1        ONLINE  ONLINE       suq1                     Open                
      2        ONLINE  ONLINE       suq2                     Open                
ora.suq.srv1.svc
      1        OFFLINE OFFLINE                                                   
ora.suq1.vip
      1        ONLINE  ONLINE       suq1                                         
ora.suq2.vip
      1        ONLINE  ONLINE       suq2   

[oracle@suq1 ~]$ srvctl modify  service -d suq -s srv1 -i suq1,suq2 -n 

[grid@suq1 admin]$ crsctl stat res -t
--------------------------------------------------------------------------------
NAME           TARGET  STATE        SERVER                   STATE_DETAILS       
--------------------------------------------------------------------------------
Local Resources
--------------------------------------------------------------------------------
ora.BACKUP.dg
               ONLINE  ONLINE       suq1                                         
               ONLINE  ONLINE       suq2                                         
ora.DATADG.dg
               ONLINE  ONLINE       suq1                                         
               ONLINE  ONLINE       suq2                                         
ora.LISTENER.lsnr
               ONLINE  ONLINE       suq1                                         
               ONLINE  ONLINE       suq2                                         
ora.SYSTEMDG.dg
               ONLINE  ONLINE       suq1                                         
               ONLINE  ONLINE       suq2                                         
ora.asm
               ONLINE  ONLINE       suq1                     Started             
               ONLINE  ONLINE       suq2                     Started             
ora.gsd
               OFFLINE OFFLINE      suq1                                         
               OFFLINE OFFLINE      suq2                                         
ora.net1.network
               ONLINE  ONLINE       suq1                                         
               ONLINE  ONLINE       suq2                                         
ora.ons
               ONLINE  ONLINE       suq1                                         
               ONLINE  ONLINE       suq2                                         
ora.registry.acfs
               ONLINE  ONLINE       suq1                                         
               ONLINE  ONLINE       suq2                                         
--------------------------------------------------------------------------------
Cluster Resources
--------------------------------------------------------------------------------
ora.LISTENER_SCAN1.lsnr
      1        ONLINE  ONLINE       suq2                                         
ora.cvu
      1        ONLINE  ONLINE       suq2                                         
ora.oc4j
      1        ONLINE  ONLINE       suq2                                         
ora.scan1.vip
      1        ONLINE  ONLINE       suq2                                         
ora.suq.db
      1        ONLINE  ONLINE       suq1                     Open                
      2        ONLINE  ONLINE       suq2                     Open                
ora.suq.srv1.svc
      1        ONLINE  ONLINE       suq1                                         
      2        OFFLINE OFFLINE                                                  
ora.suq1.vip
      1        ONLINE  ONLINE       suq1                                         
ora.suq2.vip
      1        ONLINE  ONLINE       suq2  
      
[oracle@suq1 ~]$ srvctl relocate service -d suq -s srv1 -i suq1 -t suq2   #-i 源实例 -t 目标实例

[grid@suq1 admin]$ crsctl stat res -t
--------------------------------------------------------------------------------
NAME           TARGET  STATE        SERVER                   STATE_DETAILS       
--------------------------------------------------------------------------------
Local Resources
--------------------------------------------------------------------------------
ora.BACKUP.dg
               ONLINE  ONLINE       suq1                                         
               ONLINE  ONLINE       suq2                                         
ora.DATADG.dg
               ONLINE  ONLINE       suq1                                         
               ONLINE  ONLINE       suq2                                         
ora.LISTENER.lsnr
               ONLINE  ONLINE       suq1                                         
               ONLINE  ONLINE       suq2                                         
ora.SYSTEMDG.dg
               ONLINE  ONLINE       suq1                                         
               ONLINE  ONLINE       suq2                                         
ora.asm
               ONLINE  ONLINE       suq1                     Started             
               ONLINE  ONLINE       suq2                     Started             
ora.gsd
               OFFLINE OFFLINE      suq1                                         
               OFFLINE OFFLINE      suq2                                         
ora.net1.network
               ONLINE  ONLINE       suq1                                         
               ONLINE  ONLINE       suq2                                         
ora.ons
               ONLINE  ONLINE       suq1                                         
               ONLINE  ONLINE       suq2                                         
ora.registry.acfs
               ONLINE  ONLINE       suq1                                         
               ONLINE  ONLINE       suq2                                         
--------------------------------------------------------------------------------
Cluster Resources
--------------------------------------------------------------------------------
ora.LISTENER_SCAN1.lsnr
      1        ONLINE  ONLINE       suq2                                         
ora.cvu
      1        ONLINE  ONLINE       suq2                                         
ora.oc4j
      1        ONLINE  ONLINE       suq2                                         
ora.scan1.vip
      1        ONLINE  ONLINE       suq2                                         
ora.suq.db
      1        ONLINE  ONLINE       suq1                     Open                
      2        ONLINE  ONLINE       suq2                     Open                
ora.suq.srv1.svc
      1        ONLINE  ONLINE       suq2                                         
      2        OFFLINE OFFLINE                                                
ora.suq1.vip
      1        ONLINE  ONLINE       suq1                                         
ora.suq2.vip
      1        ONLINE  ONLINE       suq2  
5.查看服务状态:
[oracle@suq1 ~]$ srvctl status service -d suq -s srv1
Service srv1 is running on instance(s) suq2

6.删除服务:

[oracle@suq1 ~]$ srvctl remove service -d suq -s srv1 
PRCR-1025 : Resource ora.suq.srv1.svc is still running
[oracle@suq1 ~]$ srvctl stop service -d suq -s srv1
[oracle@suq1 ~]$ srvctl remove service -d suq -s srv1 


你可能感兴趣的:(service,RAC)