Hello,
srvctl config database -d db_name
The above command gives the configuration information for a specific database.
My goal is:
- Retrieve database name on the $host from the list one by one for which I am using below code
for database in `crsctl status res -n $host| grep -E "ora.*\.db" | awk -F"." '{print $(NF-1)}'`
2.Check if service is running on preferred or available instance of the database.
Below example:
srvctl status service -d ksr
Service knuggets_ksr.world is running on instance(s) ksr_01
Service ksadmin_ksr.world is running on instance(s) ksr_01
srvctl config service -d ksr -s knuggets_ksr.world
Service name: knuggets_ksr.world
Service is enabled
Server pool: ksr_knuggets_ksr.world
Preferred instances: ksr_01
Available instances: ksr_02
From first command I get to know both the services are running on ksr_01 instance of the database.
From second command I get to know ksr_01 is the preffered instance of this service.
- Check if the preferred instance is running on the $host or not.($host is the argument passed in the script)
srvctl status database -d ksr
ksr_01 is running on node1
ksr_02 is running on node 2
5.Depending on another argument which would be passed while running the script whether the service to be relocated to available or preferred instance I will use flag
./relocate.sh -n node1 -t preferred
This would mean that all the services which are running on available instances for those databases hosted on node 1 should be relocated to preferred instance if the preferred instance is on node 1 for that service.
This is a cluster envrionment and multiple instances run on different nodes for the same database.
- Relocate the service
srvctl relocate service -d $database -i <current node> -t <target node $node1> -s <$service>
Best regards,
Vishal