To set up Sun Cluster 2.1, perform the following steps:
If you want to remove failover support for DB2, see "Unregistering DB2 for Failover".
To choose a failover configuration, perform the following steps:
To create the instance, use the db2icrt command, which is located in the DB2DIR/instance directory, where DB2DIR is /opt/IBMdb2/V5.0. Before creating a DB2 instance, ensure that DB2 is installed on each machine in the cluster.
You only create a DB2 instance on the logical host in the cluster where you
created the subdirectories /logical_host_name/home and
/logical_host_name/disks. The syntax of the
db2icrt command is:
where:
Notes:
Note: | FencedID may not be root or bin. |
When you create an instance, ensure that its primary and secondary groups are different from the Administration Server's primary (SYSADM) group. When you create an instance on the same machine as the Administration Server, its SYSADM group is automatically added to the secondary group list of the Administration Server so that you can use the Control Center to perform administration tasks on that instance.
To create an instance for a DB2 server, you can use the following command:
db2icrt -u db2fenc1 db2inst1
When an instance is created, its name is also added to the list of instances on the system.
The db2icrt command creates the INSTHOME/sqllib directory, where INSTHOME is the home directory of the instance owner.
Note: | To avoid a potential loss of data if an instance is deleted, you should not create user files or directories under the INSTHOME/sqllib directory, other than those created by DB2. The exeption is if your system supports fenced user defined functions and fenced stored procedures. In this situtaion, put the fenced applications in the INSTHOME/sqllib/function directory. |
Use the db2hareg script as an example of how to register DB2 with Sun Cluster. The script is located in the /opt/IBMdb2/V5.0/ha/UDB-EE_SC2.x/bin directory. The db2hareg script is as follows:
#!/bin/ksh hareg -r db2hareg -b /opt/IBMdb2/V5.0/ha/UDB-EE_SC2.x/bin -m START_NET=hadb2ee_startnet,STOP_NET=hadb2ee_stopnet,ABORT_NET=hadb2ee_abortnet -t START_NET=600,STOP_NET=600 -h log0 hareg -y hadb2ee
In the sample, log0 is the logical host. Replace log0 with the logical host that is to host the DB2 services.
You should run the db2hareg script (or an equivalent script) once for the cluster, and you must ensure that the script is the same on both machines in the cluster. You run the script as root. The script both registers DB2 for failover support, and enables the following scripts for the cluster:
As root, you must create and edit this configuration file. You must also ensure that the configuration file exists (and is the same) on both machines in the cluster. You use the configuration file to enable specific instances for failover. See "Enable Failover for an Instance" for details.
This script runs at the very beginning of a failover situation.
This file runs immediately before the db2start command
This file runs immediately before the db2stop command
Note: | This script may not be run if the machine crashes. |
This file runs just after a failover and is used to restart databases.
To enable an instance for failover, you create an entry for it in the /var/db2/v5/db2tabee file. The file must exist on each machine in the cluster. The file takes entries of the form:
TYPE INSTANCE LOGICAL_HOST ON/OFF
Where:
To start DB2 in a failover environment, use the hareg -y hadb2ee command. This command both enables the failover environment, and starts DB2.
If you want to stop DB2, first issue the hareg -n hadb2ee command to disable the failover environment. Then issue the db2stop command to stop DB2.
Note: | If you do not issue hareg -n hadb2ee first, Sun Cluster 2.1 may assume that the DB2 instance needs to be failed over. |
The /var/db2/v5/failover.ee script runs automatically when a failover occurs. You can use this script to send email (for example, to notify support staff) of the failover situation. You should keep the commands in this script to a minimum, because it runs before DB2 is started. Depending on whether DB2 is starting or stopping, the following scripts will also run (if they are available) for each instance:
This file takes as an argument the number of logical hosts that are currently running on the failover machine. If this script exists, it runs immediately before the db2start command.
This file takes as an argument the number of logical hosts that are currently running on the failover machine. If this script exists, it runs immediately before the db2stop command.
Note: | This script may not be run if the machine crashes. |
This file runs just after a failover and is used to restart databases.
You can use pre_db2startee to prevent resource contention by adjusting database manager and database configuration parameters that may consume substantial amounts of resource (for example, sheapthres). The following is an example:
#!/bin/ksh #Very simple example LOGHOSTS=$1 if ^^ $LOGHOSTS -eq 1 нн then db2 update dbm cfg using SHEAPTHRES 40000 else db2 update dbm cfg using SHEAPTHRES 20000 fi
To unregister DB2 for failover, run the hadb2ee.unreg script. This script deregisters DB2 with Sun Cluster 2.1.