DB2 DPF 双机搭建

环境准备: 

操作系统安装包:rhel-server-6.1-x86_64-dvd.iso

虚拟机软件:VMware-workstation-full-8.0.2-591240.exe

1.安装 VMware-workstation-full-8.0.2-591240.exe 虚拟机软件,安装步骤略。。。

2.在虚拟机上安装RedHat 操作系统,安装步骤略。。。把名字修改为: Red Hat DB2 DPF A 

3. 拷贝 Red Hat DB2 DPF A 并重命名: Red Hat DB2 DPF B

4. 调整Linux操作系统的参数:

A服务器: IP: 192.168.2.50 主机名:RedHat61  (定义为主服务器)

[db2inst1@RedHat61 ~]$ cat /etc/hosts
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.2.50 RedHat61
192.168.2.51 RedHat62

[root@RedHat61 ~]# vi /etc/sysctl.conf 
## for db2 dpf
kernel.msgmni = 16384
kernel.sem = 250 256000 32 4096

[root@RedHat61 ~]# sysctl -p 

[root@RedHat61 ~]# vi /etc/security/limits.conf

## for db2 dpf

* soft nofile 10240

创建dbvg卷组: 

创建db2home卷: ---用于存放公用的节点,日志等配置信息。

[root@RedHat61 ~]# lvcreate -n db2home -L 5G dbvg

[root@RedHat61 ~]# mkfs.ext4 db2home 

[root@RedHat61 ~]# mkdir /db2home

[root@RedHat61 ~]# mount /dev/dbvg/db2home  /db2home

NFS配置:

[root@RedHat61 ~]# cat /etc/exports 
/db2home    192.168.2.51(rw,sync,no_root_squash)
[root@RedHat61 ~]# 

[root@RedHat61 ~]# chkconfig --level 5 nfs on

[root@RedHat61 ~]# chkconfig --level 3 nfs on

创建db2data卷:  --用于存放数据

[root@RedHat61 ~]# lvcreate -n db2data -L 5G dbvg

[root@RedHat61 ~]# mkfs.ext4 db2data 

[root@RedHat61 ~]# mkdir /db2data

[root@RedHat61 ~]# mount /dev/dbvg/db2data  /db2data

B服务器: IP: 192.168.2.51 主机名:RedHat62 (节点服务器)

[db2inst1@RedHat62 ~]$ cat /etc/hosts
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.2.50 RedHat61
192.168.2.51 RedHat62
[db2inst1@RedHat62 ~]$ 

[root@RedHat62 ~]# vi /etc/sysctl.conf 
## for db2 dpf
kernel.msgmni = 16384
kernel.sem = 250 256000 32 4096

[root@RedHat62 ~]# sysctl -p 

[root@RedHat62 ~]# vi /etc/security/limits.conf

* soft nofile 10240

创建dbvg卷组: 

将A服务器的/db2home目录挂载到B服务器之上 (这里采用的是NFS)

[root@RedHat62 ~]# mount 192.168.2.50:/db2home /db2home

创建db2data卷:  --用于存放数据

[root@RedHat62 ~]# lvcreate -n db2data -L 5G dbvg

[root@RedHat62 ~]# mkfs.ext4 db2data 

[root@RedHat62 ~]# mkdir /db2data

[root@RedHat62 ~]# mount /dev/dbvg/db2data  /db2data


5. 分别在A、B服务器创建用户组、用户并设置用户密码:

#groupadd -g 999 dasadm1

#groupadd -g 998 db2iadm1
#groupadd -g 997 db2fadm1

#useradd -u 2014 -g db2iadm1 -m -d /db2home/db2inst1 db2inst1
#useradd -u 2013 -g db2fadm1 -m -d /db2home/db2fenc1 db2fenc1
#useradd -u 2012 -g dasadm1 -m -d /home/dasusr1 dasusr1

6. 上传DB2安装包并分别在A、B服务器安装DB2数据库软件,安装过程略。。。

#su - db2inst1
$vi .profile
. /db2home/db2inst1/sqllib/db2profile

7. 在A服务器上面创建实例db2inst1
#cd /opt/ibm/db2/V9.7/instance/
./db2icrt -s ese -u db2fenc1 db2inst1

8. 添加用户认证。

9.更改db2nodes.cfg文件

[db2inst1@RedHat61 ~]$ cat sqllib/db2nodes.cfg 
0 RedHat61 0
1 RedHat61 1
2 RedHat62 0
3 RedHat62 1
[db2inst1@RedHat61 ~]$

10.配置端口信息:

在A服务器:

[db2inst1@RedHat61 ~]# cat /etc/services

DB2c_db2inst1   50000/tcp
DB2_db2inst1    60000/tcp
DB2_db2inst1_1  60001/tcp
DB2_db2inst1_2  60002/tcp
DB2_db2inst1_END        60003/tcp

在B服务器:

[db2inst1@RedHat62 ~]# cat /etc/services

DB2_db2inst1    60000/tcp
DB2_db2inst1_1  60001/tcp
DB2_db2inst1_2  60002/tcp
DB2_db2inst1_END        60003/tcp

 

11.在A服务器上设置配置DB2的参数

su - db2inst1

[db2inst1@RedHat61 ~]$ db2 update dbm cfg using SVCENAME DB2c_db2inst1

[db2inst1@RedHat61 ~]$ db2set DB2COMM=TCPIP

[db2inst1@RedHat61 ~]$ db2set DB2RSHCMD=/usr/bin/ssh

[db2inst1@RedHat61 ~]$ db2start

07/06/2015 07:22:23     0   0   SQL1063N  DB2START processing was successful.
07/06/2015 07:22:26     1   0   SQL1063N  DB2START processing was successful.
07/06/2015 07:22:57     3   0   SQL1063N  DB2START processing was successful.
07/06/2015 07:23:01     2   0   SQL1063N  DB2START processing was successful.

--------创建表空间

CREATE LARGE TABLESPACE TBS_MAST_DAT
  IN DATABASE PARTITION GROUP "IBMDEFAULTGROUP"
  PAGESIZE 4K
  MANAGED BY DATABASE 
  USING ( File '/db2data/db2inst1/NODE0000/TESTDB/TABLESPACES/TBS_MAST_DAT001.DBF' 20M ) ON DBPARTITIONNUM(0)
  USING ( File '/db2data/db2inst1/NODE0001/TESTDB/TABLESPACES/TBS_MAST_DAT001.DBF' 20M ) ON DBPARTITIONNUM(1)
  USING ( File '/db2data/db2inst1/NODE0002/TESTDB/TABLESPACES/TBS_MAST_DAT001.DBF' 20M ) ON DBPARTITIONNUM(2)
  USING ( File '/db2data/db2inst1/NODE0003/TESTDB/TABLESPACES/TBS_MAST_DAT001.DBF' 20M ) ON DBPARTITIONNUM(3)
  EXTENTSIZE 32
  PREFETCHSIZE 32
  BUFFERPOOL IBMDEFAULTBP
  OVERHEAD 12.67
  TRANSFERRATE 0.18
  DROPPED TABLE RECOVERY OFF;

[db2inst1@RedHat62 log]$ db2 "create table tab_test(id int, name varchar(20), addr varchar(30) ) compress yes distribute by hash(id) in tbs_mast_dat"

[db2inst1@RedHat62 log]$ time db2 "select count(*) from tab_test1 with ur"
1          
-----------
    1780089
  1 record(s) selected.
real    0m10.208s
user    0m0.017s
sys     0m0.095s
[db2inst1@RedHat62 log]$ 

[db2inst1@RedHat62 log]$ time db2 "select dbpartitionnum(id) as cnt, count(*) as cnt2 from tab_test1 group by dbpartitionnum(id) order by dbpartitionnum(id)  with ur"
CNT         CNT2       
----------- -----------
          0      447581
          1      439126
          2      446780
          3      446602
  4 record(s) selected.
real    0m16.795s
user    0m0.011s
sys     0m0.024s
[db2inst1@RedHat62 log]$ 

-----------测试正式完成-------------

 








你可能感兴趣的:(DB2 DPF 双机搭建)