Instance
DB2 Instance
Definition
"An instance in DB2 for LUW is like a copy of the RDBMS including all the processes that run DB2 and memory (address spaces) associated with that instance of DB2 and some configuration parameters to control that instance".
A DB2 instance includes memory areas – memory areas that contain all the memory areas for all of the databases. A DB2 instance includes processes/threads. Some processes/threads are associated with specific databases and even specific connections, but they are all tracked back to just one instance.
A DB2 Instance also stores information specific to that instance, in the instance owner’s home directory, including:
- Node directory
- Database directory
- db2diag.log, db2 notification log, and dump files
- DBM configuration file
- db2nodes.cfg
Instance=Memory+Process/Threads
There could be multiple instances on a single server (development, production, testing) but it's highly unlikely that a server would have multiple instances in work environments.
An instance contains databases(there could be multiple databases in one single instance).
In the below figure we can see that there are two instances viz. Instance_1 and Instance_2.
In Instance_1 there are two databases DB_1 and DB_2 whereas in Instance_2 there is a single database DB_3. Each instance and database have their own configuration files(DBM CFG and DB CFG respectively),catalog and log files, all independent of one another.
In the below figure we can see that there are two instances viz. Instance_1 and Instance_2.
In Instance_1 there are two databases DB_1 and DB_2 whereas in Instance_2 there is a single database DB_3. Each instance and database have their own configuration files(DBM CFG and DB CFG respectively),catalog and log files, all independent of one another.
There is a special user associated with the instance called the instance owner.
Instance owner is a special user that is created at the OS level just like any other user.
All the admin tasks that are to be done would be run using the instance owner's ID.
It's the most important ID on a server where DB2 is hosted as anyone having access to it would be having access to manipulating the databases contained in that instance. Hence only DBA's should have the login credentials of the instance owner, although the password for instance owner can be changed by anyone having a root privilege as it's a user at the OS level but it's highly unlikely to happen in work environments.
The instance itself is created by root (assuming a root installation), but the instance owner is specified on creation.
The instance owner cannot be changed once an instance is created, and neither can the instance’s home directory. These are things that must be defined before instance creation.
Instance owner and instance have the same name
To create a instance owner inst1 and it's associated group dba we would be entering the following commands as a root user.
# groupadd dba
# groupadd fencedid
# adduser -G dba inst1
# adduser -G fencedid fenced1
After creating an instance owner and a fenced ID, we are now ready to create our DB2 Instance.
With successful creation of the above script a DB2 instance named "inst1" would be created.
Getting Current Instance
Following command will list the current instance.
Instance parameters can be viewed using the following command
Instance parameters can be changed using the following command
Note:Instance parameters are global i.e. they would be applicable on all the databases created within that instance.
# groupadd dba
# groupadd fencedid
# adduser -G dba inst1
# adduser -G fencedid fenced1
After creating an instance owner and a fenced ID, we are now ready to create our DB2 Instance.
Creating an Instance
We can find the script to create an instance in the directory where DB2 is installed in the instance direcory.
#/opt/ibm/db2/V11.1/instance/
Here the script ./db2icrt is the one that would be used to create the instance
The command to create an instance is
./db2icrt -b <fenced_id> <instance_name>Enter the below command as a root user to create an instance inst1
./db2icrt -u fenced1 inst1
With successful creation of the above script a DB2 instance named "inst1" would be created.
Listing Instances.
Instances can be listed with the following commanddb2ilist
Getting Current Instance
Following command will list the current instance.
db2 get instance
Instance Parameter
Every DB2 instance has configurable instance parameters.Instance parameters can be viewed using the following command
db2 get dbm cfg
Instance parameters can be changed using the following command
db2 update dbm cfg using <param_name> <value>
eg:db2 update dbm cfg using svcename 60000
Note:Instance parameters are global i.e. they would be applicable on all the databases created within that instance.
Comments
Post a Comment