某电商网站线上drbd+heartbeat+nfs配置

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 ; degr-wfc-timeout ; }
disk { on-io-error detach; }
net {
timeout ;
connect-int ;
ping-int ;
max-buffers ;
max-epoch-size ;
}
syncer { rate 50M; }
on nfs1.ewiz.com {
device /dev/drbd0;
disk /dev/sdb1;
address 10.1.1.1:;
meta-disk internal;
}
on nfs2.ewiz.com {
device /dev/drbd0;
disk /dev/sdb1;
address 10.1.1.2:;
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配置

yum install -y nfs
vim etc/exports
/d       10.1.1.200(rw,sync,no_root_squash)
/d       10.1.1.201(rw,sync,no_root_squash)
/d       10.1.1.202(rw,sync,no_root_squash)
 
service nfs start
chkconfig nfs on

4、heartbeat配置

yum install -y heartbeat

/etc/ha.d/ha.cf配置如下:

logfile         /var/log/ha-log
logfacility local0
keepalive
deadtime
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
crc

/etc/ha.d/haresources配置如下:

nfs1.ewiz.com IPaddr::10.1.1.3//eth0 drbddisk::r0 Filesystem::/dev/drbd0::/d::ext3 killnfsd

/etc/ha.d/resource.d/killnfsd配置如下:

killall - 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
上一篇:Java--concurrent并发包下阻塞队列介绍


下一篇:c# .net sha256 16进制 64位 签名