Db2 Installation on Linux
In this post we are going to install IBM Db2 11 on a Oracle Linux 9 server. Some basic administration commands are covered as well.
Table of Contents
Preparation
We need a Oracle Linux 9.5 VM, and we can download the IBM Db2 Community Edition from here. The current version of Db2 is 12.1.1. The Community Edition has no restrictions of features or database size, but is limited to 8 GB memory and 4 CPU cores.
Db2 Installation on Linux
To install the database server we can run the following commands in a root terminal of the linux server.
# Install required OS packages
dnf -y install libstdc++.i686 python3-dnf-plugin-versionlock pam.i686
# unpack the server software
gzip -cd /sw/db2/v12.1.1_linuxx64_server_dec.tar.gz|tar -xC ~
# Install Db2
cd ~/server_dec
./db2_install -n -b /opt/ibm/db2/V12.1 -y -p SERVER
Creating and dropping Db2 instances
The following commands create a Db2 instance:
# create the OS user
useradd db2|echo 'db2:changeme'|chpasswd
# create the Db2 instance
/opt/ibm/db2/V12.1/instance/db2icrt -u db2 db2
# drop a Db2 instance
/opt/ibm/db2/V12.1/instance/db2idrop db2
# list Db2 instances
/opt/ibm/db2/V12.1/instance/db2ilist
Sample Output
[root@lin3 ~]# /opt/ibm/db2/V12.1/instance/db2icrt -u db2 db2
DBI1446I The db2icrt command is running.
DB2 installation is being initialized.
Total number of tasks to be performed: 4
Total estimated time for all tasks to be performed: 309 second(s)
Task #1 start
Description: Setting default global profile registry variables
Estimated time 1 second(s)
Task #1 end
Task #2 start
Description: Initializing instance list
Estimated time 5 second(s)
Task #2 end
Task #3 start
Description: Configuring DB2 instances
Estimated time 300 second(s)
Task #3 end
Task #4 start
Description: Updating global profile registry
Estimated time 3 second(s)
Task #4 end
The execution completed successfully.
For more information see the DB2 installation log at "/tmp/db2icrt.log.105572".
DBI1070I Program db2icrt completed successfully.
[root@lin3 ~]# /opt/ibm/db2/V12.1/instance/db2idrop db2
DBI1446I The db2idrop command is running.
DB2 installation is being initialized.
Total number of tasks to be performed: 2
Total estimated time for all tasks to be performed: 305 second(s)
Task #1 start
Description: Initializing instance list
Estimated time 5 second(s)
Task #1 end
Task #2 start
Description: Configuring DB2 instances
Estimated time 300 second(s)
Task #2 end
The execution completed successfully.
For more information see the DB2 installation log at
"/tmp/db2idrop.log.101126".
DBI1070I Program db2idrop completed successfully.
Starting and Stopping DB2 instances
# start a Db2 instance
su - db2
db2start
# stop a Db2 instance
su - db2
db2stop
Db2 Command Line Processor commands
# start Db2 CLP
db2
# create a database
create database testdb
# start a database
activate database testdb
# list active databases
list active databases
# stop a database
deactivate database testdb
Other useful commands
# Db2 top (DB2 Interactive Snapshot Monitor)
db2top -d testdb
# get port where Db2 listens
db2 get dbm cfg|grep SVCE
cat /etc/services|grep db2c_db2
# get instance name
db2 get instance
# get diagnostic path (db2diag.log)
db2 get dbm cfg | grep DIAGPATH
Sample Output
# get port where Db2 listens
[db2@lin3 ~]$ db2 get dbm cfg|grep SVCE
TCP/IP Service name (SVCENAME) = db2c_db2
SSL service name (SSL_SVCENAME) =
[db2@lin3 ~]$ cat /etc/services|grep db2c_db2
db2c_db2 25010/tcp
[db2@lin3 ~]$
# get instance name
[db2@lin3 ~]$ db2 get instance
The current database manager instance is: db2
# get diagnostic path (db2diag.log)
[db2@lin3 ~]$ db2 get dbm cfg | grep DIAGPATH
Diagnostic data directory path (DIAGPATH) = /home/db2/sqllib/db2dump/ $m
Current member resolved DIAGPATH = /home/db2/sqllib/db2dump/DIAG0000/
Alternate diagnostic data directory path (ALT_DIAGPATH) =
Current member resolved ALT_DIAGPATH =
[db2@lin3 ~]$
Further information
Deinstallation
The IBM Db2 server software can be removed with these commands:
cd ~/server_dec
./db2_deinstall -a -b /opt/ibm/db2/V12.1
rm -rf /opt/ibm
Leave a Reply