db2cm command reference for HADR-configured clusters

You can use the Db2® cluster manager (db2cm) utility to configure and administer an HADR Db2 instance on a Pacemaker-managed Db2 Linux cluster.

Attention: Ensure that the HADR_SYNCMODE database configuration parameter is set to SYNC or NEARSYNC. Automated HADR failover is supported only by these HADR synchronization modes.

Command syntax

Read syntax diagramSkip visual syntax diagramdb2cm -create-clusterCluster creation options-awsAWS options (HADR)-azureAzure options -gcGoogle Cloud options-instanceinstanceName-hosthostName-publicEthernetpublicEthernetDeviceName-hosthostName-dbdatabaseName-instanceinstanceName-primaryVIPipv4Address-netmasksubnetMask-dbdatabaseName-instanceinstanceName-standbyVIPipv4Address-netmasksubnetMask-dbdatabaseName-instanceinstanceName-qdevicequorumDeviceHostName  | -delete-domain-awsAWS options (HADR)-azureAzure options -gcGoogle Cloud options-instanceinstanceName-hosthostName-publicEthernetpublicEthernetDeviceName-hosthostName-dbdatabaseName-instanceinstanceName-primaryVIP-dbdatabaseName-instanceinstanceName-standbyVIP-dbdatabaseName-instanceinstanceName-qdevice | -disable-all-instanceinstanceName-hosthostNameOfTheInstance | -enable-all-instanceinstanceName-hosthostNameOfTheInstance | -dump | -exportfilePath | -importfilePath | -copy_resourcesresourceAgentsPath | -hosthostName | -help | -add-instanceinstanceName | -remove-instanceinstanceName | -grant-adminUseruserName
Cluster creation options
Read syntax diagramSkip visual syntax diagram -domaindomainName -hosthostNameOfPublicEthernetDeviceName1 -publicEthernetpublicEthernetDeviceName1 -hosthostNameOfPublicEthernetDeviceName2 -publicEthernetpublicEthernetDeviceName2
Options for highly available AWS clusters
Read syntax diagramSkip visual syntax diagram-create -aws-primaryVIPipv4Address-profileprofileName-rtbroutingTableList-dbdatabaseName-instanceinstanceName-standbyVIPipv4Address-profileprofileName-rtbroutingTableList-dbdatabaseName-instanceinstanceName-fence
Read syntax diagramSkip visual syntax diagram-delete-aws-primaryVIP-dbdatabaseName-instanceinstanceName-standbyVIP-dbdatabaseName-instanceinstanceName-fence
Options for highly available Azure clusters
Read syntax diagramSkip visual syntax diagram-create -azure-primarylbl port -db databaseName -instanceinstanceName-standbylblport-dbdatabaseName-instanceinstanceName-fence
Read syntax diagramSkip visual syntax diagram-delete-azure-primarylbl-db databaseName-instanceinstanceName-standbylbl-db databaseName-instanceinstanceName-fence
Options for highly available Google Cloud clusters
Read syntax diagramSkip visual syntax diagram-create -gc-primaryVIP ipv4Adress-db databaseName -instanceinstanceName-standbyVIPipv4Adress-dbdatabaseName-instanceinstanceName-primarylbl port -db databaseName -instanceinstanceName-standbylblport-dbdatabaseName-instanceinstanceName-fence-serviceaccountaccessKeyFile
Read syntax diagramSkip visual syntax diagram-delete-gc-primaryVIP-db databaseName -instanceinstanceName-standbyVIP-dbdatabaseName-instanceinstanceName-primarylbl-db databaseName -instanceinstanceName-standbylbl-dbdatabaseName-instanceinstanceName-fence

Command parameters

-create
-cluster

Creates a new Pacemaker cluster domain with two hosts and the public Ethernet resource from scratch. The following parameters are mandatory:

-domain domainName
Specifies the name of the Pacemaker domain
-host hostName
Specifies the name of the host. The hostname provided must be the short host name.
-publicEthernet publicEthernetDeviceName
Specifies the name of the public network adapter on the host specified in the previous argument. Different device names can be used on the hosts.
For example,
sqllib/bin/db2cm -create -cluster -domain MyPCSDomain
                         -host host1 -publicEthernet eth0
                         -host host2 -publicEthernet eth2
-aws
Indicates that the specified resource will be configured for an Amazon Web Services (AWS) cloud environment.
-primaryVIP ipv4Address
Associates an overlay IP address with the primary role of the database and instance specified. Ensure you complete all prerequisite steps before running this command.
-standbyVIP ipv4Address
Associates an overlay IP address with the standby role of the database and instance specified, to facilitate reads on standby. Ensure you complete all prerequisite steps before running this command.
-fence
Configures the AWS fencing agent for clusters on AWS.
-profile profileName
The ‘default’ AWS profile is used to make API calls to AWS if one is not specified in the profile.
-rtb routingTableList
A comma-delimited list of routing tables, where each list item is an AWS route table ID that is local to the VPC.
-db databaseName
The name of the database on the cluster.
-instance instanceName
The name of the Db2 instance on the cluster.
-azure
Indicates that the specified resource will be configured for a Microsoft Azure cloud environment.
–primarylbl port -db databaseName –instance instanceName
Associates an Azure load balancer health probe resource with the primary database and instance specified. The port provided must be the health probe port of the Azure load balancer. A unique load balancer must be configured for the primary and standby role of each database. Ensure you complete all prerequisite steps before running this command.
–standbylbl port -db databaseName –instance instanceName
Associates an Azure load balancer health probe resource with the standby database and local instance specified. The port provided must be the health probe port of the Azure load balancer. A unique load balancer must be configured for the primary and standby role of each database. Ensure you complete all prerequisite steps before running this command.
-fence
Configures the Azure fencing agent for clusters on Azure. Ensure you complete all prerequisite steps before running this command.
-gc
Indicates that the specified resource will be configured for a Google Cloud environment.
–primarylbl ipv4Addres -db databaseName –instance instanceName
Associates the virtual IP address with the primary role of the database and instance specified.
The following example shows the command syntax for associating the virutal IP address 170.120.1.1 with the primary role of the database employeeDB:
/sqllib/bin/db2cm -create -primaryVIP 170.120.1.1  -db employeeDB -instance db2inst1
–standbylbl ipv4Addres -db databaseName –instance instanceName
Associate the virtual IP address with the standby role of the database and instance specified to facilitate read on standby feature.
The following example shows the command syntax for associating the virutal IP address 170.120.1.1 with the standby role of the database employeeDB:
/sqllib/bin/db2cm -create -standbyVIP 170.120.1.1  -db employeeDB -instance db2inst1
–primarylbl port -db databaseName –instance instanceName
Creates a Load Balancer resource of type ‘gcp-ilb’. The resource listens and responds to the GC health check and enables the GC backend to redirect the network traffic to the right node in the cluster. A unique load balancer must be configured for the primary role of each database. Ensure you complete all prerequisite steps before running this command.
The following example shows the command syntax for creating a load balancer that uses port 60000 for the primary role of the database employeeDB:
/sqllib/bin/db2cm -create -primarylbl 60000  -db employeeDB -instance db2inst1
–standbylbl port -db databaseName –instance instanceName
Creates a Load Balancer resource of type ‘gcp-ilb’. The resource listens and responds to the GC health check and enables the GC backend to redirect the network traffic to the right node in the cluster. A unique load balancer must be configured for the standby role of each database. Ensure you complete all prerequisite steps before running this command.
The following example shows the command syntax for creating a load balancer that uses port 60000 for the standby role of the database employeeDB:
/sqllib/bin/db2cm -create -standbylbl 60000  -db employeeDB -instance db2inst1
-fence
Configures the Google Cloud fencing agent for clusters on Google Cloud. Ensure you complete all prerequisite steps before running this command.
-instance instanceName -host hostNameOfTheInstance
Creates the instance resource and its resource model for the specified host.
For example,
sqllib/bin/db2cm -create -instance db2inst1 -host host1
-public Ethernet publicEthernetDeviceName -host hostName
Add a public Ethernet resource to the resource model with the name of the public network adapter on a host specified. Different device name can be used on different hosts. Each host can only have one public Ethernet resource.
For example,
sqllib/bin/db2cm -create -publicEthernet eth0 -host host1
-db databaseName -instance instanceName
Add HADR database resource of the specified instance on the local host to the resource model.
For example,
sqllib/bin/db2cm -create -db employeeDB -instance db2inst1
-primaryVIP ipv4Address [-netmask subnet-mask] -db databaseName [-instance instanceName]
Associate the virtual IP address with the primary role of the database and instance specified. The default netmask is auto-detected. The criteria of the VIP is for it to be on the same IP subnet as the associated local IPs on both hosts. The optional netmask parameter can be used to override the auto-detection. The IP address must be in IPv4 format. The optional netmask input can be in either the CIDR or the 32 bit format. You can create only one VIP resource for each database.
For example,
sqllib/bin/db2cm -create -primaryVIP 170.120.1.1 -netmask 21 -db employeeDB -instance db2inst1
sqllib/bin/db2cm -create -primaryVIP 170.120.1.1 -netmask 255.255.248.0 -db employeeDB -instance db2inst1
-standbyVIP ipv4Address [-netmask subnet-mask] -db databaseName [-instance instanceName]
Associate the virtual IP address with the standby role of the database to facilitate read on standby feature. The default netmask is auto-detected. The criteria of the VIP is for it to be on the same IP subnet as the associated local IPs on both hosts. The optional netmask parameter can be used to override the auto-detection. The IP address must be in IPv4 format. The optional netmask input can be in either the CIDR or the 32 bit format. You can create only one VIP resource for each database.
For example,
sqllib/bin/db2cm -create -standbyVIP 170.120.1.1 -netmask 21 -db employeeDB -instance db2inst1
sqllib/bin/db2cm -create -standbyVIP 170.120.1.2 -netmask 255.255.248.0 -db employeeDB -instance db2inst1
-qdevice quorum_device_host_name
Creates the quorum device for the corosync cluster.
For example,
sqllib/bin/db2cm -create -qdevice hostQDevice
-delete
-domain
Removes the resource model, deletes the cluster. Upon completion of this command, there should be no left-over Pacemaker process or resources on the current host.
For example,
sqllib/bin/db2cm -delete -domain
-aws
Indicates that the specified resource to be removed is configured for an AWS cloud environment.
-primaryVIP databaseName –instance instanceName
Deletes the IP address that is associated with the primary role of the database and instance specified.
-standbyVIP databaseName –instance instanceName
Deletes the IP address that is associated with the standby role of the database and instance specified.
-fence
The AWS fencing configuration.
-db databaseName
The name of the database on the cluster.
-instance instanceName
The name of the Db2 instance on the cluster.
-azure
Indicates that the specified resource to be removed is configured for a Microsoft Azure cloud environment.
–primarylbl -db databaseName –instance instanceName
Deletes the Azure load balancer health probe resource associated with the primary role of the specified database and local instance.
–standbylbl -db databaseName –instance instanceName
Deletes the Azure load balancer health probe resource associated with the standby role of the specified database and local instance.
-fence
Delete the fencing configuration utilizing the Azure fencing agent.
-gc
Indicates that the specified resource to be removed is configured for a Google Cloud environment.
–primaryVIP -db databaseName –instance instanceName
Deletes the virtual IP address that is associated with the primary role of the database and either the local instance or the specified instance.
–standbyVIP -db databaseName –instance instanceName
Deletes the virtual IP address that is associated with the standby role of the database and either the local instance or the specified instance.
–primarylbl -db databaseName –instance instanceName
Deletes the Google Cloud load balancer resource associated with the primary role of the specified database and either the local instance or the specified instance.
–standbylbl -db databaseName –instance instanceName
Deletes the Google Cloud load balancer resource associated with the standby role of the specified database and either the local instance or the specified instance.
-fence
Delete the fencing configuration that is using the Google Cloud fencing agent.
-publicEthernet publicEthernetDeviceName -host hostName
Deletes the public Ethernet resource and its associated resources.
For example,
sqllib/bin/db2cm -delete -publicEthernet eth1 -host host1
-instance instance_name -host hostNameOfTheInstance
Deletes the instance resource and its resource model. All the resources associated with the instance are also deleted.
For example,
sqllib/bin/db2cm -delete -instance db2inst1 -host host1
-db databaseName -instance instanceName
Deletes all resources in the resource model associated with the database name of the local instance name specified.
For example,
sqllib/bin/db2cm -delete -db employee_db -instance db2inst1
-primaryVIP -db databaseName [-instance instanceName]
Deletes the virtual IP address with the primary role of the database name and local instance name specified.
For example,
sqllib/bin/db2cm -delete -primaryVIP -db employee_db -instance db2inst1
-standbyVIP -db databaseName [-instance instanceName]
Deletes the virtual IP address with the standby role of the database name and local instance name specified.
For example,
sqllib/bin/db2cm -delete -standbyVIP -db employee_db -instance db2inst1
-qdevice
Removes the quorum device daemon from the corosync cluster nodes.
For example,
sqllib/bin/db2cm -delete -qdevice
However, this does not remove the quroum device daemon on the arbitrator node in case it is shared among other clusters. If the quorum device is no longer being utilized by other clusters, run the following command on the arbitrator node as root to remove it:
systemctl stop corosync-qnetd
rm -rf /etc/corosync/qnetd/nssdb
-disable
-all
Disable the automation for all Pacemaker resources of all Db2 instances in the Pacemaker domain.
For example,
sqllib/bin/db2cm -disable –all
-instance instanceName -host hostNameOfTheInstance
Disable the automation for the instance on the specified host. All the resources associated with the instance are also disabled.
For example,
sqllib/bin/db2cm -disable -instance db2inst1 -host host1
Note: The db2cm command does not manage resources created outside of the db2cm utility. This includes cloud specific resources created manually to facilitate fencing, Virtual IPs, or other cloud specific setup as per Db2 supplied instructions. For more information on disabling cloud specific resources, see Public cloud vendors supported with Db2 Pacemaker.
-enable
-all
Enable the automation for all Pacemaker resources of all Db2 instances in the Pacemaker domain. This option is meant to undo the disable -all operation.
For example,
sqllib/bin/db2cm -enable –all
-instance instanceName -host hostNameOfTheInstance
Enable the automation for the instance on the specified host. All the resources associated with the instance are also enabled. This option is meant to undo the disable -instance instanceName -host hostNameOfTheInstance operation.
For example,
sqllib/bin/db2cm -enable -instance db2inst1 -host host1
Note: The db2cm command does not manage resources created outside of the db2cm utility. This includes cloud specific resources created manually to facilitate fencing, Virtual IPs, or other cloud specific setup as per Db2 supplied instructions. For more information on enabling cloud specific resources, see Public cloud vendors supported with Db2 Pacemaker.
-list
Display the cluster configuration and status information.
For example,
sqllib/bin/db2cm -list
-dump
Export cluster information pertaining to the local host to a compressed file in the local directory. Use this for problem determination to collect data before contacting Db2 support. A db2cm.zip file is created under the directory where the tool is run.
For example,
sqllib/bin/db2cm -dump
-export
Backup the cluster configuration to a file which can be used with the -import option to quickly redeploy the cluster on the same set of hosts.
For example,
sqllib/bin/db2cm -export /tmp/backup.conf
For more information, see Backing-up cluster configuration information.
-import
Restore the cluster configuration from a previously saved configuration generated by the -export option.
For example,
sqllib/bin/db2cm -import /tmp/backup.conf
For more information, see Restore from a saved Pacemaker cluster configuration.
-copy_resources resourceAgentsPath -host hostName
Copies resource agent scripts from the specified path to the resources path on the specified host.
For example,
sqllib/bin/db2cm -copy_resources /tmp/20220830_Db2MutualFailover_Pacemaker_Beta1/Db2AgentScripts/ -host host1
-help
Print usage information for db2cm.
For example,
sqllib/bin/db2cm -help
-add -instance instanceName
Adds mount resources of a database to an existing HADR partition.
-remove -instance instanceName
Removes mount resources of a database to an existing HADR partition.
-grant -adminUser userName
Grants cluster administrator privilege to the userid specified. As the user credentials (groups) are cached in the current login session, you need to log out and log back in for the changes to take effect.
(gerry@R9GHADR-srv-1) /home/gerry/db2
$ sudo db2cm -grant -adminUser gerry
Userid 'gerry' has been granted Cluster Administrator privilege
(gerry@R9GHADR-srv-1) /home/gerry/db2
$ db2cm -create -instance gerry -host R9GHADR-srv-1
 DBT8235E  Userid "gerry" does not have sufficient permission. Reason code: 2.
(gerry@R9GHADR-srv-1) /home/gerry
$ exit
[09:31:37] root@R9GHADR-srv-1.fyre.ibm.com:/root
> su - gerry
Last login: Thu Aug  1 09:19:29 PDT 2024