
在Linux *** 作系统 中,可在虚拟机上搭建DB2 pureScale,那么搭建的步骤是怎么样的呢?DB2 pureScale又有什么用呢?下面随我一起来了解下Linux系统如何在虚拟机上部署DB2 pureScale。
在虚拟机Linux上部署DB2pureScale实践过程
1、环境准备
硬件环境:3 台 x86-64虚拟机,内存要求 1.5G 或以上(主要针对虚拟机,内存过低会造成数据库实例启动失败)
*** 作系统:Suse Linux Enterprise Server 11.3
DB2 版本:DB2 v10.5
机器名:node01 node02 node03
IP:192.168.18.201 192.168.18.202 192.168.18.203
网关:192.168.18.2
利用iscsi服务来做共享存储功能,其中node01 作为 iscsi 的 Server,node01、node02和 node03 作为 iscsi Client,这样三台虚拟机上都能看到相同的磁盘了(按照developer workers上的 文章 :非 InfiniBand 环境下搭建 DB2 pureScale,我用DB2 v10.5时启动实例失败,可能10.5做了限制,CF与member在同一台机器启动失败,帮多了一台虚拟机)。
2、 *** 作系统安装:
Node01预留出一块分区,不进行格式化(文件类型为0x83 Linux)做为 pureScale 集群的 Sharing Disk 使用,Node02与Node03跟node01 其它 相同就可,
安装必要的包:
libstdc++(32 位和 64 位库)
glibc(32 位和 64 位库)
cpp
gcc
gcc-c++
kernel-source
binutils
ksh-93u-0.8.1
openssh
ntp
完成SUSE 11 SP3的安装。
验证:检查/lib/modules/3.0.76-0.11-default/build/include/linux有无autoconf.h,如果没有autoconf.h,安装DB2时会报Compiling GPL :.......Failure错误。
解决 方法 :cp –v /usr/src/linux-3.0.76-0.11-obj/x86_64/default/include/generated /lib/modules/3.0.76-0.11-default/build/include/linux
3、添加用户和用户组
三台机器全部执行如下命令(如果不做特殊说明,以#表示root身份登录,以$表示db2inst1身份,以下相同)。
#groupadd -g 1001 db2fadm1
#groupadd -g 1002 db2iadm1
#useradd -g db2fadm1 -u 1001 -m -d /home/db2fenc1 -p db2fenc1 db2fenc1
#useradd -g db2iadm1 -u 1002 -m -d /home/db2inst1 -p db2inst1 db2inst1
#mkdir /root/.ssh
# su - db2inst1 -c "mkdir -p /home/db2inst1/.ssh"
4、配置ssh 信任连接
ssh信任通俗的说就是直接ssh不用输入密码
在/etc/hosts添加另外两台机器的IP地址及机器名(确保3台机器名与ip地址全部出现在hosts文件中)
例如我的机器hosts如下:
127.0.0.1 localhost
192.168.18.201 node01.site node01
192.168.18.202 node02.site node02
192.168.18.203 node03.site node03
node01执行如下命令:
#ssh-keygen -t rsa
#cp -v /root/.ssh/id_rsa.pub /root/.ssh/id01
#scp /root/.ssh/id01 node02:/root/.ssh
#scp /root/.ssh/id01 node03:/root/.ssh
#su - db2inst1
$ssh-keygen -t rsa
$cp -v /home/db2inst1/.ssh/id_rsa.pub /home/db2inst1/.ssh/id01
$scp /home/db2inst1/.ssh/id01 node02:/home/db2inst1/.ssh
$scp /home/db2inst1/.ssh/id01 node03:/home/db2inst1/.ssh
node02执行如下命令:
#ssh-keygen -t rsa
#cp -v /root/.ssh/id_rsa.pub /root/.ssh/id02
#scp /root/.ssh/id02 node01:/root/.ssh/
#scp /root/.ssh/id02 node03:/root/.ssh/
#su - db2inst1
$ssh-keygen -t rsa
$cp -v /home/db2inst1/.ssh/id_rsa.pub /home/db2inst1/.ssh/id02
$scp /home/db2inst1/.ssh/id02 node01:/home/db2inst1/.ssh/
$scp /home/db2inst1/.ssh/id02 node03:/home/db2inst1/.ssh/
node03执行如下命令:
#ssh-keygen -t rsa
#cp -v /root/.ssh/id_rsa.pub /root/.ssh/id03
#scp /root/.ssh/id03 node01:/root/.ssh
#scp /root/.ssh/id03 node02:/root/.ssh
#su - db2inst1
$ssh-keygen -t rsa
$cp -v /home/db2inst1/.ssh/id_rsa.pub /home/db2inst1/.ssh/id03
$scp /home/db2inst1/.ssh/id03 node01:/home/db2inst1/.ssh/
$scp /home/db2inst1/.ssh/id03 node02:/home/db2inst1/.ssh/
分别在node01、node02、node03执行如下命令
#cd /root/.ssh
#cat id01 id02 id03 >authorized_keys
#chmod 600 authorized_keys
#su - db2inst1
$cd /home/db2inst1/.ssh
$ cat id01 id02 id03 >authorized_keys
测试是否配置成功
3台机器分别以root与db2inst1执行:
#ssh node01 ls
#ssh node02 ls
#ssh node03 ls
#su - db2inst1
$ssh node01 ls
$ssh node02 ls
$ssh node03 ls
确保不用输入密码,则配置成功。
5、ISCSI 共享存储配置
Iscsi server端配置(node01上执行):
修改/etc/ietd.conf,添加如下内容:
Target iqn.2014-03.node01.site:scsidisk01
Lun 0 Path=/dev/sda4,Type=fileio
注意:我的未分区硬盘为/dev/sda4,你的可能不一样的@_@~~~~
添加自启动
#chkconfig -a iscsitarget
检查是否成功
#chkconfig -l iscsitarget
结果:iscsitarget 0:off 1:off 2:off 3:on 4:off 5:on 6:off
重启iscsitarget服务
# /etc/init.d/iscsitarget restart
iscsi client端配置(node01、node02、node03执行,):
iscsitarget文件内容如下:
#! /bin/sh
### BEGIN INIT INFO
# Provides: iscsiclsetup
#node02与node03上如果未装iscsitarget需将下下行的$iscsitarget
# Required-Start: $network $syslog $iscsitarget $remote_fs smartd
# Required-Stop:
# Default-Start: 3 5
# Default-Stop: 0 1 2 6
# Description: ISCSI client setup
### END INIT INFO
case "$1" in start)
iscsiadm --mode discoverydb --type sendtargets --portal 192.168.18.201 --discover
iscsiadm --m node --targetname iqn.2014-03.node01.site:scsidisk01 --portal 192.168.18.201:3260 --login
stop)
iscsiadm -m node -T iqn.2014-03.node01.site:scsidisk01 -p 192.168.18.201 --logout
restart) ## Stop the service and regardless of whether it was ## running or not, start it again.
$0 stop
$0 start
*)
Esac
保存后执行:#/etc/init.d/iscsiclient restart
验证iscsiclient是否启动成功:
#fdisk -l
检查有无/dev/sdb出现
6、配置Linux环境变量
/etc/profie.local添加内容
alias sl='tail -f /var/log/messages'
alias fc='fcslogrpt /var/log/messages'
export PATH=/root/bin:/usr/sbin/rsct/bin:/opt/ibm/db2/v10.5/bin:$PATH
export PATH=/usr/lpp/mmfs/bin:$PATH
export DB2USENONIB=TRUE
export DB2_CFS_GPFS_NO_REFRESH_DATA=true
然后执行# . /etc/profile.local,完成后你就可以安装purescale了,我猜测应该是设置了变量DB2USENONIB,使purescale不再要求你强制InfiniBand或万兆网卡,使我等穷人可以有机会玩这种高档、洋气、上档次的数据库。。。
7、DB2 V10.5 的安装:
node01:~/server_t # ./db2_install
DBI1324W Support of the db2_install command is deprecated. For
more information, see the DB2 Information Center.
Default directory for installation of products - /opt/ibm/db2/V10.5
***********************************************************
Install into default directory (/opt/ibm/db2/V10.5) ? [yes/no]
yes
Specify one of the following keywords to install DB2 products.
SERVER
CONSV
EXP
CLIENT
RTCL
Enter "help" to redisplay product names.
Enter "quit" to exit.
***********************************************************
server
***********************************************************
Do you want to install the DB2 pureScale Feature? [yes/no]
Yes
曾经出现的错误:
ERROR: An error occurred while compiling IBM General Parallel File System
(GPFS) Portability Layer (GPL) on host "node01". Return code "2". GPL
compilation log file location "/tmp/compileGPL.log.000". The GPFS file system
cannot be mounted properly until the GPL module is successfully compiled on
this host. For details, see the specified GPL compilation log. After fixing
the problems shown in the log file, re-run the DB2 installer. For information
regarding the GPFS GPL module compile, see DB2 Information Center.
Compiling GPL :.......Failure
ERROR: A major error occurred while installing "DB2 Server Edition " on this
computer.
解决方案:
查看错误日志:compileGPL.log.000,为以下内容:
cd /usr/lpp/mmfs/src/config./configure --genenvonlyif [ $? -eq 0 ]then /usr/bin/cpp -P def.mk.proto >./def.mkexit $? || exit 1else exit $?fi
手工执行时会发现在./configure --genenvonly这一步报找不到
/usr/bin/diff: /lib/modules/3.0.76-0.11-default/build/include/linux/autoconf.h: No such file or directory
Kernel source tree does not have the correct autoconf.h file.
See /usr/lpp/mmfs/src/README for further information
手工拷呗一下autoconf.h文件即可
#cp –v /usr/src/linux-3.0.76-0.11-obj/x86_64/default/include/generated/autoconf.h /lib/modules/3.0.76-0.11-default/build/include/linux/
GPFS 文件系统配置与挂载
方法1:使用db2cluster_prepare
node01上执行:
#/opt/ibm/db2/v10.5/instance/db2cluster_prepare -instance_shared_dev /dev/sdb
DBI1446I The db2cluster_prepare command is running.
DB2 installation is being initialized.
Total number of tasks to be performed: 1
Total estimated time for all tasks to be performed: 60 second(s)
Task #1 start
Description: Creating IBM General Parallel File System (GPFS) Cluster and Filesystem
Estimated time 60 second(s)
Task #1 end
The execution completed successfully.
For more information see the DB2 installation log at
"/tmp/db2cluster_prepare.log".
DBI1070I Program db2cluster_prepare completed successfully.
此时df -l查看一下会发现多了一个挂载点
node01:/opt/ibm/db2/V10.5/instance # df -l
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/sda2 19599036 8122392 10481060 44% /
udev 958688 120 958568 1% /dev
tmpfs 958688 76 958612 1% /dev/shm
/dev/sda3 10327940 154460 9648836 2% /home
/dev/db2fs1 15728640 627712 15100928 4% /db2sd_20140401103940
曾经出现报错:
DBI20022E The DB2 installer detected that the variable record "GPFS_CLUSTER" is
defined in the global registry. However, the GPFS cluster does not exist on
host "node01".
Creating IBM General Parallel File System (GPFS) Cluster and Filesystem :.......Failure
查看/tmp/ibm.db2.cluster.GuOypP发现有如下内容报错:
014-04-01-10.26.12.358494+480 I5385E400 LEVEL: Warning
PID : 7469 TID : 139670848014112 PROC : db2cluster
INSTANCE: NODE : 000
HOSTNAME: node01
FUNCTION: DB2 UDB, oper system services, sqloMessage, probe:1
MESSAGE : Cannot obtain registry variables
DATA #1 : Hexdump, 4 bytes
0x00007FFF17631758 : B400 0F87
解决方案:由于此前我在此机器上试过N次db2cluster_prepare,包括V9.8、V10.1,V10.5安装,导致全局注册表变量没有删除干净,使用db2greg -dump
V,GPFS_CLUSTER,NAME,db2cluster_20140403105617.site,-,DB2_CREATED将其删除。
#cp -v /var/db2/global.reg /var/db2/global.reg_20140401
#db2delgreg -delvarrec service= GPFS_CLUSTER
总结 :db2cluster_prepare这个命令失败时
检查iscsi client是否准备好,fdisk -l查看一下是否有/dev/sdb
全局注册表变量是否未删除干净 ,db2greg -dump查看
检查一下是否tsa的domain存在,lsrpdomain,使用rmrpdomain将其删掉,如果其node为活动需先将其node停掉。具体参考tsa相关命令,
检查一下gpfs cluster domain是否未清理干净,如果未清理干净,需要使用将fs、nsd、node清理掉,具体命令参考gpfs信息中心。
方法2:手工挂载GPFS
遇到过使用db2cluster_prepare时无法成功,手工安装(不确定是否遇到了 传说 中的bug)。
创建cluster,不加-filesystem -disk选项:
node01:
#db2cluster -cfs -create -domain mydomain -host node01
#db2cluster -cfs -add -host node02
# db2cluster -cfs -add -host node03
说明:上面如果不出故障当然可以加上-filesystem –disk参数,当然也可以用mmaddnode –N XXX来添加节点
添加许可协议:
提供两种方法
#mmchlicense server --accept -N node01,node02,node03
#/opt/ibm/db2/v10.5/bin/db2cluster -cfs -add -license
创建nsd:任意node执行
编写newNSD文件内容如下
%nsd:
device=/dev/sdb
nsd=nsd1
usage=dataAndMetadata
#mmcrnsd -F /tmp/newNSD (-v no)
如果报mmcrnsd: Disk device sdb refers to an existing NSD,而使用mmlsnsd 又查找不到相应的nsd,添加-v no可以跳过此验证。
#mmlsnsd 查看创建的nsd名称,记下,在第3步时需要用到.
创建Cluster File System并挂载
启动所有node,任意node执行
#mmstartup -a
#mmgetstate -a
确保所有node全部启动成功为active
# mmcrfs -T /db2sd_20140401 db2sd_20140401 nsd1(此处的nsd1为第2步的nsd名称)
#mmmount all -a
--曾经出现的错误:mmstartup -a无响应
,查看日志/var/adm/ras/mmfs.log.previous
Tue Apr 1 22:02:11 CST 2014: runmmfs starting
Removing old /var/adm/ras/mmfs.log.* files:
Unloading modules from /lib/modules/3.0.76-0.11-default/extra
runmmfs: The /lib/modules/3.0.76-0.11-default/extra/mmfslinux.ko kernel extension does not exist.
runmmfs: Unable to verify kernel/module configuration.
Loading modules from /lib/modules/3.0.76-0.11-default/extra
runmmfs: The /lib/modules/3.0.76-0.11-default/extra/mmfslinux.ko kernel extension does not exist.
runmmfs: Unable to verify kernel/module configuration.
Tue Apr 1 22:02:11 CST 2014 runmmfs: error in loading or unloading the mmfs kernel extension
Tue Apr 1 22:02:11 CST 2014 runmmfs: stopping GPFS
解决方案:重新编译一下gpfs的源码,因为手工卸载gpfs。
/usr/lpp/mmfs/src/README有详细的编译方法:主要命令方法如下:
#cd /usr/lpp/mmfs/src
#make Autoconfig
#make InstallImages
make InstallImages会在/lib/modules/`uname -r`/extra目录生成3个文件,大功告成.
创建实例
创建实例前:
node02#/opt/ibm/db2/V10.5/instance/db2icrt -cf node01 -cfnet node01
-m node02 -mnet node02 -instance_shared_dir /db2sd_20140401
-tbdev 192.168.18.2 -u db2fenc1 db2inst1
-tbdev 官方解释为:Specifies a shared device path for a device that will act as a tiebreaker in the DB2 pureScale environment to ensure that the integrity of the data is maintained. 通俗的讲就是在member出现故障时,判断哪个member可以恢复服务,穷屌丝们就用网关IP来代替了,只要能 ping 通即可判断为可用。
此时执行:# db2instance -instance db2inst1 -list可以查看
node01:/opt/ibm/db2/V10.5/instance # mmlscluster
GPFS cluster information
========================
GPFS cluster name: db2cluster_20140401103900.site
GPFS cluster id: 6571095102926235332
GPFS UID domain: db2cluster_20140401103900.site
Remote shell command: /var/db2/db2ssh/db2locssh
Remote file copy command: /var/db2/db2ssh/db2scp
GPFS cluster configuration servers:
-----------------------------------
Primary server: node01.site
Secondary server: node02.site
Node Daemon node name IP address Admin node name Designation
----------------------------------------------------------------------
1 node01.site 192.168.18.201 node01.site quorum-manager
2 node02.site 192.168.18.202 node02.site quorum-manager
曾经出现报错:
错误1、报2632-044、2632-068,此类错误为创建tsa domain时的错误,原因在于虚拟机是拷贝的,不是重新安装的。
解决方法:#/usr/sbin/rsct/install/bin/recfgct
启动实例
node01:$/home/db2inst1/sqllib/adm/db2start
怎么样,报错了吧,应该是SQL1721N
SQL1721N Starting the DB2 database manager failed because of a problem with a configuration file that is needed by RDMA.受打击吧。
你装完了实例启动不了,没关系,这么高档的玩意怎么能让你这么快启动啊。
你得设置两个注册表变量才能用普通网络.
$db2set DB2_SD_SOCKETS_RESTRICTIONS=false
$db2set DB2_CA_TRANSPORT_METHOD=SOCKETS
使用如下命令可以查看CF与member的状态。
#db2instance -instance db2inst1 -list
node01:/home/db2inst1 # db2instance -instance db2inst1 -list
ID TYPE STATE HOME_HOST CURRENT_HOST ALERT PARTITION_NUMBER LOGICAL_PORT NETNAME
-- ---- ----- --------- ------------ ----- ---------------- ------------ -------
0 MEMBER STARTED node02 node02 NO 0 0 node02
128 CF PRIMARY node01 node01 NO - 0 node01
HOSTNAME STATE INSTANCE_STOPPED ALERT
-------- ----- ---------------- -----
node01 ACTIVE NO NO
node02 ACTIVE NO NO
此时你可以使用lssam查看tsa的两个节点的状态。
#lssam
添加成员
将node03添加为另一个member,如果实例没有启动会自动启动实例,所以预先将上一步的两台机器上的db2set执行完毕先。
node01:
#/opt/ibm/db2/v10.5/instance/db2iupdt -d -add -m node03 –mnet node03 db2inst1
#su - db2inst1 -c "db2start member 1"
开启你的purescale之旅
#db2sampl
执行完毕后两台member都可以看到数据库sample,可以同时对库进行 *** 作
GPFS安装
3.1
、建立集群
3.1.1
、创建集群文件系统
node1
mmcrcluster -n /tmp/gpfs_node -p node1 -s node2 -r /usr/bin/ssh -R /usr/bin/scp
命令显示:
mmcrcluster: Processing node 1
mmcrcluster: Processing node2
mmcrcluster: Command successfully completed
mmcrcluster: Propagating the cluster configuration data to all affected nodes.
This is an
asynchronous process.
3.1.2
、显示集群文件系统
mmlscluster
GPFS cluster information
========================
GPFS cluster name:
node1
GPFS cluster id:
13882348004399855353
GPFS UID domain:
node1
Remote shell command:
/usr/bin/ssh
Remote file copy command:
/usr/bin/scp
GPFS cluster configuration servers:
-----------------------------------
Primary server:
node1
Secondary server:
Node
Daemon node name
IP address
Admin node name
Designation
1
node1
10.3.164.24
node1
quorum-manager
2
node2
10.3.164.25
node2
quorum-manager
3.2
、创建
NSD
3.2.
、使用
mmcrnsd
创建
NSD
mmcrnsd -F /tmp/gpfs_disk -v yes
命令显示
:
mmcrnsd: Processing disk hdb
mmcrnsd: Propagating the cluster configuration data to all
affected nodes.
This is an asynchronous process.
3.2.2
、显示
NSD
mmlsnsd
–
m
Disk name
NSD volume ID
Device
Node name
Remarks
-------------------------------------------------------------------------------
gpfs1nsd
C0A801F54A9B3732
/dev/hdb
node1
primary node
gpfs1nsd
C0A801F54A9B3732
/dev/hdb
node2
3.3
、启动
GPFS
文件系统
mmstartup
–
a
Mon Aug 31 10:37:48 CST 2009: mmstartup: Starting GPFS ...
3.4
、查看
GPFS
文件系统状态
mmgetstate -a
Node number
Node name
GPFS state
------------------------------------------
1
node1
active
2
node2
active
3.5
、建立文件系统
#mkdir /gpfs
建立挂载点
#./bin/mmcrfs /gpfs gpfsdev -F /tmp/gpfs_disk -A yes -B 1024K -v yes
命令显示:
The following disks of gpfsdev will be formatted on node node1:
gpfs1nsd: size 2241856 KB
Formatting file system ...
Disks up to size 2 GB can be added to storage pool 'system'.
Creating Inode File
Creating Allocation Maps
Clearing Inode Allocation Map
Clearing Block Allocation Map
Completed creation of file system /dev/gpfsdev.
mmcrfs: Propagating the cluster configuration data to all
affected nodes.
This is an asynchronous process.
3.6
、检查文件系统
#cat /etc/fstab
………………………
/dev/gpfsdev
/gpfs
gpfs
rw,mtime,atime,dev=gpfsdev,autostart 0 0
Df-g
/dev/hdb
/gpfs
IBM GPFS可以替代HDFS作为Hadoop架构的底层文件系统/数据存储。Hadoop主要是能够做DAS直连存储,(位于各个节点上的)硬盘是分布式的,数据会拷贝 3-4份进行保护。Hadoop不需要高端的产品,不用共享存储,而是用分布式存储,它的成本相比共享存储(比如DS8000)要低。
GPFS的可扩展性上还是最好的,要把二者的优点结合起来,在基础上还是用直连的方式。GPFS与Hadoop的结合是一种分布式文件系统的形式,专门针对大数据分析的应用。作为集群NAS产品的IBM SONAS则具备更多的适应性,主要面向高性能计算、海量媒体(音/视频)数据的存储。
GPFS-SNC是IBM为Hadoop分析计算环境扩展研发的产品。A key difference between GPFS-SNC and HDFS is that GPFS-SNC is a kernel-level (内核级)file system, whereas HDFS runs on top of the operating system. This means that GPFS-SNC offers several advantages over HDFS, including:Better performance,Storage flexibility,Concurrent read/write,Improved security。
GFPS-SNC 提供了 HDFS所不具备的许多优点,其中一个优点解决了上述 NameNode 问题。在 GPFSSNC内实施的 Hadoop 运行时,不一定要与这个特别的 SPOF 问题进行竞争。GPFS-SNC 使您能够建立一个更加可靠的 Hadoop 集群(其中还包括其他好处,如易于管理和性能)。
除了所提出的有关单一 NameNode 的问题之外,一些客户还指出,HDFS不是 Portable Operating System Interface for UNIX (POSIX) 兼容的文件系统。这意味着,几乎所有您在与文件进行交互时可能使用的熟悉命令(复制文件、删除文件、写入文件、移动文件等)都以不同形式在 HDFS 中可用(有语法差异,在某些情况下有功能限制)。为了解决这个问题,您必须编写自己的 Java 应用程序执行某些功能,或培训您的 IT 员工,学习不同HDFS 命令来管理和 *** 作文件系统的文件。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)