The default approach to enabling automatic startup of DB2 instances on Linux operating systems relies on the DB2 Fault Monitor. During the installation a line like this:
fmc:2345:respawn:/opt/IBM/db2/V8.1/bin/db2fmcd #DB2 Fault Monitor Coordinator
is added to the
/etc/inittab file. The fault monitor then takes care of starting and restarting the instances which were enabled for autostart by
There seem to be several problems with that approach. Firstly, the use of
/etc/inittab to start programs is deprecated in the modern Linux versions. Secondly, one may want to have a more flexible tool to manage the lifecycle of DB2 instances on the system, such as that provided by the System V init scripts.
I’ve created a couple of scripts — one for the Red Hat Linux, another for SuSE — that can be used in place of the default startup control. They can be downloaded from GitHub.
The installation is easy: drop the appropriate for your server version of the script into
/etc/init.d, naming it “db2″. Change the file permissions to allow execution. Run
chkconfig --add db2 to enable it.
At this point the scripts respond to three commands: start, stop, and status.
The start command causes the script to check all instances listed in the DB2 global registry file and start those for which the startatboot flag is set to “1”.
The stop command, on the other hand, will stop all running DB2 instances, regardless of their startatboot flag value.
To modify the flag you can use the command:
db2greg -updinstrec instancename=db2inst1!startatboot=0
Obvisously, you’ll need to replace “db2inst1″ with your instance name. Set the flag to “1” to enable autostart; set it to “0” to disable it.
For more information on the global registry file and the
db2greg utility check the manual, as always. Running
db2greg -h also provides much useful information.