650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/73/B9/wKioL1YFQDbS5kT3AAE3pr6YBa8619.jpg "title=" Image.png "alt=" Wkiol1yfqdbs5kt3aae3pr6yba8619.jpg "/>
Primary and Standby Mutual resolution set multiple IPs
# vim/etc/hosts
192.168.7.2 css01
192.168.7.3 CSS02
Second, configure the extended Yum source
wget www.lishiming.net/data/attachment/forum/epel-release-6-8_64.noarch.rpm
RPM-IVH epel-release-6-8_64.noarch.rpm
Third, upload the installation package
Yum-y Install Lrzsz
Cd/usr/local/src
Rz
Yum-y Install *
Iv. installation of Heartbeart
Yum-y Install Heartbeat
V. Modify the configuration file
1. Authkeys
[[email protected] HA.D] # more Authkeys
Auth 3
#1 CRC
#2 SHA1 hi!
3 MD5 hello!
2. ha.cf
[Email protected] ha.d]# more HA.CF
Debugfile/var/log/ha-debug
Logfile/var/log/ha-log
Logfacility local0
KeepAlive 2
Deadtime 30
Warntime 10
Initdead 30
Udpport 694
Bcast eth0
Auto_failback on
Node css01
Node CSS02
Ping 192.168.7.1
3. haresources
[Email protected] ha.d]# more haresources
Css01 192.168.7.111/24/eth0/nginx
Copy the host's configuration file to the standby machine
Vi. installation of Nginx
Yum-y Install Nginx
echo "-----------css01------------" >/usr/share/nginx/html/index.html
Primary and standby content for different convenience tests
Seven, start heartbeat
/etc/init.d/heartbeat start
Eight, observation log
Tail-f/var/log/ha-log
Ix. Test Access vip:192.168.7.111
/etc/init.d/heartbeat stop
/etc/init.d/heartbeat Sstart
Problems encountered:
I. centos6.5 64-bit system yum installing heartbeat will be missing many dependent packages
WORKAROUND: Collect all the dependencies and install the package.
Second, heartbeat detection can not be recognized eth0:1
ERROR:glib:ucast:error setting Option So_bindtodevice (W) on eth0:1: No such device
ERROR:make_io_childpair:cannot Open ucast eth0:
Solution 1: Change the heartbeat detection network to eth0 service exit gateway to Eth0:1
Detailed configuration file:
1 Configuring HA.CF
The first one is ha.cf the file is located in the/ETC/HA.D directory that was created after installation. This file includes what media path to use for heartbeat and how to configure their information. The ha.cf file in the source code directory contains all the options you can use, as detailed below:
Serial/dev/ttys0
Using the serial port heartbeat-if you do not use a serial heartbeat, you must use other media, such as Bcast (Ethernet) heartbeat. Replace/DEV/TTYS0 with the appropriate device files.
Watchdog/dev/watchdog
This option is an optional configuration. With the watchdog feature, a system with minimal functionality is available, and the system does not provide heartbeat, which can be restarted after an abnormal state of one clock is sustained. This feature helps prevent a machine from recovering heartbeat after it has been identified as dead. If this happens and the disk mount is migrated due to a failure (fail over), it is possible that two nodes will mount a disk at the same time. If you want to use this feature, you will need to load the "Softdog" kernel module and create the appropriate device files in addition to this line. The method is to load the module using the command "Insmod Softdog". Then enter "grep misc/proc/devices" and remember the resulting number (should be 10). Then enter "Cat/proc/misc | grep watchdog "and remembers the output number (should be 130). Based on the information obtained above, you can create a device file, "Mknod/dev/watchdog C 10 130".
Bcast eth1
Represents the use of broadcast heartbeat on the Eth1 interface (replacing eth1 with eth0,eth2, or any interface you use).
KeepAlive 2
Set the time interval between heartbeat to 2 seconds.
Warntime 10
The time, in seconds, to wait before issuing a "late heartbeat" warning in the log.
Deadtime 30
The node is declared dead after 30 seconds.
Initdead 120
In some configurations, the network takes some time to function properly after a reboot. This individual "deadtime" option can handle this situation. Its value should be at least twice times that of the usual deadtime.
Baud 19200
Baud rate, the speed of serial communication.
Udpport 694
Use port 694 for bcast and ucast communication. This is the default and is officially registered in the IANA port number.
Auto_failback on
This option is required to be configured. For those who are familiar with Tru64 Unix, heartbeat works like "favored member" mode. Before failover, the master nodes listed in the Haresources file have all the resources and then take over the resources from the node. When Auto_failback is set to ON, once the primary node is back online, all resources are retrieved from the node. If this option is set to OFF, the master node cannot regain resources. This option is similar to the deprecated nice_failback option. If you are upgrading from a cluster with a nice_failback set to off to this or later version, there are a few things you need to pay special attention to to prevent flash cut. Please refer to the FAQ section on how to handle such situations.
Node primary.mydomain.com
This option is required to be configured. The host name of the machine in the cluster is the same as the output of "uname–n".
Node backup.mydomain.com
This option is required to be configured. Ditto.
Respawn
This option is optional: Lists the commands that will be executed and monitored. For example: To execute the CCM daemon, add the following:
Respawn HACLUSTER/USR/LIB/HEARTBEAT/CCM
Causes heartbeat to execute the process as a userid (in this case, hacluster) and to monitor the execution of the process, and restart if its death occurs. For Ipfail, it should be:
Respawn Hacluster/usr/lib/heartbeat/ipfail
Note: If the exit code for the end process is 100, the process is not restarted.
2 Configuring Haresources
Once the HA.CF file is configured, it is the haresources file. This file lists the services provided by the cluster and the default owner of the service. Note: The file must be the same on two cluster nodes. The IP address of the cluster is the option that must be configured and cannot be configured outside of the Haresources file, and the Haresources file is used to specify the primary node of the dual-machine system, the cluster IP, the subnet mask, the broadcast address, and the services that are started. Its configuration statement format is as follows:
Node-name Network-config
Where node-name specifies the master node of the dual-machine system, the value must match one of the host names set by the node option in the Ha.cf file, and the node option sets another host name to be the slave. The network-config is used for network settings, including specifying the cluster IP, subnet mask, broadcast address, and so on. The Resource-group is used to set up heartbeat-initiated services, which are ultimately provided externally by a dual-machine system via a cluster IP. In this article we assume that the HA service to be configured is Apache and samba.
The following is required in the Haresources file:
primary.mydomain.com 192.168.85.3 httpd SMB
The line specifies that at startup, the node linuxha1 gets the IP address 192.168.85.3 and launches Apache and samba. When stopped, Heartbeat will first stop SMB, then stop Apache, and finally release the IP address 192.168.85.3. This assumes that the output of the command "Uname–n" is "primary.mydomain.com"-If the output is "primary", then "primary" should be used.
After the Haresources file is properly configured, copy the HA.CF and Haresource to the/ETC/HA.D directory.
Note: Commands that can be executed in the resource file must be visible in the/etc/ha.d/resource.d/
3 Configuring Authkeys
The third file that you need to configure Authkeys determines your authentication key. There are three kinds of authentication methods: CRC,MD5, and SHA1. You might ask, "which method should I use?" "In short: If your heartbeat is running on a secure network, such as the crossover in this example, you can use the CRC, which is the least expensive approach from a resource perspective." If the network is not secure, but you also want to reduce CPU usage, use MD5. Finally, if you want to get the best certification, regardless of CPU usage, use SHA1, which is the hardest to crack among the three.
The file format is as follows:
Auth
[]
Therefore, for SHA1, the/etc/ha.d/authkeys of the example may be
Auth 1
1 SHA1 key-for-sha1-any-text-you-want
For MD5, just replace the SHA1 above with MD5. For CRC, it can be configured as follows:
Auth 2
2 CRC
No matter what index value you specify after the keyword auth, you must later appear as the key value again. If you specify "Auth 4", then be sure to have a line at "4" in the following row.
Make sure that the access rights to the file are secure, such as 600.
Heartbeat installation configuration of HA architecture