RAC 11.2.0.3 維護命令(三) SRVCTL管理services

snowdba發表於2014-07-15
一,建立服務
在例項1建立服務 team1
[oracle@node1 ~]$ srvctl add service -d PROD -s team1 -r "PROD1"
[oracle@node1 ~]$
[oracle@node1 ~]$ srvctl config database -d PROD
Database unique name: PROD
Database name:
Oracle home: /s01/oracle/app/oracle/product/11.2.0/dbhome_1
Oracle user: oracle
Spfile:
Domain:
Start options: open
Stop options: immediate
Database role: PRIMARY
Management policy: AUTOMATIC
Server pools: PROD
Database instances: PROD1,PROD2
Disk Groups: DATA,ARCH
Mount point paths:
Services: team1
Type: RAC
Database is administrator managed

在例項2建立服務team2
[oracle@node1 ~]$ srvctl add service -d PROD -s team2 -r "PROD2"
[oracle@node1 ~]$
[oracle@node1 ~]$ srvctl config database -d PROD
Database unique name: PROD
Database name:
Oracle home: /s01/oracle/app/oracle/product/11.2.0/dbhome_1
Oracle user: oracle
Spfile:
Domain:
Start options: open
Stop options: immediate
Database role: PRIMARY
Management policy: AUTOMATIC
Server pools: PROD
Database instances: PROD1,PROD2
Disk Groups: DATA,ARCH
Mount point paths:
Services: team1,team2
Type: RAC
Database is administrator managed


二,檢視服務狀態
剛剛建立好的服務team1, team2為離線狀態
[grid@node1 ~]$ crsctl status res ora.prod.team1.svc -t
--------------------------------------------------------------------------------
NAME           TARGET  STATE        SERVER                   STATE_DETAILS      
--------------------------------------------------------------------------------
Cluster Resources
--------------------------------------------------------------------------------
ora.prod.team1.svc
      1        OFFLINE OFFLINE                                                  


[grid@node1 ~]$ crsctl status res ora.prod.team2.svc -t
--------------------------------------------------------------------------------
NAME           TARGET  STATE        SERVER                   STATE_DETAILS      
--------------------------------------------------------------------------------
Cluster Resources
--------------------------------------------------------------------------------
ora.prod.team2.svc
      1        OFFLINE OFFLINE     


三,啟動服務
啟動新建服務team1, team2
[grid@node1 ~]$ srvctl start service -d PROD -s team1

[grid@node1 ~]$ crsctl status res ora.prod.team1.svc -t
--------------------------------------------------------------------------------
NAME           TARGET  STATE        SERVER                   STATE_DETAILS      
--------------------------------------------------------------------------------
Cluster Resources
--------------------------------------------------------------------------------
ora.prod.team1.svc
      1        ONLINE  ONLINE       node1                                       


[grid@node1 ~]$ srvctl start service -d PROD -s team2
[grid@node1 ~]$ crsctl status res ora.prod.team2.svc -t
--------------------------------------------------------------------------------
NAME           TARGET  STATE        SERVER                   STATE_DETAILS      
--------------------------------------------------------------------------------
Cluster Resources
--------------------------------------------------------------------------------
ora.prod.team2.svc
      1        ONLINE  ONLINE       node2 


四,停止服務
停止新建服務team1, team2
[grid@node1 ~]$ srvctl stop service -d PROD -s team1

[grid@node1 ~]$ crsctl status res ora.prod.team1.svc -t
--------------------------------------------------------------------------------
NAME           TARGET  STATE        SERVER                   STATE_DETAILS      
--------------------------------------------------------------------------------
Cluster Resources
--------------------------------------------------------------------------------
ora.prod.team1.svc
      1        OFFLINE OFFLINE  


[grid@node1 ~]$ srvctl stop service -d PROD -s team2

[grid@node1 ~]$ crsctl status res ora.prod.team2.svc -t
--------------------------------------------------------------------------------
NAME           TARGET  STATE        SERVER                   STATE_DETAILS      
--------------------------------------------------------------------------------
Cluster Resources
--------------------------------------------------------------------------------
ora.prod.team2.svc
      1        OFFLINE OFFLINE 


五,禁用服務
[grid@node1 ~]$ srvctl disable service -d PROD -s team1

[grid@node1 ~]$ srvctl config service -d PROD
Service name: team1
Service is disabled
Server pool: PROD_team1
Cardinality: 1
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: PROD1
Available instances:
Service name: team2
Service is enabled
Server pool: PROD_team2
Cardinality: 1
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: PROD2

六,啟用服務
[grid@node1 ~]$ srvctl enable service -d PROD -s team1

[grid@node1 ~]$ srvctl config service -d PROD
Service name: team1
Service is enabled
Server pool: PROD_team1
Cardinality: 1
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: PROD1
Available instances:
Service name: team2
Service is enabled
Server pool: PROD_team2
Cardinality: 1
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: PROD2
Available instances: 


七,檢視服務狀態
[grid@node1 ~]$ srvctl status service -d PROD
Service team1 is not running.
Service team2 is not running.

八,再次啟動服務team1,team2
[grid@node1 ~]$ srvctl start service -d prod -s team1

[grid@node1 ~]$ srvctl start service -d prod -s team2

[grid@node1 ~]$ srvctl status service -d PROD
Service team1 is running on instance(s) PROD1
Service team2 is running on instance(s) PROD2

透過資料字典檢視服務狀態

SYS@PROD1> col name format a20
SYS@PROD1> col network_name for a20
SYS@PROD1> select inst_id,service_id,name,network_name from gv$services;

   INST_ID SERVICE_ID NAME                 NETWORK_NAME
---------- ---------- -------------------- --------------------
         1          3 team1                team1
         1          5 PRODXDB              PRODXDB
         1          6 PROD                 PROD
         1          1 SYS$BACKGROUND
         1          2 SYS$USERS
         2          4 team2                team2
         2          5 PRODXDB              PRODXDB
         2          6 PROD                 PROD
         2          1 SYS$BACKGROUND
         2          2 SYS$USERS

建立資料庫會預設建立與全域性資料庫同名的Service名稱,PROD。在查詢結果中可以看到例項1,例項2都有一個相同名字的服務PROD。team1,team2為手工建立。

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

相關文章