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:
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:
modify database -y AUTOMATIC
Ref: https://docs.oracle.com/cd/E11882_01/server.112/e25494/restart.htm#BABHHAHI
crsctl modify resource ora.grepora.db -attr AUTO_START=always
Note: In Oracle 11.2, the database auto-start policy in the Clusterware is "restore", which means that Clusterware will remember the last state of the database. As well as for the database resource, Oracle 11.2 comes, by default, with several important resources with attribute AUTO_START=restore in the profile.
Note2: For 12c and up, on you might need to use the flag "-unsupported" on the command above ( crsctl modify resource ora.grepora.db -attr AUTO_START=always - unsupported).
Ref: https://docs.oracle.com/cd/E11882_01/rac.112/e41959/resatt.htm#CHDFFEHJ
Observation: This is recommended for all the required components managed by via crsctl, like databases, asm, listener, diskgroups, etc. I wrote an article about it with a script that can help you.
A common problem: " I did set the SRVCTL to Automatic, but the databases still don't start automatically."
Explanation: When database management policy is configured as AUTOMATIC and the resource of the database parameter AUTO_START is configured as restore, the cluster will restore its last state, because the cluster level is the first in the chain of commands. It overrides the database. c) Save the desired state of Pluggable Databases in case of Multitenant: With the PDB in the desired state, save it with the command below:
ALTER PLUGGABLE DATABASE pdb1 SAVE STATE;
When the CDB starts, it will bring the pdbs to its saved states.
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:
I also wrote an article about those, with some info and scripts: here.
Observation: Item 1.c is still recommended here.
As a third option, we would have some community scripts, which are usually proven and don't require us to remember or to code everything. I'd take some additional time reviewing and testing them, though, as they are not Oracle provided/supported. In general, I'd recommend the material produced by Tim Hall (Oracle Base): https://oracle-base.com/articles/linux/automating-database-startup-and-shutdown-on-linux He has additional articles that may help for other versions:
srvctl modify database -d [db_unique_name] -s [start_options] -t [stop_options]
srvctl modify database -d [db_unique_name] -s OPEN -t IMMEDIATE -y automatic
(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!
Ready to optimize your Oracle Database for the future?