根据实际情况修改下安装目录等
备用节点配置:
将主节点的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 http://192.168.3.233/1.html
输出: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 http://192.168.3.233/1.html
输出:hello,192.168.3.126
ok,至此heartbeat实现nginx热备,就让我们应用起来吧
--------------------------------------分割线 --------------------------------------
CentOS 6.2实战部署Nginx+MySQL+PHP http://www.linuxidc.com/Linux/2013-09/90020.htm
使用Nginx搭建WEB服务器 http://www.linuxidc.com/Linux/2013-09/89768.htm
搭建基于Linux6.3+Nginx1.2+PHP5+MySQL5.5的Web服务器全过程 http://www.linuxidc.com/Linux/2013-09/89692.htm
CentOS 6.3下Nginx性能调优 http://www.linuxidc.com/Linux/2013-09/89656.htm
CentOS 6.3下配置Nginx加载ngx_pagespeed模块 http://www.linuxidc.com/Linux/2013-09/89657.htm
CentOS 6.4安装配置Nginx+Pcre+php-fpm http://www.linuxidc.com/Linux/2013-08/88984.htm
Nginx安装配置使用详细笔记 http://www.linuxidc.com/Linux/2014-07/104499.htm
Nginx日志过滤 使用ngx_log_if不记录特定日志 http://www.linuxidc.com/Linux/2014-07/104686.htm
--------------------------------------分割线 --------------------------------------
Nginx 的详细介绍:请点这里
Nginx 的下载地址:请点这里
本文永久更新链接地址:http://www.linuxidc.com/Linux/2014-12/110416.htm
