Managing multiple databases on a single Db2 deployment

You can add, remove, and complete other operations for your databases by using the manage_databases tool.

Usage limitations

Consider the following limitations of the manage_databases tool:

  • You must have the db2inst1 user ID to run the manage_databases tool.
  • You can add up to eight databases per deployment.
  • You need a Db2 deployment. For more information, see Creating a Db2 database deployment on the cluster.
  • By default, all databases you create with the manage_databases tool have the same:
    • Instance registry
    • Database manager configuration
    • Custom resource definition (CRD)
Tip: You can set specific customizations for each database with the manage_databases tool by using an option to override the CRD. For more information, see Customizing your database specifications.

Commands for managing databases on your deployment

Refer to the following table for commands you can use with the manage_databases tool:

Operation Command
Add To add a database to your deployment:
oc exec -it service_name -- manage_databases --dblist "database1_name,database2_name" --add
Drop To remove a database from your deployment:
oc exec -it service_name -- manage_databases --dblist "database1_name,database2_name" --drop
Show To display all databases:
oc exec -it service_name -- manage_databases --show
Verbose To return additional debugging information in the output:
oc exec -it service_name -- manage_databases --verbose
Help To return command help:
--help

Replace the following variables with values for your environment:

  • service_name: The unique identifier for your Db2 deployment. For example: c-db2oltp-1619534024988588-db2u-0.
  • database1_name, database2_name: The name for your new database.

Customizing your database specifications

To customize specifications for your database, run the following command:
oc exec -it service_name -- manage_databases --dblist "database1_name, database2_name" --db-cfg-overrides 'database1_name:parameter1@value|database2_name:parameter1@value'
Example
Consider the following example:
oc exec -it c-db2oltp-1618958410448015-db2u-0 -- manage_databases --dblist "mydb1,mydb2" --db-cfg-overrides "'mydb1:LOGARCHMETH1@OFF|mydb2:DFT_EXTENT_SZ@128,DBHEAP@1500'" --add
The following changes apply:
  • mydb1 and mydb2 are added to the Db2 service deployment.
  • For mydb1:
    • LOGARCHMETH1 configuration parameter is set to OFF.
  • For mydb2:
    • DFT_EXTENT_SZ is set to 128.
    • DBHEAP is set to 1500.