[1] environment setting before installation
========================================================== ============================
Hardware environment of the two hosts (not completely consistent ):
CPU: Xeon 3G * 2 (em64t)
Mem: 2G
NIC: Intel 1g * 2
Eth0: external IP address
Eth1: internal IP address (for HA)
The eth1 of the two hosts are directly connected through dual-host couplets.
Partitioning Method:
Filesystem capacity mount point
/Dev/sda2 9.7g/
/Dev/sda6 45g/datas
/Dev/sda1 99 m/boot
None2.0g/dev/SHM
/Dev/sda3 9.7g/OPT
In addition, each host should reserve MB of raw space or use it as a shared space for HA.
Operating System:
Redhat Enterprise 4 update2 (2.6.9-22 El)
Pre-installed software:
@ X Window System
@ GNOME Desktop Environment
@ KDE Desktop Environment
@ Editors
@ Engineering and scientific
@ Graphical Internet
@ Text-based Internet
@ Authoring and Publishing
@ Server configuration tools
@ Development tools
@ Kernel development
@ X software development
@ Gnome Software Development
@ KDE Software Development
@ Adminitools
@ System Tools
[2] network environment settings before installation: ========================================================== ======================================
Node1: Host Name: servers201 (ha01)
Eth0: 192.168.10.201 // external IP address
Eth1: 10.0.0.201 // HA heartbeat address
Node2: Host Name: servers202 (HA02)
Eth0: 192.168.10.202 // external IP address
Eth1: 10.0.0.202 // HA heartbeat address
Check the following files:
/Etc/hosts
/Etc/host. conf
/Etc/resolv. conf
/Etc/sysconfig/Network
/Etc/sysconfig/network-scripts/ifcfg-eth0
/Etc/sysconfig/network-scripts/ifcfg-eth1
/Etc/nsswitch. conf
# Vi/etc/hosts
The hosts content of node1 is as follows:
127.0.0.1 localhost. localdomain localhost
192.168.10.201 servers201 ha01
10.0.0.201 ha01
10.0.0.202 HA02
192.168.10.202 server202
The hosts content of node2 is as follows:
127.0.0.1 localhost. localdomain localhost
192.168.10.202 servers202 HA02
10.0.0.202 HA02
10.0.0.201 ha01
192.168.10.201 server201
# Cat/etc/host. conf
Order hosts, bind
# Cat/etc/resolv. conf
Nameserver 61.139.2.69 // DNS address
# Cat/etc/sysconfig/Network
Networking = Yes
Hostname = servers201 // host name
Gateway = "192.168.10.1" // Gateway
Gateway = "eth0" // The network card used by the Gateway
Onboot = Yes // load at startup
Forward_ipv4 = "yes" // only IPv4 addresses are allowed
# Cat/etc/sysconfig/network-scripts/ifcfg-eth0
Device = eth0
Onboot = Yes
Bootproto = static
Ipaddr = 192.168.10.201
Netmask = 255.255.255.0
Gateway = 192.168.10.1
Type = Ethernet
Ipv6init = No
# Cat/etc/sysconfig/network-scripts/ifcfg-eth1
Device = eth1
Onboot = Yes
Bootproto = none
Ipaddr = 10.0.0.201
Netmask = 255.255.255.0
Type = Ethernet
[Node1] and [node2] in the preceding configuration,
/Etc/hosts
/Etc/sysconfig/Network
/Etc/sysconfig/network-scripts/ifcfg-eth0
/Etc/sysconfig/network-scripts/ifcfg-eth1
Except for modification.
After the configuration is complete, try to ping the Host Name of the other host. You can ping the Host Name of the other host:
/Root # Ping HA02
Ping HA02 (10.0.0.202) 56 (84) bytes of data.
64 bytes from HA02 (10.0.0.202): icmp_seq = 0 TTL = 64 time = 0.198 MS
64 bytes from HA02 (10.0.0.202): icmp_seq = 1 TTL = 64 time = 0.266 MS
64 bytes from HA02 (10.0.0.202): icmp_seq = 2 TTL = 64 time = 0.148 MS
--- HA02 Ping statistics ---
3 packets transmitted, 3 bytes ed, 0% packet loss, Time 2002 Ms
RTT min/AVG/max/mdev = 0.148/0.204/0.266/0.048 MS, pipe 2
[3] install the HA and HA dependency packages
========================================================== ======================================
Rpm-uvh libnet-1.1.2.1-1.rh.el.um.1.i386.rpm // can be left empty
Rpm-uvh heartbeat-pils-2.0.4-1.el4.i386.rpm
Rpm-uvh heartbeat-stonith-2.0.4-1.el4.i386.rpm
Rpm-uvh heartbeat-2.0.4-1.el4.i386.rpm
Rpm-uvh ipvsadm-1.24-5.i386.rpm
[4] configuration files for configuring ha
========================================================== ======================================
---------------------------
Configure the heartbeat encryption method: authkeys
---------------------------
# Vi/etc/ha. d/authkeys
If you use dual-host couplet wires (twisted pair wires), you can configure the following:
# Vi/etc/HC. d/authkeys
Auth 1
1 CRC
Save the disk and exit, and then
# Chmod 600 authkeys
---------------------------
Configure heartbeat monitoring: haresources
---------------------------
# Vi/etc/ha. d/haresources
All hosts should be identical.
Server201 ipaddr: 192.168.10.200 ipvsadm httpd
Specify server201 to call ipvsadm to start the HTTP service. The system attaches a virtual IP address 192.168.10.200 to eth0: 0.
If server201 is down, server202 can automatically start the HTTP service and assign the IP address 192.168.10.200 to the eth0: 0 of server202.
---------------------------
Configure the heartbeat configuration file: Ha. cf
---------------------------
# Vi/etc/ha. d/ha. cf
Logfile/var/log/ha_log/ha-log.log # the location where the HA log file is recorded. If the directory does not exist, manually add
Bcast eth1 # Use eth1 for heartbeat monitoring
Keepalive 2 # Set the heartbeat (Monitoring) Time to 2 seconds
Warntime 10
Deadtime 30
Initdead 120
Hopfudge 1
Udpport 694 # Use UDP port 694 for heartbeat monitoring
Auto_failback on
Node server201 # Node 1, which must be consistent with the result obtained by the uname-N command.
Node server202 # Node 2
Ping 192.168.10.1 # ping the gateway to check whether the heartbeat is normal.
Respawn hacluster/usr/lib64/heartbeat/ipfail
Apiauth ipfail gid = root uid = root
Debugfile/datas/logs/ha_log/ha-debug.log
---------------------------
Configure ingress SADM monitoring
---------------------------
Ipvsadm-a-t 192.168.10.200: 80-s rr
Ipvsadm-a-t 192.168.10.200: 80-r 192.168.10.201: 80-m
Ipvsadm-a-t 192.168.10.200: 80-r 192.168.10.202: 80-m
Perform monitoring after execution:
# Ipvsadm -- list
If the returned result is the same as the following, the setting is correct.
IP Virtual Server version 1.2.0 (size = 4096)
Prot localaddress: Port sched1_flags
-> Remoteaddress: port forward weight activeconn inactconn
TCP 192.168.10.200: HTTP rr
-> Server202: HTTP local 1 0 0
-> Server201: HTTP masq 1 0 0
[5] startup, shutdown, and testing of the HA service ============================ ==========================================
Start ha: Service heartbeat start
Disable ha; Service heartbeat stop
The system automatically loads heartbeat at startup.
Use http service to test heartbeat
Start the HTTPd service
# Service httpd start
Edit the HTML file used for testing on the respective hosts and put it in the/var/www/html/directory.
Start heartbeat of node1 and execute this command for monitoring: Heartbeat status
[6] firewall settings
========================================================== ======================================
Heartbeat uses UDP port 694 by default for heartbeat monitoring. If the system uses iptables for firewall, remember to open this port.
# Vi/etc/sysconfig/iptables
Add the following content
-A RH-Firewall-1-INPUT-p udp-m udp -- dport 694-D 10.0.0.201-J accept
This means that UDP port 694 is open to the peer's heartbeat NIC address 10.0.0.201.
# Service iptables restart
Reload iptables.
Note: This article was generally completed in-months. Both two servers and two VMS passed the test. But when I wrote this document, I forgot the [Monitoring command] in step 5 due to carelessness! In addition, the two servers are used separately. The system reinstalls and loses the virtual machine, so there is no way to verify it again. In this article, "and execute this command for monitoring: Heartbeat status" may be different. For specific corrections, you must wait for the actual operation on the server, reinstall two virtual machines, or find other documents on the network.