HA (Highly available high avaiilable) cluster
WEB1 provides services, if the 1 main outage, 2 ready to be enabled immediately, so that there is no impact on the user side.
Configure the one Mind jumper to pass the information when the schema is in order. Mobile IP is also the VIP, is the master-slave external common IP.
650) this.width=650; "src=" http://s1.51cto.com/wyfs02/M00/8B/93/wKioL1hSDmezD2T2AABioDWW6tM868.jpg "title=" h2.jpg "alt=" Wkiol1hsdmezd2t2aabiodww6tm868.jpg "/>
[Email protected] ~]# iptables-f
[Email protected] ~]# Getenforce
Disabled
[Email protected] ~]# vim/etc/hosts #在主上编译上
10.72.4.21 LNMP
10.72.4.14 Obird
[Email protected] ~]# vim/etc/hosts #复制到从上
10.72.4.21 LNMP
10.72.4.14 Obird
#
[Email protected] ~]# wget www.lishiming.net/data/attachment/forum/epel-release-6-8_64.noarch.rpm
#下载epel
[[email protected] ~]# RPM-IVH epel-release-6-8_64.noarch.rpm #安装 (master-slave installation)
[email protected] ~]# 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
Master-Slave installation Heaerbeat & Libnet
[Email protected]lnmp ~]# Yum install-y Heartbeat
[Email protected]lnmp ~]# yum Install libnet
[Email protected]Obird ~]# Yun install-y Heartbeat
[Email protected]Obird ~]# Yum Install libnet
[Email protected] ~]# cd/usr/share/doc/heartbeat-3.0.4/#进到目录下拷贝样例
[[email protected] heartbeat-3.0.4]# ls
APPHBD.CF authkeys AUTHORS ChangeLog COPYING COPYING. LGPL ha.cf haresources README
[email protected] heartbeat-3.0.4]# cp Authkeys ha.cf haresources /etc/ha.d/
[Email protected] heartbeat-3.0.4]#
650) this.width=650; "src=" http://s4.51cto.com/wyfs02/M02/8B/94/wKioL1hSJe7Tn38VAACVHF7SoAM340.jpg "title=" h3.jpg "alt=" Wkiol1hsje7tn38vaacvhf7soam340.jpg "/>
[Email protected] heartbeat-3.0.4]# cd/etc/ha.d/
[[email protected] ha.d]# ls
Authkeys ha.cf harc haresources rc.d readme.config resource.d Shellfuncs
[Email protected] ha.d]# vim Authkeys #编译验证配置文件
#auth 1 #打开更改为auth 1
#1 CRC
#2 SHA1 hi!
#3 MD5 hello! #打开md5验证: 3 MD5 hello!
[[email protected] ha.d]# chmod authkeys #编译目录权限, otherwise the heartbeat service will not start
[Email protected] ha.d]# cd/etc/sysconfig/network-scripts/ #配置虚拟网卡 &ip
[[email protected] 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
[email protected] network-scripts]# cp ifcfg-eth0 ifcfg-eth0\:1 #配置虚拟网卡 &ip
[Email protected] 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 #开机不不启动, landlord is bridge mode, so it is static and does not start
Nm_controlled=yes
Bootproto=static
ipaddr=10.72.4.110
netmask=255.255.254.0
# gateway=10.72.4.1
~
[[email protected] network-scripts]#/etc/init.d/network Restart #重新启动网络服务, you can see two IP
[Email protected] ha.d]# vim haresources #编译
#node1 10.0.0.170 filesystem::/dev/sda1::/data1::ext2 #直接加下面一行, change the next line in the current behavior
LNMP 10.72.4.111/23/eth0:0 Nginx
[Email protected] ha.d]# >HA.CF #清空配置
[Email protected] ha.d]# vim ha.cf #写入以下内容
Debugfile/var/log/ha-debug #日志文件, and the following Ha.log records the same thing.
Logfile/var/log/ha-log
Logfacility Local0 #日志的级别, here is local 0, do not consider
KeepAlive 2 #多长时间探测一次对方是否还在
Deadtime #30秒Ping通宣告死亡
Warntime #10秒Ping不通发出警告
Initdead #防止对方服务器在重启, buffer time
Udpport 694 #心跳线通讯的端口 694
Ucast eht0 10.72.4.14 # Each other's IP, also available bcast broadcast
Auto_failback on #如果备机启用, restores the master when the primary is activated again
Node Lnmp #master
Node Obird #slave
Ping 10.72.4.1 #仲裁地址, usually with a routing or switch, with stable settings
Respawn hacluster/usr/lib64/heartbeat/ipfail #以哪个用户的身份来运行脚本. The script detects network connectivity and detects if the other is alive.
[Email protected] ha.d]# SCP authkeys haresources ha.cf obird:/etc/ha.d/
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/8B/97/wKioL1hSSdax6hAeAADkuGXCOeI445.jpg "title=" h4.jpg "alt=" Wkiol1hssdax6haeaadkugxcoei445.jpg "/>
[[email protected] ha.d]# vim ha.cf #从上的配置, only need to change IP to each other, other configuration without change
Ucast eht0 10.72.4.21
Start: Start Master First, then start from. Do not make a mistake in order.
[[email protected] ha.d]#/etc/init.d/heartbeat start #也是信了邪, the Lord's heartbeat can start
Starting high-availability Services:INFO:Resource is stopped
Done.
[Email protected] ha.d]#/etc/init.d/heartbeat start #同样的配置在从上却启动不了
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/8B/9F/wKiom1hSsZmT-WjKAAExKtV2o8w926.jpg "title=" h5.jpg "alt=" Wkiom1hsszmt-wjkaaexktv2o8w926.jpg "/>
#在网上寻求解决方法
When doing an HA experiment, the boot heartbeat error occurred:
Error:client child command [/usr/lib/heartbeat/ipfail] was not executable
Error:heartbeat not started:configuration error.
Error:configuration error, Heartbeat not started.
Because the landlord of Linux is 64-bit, in the HA.CF configuration file
/usr/lib/heartbeat/ipfail This sentence should read:
/usr/lib64/heartbeat/ipfail
Start Again/etc/init.d/heartbeat start
Starting high-availability Services:INFO:Resource is stopped
Done. Success (but landlord unclear, why from the configuration of the Lib, why can start)
[Email protected] ha.d]# vim HA.CF
[[email protected] ha.d]#/etc/init.d/heartbeat start #从上的heartbeat started successfully
Starting high-availability Services:INFO:Resource is stopped
Done.
[[Email protected] ha.d]# IP add #vip启动了
[[Email protected] ha.d]# PS aux |grep nginx #nginx start, see
650) this.width=650; "src=" http://s5.51cto.com/wyfs02/M02/8B/B9/wKioL1hXRBGjVC1ZAAJau4p3iUo426.jpg "title=" h6.jpg "alt=" Wkiol1hxrbgjvc1zaajau4p3iuo426.jpg "/>
[[Email protected] ha.d]# PS aux |grep nginx #从上的nginx is possible to start if the boot indicates HA failure
Root 3654 0.0 0.0 103252 824 pts/0 s+ 22:42 0:00 grep nginx
Next, use Nginx mo to do the test.
[Email protected] ~]# Vim/data/dis
[Email protected] dis]# echo "2016-12-19-MASTERLNMP" > forum.php
#楼主的主 (master) is in a LNMP environment where NGIXN is not reinstalled and the path and Mo path are not the same.
#C: \windows\system32\drivers\etc 10.72.4.21 www.linux.com
650) this.width=650; "src=" http://s2.51cto.com/wyfs02/M00/8B/C0/wKiom1hXicLTysihAABn90Z_P2Y653.jpg "title=" h7.jpg "alt=" Wkiom1hxicltysihaabn90z_p2y653.jpg "/>
[[email protected] dis]# iptables-a input-p icmp-j DROP #关掉主上的 Ping, the heartbeat line is ping-based
View Logs
650) this.width=650; "src=" http://s4.51cto.com/wyfs02/M00/8B/BC/wKioL1hXi3Oycz0fAAIwcRVDcpc597.jpg "title=" h9.jpg "alt=" Wkiol1hxi3oycz0faaiwcrvdcpc597.jpg "/>
The following is written from the top, accessed through the VIP. And compare, the content has changed, ha builds successfully.
[Email protected] ha.d]# echo "2016-12-19-MASTERSLVEPPPPPPPPPPPPPPPP" >/usr/share/nginx/html/index.html # On the MO from the Nginx, write the following, access via IE
650) this.width=650; "src=" http://s5.51cto.com/wyfs02/M01/8B/C2/wKiom1hXmzeiQ4j4AAB-doCyOEo889.jpg "title=" h8.jpg "alt=" Wkiom1hxmzeiq4j4aab-docyoeo889.jpg "/>
View the Nginx service boot from the top,
650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M00/8B/C2/wKiom1hXmw2jOl09AADSM5ytCWc215.jpg "title=" H10.jpg "alt=" Wkiom1hxmw2jol09aadsm5ytcwc215.jpg "/>
This article is from the "Cbo#boy_linux Road" blog, make sure to keep this source http://20151213start.blog.51cto.com/9472657/1884003
Linux ha cluster discretionary