IBM Support

How to automatically restart DB2 instances via the DB2 fault monitor.

Question & Answer


How can I automatically restart my DB2 instances? This document lists step-by-step instructions for setting up the Fault Monitor Facility to automatically restart DB2 instances.


The db2iauto command enables and disables the auto-start of an instance after each system restart. With Fault Monitor facility, if the DB2® instance exits prematurely, the fault monitor will restart it.


1. Enable auto-start of the instance by running the following command as the instance owner:

db2inst1@host01:~> db2iauto -on db2inst1

2. Log in as Root

3. Determine whether there are any db2fmcd entries in the /etc/inittab file. If there are, remove them or comment them out before proceeding. To remove the entry, use the db2fmcu -d command:

root@host01:~> cat /etc/inittab | grep db2fmcd
fmc:2345:respawn:/opt/ibm/db2/V10.5/bin/db2fmcd #DB2 Fault Monitor Coordinator
root@host01:~> /opt/ibm/db2/home/db2inst1/sqllib/bin/db2fmcu -d
root@host01:~> cat /etc/inittab | grep db2fmcd

As of RHEL 7, the /etc/inittab file has been deprecated. Issuing the db2fmcu -d command removes the '/etc/systemd/system/db2fmcd.service' file that is used by Systemd.
As of Solaris 10, the /etc/inittab file has been deprecated. Issuing the db2fmcu -d command disables the SMF service named 'db2fm'.

4. Make sure there are no db2fmcd (Fault Monitor Coordinator Daemon (FMCD)), db2fmd (Fault Monitor Daemon) or db2fm (Fault Monitor) processes running. If there are, remove (kill) the process(es) before proceeding:

root@host01:~> ps -ef | grep db2fm
root 7300 6652 0 07:01 pts/0 00:00:00 grep db2fm

5. Go to the DB2DIR/bin directory.

root@host01:~> cd /opt/ibm/db2/V10.5/bin/

6. Enable the Fault Monitor Coordinator by executing the ./db2fmcu -u -p /opt/ibm/db2/V10.5/bin/db2fmcd command. This step adds an entry to the /etc/inittab so that the FMCD process is started each time you reboot.

root@host01: /opt/ibm/db2/V10.5/bin> ./db2fmcu -u -p /opt/ibm/db2/V10.5/bin/db2fmcd
root@host01: /opt/ibm/db2/V10.5/bin> cat /etc/inittab | grep db2fm
fmc:2345:respawn:/opt/ibm/db2/V10.5/bin/db2fmcd #DB2 Fault Monitor Coordinator

As of RHEL 7, the /etc/inittab file has been deprecated. Issuing this command creates or replaces the db2fmcd.service file under the /etc/systemd/system/ directory used by Systemd.
As of Solaris 10, the /etc/inittab file has been deprecated. Issuing this command creates and enables the SMF service named 'db2fm'.

7. Start up the fault monitor daemon:

root@host01: /opt/ibm/db2/V10.5/bin> ./db2fm -i db2inst1 -U

8. Start up the fault monitor service:

root@host01: /opt/ibm/db2/V10.5/bin> ./db2fm -i db2inst1 -u

The above command may return a non-zero return code:

root@host01: /opt/ibm/db2/V10.5/bin> ./db2fm -i db2inst1 -u
./db2fm return non-zero rc, please see log file '/opt/ibm/db2/home/db2inst1/sqllib/db2dump/db2diag.log'

This is because the DB2 instance is already started. Stopping the instance and proceeding to run the same command succeeds.

9. Turn on the fault monitor for the instance:

root@host01: /opt/ibm/db2/V10.5/bin> ./db2fm -i db2inst1 -f on

10. Reboot the server. The fault monitor service should be available once the server has been rebooted.

11. Verify the fault monitor state. Log in as the instance owner and issue the db2fm -s -S command. You should see output similar to the following:

db2inst1@host01:~> db2fm -s -S
Gcf module 'fault monitor' state is AVAILABLE
Gcf module '/opt/ibm/db2/V10.5/lib64/' state is AVAILABLE

12. Log in as Root.

13. Go to the DB2DIR/bin directory (per step 5).

root@host01:~> cd /opt/ibm/db2/V10.5/bin/

14. Verify the FMC Daemon state by issuing the db2fmcu command.

root@host01: /opt/ibm/db2/V10.5/bin> ./db2fmcu
FMC: up: PID = 5319

15. At this point, if the instance is shut down in any way other than via the db2stop command, the fault monitor starts it up again. If you want to test the fault monitor's functions, bring down the DB2 instance. For example, issue the db2_kill command:

root@host01: /opt/ibm/db2/V10.5/bin> ps -efl |grep db2sysc
4 S db2inst1 6530 6528 0 80 0 - 206688 futex_ 07:07 ? 00:00:00 db2sysc
0 R root 6751 5775 0 80 0 - 1380 - 07:09 pts/0 00:00:00 grep db2sysc
root@host01: /opt/ibm/db2/V10.5/bin> su - db2inst1
db2inst1@host01:~> db2_kill
ipclean: Removing DB2 engine and client's IPC resources for db2inst1.

16. The instance will be automatically restarted:

root@host01: /opt/ibm/db2/V10.5/bin> ps -efl |grep db2sysc
4 S db2inst1 7528 7526 5 80 0 - 206688 futex_ 07:10 ? 00:00:00 db2sysc
0 R root 7554 5775 0 80 0 - 1380 - 07:10 pts/0 00:00:00 grep db2sysc

Note: This document was tested and created using DB2 versions 8.2, 9.1, 9.5, 9.7, 10.1, 10.5, 11.1 and 11.5.

Note: If you have a non-root Db2 installation and SELinux is enabled, you may need to change the SELinux type for your db2fmcd binary located in the instance home directory. This can be done by running the following commands as root:

semanage fcontext -a -t bin_t /home/db2inst1/sqllib/bin/db2fmcd
restorecon /home/db2inst1/sqllib/bin/db2fmcd

For further discussion on this topic, visit this developerWorks forum thread:

[{"Product":{"code":"SSEPGG","label":"DB2 for Linux- UNIX and Windows"},"Business Unit":{"code":"BU058","label":"IBM Infrastructure w\/TPS"},"Component":"High Availability - Cluster Management","Platform":[{"code":"PF002","label":"AIX"},{"code":"PF010","label":"HP-UX"},{"code":"PF016","label":"Linux"},{"code":"PF027","label":"Solaris"}],"Version":"9.7;10.1;10.5;11.1","Edition":"","Line of Business":{"code":"LOB10","label":"Data and AI"}}]

Document Information

Modified date:
05 July 2021