Archives

DB2 administration server Start


This utility is used to manage the DB2 Administration Server (DAS).

• Log in as an account or user ID that is part of the dasadm_group.
• Check if the process is still running using “ps” command
• Start the DAS using the db2admin command as follows: Db2admin start

[dasusr1@mercury ~]$ db2admin start
[dasusr1@mercury ~]$ ps -ef | grep db

The Process “/home/dasusr1/das/adm/db2dasrrm” would be running

Screenshot: Start DAS Process
dasstart
 

DB2 administration server Stop


This utility is used to manage the DB2 Administration Server (DAS). If no parameters are specified, and the DAS exists, this command returns the name of the DAS.

• Log in as an account or user ID that is part of the dasadm_group.
• Stop the DAS using the db2admin command as follows: Db2admin stop

[dasusr1@mercury ~]$ ps -ef | grep db
[dasusr1@mercury ~]$ db2admin stop

“/home/dasusr1/das/adm/db2dasrrm ” would be stopped

Screenshot: Stop DAS Process
dasstop

DB2 administration server


The DB administration server (DAS) provides support services for DB2 tools such as the Control Center and the Configuration Assistant.
DAS assists the Control Center and Configuration Assistant when working on the following administration tasks:
• Enabling remote administration of DB2 UDB servers.
• Providing the facility for job management,
• Administrative tasks against jobs located either remotely or locally to the DAS using the Task Center.
• Providing a means for discovering information about the configuration of DB2 UDB instances, databases, and other DB2 administration.

To create a DAS, you must have root user authority on UNIX operating systems or you must be using an account that has the correct authorization to create a service.
You can only have one DAS in a database server.

1) Login as root
2) Ensure that dasusr1 user is created

[root@mercury instance]# cd /opt/ibm/db2/V9.1/instance
[root@mercury instance]# ./dascrt -u dasusr1

-u DASuser
DASuser is the user ID under which the DAS will be created. The DAS will be created under the /home/DASuser/das directory.


 

Create SAMPLE Db in DB2


To use the sample programs shipped with DB2®, you need to create the sample database on a server workstation. This will require approximately 23.5 megabytes of hard-drive space. An empty DB2 database requires approximately 21.5 megabytes of hard-drive space.

“db2sampl” command Creates a sample database named SAMPLE.There are many options like -dbpath path-name, -name database-name etc

[db2inst1@mercury dbbackup]$ db2sampl

Screenshot : Create a SAMPLE DB
db2sampl

Connect and Disconnect from DB2 Instance

 

Before you can issue an SQL statement, you have to connect to a database. To connect to a database, enter the command:

db2 CONNECT TO database USER userID USING password

[db2inst1@mercury dbbackup]$ db2 CONNECT TO sample USER db2inst1 using password

Once you have connected to a database, you can then issue SQL statements or DB2 commands against that database. For example, to select all of the rows from the EMPLOYEE table in the SAMPLE database, issue this command:

[db2inst1@mercury dbbackup]$ db2 “SELECT * FROM employee”

Screenshot : Db2connect
db2connect
=============================================================
Disconnect from DB2
=============================================================

Using : connect reset

[db2inst1@mercury dbbackup]$ db2 connect reset

Connect Reset breaks a connection to a database , but does not terminate the back-end process.

Screenshot : Db2 connect reset
db2connectrst

Using : db2 terminate

[db2inst1@mercury dbbackup]$ db2 terminate

If an application is connected to a database, or a process is in the middle of a unit of work, TERMINATE causes the database connection to be lost.
An internal commit is then performed.
Although TERMINATE and CONNECT RESET both break the connection to a database, only TERMINATE results in termination of the back-end process.
It is recommended that TERMINATE be issued prior to executing the db2stop command. This prevents the back-end process from maintaining an attachment to a database manager instance that is no longer available

 

DB2 Size and Capacity

 

To check the DB2 Size and Capacity execute the following as the instance owner “db2 ‘call get_dbsize_info(?,?,?,0)'”

Dbsize
An output parameter of type BIGINT that returns the size of the database (in bytes). The database size is calculated as follows: dbsize = sum (used_pages * page_size) for each table space (SMS & DMS).

Dbcapacity
An output parameter of type BIGINT that returns the database capacity (in bytes). This value is not available on partitioned database systems. The database capacity is calculated as follows: dbcapacity = SUM (DMS usable_pages * page size) + SUM (SMS container size + file system free size per container). If multiple SMS containers are defined on the same file system, the file system free size is included only once in the calculation of capacity.

[db2inst1@mercury dbbackup]$ db2 ‘call get_dbsize_info(?,?,?,0)’

Where the the output parameters are denoted with question mark (?), and specify the refresh-window (input parameter) with an integer value (0 means immediately; -1 means the default refresh window of 30 minutes; 15 means 15 minutes, etc).

Screenshot : Db2 Size and capacity
db2size
 

DB2 Restore

 

Restore Full DB2 backup from a directory

[db2inst1@mercury dbbackup]$ db2 restore db sample from /db2backup/ taken at 20110524073459

This would restore the db2 backup from the directory /db2backup with the backup
filename as SAMPLE.0.db2inst1.NODE0000.CATN0000.20110524073459.001

Restart the db2instance once the restore has completed

=============================================================
To restore the DB there are various options ie Restore from Incremental Backup Automatic

[db2inst1@mercury dbbackup]$ db2 restore db sample incremental automatic taken at 20110524091023


Screenshot :
Restore Incremental Database
db2restore

Restart the db2instance once the restore has completed

DB2 Backup

db2backup

Backup the SAMPLE database while it is offline. The backup image will be created in your current directory.

[db2inst1@mercury adm]$ db2 backup db sample

 

Screenshot: Offline Backup

where — SAMPLE.0.db2inst1.NODE0000.CATN0000.20110524073459.001 is the backed up file

Online Backup :
To take Backup the SAMPLE database to the /database1 and /datababase2 directories while the database is still accessible by other users.

.

[db2inst1@mercury dbbackup]$ backup db sample online to /databasebkp1, /databasebkp2Where /databasebkp1, /databasebkp2 are directories where backup would be created

 

Screenshot: Online Backup
db2backup1

List recent backups and where they are stored

[db2inst1@mercury dbbackup]$ db2 list history backup all for sample

Screenshot: Backup History
db2backup2

Check the integrity of a backup image

[db2inst1@mercury dbbackup]$ db2ckbkp SAMPLE.0.db2inst1.NODE0000.CATN0000.20110524073459.001
where SAMPLE.0.db2inst1.NODE0000.CATN0000.20110524073459.001 is the backup file

 

 

Display DB2 Version Info


=============================================================
DB2 Level
=============================================================

To display the version of DB2 running on the system
Login as the instance owner and execute the db2level command

[db2inst1@mercury adm]$ db2level

ScreenShot : List the Db2 version
db2level

Where The version of DB2 is 9.1.0.4 and its 32 bit

Db2 License Management


=============================================================
DB2 License Management
=============================================================

There are two types of license keys associated with DB2 database products:
a) Base license keys
b) Full license keys.

These license keys are stored in plain text files, which are referred to as license files or license entitlement certificates.

A “base” license does not has any usage rights. It is included in the DB2 database product installation media and is applied automatically during the installation process.
For example, db2ese.lic is a base license file for DB2 Enterprise Server Edition.

License keys are required for all DB2 database products including DB2 Connect and for each optional database feature.
The license key is found in the /db2/license directory of the Activation CD, which is supplied as a part of the product installation media.
For example, db2ese_u.lic is a license key and can be found on the IBM DB2 Enterprise Server Edition – Authorized User Option Activation CD.

Obtain License
>>The licenses for DB2 database products can be purchased either per processor (priced by Processor Value Unit (PVU)) or by authorized user.
>>You can obtain license keys from the Passport Advantage Web site: http://www.ibm.com/software/lotus/passportadvantage/.

Some of the licenses for DB2 ESE
db2ese.lic DB2 Enterprise Server Edition (Unlicensed base)
db2ese_c.lic DB2 Enterprise Server Edition (CPU option)
db2ese_u.lic DB2 Enterprise Server Edition (Authorized User option)

License Type: “Developer”, it means that your DB2 database product was obtained as part of Database Enterprise Developer Edition for Linux, UNIX, and Windows.
License Type: “Restricted use”, it means that your DB2 database product was obtained as part of another IBM® product. In this case, the license terms of the bundling product take precedence over the usual DB2 Version 9.5 license terms.
License Type: “License not registered”, it means that only a base license key has been registered. You should register the appropriate full license key for the DB2 database product.

On Linux OS to register a DB2 license key by entering the following command:

INSTHOME/sqllib/adm/db2licm -a filename
— INSTHOME is the home directory of the instance owner
— filename is the full path name and file name for the license key that corresponds to the product or feature you have purchased.

[db2inst1@mercury adm]$cd /home/db2inst1/sqllib/adm/
[db2inst1@mercury adm]$ ./db2licm -l

ScreenShot : List the Db2 Licenses
db2licm

=============================================================

To Generate a compliance report
Enter the following command from the command line:
db2licm -g filename — filename is the path and file name where output is to be stored.

Analyze the compliance report. If you have not registered the license key for a DB2 feature, the compliance report will list the feature as a “Violation”.

[db2inst1@mercury adm]$cd /home/db2inst1/sqllib/adm/
[db2inst1@mercury adm]$ ./db2licm -g /tmp/licences

 

ScreenShot : Compliance report of the Db2 License

db2licm1

=============================================================

To remove the license

Enter the following command from the command line:
db2licm -r

Where -r Removes the license for a product. After the license is removed, the product functions in “Try & Buy” mode.

[db2inst1@mercury adm]$cd /home/db2inst1/sqllib/adm/
[db2inst1@mercury adm]$ ./db2licm -r

 

ScreenShot : Remove the DB2 License
db2licm2