Javatpoint Logo
Javatpoint Logo

DB2 Instance

A DB2 instance is a logical Database Manager environment for DB2. It is used to manage databases. You can create multiple instances according to your requirements.

An instance directory contains:

  • Database Manager Configuration file
  • System Database Directory
  • Node Directory
  • Node Configuration File [db2nodes.cfg]
  • Debugging files, dump files

The default instanceor for DB2 Database Server is "DB2". You cannot change the location of Instance directory after its creation. An instance can manage multiple databases. In an instance, each database has a unique name, its own set of catalog tables, configurations files, authorities and privileges.

Instance Architecture in DB2 Product

Instance Architecture in DB2 Product

Note: You can create multiple instances in one DB2Server on Linux, UNIX and Windows. You can also install multiple DB2Servers on a physical machine.

Create Instance on Linux

If DB2 Server is installed as root user then you can create multiple instances on Linux and UNIX. An instance can run simultaneously on Linux and UNIX independently. You can work within a single instance of the database manager at a time.

An Instance folder contains database configuration files and folders. The Instance directory is stored at different locations on Windows depending on the operating system versions.

How to list instances

db2ilist command is used to list the all the instances that are available on a system.

Syntax:

For example:

Instances

Instance environment commands

To Get Instance:

db2 get instance command is used to see details of the currently running instances.

Syntax:

Instances

To Set Instance:

If you want to start or stop the database manager of an instance on DB2 UDB, the following command is executed for the current instance.

Syntax:

For Example: Arrange the "db2admin" environment to current user:

Start DB2 Server

db2start command is used to start an instance. Before this, you need to run "set instance".

Syntax:

Instances

Stop DB2 Server

db2stop command is used to stop the running instance.

Syntax:

Instances

Create an Instance

To create a new instance, you have to log in with root. Instance id is not a root id or a root name. Follow the following steps to create a new instance.

Syntax:

For Example

Create a user for instance with name 'db2inst2' in group 'db2iadm1' and password 'db2inst2'

Instances

You can see that db2inst2 is already exist. You can see that

Step2: Go to the DB2 instance directory in root user for create new instance.

Location:

Instances

Update an Instance

db2iupdt command is used to update the existing instance within the same version release.

Before executing this command, you need to stop the instance database manager using "db2stop" command.

The syntax below "inst_name" indicates the previous released or installed db2 server instance name, which you want to update to newer release or installed db2 server version.

Syntax1: (Update Instance in Normal mode)

Syntax2: (Update Instance in Debugging Mode)

Other Commands use with Instance

Command to find out which DB2 instance we are working on now.

Syntax 1: [to check the current instance activated by database manager]

Output:

Instances

Syntax 2: [To see the current instance with operating bits and release version]

Example:

Instances

Syntax 3: [To check the name of currently working instance]

Example:

Output:

Instances




Please Share

facebook twitter google plus pinterest

Learn Latest Tutorials


Preparation


B.Tech / MCA