Introduction
An Instance is a coherent domain for DB2 Database Manager. Utilizing example, you can oversee databases. Contingent upon our prerequisites, you can make various occurrences on one physical machine. The substance of Instance registry are:
- Database Manager Configuration document
- Framework Database Directory
- Hub Directory
- Hub Configuration File [db2nodes.cfg]
- Troubleshooting records, dump documents
For DB2 Database Server, the default occurrence is "DB2". It is beyond the realm of imagination to expect to change the area of Instance registry after its creation. An example can deal with various databases. In an occurrence, every database has a remarkable name, its own arrangement of index tables, setups records, specialists and benefits.
Architecture of instance in DB2 product
Multiple instances
You can make numerous examples in one DB2Server on Linux, UNIX and Windows. It is conceivable to introduce various DB2Servers on a physical machine.
Creating instance on Linux
You can make different cases on Linux and UNIX if DB2 Server is introduced as root client. An occasion can run at the same time on Linux and UNIX autonomously. You can work inside a solitary occasion of the database chief at once.
An Instance envelope contains database design documents and organizers. The Instance catalog is put away at various areas on Windows relying upon the working framework adaptations.
Listing instances
The accompanying order is utilized to list occasions:
db2ilist
This order records all the occasions that are accessible on a framework.
Syntax:
db2ilist
Example:[To perceive what number of occasions are made in DB2 copy]
db2ilist
Output:
db2inst1
db2inst2
db2inst3
Instance environment commands
These orders are helpful to work with course of action of occurrence in the DB2 CLI.
Get instance
This order shows subtleties of the as of now running occasion.
Syntax:
db2 get instance
Example:[To see the current instance which activated the current user]
db2 get instance
Output:
The current database manager instance is : db2inst1
Set instance
To begin or stop the database supervisor of an occurrence on DB2 UDB, the accompanying order is executed for the present example.
Syntax:
set db2instance=<instance_name>
Example:[ To arrange the “db2inst1” environment to current user]
set db2instance=db2inst1
db2start
Utilizing this order, you can begin an occurrence. Prior to this, you have to run "set occurrence".
Syntax:
db2start
Example:[To start an instance]
db2start
Output:
SQL1063N DB2START processing was successful
db2stop
Using this command you can stop a running instance.
Syntax:
db2stop
Output:
SQL1064N DB2STOP processing was successful.
Creating an instance
Let us perceive how to make another example.
db2icrt
On the off chance that you need to make another example, you have to sign in with root. Case id isn't a root id or a root name.
Here are the means to make another example:
Step1: Create a working framework client for example.
Syntax:
useradd -u <ID> -g <group name> -m -d <user location> <user name>
-p <password>
Example: [To create a user for instance with name ‘db2inst2’ in group ‘db2iadm1’ and password ‘db2inst2’]
useradd -u 1000 -g db2iadm1 -m -d /home/db2inst2 db2inst2 -p db2inst2
Step2: Go to the DB2 instance directory in root user for create new instance.
Location:
cd /opt/ibm/db2/v10.1/instance
Step3: Create instance using the syntax below:
Syntax:
./db2icrt -s ese -u <inst id> <instance name>
Example: [To create a new instance ‘db2inst2’ in user ‘db2inst2’ with the features of ‘ESE’ (Enterprise Server Edition)]
./db2icrt -s ese -u db2inst2 db2inst2
Output:
DBI1446I The db2icrt command is running, please wait.
….
…..
DBI1070I Program db2icrt completed successfully.
Arranging communication port and host for an instance
Alter the/and so on/administrations document and include the port number. In the linguistic structure given beneath, 'inst_name' shows the Instance name and 'inst_port' demonstrates port number of example.
Syntax:
db2c_<inst name> <inst_port>/tcp
Example: [Adding ‘50001/tcp’ port number for instance ‘db2inst2’ with variable ‘db2c_db2inst2’ in ‘services’ file]
db2c_db2inst2 50001/tcp
Syntax 1: [Update Database Manager Configuration with service name. The following syntax ‘svcename’ indicates the instance service name and ‘inst_name’ indicates the instance name]
db2 update database manager configuration using svcename db2c_&<inst_name>
Example 1: [Updating DBM Configuration with variable svcename with value ‘db2c_db2inst2’ for instance ‘db2inst2’
db2 update database manager configuration using svcename db2c_db2inst2
Output
DB20000I The UPDATE DATABASE MANAGER CONFIGURATION command completed successfully.
Syntax 2: set the “tcpip” communication protocol for the current instance
db2set DB2COMM=tcpip
Syntax 3: [Stopping and starting current instance to get updated values from database manager configuration]
db2stop
db2start
Updating an instance
You can refresh an occurrence utilizing following order:
db2iupdt
This order is utilized to refresh the occasion inside a similar form discharge. Prior to executing this order, you have to stop the example database supervisor utilizing "db2stop" order. The language structure beneath "inst_name" demonstrates the past discharged or introduced db2 server occurrence name, which you need to refresh to more up to date discharge or introduced db2 server variant.
Syntax 1: To update an instance in normal mode
db2iupdt <inst_name>
Example1:
./db2iupdt db2inst2
Syntax 2: To update an instance in debugging mode
db2iupdt -D <inst_name>
Example
db2iupdt -D db2inst2
Upgrading an instance
You can redesign an example from past rendition of DB2 duplicate to current recently introduced adaptation of DB2 duplicate.
db2iupgrade
On Linux or UNIX framework, this order is situated in DB2DIR/case catalog. In the accompanying language structures, "inst_name" shows the past rendition DB2 example and "inst_username" demonstrates the current introduced adaptation DB2 duplicate case client.
Syntax 2:
db2iupgrade -d -k -u <inst_username> <inst_name>
Example:
db2iupgrade -d -k -u db2inst2 db2inst2
Order Parameters:
- d : Turns investigating mode on.
- k : Keeps the pre-update case type in the event that it is bolstered in the DB2 duplicate, from where you are running this order.
On the off chance that you are utilizing the Super User (su) on Linux for db2iupgrade order, you should issue the "su" order with the "- " choice.
Dropping an instance
You can drop or erase the occurrence, which was made by "db2icrt" order.
db2idrop
On Linux and UNIX working framework, this order is situated in the DB2_installation_folder/occurrence index.
Syntax: [in the following syntax, ‘inst_username’ indicates username of instance and ‘inst_name’ indicates instance name]
db2idrop -u <inst_username> <inst_name>
Example: [To drop db2inst2]
./db2idrop -u db2inst2 db2inst2
Using other commands with instance
Order to discover which DB2 occasion we are taking a shot at now.
Syntax 1: [to check the current instance activated by database manager]
db2 get instance
Output:
The current database manager instance is: db2inst1
Syntax 2: [To see the current instance with operating bits and release version]
db2pd -inst | head -2
Example:
db2pd -inst | head -2
Output:
Instance db2inst1 uses 64 bits and DB2 code release SQL10010
Syntax 3: [To check the name of currently working instance]
db2 select inst_name from sysibmadm.env_inst_info
Example:
db2 select inst_name from sysibmadm.env_inst_info
Output:
INST_NAME --------------------------------------
db2inst1
1 record(s) selected.
Syntax: [To set a new instance as default]
db2set db2instdef=<inst_name> -g
Example: [To array newly created instance as a default instance]
db2set db2instdef=db2inst2 -g
