HA(高可用 High avaiilable)集群
Web1 提供服务,如果1主宕机了,2备就可以马上启用,这样有用户这端没有任何影响。
在架构的时候要配置一条心跳线来传递信息。流动IP 也是就是VIP,是主从对外共同的IP。
[root@LNMP ~]# iptables -F
[root@LNMP ~]# getenforce
Disabled
[root@LNMP ~]# vim /etc/hosts #在主上编译上
10.72.4.21 LNMP
10.72.4.14 OBird
[root@OBird ~]# vim /etc/hosts #复制到从上
10.72.4.21 LNMP
10.72.4.14 OBird
#
[root@LNMP ~]# wget www.lishiming.net/data/attachment/forum/epel-release-6-8_64.noarch.rpm
#下载epel
[root@LNMP ~]# rpm -ivh epel-release-6-8_64.noarch.rpm #安装(主从都安装)
[root@LNMP ~]# yum list |grep heartbeat
heartbeat.x86_64 3.0.4-2.el6 epel
heartbeat-devel.i686 3.0.4-2.el6 epel
heartbeat-devel.x86_64 3.0.4-2.el6 epel
heartbeat-libs.i686 3.0.4-2.el6 epel
heartbeat-libs.x86_64 3.0.4-2.el6 epel
主从各自安装 heaerbeat & libnet
[root@LNMP ~]# yum install -y heartbeat
[root@LNMP ~]# yum install libnet
[root@OBird ~]# yun install -y heartbeat
[root@OBird ~]# yum install libnet
[root@LNMP ~]# cd /usr/share/doc/heartbeat-3.0.4/ #进到目录下拷贝样例
[root@LNMP heartbeat-3.0.4]# ls
apphbd.cf authkeys AUTHORS ChangeLog COPYING COPYING.LGPL ha.cf haresources README
[root@LNMP heartbeat-3.0.4]# cp authkeys ha.cf haresources /etc/ha.d/
[root@LNMP heartbeat-3.0.4]#
[root@LNMP heartbeat-3.0.4]# cd /etc/ha.d/
[root@LNMP ha.d]# ls
authkeys ha.cf harc haresources rc.d README.config resource.d shellfuncs
[root@LNMP ha.d]# vim authkeys #编译验证配置文件
#auth 1 #打开更改为 auth 1
#1 crc
#2 sha1 HI!
#3 md5 Hello! #打开md5验证:3 md5 Hello!
[root@LNMP ha.d]# chmod 600 authkeys #编译目录权限,不然heartbeat 服务不能启动
[root@LNMP ha.d]# cd /etc/sysconfig/network-scripts/ #配置虚拟网卡&IP
[root@LNMP network-scripts]# ls
ifcfg-eth0 ifdown-eth ifdown-post ifdown-tunnel ifup-eth ifup-plip ifup-routes init.ipv6-global
ifcfg-lo ifdown-ippp ifdown-ppp ifup ifup-ippp ifup-plusb ifup-sit net.hotplug
ifdown ifdown-ipv6 ifdown-routes ifup-aliases ifup-ipv6 ifup-post ifup-tunnel network-functions
ifdown-bnep ifdown-isdn ifdown-sit ifup-bnep ifup-isdn ifup-ppp ifup-wireless network-functions-ipv6
[root@LNMP network-scripts]# cp ifcfg-eth0 ifcfg-eth0\:1 #配置虚拟网卡&IP
[root@LNMP network-scripts]# vim ifcfg-eht0\:1
DEVICE=eth0:1
#HWADDR=00:0C:29:5A:02:3F
TYPE=Ethernet
#UUID=22567e42-4d72-40e9-8ca3-98098c239d9c
ONBOOT=no #开机不不启动,楼主是桥接模式,所以是静态且不启动
NM_CONTROLLED=yes
BOOTPROTO=static
IPADDR=10.72.4.110
NETMASK=255.255.254.0
#GATEWAY=10.72.4.1

◆◆0
发表评论