Add service to run in PRIMARY ROLE
[oracle@oratest2
~]$ srvctl add service -s TEST01_SVC -d ORA_PRIM -role PRIMARY -preferred
ORAPRIM1 -available ORAPRIM2 -pdb UK_PDB -P BASIC
[oracle@oratest2
~]$ srvctl status service -d ORA_PRIM
Service test01_svc is not running.
Service
uk_prim is running on instance(s) ORAPRIM1,ORAPRIM2
Service
uk_svc is running on instance(s) ORAPRIM1,ORAPRIM2
Add service to run only in PHYSICAL STANDBY
[oracle@oratest2
~]$ srvctl add service -s UK_READONLY -d ORA_PRIM -role PHYSICAL_STANDBY
-preferred ORAPRIM1 -available ORAPRIM2
-pdb UK_PDB -P BASIC
[oracle@oratest2
~]$ srvctl status service -d ORA_PRIM
Service
test01_svc is not running.
Service
uk_prim is running on instance(s) ORAPRIM1,ORAPRIM2
Service uk_readonly is not running.
Service
uk_svc is running on instance(s) ORAPRIM1,ORAPRIM2
Add Service At CDB Level
[oracle@oratest2
~]$ srvctl add service -s ORA_PRIMARY -d ORA_PRIM -role
PRIMARY,PHYSICAL_STANDBY -preferred ORAPRIM1 -available ORAPRIM2 -P BASIC
[oracle@oratest2
~]$ srvctl status service -d ORA_PRIM
Service ora_primary is not running.
Service
test01_svc is not running.
Service
uk_prim is running on instance(s) ORAPRIM1,ORAPRIM2
Service
uk_readonly is not running.
Service
uk_svc is running on instance(s) ORAPRIM1,ORAPRIM2
NOTE: if we don't use '-pdb' keyword then by default service will create at CDB level.
Add Service In At PDB Level
[oracle@oratest2
~]$ srvctl add service -s uk_db -d ORA_PRIM -role primary,physical_standby
-preferred ORAPRIM1,ORAPRIM2 -pdb UK_PDB
[oracle@oratest2
~]$ srvctl status service -s uk_db -d ORA_PRIM
Service
uk_db is not running.
NOTE: To add service at PDB
level we need to add ‘-pdb’ keyword
Check All Service Status
[oracle@oratest2
~]$ srvctl status service -d ORA_PRIM
Service ora_primary is not running.
Service
test01_svc is not running.
Service
uk_prim is running on instance(s) ORAPRIM1,ORAPRIM2
Service
uk_readonly is not running.
Service
uk_svc is running on instance(s) ORAPRIM1,ORAPRIM2
Check Specific Service Status
[oracle@oratest2
~]$ srvctl status service -s UK_READONLY -d
ORA_PRIM
Service
UK_READONLY is not running.
NOTE
: UK_READONLY is a service name
Stop All Service In RAC
[oracle@oratest2
~]$ srvctl stop service -d ORA_PRIM
[oracle@oratest2
~]$ srvctl status service -d ORA_PRIM
Service
ora_primary is not running.
Service
uk_prim is not running.
Service
uk_svc is not running.
Start All Services In RAC
[oracle@oratest2
~]$ srvctl start service -d ORA_PRIM
[oracle@oratest2
~]$ srvctl status service -d ORA_PRIM
Service
ora_primary is running on instance(s) ORAPRIM1
Service
uk_prim is running on instance(s) ORAPRIM1,ORAPRIM2
Service
uk_svc is running on instance(s) ORAPRIM1,ORAPRIM2
Start Specific Service In RAC
[oracle@oratest2
~]$ srvctl status service -s UK_SVC -d ORA_PRIM
Service
UK_SVC is not running.
[oracle@oratest2
~]$ srvctl start service -s UK_SVC -d ORA_PRIM
[oracle@oratest2
~]$ srvctl status service -s UK_SVC -d ORA_PRIM
Service
UK_SVC is running on instance(s) ORAPRIM1,ORAPRIM2
Remove Service In RAC
[oracle@oratest2
~]$ srvctl remove service -s UK_READONLY -d ORA_PRIM
[oracle@oratest2
~]$ srvctl status service -d | grep -i UK_READONLY
[oracle@oratest2
~]$
Relocate Service In RAC
[oracle@oratest2
~]$ srvctl status service -d ORA_PRIM
Service ora_primary is running on instance(s) ORAPRIM1
Service
uk_prim is running on instance(s) ORAPRIM1,ORAPRIM2
Service
uk_svc is running on instance(s) ORAPRIM1,ORAPRIM2
[oracle@oratest2
~]$ srvctl relocate service -s ORA_PRIMARY -i ORAPRIM1 -t ORAPRIM2 -d ORA_PRIM
[oracle@oratest2
~]$ srvctl status service -s ORA_PRIMARY -d ORA_PRIM
Service ORA_PRIMARY is running on instance(s) ORAPRIM2
NOTE: ‘i’ represents the current instance and ‘t’ represents the target instance where we want to move our services in RAC
Modify Service configuration
[oracle@oratest2
~]$ srvctl config service -s UK_PRIM -d ORA_PRIM | grep -i "Service
Role"
Service
role: PRIMARY
[oracle@oratest2
~]$ srvctl config service -s UK_PRIM -d ORA_PRIM | grep -i "Service
Role"
Service
role: PHYSICAL_STANDBY
Modify Preferred or Available Instance For Service
[oracle@oratest2
~]$ srvctl config service -s UK_PRIM -d
ORA_PRIM | egrep -i "preferred|available"
Preferred
instances: ORAPRIM1,ORAPRIM2
Available
instances:
[oracle@oratest2 ~]$ srvctl modify service -s UK_PRIM -modifyconfig -d ORA_PRIM -pdb UK_PDB -preferred ORAPRIM1 -available ORAPRIM2
[oracle@oratest2
~]$ srvctl config service -s UK_PRIM -d
ORA_PRIM | egrep -i "preferred|available"
Preferred
instances: ORAPRIM1
Available
instances: ORAPRIM2
NOTE: To change the instance preference and availability in service configuration we must have to use '-modifyconfig' keyword in modify service command.
Check Service Configuration
[oracle@oratest2
~]$ srvctl config service -s UK_PRIM -d ORA_PRIM
Service
name: UK_PRIM
Server
pool:
Cardinality:
2
Service
role: PRIMARY
Management
policy: AUTOMATIC
DTP
transaction: false
AQ
HA notifications: false
Global:
false
Commit
Outcome: false
Failover
type:
Failover
method:
Failover
retries:
Failover
delay:
Failover
restore: NONE
Connection
Load Balancing Goal: LONG
Runtime
Load Balancing Goal: NONE
TAF
policy specification: BASIC
Edition:
Pluggable
database name:
Hub
service:
Maximum
lag time: ANY
SQL
Translation Profile:
Retention:
86400 seconds
Replay
Initiation Time: 300 seconds
Drain
timeout:
Stop
option:
Session
State Consistency: DYNAMIC
GSM
Flags: 0
Service
is enabled
Preferred
instances: ORAPRIM1,ORAPRIM2
Available
instances:
CSS
critical: no
Service
uses Java: false