Automatic Graceful Shutdown and Consistent Startup Method for Oracle DB on Linux
Having questions about automatic startup and shutdown is quite common when dealing with new environments or configurations. There is more than one way to implement this depending on the environment configuration, licensing and version. So, here is a summary: 1. Use Oracle Restart This is the most recommended method provided by Oracle. It can be a bit confusing, however, which can lead us to think it's not working. So, here is a summary of the configuration I'd recommend: a) Configure database management to AUTOMATIC on SRVCTL srvctl modify database -y AUTOMATICWhen the CDB starts, it will bring the pdbs to its saved states. 2. As a second Option, Oracle-Provided Scripts Oracle has some scripts to automate it in a standard and supported way. This is documented for 12.1 in Stopping and Starting Oracle Software. Notes:(Note the SRVCTL syntax can vary on the versions. This one is valid for 11.2). I hope this helps you understand the process. See you next time!
- If AUTOMATIC (the default), the database is automatically restored to its previous running condition (started or stopped) upon restart of the database host computer.
- If MANUAL, the database is never automatically restarted upon restart of the database host computer.
crsctl modify resource ora.grepora.db -attr AUTO_START=always
- ALWAYS: Restarts the resource when the server restarts regardless of the state of the resource when the server stopped.
- RESTORE: Restores the resource to the same state that it was in when the server stopped. Oracle Clusterware attempts to restart the resource if the value of TARGET was ONLINE before the server stopped.
- NEVER: Oracle Clusterware never restarts the resource regardless of the state of the resource when the server stopped.
ALTER PLUGGABLE DATABASE pdb1 SAVE STATE;
- Oracle 11gR2 documentation states the use of the dbstart and dbshut scripts are deprecated. It’s supposed to be replaced by Oracle Restart.
- The Oracle 12c documentation has no mention of the deprecation of dbstart and dbshut and has reinstated the documentation about them (as I linked above). So, feel free to use dbstart and dbshut in a supported manner for all versions of the database.
- Automating Shutdown and Startup (12.2)
- Automating Shutdown and Startup (12.1)
- Automating Shutdown and Startup (11.2)
- Automating Shutdown and Startup (10.2)
- Automating Startup and Shutdown (10.1)
- Automating Database Startup and Shutdown (9.2)
- Linux Services (systemd, systemctl)
- The Oracle Restart configuration assumes the CRS is left "enabled". Disabling it means we don't want it to start automatically. So, if you want the CRS to start with your server, it needs to be enabled. After this, to start targets, depending on configurations as mentioned in my previous post referred to this.
- Oracle will not execute any rpm change or relink automatically, as this is not part of any "restart" process. It may be required due to any configuration change or corruption, and it cannot be automated.
- Regarding gracefulness, it depends on the configuration you have on your SRVCTL too. This can be configured using stop and start option, as per the example below:
srvctl modify database -d [db_unique_name] -s [start_options] -t [stop_options]
- So, a complete command containing what was recommended on my previous post PLUS gracefulness, it would be:
srvctl modify database -d [db_unique_name] -s OPEN -t IMMEDIATE -y automatic