I. Introduction to the Environment
Description: All cases are completed on the virtual machine (VMware)
Operating system: CentOS 6.5 64bit
Highly available software: Heartbeat 3.0.4
Web application server: Apache httpd 2.2.15
Second, Heartbeat service Host resource planning
Host Name
|
Interface
|
Ip
|
Use
|
Heartbeat-master
|
Eth0
|
172.18.10.227
|
External network management IP for WAN data forwarding
|
|
Eth1
|
172.18.0.227
|
Heartbeat line for inter-server heartbeat connection (direct Connect) |
|
|
172.18.10.200
|
Virtual IP (VIP) that provides app service a
|
Heartbeat-slave
|
Eth0
|
172.18.10.228
|
External network management IP for WAN data forwarding |
|
Eth1
|
172.18.0.228
|
Heartbeat line for inter-server heartbeat connection (direct Connect) |
|
|
172.18.10.201
|
Provides virtual IP (VIP) for app service B |
III. installation configuration (same configuration as master and slave server configuration)
1 Configuring the Host name and Hosts file
1.1 Replace host name with Heartbeat-master
[Email protected] ~]# sed-i ' s#hostname=base#hostname=heartbeat-master#g '/etc/sysconfig/network[[email protected] ~ ]# hostname Heartbeat-master
Exit Login System (CTRL+D)
[Email protected] ~]#
1.2 Configuring the Hosts file
[[email protected] ~]# cat >>/etc/hosts<<eof> 172.18.0.227 heartbeat-master # BIND host name to heart jumper > 172.18.0.228 Heartbeat-slave # BIND host name to heart jumper > Eof[[email protected] ~]# tail-2/etc/hosts172.18.0.227 heartbeat-master172.18.0.228 Heartbeat-slave
1.3 Check that the configuration is correct
[[email protected] ~]# tail-2/etc/hosts172.18.0.227 heartbeat-master172.18.0.228 heartbeat-slave[[email protected] ~] # ping Heartbeat-master[[email protected] ~]# ping Heartbeat-slave
2 Increasing host routing
2.1 Configure the following on the Heartbeat-master host:
[[Email protected] ~]# route add -host 172.18.0.228 dev eth1[[email protected] ~]# echo "/sbin/route add -host 172.18.0.228 dev eth1 " >> /etc/rc.local[[email protected] ~]# tail -1 /etc/rc.local/sbin/ Route add -host 172.18.0.228 dev eth1[[email protected] ~]# route -nKernel IP routing tableDestination Gateway genmask flags Metric Ref Use Iface172.18.0.228 0.0.0.0 255.255.255.255 UH 0 0 0 eth1172.18.0.0 0.0.0.0 255.255.255.0 u 0 0 0 eth1172.18.10.0 0.0.0.0 255.255.255.0 u 0 0 0 eth0 ... Omitted
The
2.2 is configured on the Heartbeat-slave host as follows:
[[Email protected] ~]# route add -host 172.18.0.227 dev eth1[[email protected] ~]# echo "/sbin/route add -host 172.18.0.227 dev eth1 " >> /etc/rc.local [[email protected] ~]# tail -1 /etc/rc.local /sbin/route add -host 172.18.0.227 dev eth1[[email protected] ~]# route -n #检查路由是否配置正确Kernel IP routing tableDestination Gateway Genmask Flags Metric Ref Use Iface172.18.0.227 0.0.0.0 255.255.255.255 UH 0 0 0 Eth1172.18.0.0 0.0.0.0 255.255.255.0 U 0 0 0 eth1172.18.10.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0 ... Omitted
Iv. Installation of Heartbeat software
Need to explain, The CentOS5.8 system comes with heartbeat software that can be installed directly via Yum, but the CentOS6 version will no longer support the installation of Heartbeat via Yum, which requires the installation of Epel packages and Epel software installed through the heartbeat package.
1 Creating a Software storage directory (good Habits)
[Email protected] ~]# mkdir-p/home/oldcat/tools[[email protected] ~]# cd/home/oldcat/tools/
2 download and install the Epel package
[[email protected] tools]# wget http://mirrors.ustc.edu.cn/fedora/epel/6/x86_64/ epel-release-6-8.noarch.rpm--2016-01-08 00:16:00-- http://mirrors.ustc.edu.cn/fedora/epel/6/ X86_64/EPEL-RELEASE-6-8.NOARCH.RPM is parsing host mirrors.ustc.edu.cn... 202.141.160.110, 2001:da8:d800 : 95::110 is connected mirrors.ustc.edu.cn|202.141.160.110|:80... connected. Issued HTTP request, waiting for response ... 200 ok ... Omit [[email protected] tools]# rpm -ivh epel-release-6-8.noarch.rpm warning: epel-release-6-8.noarch.rpm: header v3 rsa/sha256 signature, key id 0608b895: nokeypreparing... ########################################### [100%] 1:epel-release ########################################### [100%][[email&nbSp;protected] tools]# rpm -qa|grep epelepel-release-6-8.noarch
3 yum install heartbeat
[[email protected] tools]# yum install heartbeat -yloaded plugins: fastestmirror, securitybase | 3.7 kB 00:00 base/primary_db | 4.6 mb 00:00 epel/metalink | 4.5 kb 00:00 epel ... Omitted
V. Installation of Apache HTTPD software
1 Yum Installation httpd
[email protected] ~]# Yum install httpd-y
Vi. Configuring high-availability Services
1 Configuring Heartbeat
1.1 Heartbeat The default profile directory is/etc/ha.d/after installation via Yum, but the default does not include the configuration file, you need to
HA.CF, Authkeys, and Haresources copied to the/etc/ha.d/directory in the/usr/share/doc/heartbeat-3.0.4/directory
[[email protected] heartbeat-3.0.4]# cp authkeys ha.cf haresources /etc/ ha.d/[[email protected] heartbeat-3.0.4]# cd /etc/ha.d/[[email protected] ha.d]# ll Total dosage 44-rw-r--r--. 1 root root 645 1 month 8 01:03 authkeys-rw-r--r--. 1 root root 10502 1 Month 8 01:03 ha.cf-rwxr-xr-x. 1 root root 745 12 Month 3 2013 harc-rw-r--r--. 1 root root 5905 1 Month 8 01:03 Haresourcesdrwxr-xr-x. 2 root root 4096 1 Month 8 00:30 Rc.d-rw-r--r--. 1 root root 692 12 Month 3 2013 Readme.configdrwxr-xr-x. 2 root root 4096 1 Month 8 00:30 resource.d-rw-r--r--. 1 rOot root 2082 11 Month 10 19:00 shellfuncs
1.2 Edit Authkeys file
[[email protected] ha.d]# cat authkeys auth 11 sha1 49234s43k345lkj3lk239sljdf23478cxj90s8lwe5rll # key string is custom, as long as possible to configure the description: SHA1 encryption, optional encryption and CRC and MD5, However, the use of CRC is not recommended by the authorities. ## authentication file. must be mode 600### must have exactly one auth directive at the front.# auth send Authentication using this method-id## then, list the method and key that go with that method-id## &NBSP;&NBSP;&NBSP;&NBSP;&NBSP;AVAILABLE&NBSP;METHODS:&NBSP;CRC&NBSP;SHA1,&NBSP;MD5.&NBSP;&NBSP;CRC&NBSP;DOESN ' t need/want a key.## you normally only Have one authentIcation method-id listed in this file## put more than one to make a smooth transition when changing auth# methods and/or keys.### sha1 is believed to be the "Best", md5 next Best.## crc adds no security, except from packet corruption.# use only on physically secure networks. [[The Email protected] ha.d]# chmod 600 authkeys # authkeys file must have the permissions of 600!! [[email protected] ha.d]# ll total dosage 40-rw-------. 1 root root 60 1 Month 8 01:09 authkeYs-rw-r--r--. 1 root root 10502 1 Month 8 01:03 ha.cf-rwxr-xr-x . 1 root root 745 12 month 3 2013 harc-rw-r--r--. 1 root root 99 1 Month 8 01:13 Haresourcesdrwxr-xr-x. 2 root root 4096 1 Month 8 00:30 Rc.d-rw-r--r--. 1 root root 692 12 Month 3 2013 Readme.configdrwxr-xr-x. 2 root root 4096 1 Month 8 00:30 resource.d-rw-r--r--. 1 root root 2082 11 Month 10 19:00 Shellfuncs
1.3 Edit Haresources File
[email protected] ha.d]# cat >> haresources <<eof> heartbeat-master ipaddr::172.18.10.200/24/eth0 httpd > Heartbeat-slave ipaddr::172.18.10.201/24/eth0> eof[[email protected] ha.d]# cat haresources Heartbeat-master Ipaddr::172.18.10.200/24/eth0 Httpdheartbeat-slave Ipaddr::172.18.10.201/24/eth0
Configuration Description:
A.172.18.10.200 is initially bound to the VIP on the Heartbeat-master host, the same 172.18.10.201 as the initial binding
The VIP on the Heartbeat-slave host.
B. Although both master and slave VIPs are configured, the initial binding binds only the VIP that belongs to the native, only within the configured time
Receiving no heartbeat data from the peer server will take over the VIP and all resources of the peer host.
The C.HTTPD parameter is responsible for delegating the start stop operation of the httpd service to heartbeat.
1.4 Edit HA.CF File
[email protected] ha.d]# cat ha.cfdebugfile/var/log/ha-debug.loglogfile/var/log/ha.loglogfacility local1keepalive 2deadtime 30warntime 10initdead 90mcast eth1 225.0.0.100 694 1 0auto_failback onnode heartbeat-masternode heartbeat-slave CRM No
To be Continued ...
Application of Web applications to high availability through heartbeat