码迷,mamicode.com
首页 > Web开发 > 详细

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

时间:2015-07-27 16:16:53      阅读:162      评论:0      收藏:0      [点我收藏+]

标签:

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配置

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       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

 

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

标签:

原文地址:http://www.cnblogs.com/breezey/p/4680404.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!