DB2 instances
DB2 instance is a logical environment for a IBM DB2 database Manager. A physical machine can contain multiple DB2 instances. A DB2 instance can contain multiple databases.
DB2 instance directory contents:
- Database Manager Configuration file
- System Database Directory
- Node Directory
- Node Configuration File [db2nodes.cfg] and
- Debugging files, dump files
How to create DB2 instance
-
Login as root
-
create a seperate operating system user for the instance you want to create.
useradd -u <ID> -g <group name> -m -d <user location> <user name> -p <password>
-
Go to DB2 instance directory
cd /opt/ibm/db2/v10.1/instance
-
create DB2 instance
./db2icrt -s ese -u <inst id> <instance name>
-
Verify using list the instances present
db2ilist
How to update a DB2 instance
This command is used to update the DB2 instance with same version release.
Note: Stop the instance before updating it
Syntax
#To update the instance in normal mode
db2iupdt <inst_name>
#To update the instance in debugging mode
db2iupdt -D <inst_name>
How to upgrade a DB2 instance
This command is used to upgrade the current version of DB2 instance to a higher version.
Navigate to DB2DIR/instance directory on UNIX/Linux.
Syntax
db2iupgrade -d -k -u <inst_username> <inst_name>
Note:
-d: debbuging mode
-k: to keep the pre-upgrade version in the DB2copy if it's supported.
How to delete a DB2 instance
This command is used to delete a DB2 instance. Navigate to DB2_installation_folder/instance directory on Unix/Linux.
Syntax
db2idrop -u <inst_username> <inst_name>
Commands
- Get Instance
This command shows the name of the active DB2 instance.Syntax
db2 get instance
- Set Instance
This command is issued to refer the instance name before start or stop of the database manager of a DB2 instanceSyntax
set db2instance=<instance_name>
- Start a DB2 instance
This command is used to start a DB2 instanceSyntax
db2start
- Stop a DB2 instance
This command is used to stop a DB2 instanceSyntax
db2stop