===== DB2 Express C on CentOS or RHEL and like =====
Set SELinux to permissive, editing /etc/selinux/config.
$ sudo yum install kernel-headers gcc-c++ cpp gcc pam.i686 compat-libstdc++-33
Create a db2 user:
$ sudo useradd db2
$ sudo passwd db2
Change to db2 user. If you run db2prereqcheck utility you will receive a this message:
//The db2prereqcheck utility determined that the current platform is not supported by the following version: "9.8.0.2".// You can ignore it if you are using CentOS.
$ ./db2_install
==== Systemd ====
[Unit]
Description=Starts db2.
[Service]
Type=forking
User=db2
ExecStart=/bin/bash -c "source /home/db2/sqllib/db2profile ; /home/db2/sqllib/adm/db2start"
ExecStop=/bin/bash -c "source /home/db2/sqllib/db2profile ; /home/db2/sqllib/adm/db2stop"
[Install]
WantedBy=multi-user.target
If you have more databases:
[Unit]
Description=Starts db2.
[Service]
Type=forking
User=db2inst1
ExecStart=/bin/bash -c "source /home/db2inst1/sqllib/db2profile ; /home/db2inst1/sqllib/adm/db2start"
ExecStartPost=/bin/bash -c "source /home/db2inst1/sqllib/db2profile; /home/db2inst1/sqllib/bin/db2 activate database APPCNTR ; /home/db2inst1/sqllib/bin/db2 activate database MFPDATA"
ExecStop=/bin/bash -c "source /home/db2inst1/sqllib/db2profile ; /home/db2inst1/sqllib/bin/db2 deactivate database MFPDATA"
ExecStop=/bin/bash -c "source /home/db2inst1/sqllib/db2profile ; /home/db2inst1/sqllib/bin/db2 deactivate database APPCNTR"
ExecStop=/bin/bash -c "source /home/db2inst1/sqllib/db2profile ; /home/db2inst1/sqllib/adm/db2stop"
[Install]
WantedBy=multi-user.target