本文详细记录了DB2 purescale 10.5在VMware Workstation 上的安装过程,如果大家看了本人的博文后,实践过程中有什么问题,欢迎加本人微信84077708,我将尽我所能为大家解惑。


    配置db2locssh步骤如下:

分别在node01和node02上执行以下命令:

node01:~ # /opt/server_t/db2/linuxamd64/install/setup_db2locssh db2sdin1

DBI1070I  Program setup_db2locssh completed successfully.


node02:~ # /opt/server_t/db2/linuxamd64/install/setup_db2locssh db2sdin1

DBI1070I  Program setup_db2locssh completed successfully.


然后分别进入node01和node02服务器的/var/db2/db2ssh目录

node01:~ # cd /var/db2/db2ssh/

node01:/var/db2/db2ssh # ls -al

total 420

drwxr-xr-x 6 root root   4096 Jun 17 12:45 .

drwxr-xr-x 3 root root   4096 Jun 17 09:55 ..

drwxr-xr-x 3 root root   4096 Feb  7  2014 .metadata

-rw-r--r-- 1 root root      0 Jun 17 12:45 .remote_shell_cmd

-rwx------ 1 root root 157685 Jun 17 09:54 db2locssh

-rws--x--x 1 root root 111304 Jun 17 09:54 db2remssh

-rwx------ 1 root root 104856 Jun 17 09:54 db2scp

-rw------- 1 root root   1196 Jun 17 12:45 db2ssh.cfg

drwxr-xr-x 3 bin  bin    4096 Feb  7  2014 gskit

drwxr-xr-x 3 bin  bin    4096 Feb  7  2014 lib32

drwxr-xr-x 3 bin  bin    4096 Feb  7  2014 lib64

-rw------- 1 root root   1675 Jun 17 12:45 [email protected]

-rw-r--r-- 1 root root    426 Jun 17 12:45 [email protected]


然后将node01上的/var/db2/db2ssh/目录下的[email protected]文件复制到node02上的/var/db2/db2ssh/目录下。

node01:/var/db2/db2ssh # scp root\@node01.pub  root@node02:/var/db2/db2ssh/

[email protected]                               100%  426     0.4KB/s   00:00



node02:~ # cd /var/db2/db2ssh

node02:/var/db2/db2ssh # ls -al

total 424

drwxr-xr-x 6 root root   4096 Jun 17 12:50 .

drwxr-xr-x 3 root root   4096 Jun 17 12:14 ..

drwxr-xr-x 3 root root   4096 Feb  7  2014 .metadata

-rw-r--r-- 1 root root      0 Jun 17 12:46 .remote_shell_cmd

-rwx------ 1 root root 157685 Jun 17 12:13 db2locssh

-rws--x--x 1 root root 111304 Jun 17 12:13 db2remssh

-rwx------ 1 root root 104856 Jun 17 12:13 db2scp

-rw------- 1 root root   1196 Jun 17 12:46 db2ssh.cfg

drwxr-xr-x 3 bin  bin    4096 Feb  7  2014 gskit

drwxr-xr-x 3 bin  bin    4096 Feb  7  2014 lib32

drwxr-xr-x 3 bin  bin    4096 Feb  7  2014 lib64

-rw-r--r-- 1 root root    426 Jun 17 12:50 [email protected]

-rw------- 1 root root   1679 Jun 17 12:46 [email protected]

-rw-r--r-- 1 root root    426 Jun 17 12:46 [email protected]

然后将node02上的/var/db2/db2ssh/目录下的[email protected]文件复制到node01上的/var/db2/db2ssh/目录下。

node02:/var/db2/db2ssh # scp root\@node02.pub root@node01:/var/db2/db2ssh/

[email protected]                               100%  426     0.4KB/s   00:00



接下来验证db2locssh远程登陆是否能功:

node01:/var/db2/db2ssh # ./db2locssh node01 hostname

node01

node01:/var/db2/db2ssh # ./db2locssh node02 hostname

node02

node01:/var/db2/db2ssh #



node02:/var/db2/db2ssh # ./db2locssh node01 hostname

node01

node02:/var/db2/db2ssh # ./db2locssh node02 hostname

node02

node02:/var/db2/db2ssh #



到此,需要的配置就全部配置完成了。


下面可以开始创建实例了。


下面的命令创建DB2 purescale实例,在node01上创建一个CF节点 , 在node02上创建一个member成员节点。使用/dev/sdc作为共享存储 , 使用192.168.142.1网关地址作为心跳,tbdev是心跳设备,可以像ORACLE RAC一样使用一个共享磁盘作为心跳设备,也可以使用两个节点都能同时PING通的一个IP地址代替。

node01:/opt/ibm/db2/V10.5/instance # ./db2icrt -cf node01 -cfnet node01.purescale.ibm.local -m node02 -mnet node02.purescale.ibm.local -instance_shared_dev /dev/sdc  -instance_shared_mount /db2sd  -tbdev 192.168.142.1 -u db2sdfe1  db2sdin1

DBI1446I  The db2icrt command is running.



DB2 installation is being initialized.


 Total number of tasks to be performed: 11

Total estimated time for all tasks to be performed: 1104 second(s)


Task #1 start

Description: Installing DB2 files on remote hosts

Estimated time 600 second(s)

Task #1 end


Task #2 start

Description: Installing or updating DB2 HA scripts for IBM Tivoli System Automation for Multiplatforms (Tivoli SA MP)

Estimated time 40 second(s)

Task #2 end


Task #3 start

Description: Installing or updating DB2 Cluster Scripts for IBM General Parallel File System (GPFS)

Estimated time 40 second(s)

Task #3 end


Task #4 start

Description: Registering licenses on remote hosts

Estimated time 40 second(s)

Task #4 end


Task #5 start

Description: Compiling GPL

Estimated time 30 second(s)

Task #5 end


Task #6 start

Description: Setting default global profile registry variables

Estimated time 1 second(s)

Task #6 end


Task #7 start

Description: Register NTP

Estimated time 40 second(s)

Task #7 end


Task #8 start

Description: Initializing instance list

Estimated time 5 second(s)

Task #8 end


Task #9 start

Description: Initiating the remote host list

Estimated time 5 second(s)

Task #9 end


Task #10 start

Description: Configuring DB2 instances

Estimated time 300 second(s)

Task #10 end


Task #11 start

Description: Updating global profile registry

Estimated time 3 second(s)

Task #11 end


The execution completed successfully.


For more information see the DB2 installation log at "/tmp/db2icrt.log.59798".

Required: Review the following log file also for warnings or errors:

"/tmp/db2icrt_local.log.*"

DBI1070I  Program db2icrt completed successfully.


查看实例创建日志

node01:~ # tail -200f /tmp/db2icrt.log.59798


DB2 Setup log file started at:  Sat Jun 17 18:08:20 2017 CST

============================================================


Operating system information: Linux 3.0.76-0.11-default.#1 SMP Fri Jun 14 08:21:43 UTC 2013 (ccab990) x86_64

WARNING: The DB2prereqcheck tool executed successfully, but few warnings were found.For detailed information please check /tmp/db2prereqcheckOut.log file


WARNING: The DB2prereqcheck tool executed successfully, but few warnings were found.For detailed information please check /tmp/db2prereqcheckOut.log file


WARNING: The DB2prereqcheck tool executed successfully, but few warnings were found.For detailed information please check /tmp/db2prereqcheckOut.log file



The cluster interconnect netname specified for each host must correspond to a

DB2 supported network adapter. Use of any other network adapter for the

cluster interconnect is not supported. Verify the cluster interconnect

netnames.


WARNING: Recommendations for the configuration of the DB2 pureScale instance: db2sdin1



The number of defined cluster caching facilities (CFs) and DB2 members is less

than the recommendation. Two CF hosts and at least two DB2 members is

recommended.






DB2 cluster services:

    Mount point:                                /db2sd

    DB2 cluster services tiebreaker disk device path:   192.168.142.1

    DB2 cluster file system device path:        /dev/sdc


New instances:

    Instance name:                              db2sdin1

        FCM port range:                         60000-60005

        CF port:                                56001

        CF Management port:                     56000

        Instance user information:

            User name:                          db2sdin1

            UID:                                1000

            Group name:                         db2iadm

            GID:                                1000

            Home directory:                     /home/db2sdin1

        Fenced user information:

            User name:                          db2sdfe1

            UID:                                1001

            Group name:                         db2fadm

            GID:                                1001

            Home directory:                     /home/db2sdfe1


Cluster caching facilities:

    Preferred primary cluster caching facility:         node01

DB2 members:

    node02



New Host List:

    Host                                        Cluster Interconnect Netname

    node02                                      node02.purescale.ibm.local

    node01                                      node01.purescale.ibm.local




Binary installation succeeded on the following hosts: "node02".


Installing DB2 file sets :.......Success

Installing or updating DB2 HA scripts for IBM Tivoli System Automation for Multiplatforms (Tivoli SA MP) :.......Success

Installing or updating DB2 Cluster Scripts for IBM General Parallel File System (GPFS) :.......Success

Registering licenses on remote hosts :.......Success

Compiling GPL :.......Success

Setting default global profile registry variables :.......Success

Register NTP :.......Success

Initializing instance list :.......Success

Initiating the remote host list :.......Success

Creation of the RSCT peer domain, "db2domain_20170617181528", succeeded on the

host "node01".


Creation of the IBM General Parallel File System (GPFS) cluster,

"db2cluster_20170617181559.purescale.ibm.local", succeeded on host "node01".


Creation of the IBM General Parallel File System (GPFS) file system succeeded

at mount point "/db2sd".


Extension of the RSCT peer domain, "db2domain_20170617181528", succeeded on the

following hosts: "node02".


Extension of the IBM General Parallel File System (GPFS) cluster succeeded on

the following hosts "node02".


Configuration of instance "db2sdin1" succeeded on hosts "node01, node02"


The instance "db2sdin1" has been created successfully.


The value "DB2AUTOSTART=NO" was set in the Profile Registry for the "db2sdin1"

instance.


The shared file system cluster option 'usePersistentReserve' has not been set to the optimal value of 'yes'.  See the DB2 Information Center for more details.

Configuring DB2 instances :.......Success

Updating global profile registry :.......Success


Post Install Recommendations

-----------------------------


Required steps:

Start using the DB2 product using a valid user ID such as the DB2 instance owner's ID "db2sdin1".


Optional steps:

The network monitor configuration file for the DB2 pureScale instance has been updated on each host to include the IP address of the hosts gateway. The configuration file /var/ct/cfg/netmon.cf was updated on the following hosts: "node01  node02". This file must be modified in the event of future changes to the hosts gateway IP address.


The default database path in the database manager configuration (DFTDBPATH) is set to "/db2sd".   This is also the path to the instance shared directory in a shared file system.  DFTDBPATH can be updated to a new shared file system created using the db2cluster command (for example, db2cluster -cfs -create -filesystem fs-name).  For details on creating a shared file system, see the db2cluster command in the DB2 Information Center.


To validate your installation files, instance, and database functionality, run the Validation Tool, /opt/ibm/db2/V10.5/bin/db2val. For more information, see "db2val" in the DB2 Information Center.


Open First Steps by running "db2fs" using a valid user ID such as the DB2 instance owner's ID. You will need to have DISPLAY set and a supported web browser in the path of this user ID.


Verify that you have access to the DB2 Information Center based on the choices you made during this installation. If you performed a typical or a compact installation, verify that you can access the IBM Web site using the internet. If you performed a custom installation, verify that you can access the DB2 Information Center location specified during the installation.


Ensure that you have the correct license entitlements for DB2 products and features installed on this machine. Each DB2 product or feature comes with a license certificate file (also referred to as a license key) that is distributed on an Activation CD, which also includes instructions for applying the license file. If you purchased a base DB2 product, as well as, separately priced features, you might need to install more than one license certificate. The Activation CD for your product or feature can be downloaded from Passport Advantage if it is not part of the physical media pack you received from IBM. For more information about licensing, search the Information Center (http://publib.boulder.ibm.com/infocenter/db2luw/v10r5/index.jsp) using terms such as "license compliance", "licensing" or "db2licm".


To use your DB2 database product, you must have a valid license. For information about obtaining and applying DB2 license files, see http://pic.dhe.ibm.com/infocenter/db2luw/v10r5/topic/com.ibm.db2.luw.qb.server.doc/doc/c0061199.html.




Host Summary

------------------


Host Name: node02

Install Status: successful

Detailed Log Location: /tmp/db2log.59805/node02



DB2 Setup log file finished at:  Sat Jun 17 18:31:24 2017 CST

============================================================


从日志中也可以看到,没有任何错误,到此,DB2 purescale集群实例就创建成功了,现在包含一个CF , ,一个member.


由于环境变量中将DB2AUTOSTART设置为了NO (DB2AUTOSTART=NO),所以实例创建完成后,并不会自动启动,而且,由于我们是在虚拟机中搭建的测试环境,硬件资源很多都并足以让DB2 purescale很好的运行,所以为了让DB2 purescale运行起来,我们在启动实例之前,还需要设置两个环境变量:


db2set DB2_SD_SOCKETS_RESTRICTIONS=false 

db2set DB2_CA_TRANSPORT_METHOD=SOCKETS


我们分别在node01和node02上设置这两个环境变量

node01:/opt/ibm/db2/V10.5/instance # su - db2sdin1

db2sdin1@node01:~> db2set DB2_SD_SOCKETS_RESTRICTIONS=false

db2sdin1@node01:~> db2set DB2_CA_TRANSPORT_METHOD=SOCKETS


node02:/var/db2/db2ssh # su - db2sdin1

db2sdin1@node02:~> db2set DB2_SD_SOCKETS_RESTRICTIONS=false

db2sdin1@node02:~> db2set DB2_CA_TRANSPORT_METHOD=SOCKETS



现在实例可以正常启动了,在启动实例之前,如果我们有DB2的license,最好先导入license,我手上有DB2 10.5的通用license。


先在node01上导入license

db2sdin1@node01:~> cd /opt/ibm/db2/V10.5/adm

db2sdin1@node01:/opt/ibm/db2/V10.5/adm> db2lic

db2licd  db2licm

db2sdin1@node01:/opt/ibm/db2/V10.5/adm> db2licm -a /mnt/hgfs/C/db2aese_u.lic


LIC1402I  License added successfully.



LIC1426I  This product is now licensed for use as outlined in your License Agreement.  USE OF THE PRODUCT CONSTITUTES ACCEPTANCE OF THE TERMS OF THE IBM LICENSE AGREEMENT, LOCATED IN THE FOLLOWING DIRECTORY: "/opt/ibm/db2/V10.5/license/en_US.iso88591"

db2sdin1@node01:/opt/ibm/db2/V10.5/adm> db2lic

db2licd  db2licm

db2sdin1@node01:/opt/ibm/db2/V10.5/adm> db2licm -l

Product name:                     "DB2 Advanced Enterprise Server Edition"

License type:                     "Authorized User Single Install"

Expiry date:                      "Permanent"

Product identifier:               "db2aese"

Version information:              "10.5"

Enforcement policy:               "Soft Stop"

Number of licensed authorized users: "25"



然后在node02上导入license

db2sdin1@node02:/opt/ibm/db2/V10.5/adm> db2licm -a /mnt/hgfs/C/db2aese_u.lic


LIC1402I  License added successfully.



LIC1426I  This product is now licensed for use as outlined in your License Agreement.  USE OF THE PRODUCT CONSTITUTES ACCEPTANCE OF THE TERMS OF THE IBM LICENSE AGREEMENT, LOCATED IN THE FOLLOWING DIRECTORY: "/opt/ibm/db2/V10.5/license/en_US.iso88591"

db2sdin1@node02:/opt/ibm/db2/V10.5/adm> db2licm -l

Product name:                     "DB2 Advanced Enterprise Server Edition"

License type:                     "Authorized User Single Install"

Expiry date:                      "Permanent"

Product identifier:               "db2aese"

Version information:              "10.5"

Enforcement policy:               "Soft Stop"

Number of licensed authorized users: "25"


下一步,我们查看实例的状态:

db2sdin1@node01:/opt/ibm/db2/V10.5/adm> db2instance -list

ID        TYPE             STATE                HOME_HOST               CURRENT_HOST            ALERT   PARTITION_NUMBER        LOGICAL_PORT    NETNAME

--        ----             -----                ---------               ------------            -----   ----------------        ------------    -------

0       MEMBER           STOPPED                   node02                     node02               NO                  0                   0    node02.purescale.ibm.local

128     CF               STOPPED                   node01                     node01               NO                  -                   0    node01.purescale.ibm.local


HOSTNAME                   STATE                INSTANCE_STOPPED        ALERT

--------                   -----                ----------------        -----

  node01                  ACTIVE                              NO           NO

  node02                  ACTIVE                              NO           NO

db2sdin1@node01:/opt/ibm/db2/V10.5/adm>


可以看到,现在DB2 purescale集群中,有一个CF在node01上,有一个MEMBER在node02上,且目前状态都为STOPPED。


现在启动实例:

db2sdin1@node01:~> db2start CF 128

SQL1063N  DB2START processing was successful.

db2sdin1@node01:~> db2start member 0

06/17/2017 19:23:27     0   0   SQL1063N  DB2START processing was successful.

SQL1063N  DB2START processing was successful.


再次查看实例状态

db2sdin1@node01:/opt/ibm/db2/V10.5/adm> db2instance -list

ID        TYPE             STATE                HOME_HOST               CURRENT_HOST            ALERT   PARTITION_NUMBER        LOGICAL_PORT    NETNAME

--        ----             -----                ---------               ------------            -----   ----------------        ------------    -------

0       MEMBER           STARTED                   node02                     node02               NO                  0                   0    node02.purescale.ibm.local

128     CF               PRIMARY                   node01                     node01               NO                  -                   0    node01.purescale.ibm.local


HOSTNAME                   STATE                INSTANCE_STOPPED        ALERT

--------                   -----                ----------------        -----

  node01                  ACTIVE                              NO           NO

  node02                  ACTIVE                              NO           NO

db2sdin1@node01:/opt/ibm/db2/V10.5/adm>


CF和MEMBER都启动起来了。


最后要做的事情就是在node01上添加一个MEMBER成员节点,在node02上添加一个CF节点。

在添加MEMBER和CF之前,必须先停止实例。

db2sdin1@node01:~> db2stop member 0

06/17/2017 19:47:26     0   0   SQL1064N  DB2STOP processing was successful.

SQL1064N  DB2STOP processing was successful.

db2sdin1@node01:~> db2stop CF 128

SQL1064N  DB2STOP processing was successful.


然后执行以下命令,先在node01上添加一个member成员节点。

node01:/opt/ibm/db2/V10.5/instance # ./db2iupdt -add -m node01 -mnet node01.purescale.ibm.local  db2sdin1

DBI1446I  The db2iupdt command is running.



DB2 installation is being initialized.


 Total number of tasks to be performed: 8

Total estimated time for all tasks to be performed: 434 second(s)


Task #1 start

Description: Installing or updating DB2 HA scripts for IBM Tivoli System Automation for Multiplatforms (Tivoli SA MP)

Estimated time 40 second(s)

Task #1 end


Task #2 start

Description: Installing or updating DB2 Cluster Scripts for IBM General Parallel File System (GPFS)

Estimated time 40 second(s)

Task #2 end


Task #3 start

Description: Setting default global profile registry variables

Estimated time 1 second(s)

Task #3 end


Task #4 start

Description: Register NTP

Estimated time 40 second(s)

Task #4 end


Task #5 start

Description: Initializing instance list

Estimated time 5 second(s)

Task #5 end


Task #6 start

Description: Initiating the remote host list

Estimated time 5 second(s)

Task #6 end


Task #7 start

Description: Configuring DB2 instances

Estimated time 300 second(s)

Task #7 end


Task #8 start

Description: Updating global profile registry

Estimated time 3 second(s)

Task #8 end


The execution completed successfully.


For more information see the DB2 installation log at "/tmp/db2iupdt.log.41744".

DBI1070I  Program db2iupdt completed successfully.



最后在node02节点上添加一个CF节点:

node01:/opt/ibm/db2/V10.5/instance # ./db2iupdt -add -cf node02 -cfnet node02.purescale.ibm.local  db2sdin1

DBI1446I  The db2iupdt command is running.



DB2 installation is being initialized.


 Total number of tasks to be performed: 10

Total estimated time for all tasks to be performed: 1074 second(s)


Task #1 start

Description: Installing DB2 files on remote hosts

Estimated time 600 second(s)

Task #1 end


Task #2 start

Description: Installing or updating DB2 HA scripts for IBM Tivoli System Automation for Multiplatforms (Tivoli SA MP)

Estimated time 40 second(s)

Task #2 end


Task #3 start

Description: Installing or updating DB2 Cluster Scripts for IBM General Parallel File System (GPFS)

Estimated time 40 second(s)

Task #3 end


Task #4 start

Description: Registering licenses on remote hosts

Estimated time 40 second(s)

Task #4 end


Task #5 start

Description: Setting default global profile registry variables

Estimated time 1 second(s)

Task #5 end


Task #6 start

Description: Register NTP

Estimated time 40 second(s)

Task #6 end


Task #7 start

Description: Initializing instance list

Estimated time 5 second(s)

Task #7 end


Task #8 start

Description: Initiating the remote host list

Estimated time 5 second(s)

Task #8 end


Task #9 start

Description: Configuring DB2 instances

Estimated time 300 second(s)

Task #9 end


Task #10 start

Description: Updating global profile registry

Estimated time 3 second(s)

Task #10 end


The execution completed successfully.


For more information see the DB2 installation log at "/tmp/db2iupdt.log.4048".

DBI1070I  Program db2iupdt completed successfully.



查看实例状态:

db2sdin1@node01:~> db2instance -list

ID        TYPE             STATE                HOME_HOST               CURRENT_HOST            ALERT   PARTITION_NUMBER        LOGICAL_PORT    NETNAME

--        ----             -----                ---------               ------------            -----   ----------------        ------------    -------

0       MEMBER           STOPPED                   node02                     node02               NO                  0                   0    node02.purescale.ibm.local

1       MEMBER           STOPPED                   node01                     node01               NO                  0                   0    node01.purescale.ibm.local

128     CF               STOPPED                   node01                     node01               NO                  -                   0    node01.purescale.ibm.local

129     CF               STOPPED                   node02                     node02               NO                  -                   0    node02.purescale.ibm.local


HOSTNAME                   STATE                INSTANCE_STOPPED        ALERT

--------                   -----                ----------------        -----

  node01                  ACTIVE                              NO           NO

  node02                  ACTIVE                              NO           NO

db2sdin1@node01:~> db2start CF 128

SQL1063N  DB2START processing was successful.

db2sdin1@node01:~> db2start CF 129

SQL1063N  DB2START processing was successful.

db2sdin1@node01:~> db2start member 0

06/17/2017 20:23:27     0   0   SQL1063N  DB2START processing was successful.

SQL1063N  DB2START processing was successful.

db2sdin1@node01:~> db2start member 1

06/17/2017 20:24:18     1   0   SQL1063N  DB2START processing was successful.

SQL1063N  DB2START processing was successful.


db2sdin1@node01:~> db2instance -list

ID        TYPE             STATE                HOME_HOST               CURRENT_HOST            ALERT   PARTITION_NUMBER        LOGICAL_PORT    NETNAME

--        ----             -----                ---------               ------------            -----   ----------------        ------------    -------

0       MEMBER           STARTED                   node02                     node02               NO                  0                   0    node02.purescale.ibm.local

1       MEMBER           STARTED                   node01                     node01               NO                  0                   0    node01.purescale.ibm.local

128     CF               PRIMARY                   node01                     node01               NO                  -                   0    node01.purescale.ibm.local

129     CF               CATCHUP                   node02                     node02               NO                  -                   0    node02.purescale.ibm.local


HOSTNAME                   STATE                INSTANCE_STOPPED        ALERT

--------                   -----                ----------------        -----

  node01                  ACTIVE                              NO           NO

  node02                  ACTIVE                              NO           NO

db2sdin1@node01:~>


可以看见,现在node01上有一个CF 和一个MEMBER , node02上有一个CF  和一个MEMBER 。 并且现在全部处于启动状态。


实例创建成功了,其他的操作(比如创建数据库,创建表等)都与单实例一样的,请阅读相关DB2书籍,京东有售。



到此,本次安装任务全部结束。


如果大家找不到DB2安装文件或者安装过程中有任何问题,都可以加微信联系我。