HADR规划
| Hostname |
hao111 |
localhost |
| 数据库实例名 |
cms |
| 端口 |
50001 |
| 根目录 |
/home/cms/db2fs |
| 在线日志路径 |
/home/cms/db2log/trans |
| 归档日志路径 |
/home/cms/db2log/arch |
| db2 hadr service port |
db2h_cmsinst1 70000/tcp |
| IP |
192.168.56.102 primary-node1 192.168.56.104 primary-node2 |
192.168.56.103 standby-node1 192.168.56.105 standby-node2 |
| |
|
|
数据库安装 (主、备)
[root@hao111 ~]# mount -o loop -t iso9660 db29.7_07_linux64.iso /mnt/db2rom/
[root@hao111 ~]# cd /mnt/db2rom/
[root@hao111 db2rom]# ./db2_install
WARNING:
DBT3534W The db2prereqcheck utility determined that ASLR is set to ON and that this could cause issues with some tools.
WARNING:
The 32-bit library file libpam.so is not found on the system.
Default directory for installation of products - /opt/ibm/db2/V9.7
***********************************************************
Do you want to choose a different directory to install [yes/no]
no
[root@hao111 ~]# groupadd -g 2000 db2iadm1
[root@hao111 ~]# groupadd -g 2001 db2fadm1
[root@hao111 ~]# useradd -m -g db2iadm1 -d /home/db2inst1 db2inst1
[root@hao111 ~]# useradd -m -g db2fadm1 -d /home/db2fenc1 db2fenc1
[root@hao111 ~]# useradd -m -g db2iadm1 -d /home/cms cms
[root@hao111 ~]# useradd -m -g db2iadm1 -d /home/scms scms
[root@hao111 ~]# passwd db2inst1
[root@hao111 ~]# passwd db2fenc1
[root@hao111 ~]# passwd cms
[root@hao111 ~]# passwd scms
创建实例
[root@hao111 ~]# cd /opt/ibm/db2/V9.7/instance/
[root@hao111 instance]# ./db2icrt -p 50000 -u db2fenc1 db2inst1
DBI1070I Program db2icrt completed successfully.
[root@hao111 instance]# ./db2icrt -p 50001 -u db2fenc1 cms
DBI1070I Program db2icrt completed successfully.
[root@hao111 instance]# ./db2icrt -p 50002 -u db2fenc1 scms
DBI1070I Program db2icrt completed successfully.
安装许可证
[root@hao111 instance]# su - db2inst1
[db2inst1@hao111 ~]$ db2licm -l
[db2inst1@hao111 ~]$ exitlogout
[root@hao111 instance]# cd /opt/ibm/db2/V9.7/adm/
[root@hao111 adm]# ./db2licm -a /root/db2ese_c.lic
LIC1402I License added successfully.
建库
$ db2start
$ db2 create db cms automatic storage yes on /home/cms/db2fs using codeset GBK territory CN
操作系统内核参数配置
$ vi /etc/sysctl.conf
----以内存为16GB的配置例子
----如果大于16GB,SEMMSL、SEMMNS、SEMOPM、msgmax和msgmnb保持不变
----shmmni、shmmax、shmall、SEMMNI和msgmni的设置成比例增大,见下面加黑内容
kernel.msgmnb = 65536
kernel.msgmax = 65536
kernel.msgmni=1638
kernel.shmmax = 68719476736
kernel.shmmni=4096
kernel.shmall = 4294967296
----kernel.sem=
kernel.sem=250 25600 32 4096
# sysctl -p ----使设置生效
# ipcs -l ----显示当前内核参数

修改limits.conf
# vi /etc/security/limits.conf ----根据实际情况,酌情修改
修改/etc/hosts
# vi /etc/hosts

DB2参数配置
环境变量配置 (主、备)
$ db2set DB2_USE_IOCP=OFF
$ db2set DB2COMM=tcpip
$ db2set DB2CODEPAGE=1386
$ db2set DB2AUTOSTART=YES
$ db2set DB2_HADR_ROS=ON
$ db2set DB2_STANDBY_ISO=UR
设置 DBM CFG (主、备)
$ db2 update dbm cfg using DIAGLEVEL 3
$ db2 update dbm cfg using DIAGSIZE 1024
$ db2 update dbm cfg using SHEAPTHRES 0 ----SHEAPTHRES的值为0时,使用共享排序
设置 DB CFG (主)
预取和清页进程数目设定
connect to cms;
update db cfg using NUM_IOCLEANERS AUTOMATIC;
update db cfg using NUM_IOSERVERS AUTOMATIC;
锁参数设定
connect to cms;
update db cfg using MAXLOCKS 40;
update db cfg using LOCKLIST 20480;
update db cfg using LOCKTIMEOUT 30;
日志参数设定
connect to cms;
update db cfg using LOGBUFSZ 5120;
update db cfg using LOGFILSIZ 51200;
update db cfg using LOGPRIMARY 50;
update db cfg using LOGSEC