标签:
1、环境
nfs1.test.com 10.1.1.1 nfs2.test.com 10.1.1.2
2、drbd配置
安装drbd
yum -y install gcc gcc-c++ make glibc flex yum -y install drbd kmod-drbd
加载drbd模块
modprobe drbd lsmod | grep drbd
/etc/drbd.conf配置
resource r0 { protocol C; startup { wfc-timeout 0; degr-wfc-timeout 120; } disk { on-io-error detach; } net { timeout 60; connect-int 10; ping-int 10; max-buffers 2048; max-epoch-size 2048; } syncer { rate 50M; } on nfs1.ewiz.com { device /dev/drbd0; disk /dev/sdb1; address 10.1.1.1:7777; meta-disk internal; } on nfs2.ewiz.com { device /dev/drbd0; disk /dev/sdb1; address 10.1.1.2:7777; meta-disk internal; } }
初始化drbd并启动
drbdadm create-md r0 /etc/init.d/drbd start chkconfig drbd on
将nfs1上的drbd提升为主
[root@nfs1 ~]# drbdsetup /dev/drbd0 primary -o
查看两台服务器drbd状态
[root@nfs1 ~]# cat /proc/drbd Connected st:Primary/Secondary [root@nfs2 ~]# cat /proc/drbd Connected st:Secondary/Primary
格式化并挂载drbd设备
[root@nfs1 ~]# mkdir /d [root@nfs1 ~]# mkfs.ext3 /dev/drbd0 [root@nfs1 ~]# mount /dev/drbd0 /d
3、NFS配置
4、heartbeat配置
yum install -y heartbeat
/etc/ha.d/ha.cf配置如下:
logfile /var/log/ha-log logfacility local0 keepalive 2 deadtime 5 ucast eth0 10.1.1.2 #此为nfs1上配置,nfs2上改为10.1.1.1 auto_fallback off node nfs1.test.com nfs2.test.com
/etc/ha.d/authkeys配置如下:
auth 1 1 crc
/etc/ha.d/haresources配置如下:
nfs1.ewiz.com IPaddr::10.1.1.3/24/eth0 drbddisk::r0 Filesystem::/dev/drbd0::/d::ext3 killnfsd
/etc/ha.d/resource.d/killnfsd配置如下:
killall -9 nfsd; /etc/init.d/nfs restart; exit
给/etc/ha.d/resource.d/killnfsd可执行权限:
chmod +x /etc/ha.d/resource.d/killnfsd
启动heartbeat:
/etc/init.d/heartbeat start
5、客户端挂载
mount -t nfs 1.1.1.3:/d /web
标签:
原文地址:http://www.cnblogs.com/breezey/p/4680404.html