HeartBeat操作含双网卡配置

回复 收藏
本帖最后由 ankang 于 2016-5-24 18:11 编辑

工具准备两台centos虚拟机
配置网卡如下:
其中一台机器网卡ip: eth2:192.168.1.202 eth3:192.168.1.201
另一台机器网卡ip: eth1:192.168.1.249 eth3:192.168.1.110
虚拟网卡vip:192.168.1.203

1号网卡配置:
vi /etc/sysconfig/network-scripts/ifcfg-eth1

DEVICE=eth1
HWADDR=00:0C:29:29:5A:47
TYPE=Ethernet
UUID=5f47a70e-8dfc-41b4-9778-eb200a51c80a
ONBOOT=yes
NM_CONTROLLED=yes
BOOTPROTO=static
IPADDR=192.168.1.249
GATEWAY=192.168.1.1
NETMASK=255.255.255.0
DNS1=119.29.29.29
DNS2=8.8.8.8


vi /etc/sysconfig/network-scripts/ifcfg-eth3

DEVICE=eth3
HWADDR=00:0C:29:29:5A:51
TYPE=Ethernet
#UUID=5f47a70e-8dfc-41b4-9778-eb200a51c80a
ONBOOT=yes
#NM_CONTROLLED=yes
BOOTPROTO=static
IPADDR=192.168.1.110
NETMASK=255.255.255.0


2号网卡配置

vi /etc/sysconfig/network-scripts/ifcfg-eth2

DEVICE=eth2
HWADDR=00:0C:29:98:19:aa
TYPE=Ethernet
#UUID=5f47a70e-8dfc-41b4-9778-eb200a51c80a
ONBOOT=yes
#NM_CONTROLLED=yes
BOOTPROTO=static
IPADDR=192.168.1.202
NETMASK=255.255.255.0


DEVICE=eth3
HWADDR=00:0C:29:98:19:B4
TYPE=Ethernet
UUID=5f47a70e-8dfc-41b4-9778-eb200a51c80a
ONBOOT=yes
NM_CONTROLLED=yes
BOOTPROTO=static
IPADDR=192.168.1.201
GATEWAY=192.168.1.1
NETMASK=255.255.255.0
DNS1=119.29.29.29
DNS2=8.8.8.8


下载HeartBeat源
准备工作:
安装epel扩展源
yum install -y epel-release
安装heartbeat
yum install -y heartbeat* libnet

修改主从机器host
hostname master
hostname slave
vim /etc/hosts

127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.1.110 master
192.168.1.201 slave

其中master主配置
cd /usr/share/doc/heartbeat-3.0.4/
cp authkeys ha.cf haresources /etc/ha.d/
cd /etc/ha.d
修改认证文件
vi authkeys
//加入或更改为
auth 3
3 md5 Hello!

修改认证文件授权
chmod 600 authkeys
vi haresources //最下面加入
master 192.168.1.203/24/eth3:0 nginx

vi ha.cf //改为如下内容:
debugfile /var/log/ha-debug

logfile /var/log/ha-log

logfacility local0

keepalive 2

deadtime 30

warntime 10

initdead 60

udpport 694

ucast eth3 192.168.1.110

auto_failback on

node master

node slave

ping 192.168.1.1 #交换机或者路由器

respawn hacluster /usr/lib/heartbeat/ipfail

把master的三个配置拷贝到slave:
cd /etc/ha.d/
scp authkeys ha.cf haresources slave:/etc/ha.d/

scp软件下载

yum install openssh-clients -y

yum install scp
登录slave编辑ha.cf

vi /etc/ha.d/ha.cf //只需要更改一个地方

ucast eth3 192.168.1.110 改为 ucast eth3 192.168.1.201

启动heartbeat :
先主,后从
service heartbeat start
检查测试
ifconfig 看是否有 eth3:0
ps aux |grep nginx 看是否有nginx进程
1.测试1
主上故意禁ping
iptables -I INPUT -p icmp -j DROP
2.测试2
主上停止heartbeat服务
service heartbeat stop
3..测试3
主和从上都down掉eth3网卡
ifdown eth3


2016-05-24 18:12 举报
已邀请:

回复帖子,请先登录注册

退出全屏模式 全屏模式 回复
评分
可选评分理由: