So RAC has a pretty cool tool called Server Control or better known as srvctl, with this you can manage the services in a RAC farm, and one of the sometimes and much needed is when you have several ORACLE_HOMEs and you only need to shutdown one, as you are going to apply a patch to that one, no problem
srvctl stop home -o -s -n [-t ] [-f]
But what happens to the rest of the people who don’t have this tool and are still in a single node environment, you can still do this with this simple Unix shell script. I won’t say this more than once, use at your own discretion and revise before using it, this should always be tested before using it on a production environment.
The most important thing is you need to have a directory in which you have you environment variables for each of your Databases that are in the host, in this case is in ~/environment_vars/.
This script accepts 4 inputs
- DB_LIST .- This can be the name of the Database that you will shutdown or you can input oratab to cycle through the oratab file and execute the same command
- INIT_COMMAND.- This is either STARTUP or SHUTDOWN
- INIT_MODE.- This depends on the previous command, as if its STARTUP you can have NOMOUNT, MOUNT, OPEN or if its SHUTDOWN it can be IMMEDIATE , TRANSACTIONAL , ABORT
- HOME_TO_FILTER.- This will filter the oratab by the type of ORACLE_HOME that you want to shutdown
You will see a result similar to this one