红帽企业集群和存储管理之
[root@node1 ~]# uname -rv
2.6.18-164.el5 #1 SMP Tue Aug 18 15:51:54 EDT 2009
[root@node1 ~]# cat /etc/redhat-release
Red Hat Enterprise Linux Server release 5.4 (Tikanga)
[root@node1 ~]# hwclock -s
[root@node1 ~]# date
Wed Feb 8 13:55:50 CST 2012
[root@node1 ~]# hostname
[root@node1 ~]# cat /etc/sysconfig/network
[root@node1 ~]#setup
[root@node1 ~]# service network restart
Shutting down interface eth0: [ OK ]
Shutting down loopback interface: [ OK ]
Bringing up loopback interface: [ OK ]
Bringing up interface eth0: [ OK ]
[root@node1 ~]# ifconfig eth0
eth0 Link encap:Ethernet HWaddr 00:0C:29:AE:83:D1
inet addr:192.168.101.211 Bcast:192.168.101.255 Mask:255.255.255.0
[root@node1 ~]# echo "192.168.101.211 node1.junjie.com node1" >>/etc/hosts
[root@node1 ~]# echo "192.168.101.212 node2.junjie.com node2" >>/etc/hosts
[root@node1 ~]# fdisk -l
Disk /dev/sda: 21.4 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sda1 * 1 13 104391 83 Linux
/dev/sda2 14 1318 10482412+ 83 Linux
/dev/sda3 1319 1579 2096482+ 82 Linux swap / Solaris
[root@node1 ~]# fdisk /dev/sda
[root@node1 ~]# fdisk -l
Disk /dev/sda: 21.4 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sda1 * 1 13 104391 83 Linux
/dev/sda2 14 1318 10482412+ 83 Linux
/dev/sda3 1319 1579 2096482+ 82 Linux swap / Solaris
/dev/sda4 1580 1702 987997+ 83 Linux
[root@node1 ~]# partprobe /dev/sda
[root@node1 ~]# cat /proc/partitions
major minor #blocks name
8 0 20971520 sda
8 1 104391 sda1
8 2 10482412 sda2
8 3 2096482 sda3
8 4 987997 sda4
1.2 node2基本配置&新建磁盘
[root@node2 ~]# uname -rv
2.6.18-164.el5 #1 SMP Tue Aug 18 15:51:54 EDT 2009
[root@node2 ~]# cat /etc/redhat-release
Red Hat Enterprise Linux Server release 5.4 (Tikanga)
[root@node2 ~]# hwclock -s
[root@node2 ~]# date
Wed Feb 8 14:02:22 CST 2012
[root@node2 ~]# hostname
[root@node2 ~]# cat /etc/sysconfig/network
[root@node2 ~]# setup
[root@node2 ~]# service network restart
Shutting down interface eth0: [ OK ]
Shutting down loopback interface: [ OK ]
Bringing up loopback interface: [ OK ]
Bringing up interface eth0: [ OK ]
[root@node2 ~]# ifconfig eth0
eth0 Link encap:Ethernet HWaddr 00:0C:29:D1:D4:32
inet addr:192.168.101.212 Bcast:192.168.101.255 Mask:255.255.255.0
[root@node2 ~]# echo "192.168.101.211 node1.junjie.com node1" >>/etc/hosts
[root@node2 ~]# echo "192.168.101.212 node2.junjie.com node2" >>/etc/hosts
[root@node2 ~]# fdisk -l
Disk /dev/sda: 21.4 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sda1 * 1 13 104391 83 Linux
/dev/sda2 14 1318 10482412+ 83 Linux
/dev/sda3 1319 1579 2096482+ 82 Linux swap / Solaris
[root@node2 ~]# fdisk /dev/sda
[root@node2 ~]# fdisk -l
Disk /dev/sda: 21.4 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sda1 * 1 13 104391 83 Linux
/dev/sda2 14 1318 10482412+ 83 Linux
/dev/sda3 1319 1579 2096482+ 82 Linux swap / Solaris
/dev/sda4 1580 1702 987997+ 83 Linux
[root@node2 ~]# partprobe /dev/sda
[root@node2 ~]# cat /proc/partitions
major minor #blocks name
8 0 20971520 sda
8 1 104391 sda1
8 2 10482412 sda2
8 3 2096482 sda3
8 4 987997 sda4
1.3 在node1和node2上配置ssh密钥信息,
1.3.1 在node1上配置ssh密钥信息
[root@node1 ~]# ssh-keygen -t rsa
[root@node1 ~]# ssh-copy-id -i .ssh/id_rsa.pub [email protected]
1.3.2 在node2上配置ssh密钥信息
[root@node2 ~]# ssh-keygen -t rsa
[root@node2 ~]# ssh-copy-id -i .ssh/id_rsa.pub [email protected]
drbd83-8.3.8-1.el5.centos.i386.rpm
2.1、安装DRBD 套件
[root@node1 ~]# rpm -ivh drbd83-8.3.8-1.el5.centos.i386.rpm
[root@node1 ~]# rpm -ivh kmod-drbd83-8.3.8-1.el5.centos.i686.rpm
[root@node2 ~]# rpm -ivh drbd83-8.3.8-1.el5.centos.i386.rpm
[root@node2 ~]# rpm -ivh kmod-drbd83-8.3.8-1.el5.centos.i686.rpm
2.2、加载DRBD 模块
[root@node1 ~]# modprobe drbd
[root@node1 ~]# lsmod | grep drbd
[root@node1 ~]#
[root@node2 ~]# modprobe drbd
[root@node2 ~]# lsmod | grep drbd
[root@node2 ~]#
2.3.1 在node1上作以下配置
[root@node1 ~]# cd /etc/drbd.d/
[root@node1 drbd.d]# ll
total 4
-rwxr-xr-x 1 root root 1418 Jun 4 2010 global_common.conf
[root@node1 drbd.d]# cp global_common.conf global_common.conf.bak
2.3.2 复制配置到node2上:
[root@node1 drbd.d]# scp /etc/drbd.conf node2:/etc/
drbd.conf 100% 133 0.1KB/s 00:00
[root@node1 drbd.d]# scp /etc/drbd.d/* node2:/etc/drbd.d/
global_common.conf 100% 427 0.4KB/s 00:00
global_common.conf.bak 100% 1418 1.4KB/s 00:00
nfs.res 100% 330 0.3KB/s 00:00
[root@node1 drbd.d]#
[root@node1 drbd.d]# drbdadm adjust nfs
0: Failure: (119) No valid meta-data signature found.
==> Use 'drbdadm create-md res' to initialize meta-data area. <==
Command 'drbdsetup 0 disk /dev/sda4 /dev/sda4 internal --set-defaults --create-device --fencing=resource-only --on-io-error=detach' terminated with exit code 10
[root@node1 drbd.d]# drbdadm adjust nfs
drbdsetup 0 show:5: delay-probe-volume 0k => 0k out of range [4..1048576]k.
[root@node1 drbd.d]#
2.5.1 在node1上创建nfs 的资源
[root@node1 drbd.d]# drbdadm create-md nfs
Writing meta data...
initializing activity log
NOT initialized bitmap
New drbd meta data block successfully created.
[root@node1 drbd.d]# ll /dev/drbd0
brw-r----- 1 root disk 147, 0 Feb 8 14:27 /dev/drbd0
2.5.2 在node2上创建nfs 的资源
[root@node1 drbd.d]# ssh node2.junjie.com 'drbdadm create-md nfs'
NOT initialized bitmap
Writing meta data...
initializing activity log
New drbd meta data block successfully created.
[root@node1 drbd.d]# ssh node2.junjie.com 'ls -l /dev/drbd0'
brw-r----- 1 root disk 147, 0 Feb 8 14:19 /dev/drbd0
2.6 启动DRBD服务
[root@node1 drbd.d]# service drbd start
Starting DRBD resources: drbdsetup 0 show:5: delay-probe-volume 0k => 0k out of range [4..1048576]k.
[root@node1 drbd.d]# ssh node2.junjie.com 'service drbd start'
Starting DRBD resources: drbdsetup 0 show:5: delay-probe-volume 0k => 0k out of range [4..1048576]k.
[root@node1 drbd.d]#
2.7 启动DRBD服务,查看DRBD状态
[root@node1 drbd.d]# service drbd status
drbd driver loaded OK; device status:
version: 8.3.8 (api:88/proto:86-94)
GIT-hash: d78846e52224fd00562f7c225bcc25b2d422321d build by [email protected], 2010-06-04 08:04:16
m:res cs ro ds p mounted fstype
0:nfs Connected Secondary/Secondary Inconsistent/Inconsistent C
[root@node1 drbd.d]# ssh node2.junjie.com 'service drbd status'
drbd driver loaded OK; device status:
version: 8.3.8 (api:88/proto:86-94)
GIT-hash: d78846e52224fd00562f7c225bcc25b2d422321d build by [email protected], 2010-06-04 08:04:16
m:res cs ro ds p mounted fstype
0:nfs Connected Secondary/Secondary Inconsistent/Inconsistent C
[root@node1 drbd.d]#
[root@node1 drbd.d]# drbd-overview
0:nfs Connected Secondary/Secondary Inconsistent/Inconsistent C r----
[root@node1 drbd.d]# ssh node2.junjie.com 'drbd-overview'
0:nfs Connected Secondary/Secondary Inconsistent/Inconsistent C r----
[root@node1 drbd.d]#
[root@node1 drbd.d]# chkconfig drbd on
[root@node1 drbd.d]# chkconfig --list drbd
drbd 0:off 1:off 2:on 3:on 4:on 5:on 6:off
[root@node1 drbd.d]# ssh node2.junjie.com 'chkconfig drbd on'
[root@node1 drbd.d]# ssh node2.junjie.com 'chkconfig --list drbd'
drbd 0:off 1:off 2:on 3:on 4:on 5:on 6:off
2.8 在node1主节点上进行以下配置,并查看挂载信息。
[root@node1 drbd.d]# mkdir /mnt/nfs
[root@node1 drbd.d]# ssh node2.junjie.com 'mkdir /mnt/nfs'
[root@node1 drbd.d]# drbdsetup /dev/drbd0 primary -o
[root@node1 drbd.d]# mkfs.ext3 /dev/drbd0
[root@node1 drbd.d]# mount /dev/drbd0 /mnt/nfs/
两台服务器都修改nfs 配置文件,都修改nfs 启动脚本,如下:
[root@node1 ~]# yum localinstall -y heartbeat-2.1.4-9.el5.i386.rpm heartbeat-pils-2.1.4-10.el5.i386.rpm heartbeat-stonith-2.1.4-10.el5.i386.rpm libnet-1.1.4-3.el5.i386.rpm perl-MailTools-1.77-1.el5.noarch.rpm --nogpgcheck
[root@node1 ~]#
[root@node2 ~]# yum localinstall -y heartbeat-2.1.4-9.el5.i386.rpm heartbeat-pils-2.1.4-10.el5.i386.rpm heartbeat-stonith-2.1.4-10.el5.i386.rpm libnet-1.1.4-3.el5.i386.rpm perl-MailTools-1.77-1.el5.noarch.rpm --nogpgcheck
[root@node2 ~]#
[root@node1 ~]# cd /usr/share/doc/heartbeat-2.1.4/
[root@node1 heartbeat-2.1.4]# cp authkeys ha.cf haresources /etc/ha.d/
[root@node1 heartbeat-2.1.4]# cd /etc/ha.d/
[root@client ~]# mkdir /data
[root@client ~]# mount 192.168.101.210:/mnt/nfs/ /data/
[root@client ~]# cd /data/
[root@client data]# ll
total 20
-rw-r--r-- 1 root root 4 Feb 8 17:41 f1
drwx------ 2 root root 16384 Feb 8 14:57 lost+found
[root@client data]# touch f-client-1
[root@client data]# ll
total 20
-rw-r--r-- 1 root root 0 Feb 8 19:50 f-client-1
-rw-r--r-- 1 root root 4 Feb 8 17:41 f1
drwx------ 2 root root 16384 Feb 8 14:57 lost+found
[root@client data]#cd
[root@client ~]#
3、将主节点node1 的heartbeat服务停止,则备节点node2 接管服务
[root@node1 ha.d]# service heartbeat stop
Stopping High-Availability services:
[ OK ]
[root@node1 ha.d]# drbd-overview
0:nfs Connected Secondary/Primary UpToDate/UpToDate C r----
[root@node1 ha.d]# ifconfig eth0:0
eth0:0 Link encap:Ethernet HWaddr 00:0C:29:AE:83:D1
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
Interrupt:67 Base address:0x2000
[root@node1 ha.d]#
[root@node2 ha.d]# drbd-overview
0:nfs Connected Primary/Secondary UpToDate/UpToDate C r---- /mnt/nfs ext3 950M 18M 885M 2%
[root@node2 ha.d]# ifconfig eth0:0
eth0:0 Link encap:Ethernet HWaddr 00:0C:29:D1:D4:32
inet addr:192.168.101.210 Bcast:192.168.101.254 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
Interrupt:67 Base address:0x2000
[root@node2 ha.d]#
[root@client ~]# ./nfs.sh
---> trying touch x : Wed Feb 8 20:00:58 CST 2012
<----- done touch x : Wed Feb 8 20:00:58 CST 2012
---> trying touch x : Wed Feb 8 20:00:59 CST 2012
<----- done touch x : Wed Feb 8 20:00:59 CST 2012
---> trying touch x : Wed Feb 8 20:01:00 CST 2012
<----- done touch x : Wed Feb 8 20:01:00 CST 2012
---> trying touch x : Wed Feb 8 20:01:01 CST 2012
<----- done touch x : Wed Feb 8 20:01:01 CST 2012
---> trying touch x : Wed Feb 8 20:01:02 CST 2012
<----- done touch x : Wed Feb 8 20:01:02 CST 2012
---> trying touch x : Wed Feb 8 20:01:03 CST 2012
<----- done touch x : Wed Feb 8 20:01:03 CST 2012
---> trying touch x : Wed Feb 8 20:01:04 CST 2012
<----- done touch x : Wed Feb 8 20:01:04 CST 2012
---> trying touch x : Wed Feb 8 20:01:05 CST 2012
<----- done touch x : Wed Feb 8 20:01:05 CST 2012
[root@client ~]# mount
/dev/sda2 on / type ext3 (rw)
proc on /proc type proc (rw)
sysfs on /sys type sysfs (rw)
devpts on /dev/pts type devpts (rw,gid=5,mode=620)
/dev/sda1 on /boot type ext3 (rw)
tmpfs on /dev/shm type tmpfs (rw)
none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
sunrpc on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw)
nfsd on /proc/fs/nfsd type nfsd (rw)
192.168.101.210:/mnt/nfs on /data type nfs (rw,addr=192.168.101.210)
[root@client ~]#
[root@client ~]# ll /data/
total 20
-rw-r--r-- 1 root root 0 Feb 8 19:50 f-client-1
-rw-r--r-- 1 root root 4 Feb 8 17:41 f1
drwx------ 2 root root 16384 Feb 8 14:57 lost+found
[root@client ~]#
[root@node1 ha.d]# service heartbeat start
Starting High-Availability services:
2012/02/08_20:04:49 INFO: Resource is stopped
[ OK ]
[root@node1 ha.d]# drbd-overview
0:nfs Connected Primary/Secondary UpToDate/UpToDate C r---- /mnt/nfs ext3 950M 18M 885M 2%
[root@node1 ha.d]#
--xjzhujunjie