Starting the database
[db2inst1@bloemkool ~]$ db2start 01/11/2022 14:57:48 0 0 SQL1063N DB2START processing was successful. SQL1063N DB2START processing was successful. [db2inst1@bloemkool ~]$
Stopping the database
[db2inst1@bloemkool ~]$ db2stop 01/11/2022 14:58:43 0 0 SQL1064N DB2STOP processing was successful. SQL1064N DB2STOP processing was successful. [db2inst1@bloemkool ~]$
Stopping the database when there are connections/applications in the database.At first we do not succeed…ther are applications in the database.
[db2inst1@bloemkool ~]$ db2stop 01/11/2022 15:00:11 0 0 SQL1025N The database manager was not stopped because databases are still active. SQL1025N The database manager was not stopped because databases are still active. [db2inst1@bloemkool ~]$ [db2inst1@bloemkool ~]$ db2stop force 01/11/2022 15:00:17 0 0 SQL1064N DB2STOP processing was successful. SQL1064N DB2STOP processing was successful. [db2inst1@bloemkool ~]$
Connecting to the database
[db2inst1@bloemkool ~]$ db2 connect to tinus user martijn using pwd Database Connection Information Database server = DB2/LINUXX8664 11.5.6.0 SQL authorization ID = MARTIJN Local database alias = TINUS [db2inst1@bloemkool ~]$
Disconnecting/terminating the connection
[db2inst1@bloemkool ~]$ db2 terminate DB20000I The TERMINATE command completed successfully. [db2inst1@bloemkool ~]$
List applications in the database
[db2inst1@bloemkool ~]$ db2 list applications Auth Id Application Appl. Application Id DB # of Name Handle Name Agents -------- -------------- ---------- ------------------------------------- -------- ----- MARTIJN db2bp 65 *LOCAL.db2inst1.220111200924 TINUS 1 DB2INST1 db2bp 51 *LOCAL.db2inst1.220111200910 TINUS 1 [db2inst1@bloemkool ~]$
As you can see there are 2 connections in the database.
Forcing a connection of off the database
[db2inst1@bloemkool ~]$ db2 "force application (65)" DB20000I The FORCE APPLICATION command completed successfully. DB21024I This command is asynchronous and may not be effective immediately. [db2inst1@bloemkool ~]$
The number 65 is the application-handle (see the former example (list applications))
This will (ofcourse) result in errors on the application side of things:
[db2inst1@bloemkool ~]$ db2 "select count(*) from t1" SQL1224N The database manager is not able to accept new requests, has terminated all requests in progress, or has terminated the specified request because of an error or a forced interrupt. SQLSTATE=55032 [db2inst1@bloemkool ~]$
Getting configuration parameters
[db2inst1@bloemkool ~]$ db2 get database configuration | grep -i logsecond Number of secondary log files (LOGSECOND) = 100 [db2inst1@bloemkool ~]$ [db2inst1@bloemkool ~]$ db2 get db cfg | grep -i logsecond Number of secondary log files (LOGSECOND) = 100 [db2inst1@bloemkool ~]$
The command will get all database configuration parameters. So we need to grep the parameters we are interested.
If you are lazy (as every good DBA should be) you can use the second form.
And setting a configuration parameter
[db2inst1@bloemkool ~]$ db2 update database configuration using logsecond 101 DB20000I The UPDATE DATABASE CONFIGURATION command completed successfully. [db2inst1@bloemkool ~]$