DB2® HADR Installation Guide This guide covers the preparation and installation of IBM DB2® on Redhat Linux systems in the SoftLayer cloud environment. System Requirements. Step 1: Prepare Installation - Primary and Standby Servers. Step 2: Install DB2 binaries and build instance - Primary and Standby Servers. Step 3: Create Database - Primary Server. Step 4: Build Standby Database. Step 5: Configure HADR – Primary Server. Step 6: Configure and Start HADR Standby Server. Step 7: Start HADR Primary. Step 8: Prepare Nodes – TSA. Step 9: Install TSA - Standby Server. Step 10: Install TSA - Primary Server. System Requirements Operating System: Redhat Enterprise Server 6.? Database Software: IBM DB2® Version 9.7, 10.1, 10.5 Step 1: Prepare Installation Step 1.1: Create the base file systems and instance owner – Both Primary and Standy Server. As the root user execute the following commands assuming the Instance Name/Owner = db2inst1. #set umask umask 022 #add the DB2 instance owner and fenced user groups groupadd -g 601 db2inst1 groupadd -g 602 db2fenc1 #add the DB2 instance owner useradd -d /db2/db2inst1 -g 601 -u 601 db2inst1 #add home directories mkdir -p /db2/db2inst1/home #create the DB2 fenced user useradd -d /db2/db2inst1/home/db2fenc1 -g 602 -u 602 db2fenc1 #create DB2 directories mkdir -p /db2/db2inst1/data_01 mkdir -p /db2/db2inst1/log_01 mkdir -p /db2/db2inst1/dump_01/archive_01 mkdir -p /db2/db2inst1/install chmod -R 755 /db2 chown -R db2inst1:db2inst1 /db2 mkdir /db2/db2inst1/ibm chown root:root /db2/db2inst1/ibm mkdir -p /db2/db2inst1/ibm/ibmdb2/v10.5 Step 1.2: Install required packages. Execute the following commands as the root user: yum install ksh yum install libstdc++ yum install compat-libstdc++-33 yum install pam.i686 yum install libstdc++.i686 Step 2: Install DB2 binaries and build instance - Primary and Standby Servers Step 2.1: Copy and expand the install package. As the instance owner cp /tmp/install_db2.tar /db2/db2inst1/install/ cd /db2/db2inst1/install/ tar -xvf install_db2.tar Step 2.2: Edit the config file. As the instance owner vi create.cfg #Replace the variables with the current install parameters: INSTANCENAME db2inst1 FENCEDNAME db2fenc1 PORTNUMBER 50000 DB2VERSION v10.5 Step 2.3: Execute the install script. As the root user set umask 022 ./install_db2_instance.ksh Step 3: Create and Configure Database – Primary Server. As the instance owner on the primary instance. CREATE DATABASE db2v10 ON /db2/db2inst1/data_01/db2v10 USING CODESET UTF8 TERRITORY US PAGESIZE 32 K CATALOG TABLESPACE MANAGED BY SYSTEM USING ('/db2/db2inst1/data_01/db2v10/SYSCAT') EXTENTSIZE 256 PREFETCHSIZE 256 USER TABLESPACE MANAGED BY SYSTEM USING ('/db2/db2inst1/data_01/db2v10/USERSPACE1') EXTENTSIZE 256 PREFETCHSIZE 256 TEMPORARY TABLESPACE MANAGED BY SYSTEM USING ('/db2/db2inst1/temp_01/db2v10/TEMPSPACE1') EXTENTSIZE 256 PREFETCHSIZE 256 ; terminate ; db2 update db cfg for db2v10 using CUR_COMMIT ON db2 update db cfg for db2v10 using SELF_TUNING_MEM ON db2 update db cfg for db2v10 using DATABASE_MEMORY COMPUTED db2 update db cfg for db2v10 using LOCKLIST AUTOMATIC db2 update db cfg for db2v10 using MAXLOCKS AUTOMATIC db2 update db cfg for db2v10 using PCKCACHESZ AUTOMATIC db2 update db cfg for db2v10 using SHEAPTHRES_SHR AUTOMATIC db2 update db cfg for db2v10 using SORTHEAP AUTOMATIC db2 update db cfg for db2v10 using NUM_IOCLEANERS AUTOMATIC db2 update db cfg for db2v10 using NUM_IOSERVERS AUTOMATIC db2 update db cfg for db2v10 using DFT_PREFETCH_SZ AUTOMATIC db2 update db cfg for db2v10 using NUM_IOSERVERS AUTOMATIC db2 update db cfg for db2v10 using MAXAPPLS AUTOMATIC db2 update db cfg for db2v10 using APPLHEAPSZ AUTOMATIC db2 update db cfg for db2v10 using APPL_MEMORY AUTOMATIC db2 update db cfg for db2v10 using DBHEAP AUTOMATIC db2 update db cfg for db2v10 using NUM_IOSERVERS AUTOMATIC db2 update db cfg for db2v10 using DFT_DEGREE 1 db2 update db cfg for db2v10 using DB2LOCK_TO_RB STATEMENT Additional Settings: db2 update db cfg for db2v10 using LOGPRIMARY 20 db2 update db cfg for db2v10 using LOGFILSIZ 102400 db2 update db cfg for db2v10 using LOGSECOND 190 db2 update db cfg for db2v10 using LOGRETAIN RECOVERY db2 update db cfg for db2v10 using LOGARCHMETH1 DISK:/db2/db2inst1/dump_01/archive_01 db2set DB2_PMODEL_SETTINGS=MAX_BACKGROUND_SYSAPPS:500 DB2COMM=TCPIP #Backup the database mkdir /db2/db2inst1/dump_01/db2v10 db2 backup database dbv10 to /db2/db2inst1/dump/db2v10 Step 4: Build Standby Database. Copy the database backup to the standby node. #restore the database on the standy node restore database db from /db2/db2inst1/dump_01/db2v10 Step 5: Configure HADR – Primary Server As root on the Primary Server #Add new port in /etc/services for HADR cat /etc/services DB2_db2inst1 50000/tcp DB2_db2inst1_1 50001/tcp DB2_db2inst1_2 50002/tcp DB2_db2inst1_3 50003/tcp DB2_db2inst1_4 50004/tcp DB2_db2inst1_END 50011/tcp #Add port 50005 DB2_db2inst1 50000/tcp DB2_db2inst1_1 50001/tcp DB2_db2inst1_2 50002/tcp DB2_db2inst1_3 50003/tcp DB2_db2inst1_4 50004/tcp DB2_db2inst1_5 50005/tcp DB2_db2inst1_END 50011/tcp As the instance owner Set DB2 HADR Parameters: db2 get db cfg for db2v10 | grep HADR HADR database role = STANDARD HADR local host name (HADR_LOCAL_HOST) = HADR local service name (HADR_LOCAL_SVC) = HADR remote host name (HADR_REMOTE_HOST) = HADR remote service name (HADR_REMOTE_SVC) = HADR instance name of remote server (HADR_REMOTE_INST) = HADR timeout value (HADR_TIMEOUT) = 120 HADR target list (HADR_TARGET_LIST) = HADR log write synchronization mode (HADR_SYNCMODE) = NEARSYNC HADR spool log data limit (4KB) (HADR_SPOOL_LIMIT) = AUTOMATIC(0) HADR log replay delay (seconds) (HADR_REPLAY_DELAY) = 0 HADR peer window duration (seconds) (HADR_PEER_WINDOW) = 0 #Execute the update commands: db2 update db cfg using HADR_LOCAL_HOST server1.something.something db2 update db cfg using HADR_LOCAL_SVC DB2_db2inst1_5 db2 update db cfg using HADR_REMOTE_HOST server2.something.something db2 update db cfg using HADR_REMOTE_SVC DB@_db2inst1_5 db2 update db cfg using HADR_REMOTE_INST db2inst1 db2 update db cfg using HADR_PEER_WINDOW 120 Step 6: Configure and Start HADR Standby Server. As root on the Primary Server #Add new port in /etc/services for HADR cat /etc/services DB2_db2inst1 50000/tcp DB2_db2inst1_1 50001/tcp DB2_db2inst1_2 50002/tcp DB2_db2inst1_3 50003/tcp DB2_db2inst1_4 50004/tcp DB2_db2inst1_END 50011/tcp #Add port 50005 DB2_db2inst1 50000/tcp DB2_db2inst1_1 50001/tcp DB2_db2inst1_2 50002/tcp DB2_db2inst1_3 50003/tcp DB2_db2inst1_4 50004/tcp DB2_db2inst1_5 50005/tcp DB2_db2inst1_END 50011/tcp As the instance owner Set DB2 HADR Parameters: db2 get db cfg for db2v10 | grep HADR HADR database role = STANDARD HADR local host name (HADR_LOCAL_HOST) = HADR local service name (HADR_LOCAL_SVC) = HADR remote host name (HADR_REMOTE_HOST) = HADR remote service name (HADR_REMOTE_SVC) = HADR instance name of remote server (HADR_REMOTE_INST) = HADR timeout value (HADR_TIMEOUT) = 120 HADR target list (HADR_TARGET_LIST) = HADR log write synchronization mode (HADR_SYNCMODE) = NEARSYNC HADR spool log data limit (4KB) (HADR_SPOOL_LIMIT) = AUTOMATIC(0) HADR log replay delay (seconds) (HADR_REPLAY_DELAY) = 0 HADR peer window duration (seconds) (HADR_PEER_WINDOW) = 0 #Execute the update commands: db2 update db cfg using HADR_LOCAL_HOST server2.something.something db2 update db cfg using HADR_LOCAL_SVC DB2_db2inst1_5 db2 update db cfg using HADR_REMOTE_HOST server1.something.something db2 update db cfg using HADR_REMOTE_SVC DB2_db2inst1_5 db2 update db cfg using HADR_REMOTE_INST db2inst1 db2 update db cfg using HADR_PEER_WINDOW 120 db2 update db cfg using LOGINDEXBUILD ON Index re-creation time and redo index build (INDEXREC) = SYSTEM (RESTART) Log pages during index build (LOGINDEXBUILD) = ON Step 7: Start HADR Primary As the instance owner on the Standby Server: Start HADR – Note HADR is always started on the Standby Instances db2 start hadr on db db2v10 as standby As the instance owner on the Primary Server: db2 start hadr on db db2v10 as primary Step 8: Prepare Nodes – TSA As ROOT on both servers: Execute the preprpnode command followed by both hostnames. It does not matter which box you issue it first or in what order the hostnames are specified. preprpnode server1.something.something server1.something.something Also make sure the following ports are open udp 12347 12348 657 tcp 657 Step 9: Install TSA - Standby Server. -bash8-4.1$ db2haicu Welcome to the DB2 High Availability Instance Configuration Utility (db2haicu). You can find detailed diagnostic information in the DB2 server diagnostic log file called db2diag.log. Also, you can use the utility called db2pd to query the status of the cluster domains you create. For more information about configuring your clustered environment using db2haicu, see the topic called 'DB2 High Availability Instance Configuration Utility (db2haicu)' in the DB2 Information Center. db2haicu determined the current DB2 database manager instance is 'db2inst1'. The cluster configuration that follows will apply to this instance. db2haicu is collecting information on your current setup. This step may take some time as db2haicu will need to activate all databases for the instance to discover all paths ... When you use db2haicu to configure your clustered environment, you create cluster domains. For more information, see the topic 'Creating a cluster domain with db2haicu' in the DB2 Information Center. db2haicu is searching the current machine for an existing active cluster domain ... db2haicu did not find a cluster domain on this machine. db2haicu will now query the system for information about cluster nodes to create a new cluster domain ... db2haicu did not find a cluster domain on this machine. To continue configuring your clustered environment for high availability, you must create a cluster domain; otherwise, db2haicu will exit. Create a domain and continue? [1] 1. Yes 2. No Select the default of “Yes” Create a unique name for the new domain: #Enter the a name for the hadr domain Reponse: db2v10d Nodes must now be added to the new domain. How many cluster nodes will the domain 'db2v10d' contain? #Enter the number of nodes Reponse: 2 Enter the host name of a machine to add to the domain: Reponse: server1.something.something Enter the host name of a machine to add to the domain: Reponse: server2.something.something db2haicu can now create a new domain containing the 2 machines that you specified. If you choose not to create a domain now, db2haicu will exit. Create the domain now? [1] 1. Yes 2. No Reponse: 1 Creating domain 'db2v10d' in the cluster ... Creating domain 'db2v10d' in the cluster was successful. You can now configure a quorum device for the domain. For more information, see the topic "Quorum devices" in the DB2 Information Center. If you do not configure a quorum device for the domain, then a human operator will have to manually intervene if subsets of machines in the cluster lose connectivity. Configure a quorum device for the domain called 'db2v10d'? [1] 1. Yes 2. No Reponse: 1 The following is a list of supported quorum device types: 1. Network Quorum Enter the number corresponding to the quorum device type to be used: [1] Reponse: 1 Specify the network address of the quorum device: Reponse: 10.106.0.129 Configuring quorum device for domain 'db2v10d' ... Configuring quorum device for domain 'db2v10d' was successful. The cluster manager found the following total number of network interface cards on the machines in the cluster domain: '4'. You can add a network to your cluster domain using the db2haicu utility. Create networks for these network interface cards? [1] 1. Yes 2. No Reponse: 1 Enter the name of the network for the network interface card: 'eth0' on cluster node: 'server1.something.something' 1. Create a new public network for this network interface card. 2. Create a new private network for this network interface card. Enter selection: Reponse: 1 Are you sure you want to add the network interface card 'eth0' on cluster node 'server1.something.something' to the network 'db2_public_network_0'? [1] 1. Yes 2. No Reponse: 1 Adding network interface card 'eth0' on cluster node 'server1.something.something' to the network 'db2_public_network_0' ... Adding network interface card 'eth0' on cluster node 'server1.something.something' to the network 'db2_public_network_0' was successful. Enter the name of the network for the network interface card: 'eth0' on cluster node: 'server2.something.something' 1. db2_public_network_0 2. Create a new public network for this network interface card. 3. Create a new private network for this network interface card. Enter selection: Reponse: 1 Are you sure you want to add the network interface card 'eth0' on cluster node 'server2.something.something' to the network 'db2_public_network_0'? [1] 1. Yes 2. No Reponse: 1 Adding network interface card 'eth0' on cluster node 'server2.something.something' to the network 'db2_public_network_0' ... Adding network interface card 'eth0' on cluster node 'server2.something.something' to the network 'db2_public_network_0' was successful. Enter the name of the network for the network interface card: 'eth0' on cluster node: 'server1.something.something' 1. db2_public_network_0 2. Create a new public network for this network interface card. 3. Create a new private network for this network interface card. Enter selection: Reponse: 3 Are you sure you want to add the network interface card 'eth0' on cluster node 'server1.something.something' to the network 'db2_private_network_0'? [1] 1. Yes 2. No Reponse: 1 Adding network interface card 'eth0' on cluster node 'server1.something.something' to the network 'db2_private_network_0' ... Adding network interface card 'eth0' on cluster node 'server1.something.something' to the network 'db2_private_network_0' was successful. Enter the name of the network for the network interface card: 'eth0' on cluster node: 'server2.something.something' 1. db2_private_network_0 2. db2_public_network_0 3. Create a new public network for this network interface card. 4. Create a new private network for this network interface card. Enter selection: Reponse: 1 Are you sure you want to add the network interface card 'eth0' on cluster node 'server2.something.something' to the network 'db2_private_network_0'? [1] 1. Yes 2. No Reponse: 1 Adding network interface card 'eth0' on cluster node 'server2.something.something' to the network 'db2_private_network_0' ... Adding network interface card 'eth0' on cluster node 'server2.something.something' to the network 'db2_private_network_0' was successful. Retrieving high availability configuration parameter for instance 'db2inst1' ... The cluster manager name configuration parameter (high availability configuration parameter) is not set. For more information, see the topic "cluster_mgr - Cluster manager name configuration parameter" in the DB2 Information Center. Do you want to set the high availability configuration parameter? The following are valid settings for the high availability configuration parameter: 1.TSA 2.Vendor Enter a value for the high availability configuration parameter: [1] Reponse: 1 Setting a high availability configuration parameter for instance 'db2inst1' to 'TSA'. Adding DB2 database partition '0' to the cluster ... Adding DB2 database partition '0' to the cluster was successful. Do you want to validate and automate HADR failover for the HADR database 'DB2V10'? [1] 1. Yes 2. No Reponse: 1 Adding HADR database 'DB2V10' to the domain ... HADR database 'DB2V10' has been determined to be valid for high availability. However, the database cannot be added to the cluster from this node because db2haicu detected this node is the standby for HADR database 'DB2V10'. Run db2haicu on the primary for HADR database 'DB2V10' to configure the database for automated failover. \All cluster configurations have been completed successfully. db2haicu exiting ... -bash-4.1$ Step 10: Install TSA - Primary Server. As the root user on the primary server -bash-4.1$ db2haicu Welcome to the DB2 High Availability Instance Configuration Utility (db2haicu). You can find detailed diagnostic information in the DB2 server diagnostic log file called db2diag.log. Also, you can use the utility called db2pd to query the status of the cluster domains you create. For more information about configuring your clustered environment using db2haicu, see the topic called 'DB2 High Availability Instance Configuration Utility (db2haicu)' in the DB2 Information Center. db2haicu determined the current DB2 database manager instance is 'db2inst1'. The cluster configuration that follows will apply to this instance. db2haicu is collecting information on your current setup. This step may take some time as db2haicu will need to activate all databases for the instance to discover all paths ... When you use db2haicu to configure your clustered environment, you create cluster domains. For more information, see the topic 'Creating a cluster domain with db2haicu' in the DB2 Information Center. db2haicu is searching the current machine for an existing active cluster domain ... db2haicu found a cluster domain called 'db2v10d' on this machine. The cluster configuration that follows will apply to this domain. Retrieving high availability configuration parameter for instance 'db2inst1' ... The cluster manager name configuration parameter (high availability configuration parameter) is not set. For more information, see the topic "cluster_mgr - Cluster manager name configuration parameter" in the DB2 Information Center. Do you want to set the high availability configuration parameter? The following are valid settings for the high availability configuration parameter: 1.TSA 2.Vendor Enter a value for the high availability configuration parameter: [1] Reponse: 1 Setting a high availability configuration parameter for instance 'db2inst1' to 'TSA'. Adding DB2 database partition '0' to the cluster ... Adding DB2 database partition '0' to the cluster was successful. Do you want to validate and automate HADR failover for the HADR database 'DB2V10'? [1] 1. Yes 2. No Reponse: 1 Adding HADR database 'DB2V10' to the domain ... Adding HADR database 'DB2V10' to the domain was successful. Do you want to configure a virtual IP address for the HADR database 'DB2V10'? [1] 1. Yes 2. No Reponse: 2 All cluster configurations have been completed successfully. db2haicu exiting ...