使用的linux版本是suse10.
1、在编目节点,建立NFS共享,作为DPF数据库的共享实例目录
ha1:/home # cd /
ha1:/ # ls
.rnd boot dev home lib64 mnt proc sbin sys usr
bin db2data etc lib media opt root srv tmp var
ha1:/ # mkdir /db2home
ha1:/ # vi /etc/exports
ha1:/ # more /etc/exports
# See the exports(5) manpage for a description of the syntax of thisfile.
# This file contains a list of all directories that are to be exported to
# other computers via NFS (Network File System).
# This file used by rpc.nfsd and rpc.mountd. See their manpages fordetails
# on how make changes in this file effective.
/db2home 192.168.56.*(rw,sync,no_root_squash)
ha1:/ #
启动NFS服务并检查配置:
ha1:/ # chkconfig -a nfsserver
nfsserver 0:off 1:off 2:off 3:on 4:off 5:on 6:off
ha1:/ # /etc/init.d/nfsserver restart
Shutting down kernel based NFS server done
Starting kernel based NFS server done
ha1:/ # rpcinfo -p localhost | grep nfs
100003 2 udp 2049 nfs
100003 3 udp 2049 nfs
100003 4 udp 2049 nfs
100003 2 tcp 2049 nfs
100003 3 tcp 2049 nfs
100003 4 tcp 2049 nfs
ha1:/ #
在另一台机器ha2上,进行操作如下:
ha2:/ # mount -t nfs 192.168.56.171:/db2home /db2home
2、建立用户、用户组,配置SSH互信,并保证两台机器的hosts文件一致
编目节点
groupadd -g 899 db2iadm2
groupadd -g 898 db2fadm2
useradd -u 3014 -g db2iadm2 -m -d /db2home/db2inst2 db2inst2
useradd -u 3013 -g db2fadm2 -m -d /db2home/db2fenc2 db2fenc2
ha1:/db2home # useradd -u 3013 -g db2fadm2 -m -d /db2home/db2fenc2db2fenc2
ha1:/db2home # useradd -u 3014 -g db2iadm2 -m -d /db2home/db2inst2db2inst2
ha1:/db2home # ls
db2fenc2 db2inst2
数据节点
groupadd -g 899 db2iadm2
groupadd -g 898 db2fadm2
useradd -u 3014 -g db2iadm2 -d /db2home/db2inst2 db2inst2
useradd -u 3013 -g db2fadm2 -d /db2home/db2fenc1 db2fenc2
ha2:/db2home # useradd -u 3013 -g db2fadm2 -d /db2home/db2fenc2db2fenc2
ha2:/db2home # useradd -u 3014 -g db2iadm2 -d /db2home/db2inst2db2inst2
ha2:/db2home # ls -l
total 1
drwxr-xr-x 8 db2fenc2 db2fadm2616 Jun 21 16:30 db2fenc2
drwxr-xr-x 8 db2inst2 db2iadm2 616 Jun 21 16:30db2inst2
ha2:/db2home # useradd -u 3014 -g db2iadm2 -d /db2home/db2inst2db2inst2
ha2:/db2home # ls -l
total 1
drwxr-xr-x 8 db2fenc2 db2fadm2616 Jun 21 16:30 db2fenc2
drwxr-xr-x 8 db2inst2 db2iadm2 616 Jun 21 16:30db2inst2
配置db2inst2的SSH互信:
在第一台机器:
db2inst2@ha1:~> ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/db2home/db2inst2/.ssh/id_rsa):
Created directory '/db2home/db2inst2/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /db2home/db2inst2/.ssh/id_rsa.
Your public key has been saved in /db2home/db2inst2/.ssh/id_rsa.pub.
The key fingerprint is:
82:17:52:2c:57:ae:b8:03:b6:1d:6f:0a:a3:c9:e9:c6 db2inst2@ha1
db2inst2@ha1:~> ssh-keygen -t dsa
Generating public/private dsa key pair.
Enter file in which to save the key (/db2home/db2inst2/.ssh/id_dsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /db2home/db2inst2/.ssh/id_dsa.
Your public key has been saved in /db2home/db2inst2/.ssh/id_dsa.pub.
The key fingerprint is:
7a:19:d2:b7:67:c7:d4:3b:0b:f3:a8:a0:cf:21:2a:84 db2inst2@ha1
db2inst2@ha1:~> cat ~/.ssh/id_rsa.pub >>~/.ssh/authorized_keys
db2inst2@ha1:~> cat ~/.ssh/id_dsa.pub >>~/.ssh/authorized_keys
db2inst2@ha1:~> ssh ha2 cat ~/.ssh/id_rsa.pub >>~/.ssh/authorized_keys
The authenticity of host 'ha2 (192.168.56.173)' can't be established.
RSA key fingerprint is63:42:c3:d4:06:51:dd:2c:86:93:41:df:01:92:80:0d.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'ha2,192.168.56.173' (RSA) to the list of knownhosts.
db2inst2@ha1:~> ssh ha2 cat ~/.ssh/id_dsa.pub >>~/.ssh/authorized_keys
db2inst2@ha1:~> ssh ha2 date
Fri Jun 21 16:56:30 CST 2013
db2inst2@ha1:~> ssh ha2
Last login: Fri Jun 21 16:48:08 2013 from 192.168.56.171
db2inst2@ha2:~> exit
logout
Connection to ha2 closed.
由于还有第二块网卡,所以,需要将第二块网卡也配置ssh互信
ha1:~ # su - db2inst2
db2inst2@ha1:~> ssh ha2.localhost cat ~/.ssh/id_rsa.pub >>~/.ssh/authorized_keys
db2inst2@ha1:~> ssh ha2.localhost cat ~/.ssh/id_dsa.pub >>~/.ssh/authorized_keys
db2inst2@ha1:~> ssh ha2.localhost date
Fri Jun 21 17:50:51 CST 2013
db2inst2@ha1:~> ssh ha2.localhost
Last login: Fri Jun 21 16:56:36 2013 from 192.168.56.171
db2inst2@ha2:~> exit
logout
Connection to ha2.localhost closed.
db2inst2@ha1:~>
ha2:/db2home # su - db2inst2
db2inst2@ha2:~> ssh ha1.localhost
Lastlogin: Fri Jun 21 16:56:55 2013 from 192.168.56.173
db2inst2@ha1:~> exit
logout
Connectionto ha1.localhost closed.
db2inst2@ha2:~>
db2inst2@ha2:~> ssh ha1.localhost
Lastlogin: Fri Jun 21 16:56:55 2013 from 192.168.56.173
db2inst2@ha1:~> exit
logout
Connectionto ha1.localhost closed.
db2inst2@ha2:~>
3、建立实例
在编目节点上,建立实例
ha1:/opt/ibm/db2/V9.7/instance # ./db2icrt -u db2fenc2 db2inst2
DBI1070I Program db2icrt completed successfully.
ha1:/opt/ibm/db2/V9.7/instance # su - db2inst2
db2inst2@ha1:~> db2ilist
db2inst2
db2inst1
db2inst2@ha1:~> exit
4、更改services文件和dbm的参数
编目节点
DB2c_db2inst1 50000/tcp
DB2_db2inst1 60000/tcp
DB2_db2inst1_1 60001/tcp
DB2_db2inst1_2 60002/tcp
DB2_db2inst1_END 60003/tcp
cthats 12347/udp
cthags 12348/udp
DB2c_db2inst2 70000/tcp
DB2_db2inst2 60004/tcp
DB2_db2inst2_1 60005/tcp
DB2_db2inst2_2 60006/tcp
DB2_db2inst2_END 60007/tcp
db2inst1@ha1:/home/db2inst2> db2 update dbm cfg using SVCENAMEDB2c_db2inst2
DB20000I The UPDATE DATABASE MANAGER CONFIGURATION command completed
successfully.
db2inst1@ha1:/home/db2inst1>db2 get dbm cfg | grep -i SVCENAME
TCP/IP Servicename (SVCENAME) = DB2c_db2inst2
SSL servicename (SSL_SVCENAME) =
db2inst1@ha1:/home/db2inst1>
TCP/IP Servicename (SVCENAME) = DB2c_db2inst2
SSL servicename (SSL_SVCENAME) =
db2inst1@ha1:/home/db2inst1>
数据节点也填写一样的内容
5、更改db2环境变量
只在编目节点进行操作:
db2inst2@ha1:~> db2set DB2RSHCMD=/usr/bin/ssh
db2inst2@ha1:~> db2set DB2COMM=TCPIP
db2inst2@ha1:~> db2set -all
[i] DB2RSHCMD=/usr/bin/ssh
[i] DB2COMM=TCPIP
[g] DB2SYSTEM=ha1
[g] DB2INSTDEF=db2inst1
db2inst2@ha1:~>
6、配置db2nodes.cfg文件
db2inst2@ha1:~/sqllib> more db2nodes.cfg
0 ha1 0
db2inst2@ha1:~/sqllib> vi db2nodes.cfg
db2inst2@ha1:~/sqllib> more db2nodes.cfg
0 ha1 0
1 ha1 1
2 ha2 0
3 ha2 1
db2inst2@ha1:~/sqllib>
7、启动DPF数据库
从编目节点启动:
ha1:~ # ps -ef | grep -i db2sysc
root 5777 5451 0 19:36 pts/1 00:00:00 grep -i db2sysc
db2inst2@ha1:~> db2start
06/21/201319:39:18 0 0 SQL1063N DB2START processing was successful.
06/21/201319:39:18 1 0 SQL1063N DB2START processing was successful.
06/21/201319:39:18 2 0 SQL1063N DB2START processing was successful.
06/21/201319:39:26 3 0 SQL1063N DB2START processing was successful.
SQL1063N DB2START processing was successful.
db2inst2@ha1:~>
06/21/201319:39:18 0 0 SQL1063N DB2START processing was successful.
06/21/201319:39:18 1 0 SQL1063N DB2START processing was successful.
06/21/201319:39:18 2 0 SQL1063N DB2START processing was successful.
06/21/201319:39:26 3 0 SQL1063N DB2START processing was successful.
SQL1063N DB2START processing was successful.
db2inst2@ha1:~>
db2inst2@ha1:~> ps -ef | grep -i db2sysc
db2inst1 6245 6231 1 19:36 ? 00:00:03 db2sysc0
db2inst2 7982 7976 1 19:38 ? 00:00:01 db2sysc0
db2inst2 8509 8503 1 19:38 ? 00:00:01 db2sysc 1
到数据节点查看:
db2inst2@ha2:~> ps -ef | grep -i db2sysc
db2inst1 4932 4930 1 19:36 ? 00:00:03 db2sysc0
db2inst2 6892 6873 1 19:38 ? 00:00:01 db2sysc2
db2inst2 7412 7410 0 19:39 ? 00:00:01 db2sysc3
db2inst2 7816 5502 0 19:41 pts/0 00:00:00 grep -i db2sysc
db2inst2@ha2:~>
环境搭建完毕。