首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 其他教程 > 操作系统 >

利用DRBD+heartbeat兑现NFS文件共享服务高可性

2012-08-25 
利用DRBD+heartbeat实现NFS文件共享服务高可性原文地址:http://www.opvps.com/?p331一.目的:二台NFSrimar

利用DRBD+heartbeat实现NFS文件共享服务高可性

原文地址:http://www.opvps.com/?p=331

一.目的:二台NFSrimary/Secondary ds:UpToDate/UpToDate C r---
? ? ns:14357752 nr:1848 dw:361872 dr:13998555 al:264 bm:3581 lo:0 pe:0 ua:0 ap:0
? ?? ???resync: used:0/61 hits:928654 misses:1079 starving:0 dirty:0 changed:1079
? ?? ???act_log: used:0/127 hits:89742 misses:268 starving:0 dirty:4 changed:264

2.Heartbeat配置共涉及4个文件
/etc/ha.d/ha.cf
/etc/ha.d/haresources
/etc/ha.d/authkeys
/etc/ha.d/resource.d/killnfsd
二个节的配置的配置文件都是一样,文件内容如下
[root@node1 ha.d]# cat /etc/ha.d/ha.cf
debugfile /var/log/ha-debug
logfile /var/log/ha-log
logfacility? ???local0
keepalive 2
deadtime 20
bcast eth0
auto_failback off
node? ? node1 node2
[root@node1 ha.d]# cat /etc/ha.d/haresources
node1 IPaddr::192.168.10.113/24/eth0 drbddisk::r0 Filesystem::/dev/drbd0::/u1::ext3 killnfsd
[root@node1 ha.d]# cat /etc/ha.d/authkeys
auth 1
1 crc
#2 sha1 HI!
#3 md5 Hello!
[root@node1 ha.d]# cat /etc/ha.d/resource.d/killnfsd
killall -9 nfsd ; /etc/init.d/nfs restart ; exit 0

需要将 /etc/ha.d/authkeys设为600的权限 将cat /etc/ha.d/resource.d/killnfsd设为755的权限
chmod 600 /etc/ha.d/authkeys
chmod 755 /etc/ha.d/resource.d/killnfsd

为什么要使用这个killnfsd的原因,使用/etc/inin.d/nfs stop 不能停掉nfsd,所有我使用了killall -9 nfsd再加了一个/etc/inin.d/nfs restart确保万一
在二个节点启动Heartbeat即可,先在主节点启动
/etc/init.d/heartbeat start

五.测试
将192.168.10.113:/u1挂到本地/mnt
mount 192.168.10.113:/u1 /mnt
创建测试shell,二秒一个
cat /mnt/test.sh
while true
do
??echo? ???---\> trying touch x : `date`
??touch x
??echo? ???\<----- done touch x : `date`
??echo
??sleep 2

done

将主节点的heartbeat服务停止,则备节点node2接管服务
/etc/init.d/heartbeat stop

测试脚本终端显示如下
---> trying touch x : ?t 6?? 30 15:17:16 CST 2009
<----- done touch x : ?t 6?? 30 15:17:16 CST 2009

---> trying touch x : ?t 6?? 30 15:17:19 CST 2009
<----- done touch x : ?t 6?? 30 15:17:19 CST 2009

---> trying touch x : ?t 6?? 30 15:17:21 CST 2009
<----- done touch x : ?t 6?? 30 15:17:21 CST 2009

---> trying touch x : ?t 6?? 30 15:17:23 CST 2009
<----- done touch x : ?t 6?? 30 15:17:23 CST 2009

---> trying touch x : ?t 6?? 30 15:17:25 CST 2009
<----- done touch x : ?t 6?? 30 15:17:25 CST 2009

---> trying touch x : ?t 6?? 30 15:17:27 CST 2009
touch: cannot touch ??x?ˉ: Stale NFS file handle
<----- done touch x : ?t 6?? 30 15:17:42 CST 2009

---> trying touch x : ?t 6?? 30 15:17:44 CST 2009
touch: cannot touch ??x?ˉ: Stale NFS file handle
<----- done touch x : ?t 6?? 30 15:17:44 CST 2009

---> trying touch x : ?t 6?? 30 15:17:46 CST 2009
touch: cannot touch ??x?ˉ: Stale NFS file handle
<----- done touch x : ?t 6?? 30 15:17:46 CST 2009

---> trying touch x : ?t 6?? 30 15:18:03 CST 2009
<----- done touch x : ?t 6?? 30 15:18:03 CST 2009

---> trying touch x : ?t 6?? 30 15:18:05 CST 2009
<----- done touch x : ?t 6?? 30 15:18:05 CST 2009

至此,测试已实现所需的功能

热点排行