根据实际情况修改下安装目录等
备用节点配置:
将主节点的ha.cf haresources authkeys 复制到备用节点上
修改ha.cf中
ucast eth0 192.168.8.124 #采用网卡eth0的udp单播来组织心跳,后面跟的IP地址应为双机对方的IP地址。
3.测试
(1)启动主备节点上的heartbeat
service heartbeat start
(2)输入命令ip a查看主节点上虚拟ip192.168.3.233是否启动
[root@usvr-124 ha.d]# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue state UNKNOWN
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP qlen 1000
link/ether 00:50:56:89:a2:16 brd ff:ff:ff:ff:ff:ff
inet 192.168.3.124/24 brd 192.168.3.255 scope global eth0
inet 192.168.8.124/24 brd 192.168.8.255 scope global eth0:0
inet 192.168.3.233/24 brd 192.168.3.255 scope global secondary eth0
inet6 fe80::250:56ff:fe89:a216/64 scope link
valid_lft forever preferred_lft forever
此时主节点上的nginx也正常启动,但是备用节点上nginx没有启动
在192.168.216上查看:
curl
输出:hello,192.168.3.124
(3)将主节点的heartbeat停掉,我们在备用节点上ip a查看
[root@usvr-126 ha.d]# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue state UNKNOWN
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP qlen 1000
link/ether 00:50:56:89:91:a0 brd ff:ff:ff:ff:ff:ff
inet 192.168.3.126/24 brd 192.168.3.255 scope global eth0
inet 192.168.8.126/24 brd 192.168.8.255 scope global eth0:0
inet 192.168.3.233/24 brd 192.168.3.255 scope global secondary eth0
inet6 fe80::250:56ff:fe89:91a0/64 scope link
此时备用节点上的nginx启动,但是主节点上的nginx已经由heartbeat将nginx停掉
在192.168.216上查看:
curl
输出:hello,192.168.3.126
ok,至此heartbeat实现nginx热备,就让我们应用起来吧
--------------------------------------分割线 --------------------------------------
CentOS 6.2实战部署Nginx+MySQL+PHP
搭建基于Linux6.3+Nginx1.2+PHP5+MySQL5.5的Web服务器全过程
CentOS 6.3下配置Nginx加载ngx_pagespeed模块
CentOS 6.4安装配置Nginx+Pcre+php-fpm
--------------------------------------分割线 --------------------------------------