DB2 Instance Creation
Before creating the instance we have to create required users and groups.
db2inst1 for instance user → Purpose: Communication with applications
db2fenc1 for fenced user → Purpose: To create the instance.
db2das is for das user. → To access the db from GUI screen. We don’t need to create DAS from V9.7. It
is included in instance itself.
Group Creation: Prior to 9.7 we have to create 3 users and 2 groups, before creating the instance.
login as root, $ su – or sudo su -
groupadd db2iadm → instance user group
groupadd db2fadm → Fenced user group
groupadd db2dadm → das user group
User Creation:
login as root, $ su – or sudo su -
useradd db2inst1 -m -d /home/db2inst1 -g db2iadm → Instance user
useradd db2fenc1 -m -d /home/db2fenc1 -g db2fadm → Fenced user
useradd db2das1 -m -d /home/db2das1 -g db2dadm → Das user
Instance Creation:
Login as root, $ su – or sudo su -
Go to installation path and then instance directory
cd /opt/ibm/db2/V10.5 and cd instance
run ./db2icrt -u fenceduser instanceuser
./db2icrt -u db2fenc1 db2inst1
user and group name requirements: User & Group should have max 8 char length and no special char
allowed. Name should not start with ibm,appa,users,admin,linux,aix
[root@811434-rsdfwp-pvheu-pr2db01 instance]# ./db2icrt -u db2inst2 db2inst2 → From V9.7 we can
use instance user as a fenced user. We don’t need seperate fenced user.
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.5517".
DBI1070I Program db2icrt completed successfully.
[root@811434-rsdfwp-pvheu-pr2db01 instance]#
[root@811434-rsdfwp-pvheu-pr2db01 instance]# ./db2ilist
db2inst1
db2inst2
Instance drop:
[root@811434-rsdfwp-pvheu-pr2db01 instance]#
Instance drop command: go to /opt/ibm/db2/V10.5_fp8/instance and run
./db2drop b2ceupr
[root@811434-rsdfwp-pvheu-pr2db01 instance]# ./db2idrop vijkmr
DBI1446I The db2idrop command is running.
db2 installation is being initialized.
The db2 installer detects that one or more db2 instances "vijkmr" are still
active. Stop the active instances and rerun the command again.
A major error occurred during the execution that caused this program to
terminate prematurely. If the problem persists, contact your technical service
representative.
For more information see the db2 installation log at "/tmp/db2idrop.log.37187".
DBI1264E This program failed. Errors encountered during execution were
written to the installation log file. Program name:
db2idrop. Log file name: /tmp/db2idrop.log.37187.
Explanation:
This message is returned when some processes and operations have failed.
Detailed information about the error was written to the log file.
User response:
Contact IBM support to get assistance in resolving this issue. Keep the
log file intact as this file is an important reference for IBM support.
Related information:
Contacting IBM Software Support
To drop the instance instance should be down:
[root@811434-rsdfwp-pvheu-pr2db01 instance]# ./db2idrop vijkmr
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.40216".
DBI1070I Program db2idrop completed successfully.
[root@811434-rsdfwp-pvheu-pr2db01 instance]#
Observations after creating the instance:
login as instance owner:
su – db2inst1
1. db2 executable code will be added in .bashrc file, This file exist in instance home directory.
$ cd , $pwd, $ ls -al, $ cat .bashrc
# The following three lines have been added by UDB db2.
if [ -f /home/db2inst1/sqllib/db2profile ]; then
. /home/db2inst1/sqllib/db2profile
fi
[db2inst1@811434-rsdfwp-pvheu-pr2db01 ~]$
2. sqllib directory will be created in instance home directory
$ cd , $ ls -ltr
3. soft links have been created in /home/db2inst1/sqllib directory.
$ cd /home/db2inst1/sqllib , $ ls -ltr
4. dbm cfg file created.
$ db2 get dbm cfg | more
5. global profile registry variables updated.
$ db2set -all
6. default port numbers will be added in /etc/services
cat /etc/services | grep -i db2inst1
How to check all profile registry variables in the instance(same for all instances).
$ db2set -lr
How to check all configured profile registry variables.
$db2set -all
How to check dbm cfg parameters.
$ db2 get dbm cfg | more
How to enable remote communication:
1. Update profile registry variable db2COMM with TCPIP.
db2set db2COMM=TCPIP
2. Update dbm cfg parameter with required port number. The port number should be exist in
/etc/services file.
Login as root: su -
root@sbsvmaxbw01p#vi /etc/serivces and add required port number.
$ db2 get dbm cfg | grep -i svce
$ db2 update dbm cfg using SVCENAME 50050
3. Recycle the instance
db2stop and db2start
$db2level → Instance which we logged in, s/w installation path, db2 version and fix pack, bit
computing.
$db2ls → s/w’s which are installed on server and s/w installed date and time.
$db2licm -l → To check the license information of db2.
We can the db2 commands from any location.