CentOS 6 High Availability service Heartbeat v3 installation and configuration
System: CentOS 6.6 x86_64 (two virtual machines)
Security: SElinux disabled
Network: Business Network + heartbeat Network
Heartbeat version: v3.0.6
Cluster Gule version: v1.0.12
Resource Agents version: v3.9.6
Package installation method: source code Installation
Heartbeat 3.0 and later are composed of three parts: gule, heartbeat, and agents. Therefore, we need to install them separately.
Install necessary basic tools and compilation tools in advance:
Gcc Series
Compilation and parsing of flex and bison
Net-snmp header file
OpenIPMI development Header
Python Interpreter
Add users and groups running heartbeat (this operation is required on both the master and slave servers)
# Groupadd-r haclient
# Useradd-r-g haclient-M-s/sbin/nologin hacluster
Download and install Cluster Gule
# Wget-O Glue_1.0.12.tar.bz2 http://hg.linux-ha.org/glue/archive/0a7add1d9996.tar.bz2
# Tar xf Glue_1.0.12.tar.bz2
# Cd Reusable-Cluster-Components-glue -- 0a7add1d9996/
# Bash autogen. sh
#./Configure LIBS = '/lib64/libuuid. so.1'
.......................
Cluster-glue configuration:
Version = 1.0.12 (Build: 0a7add1d9996b6d869d441da6c82fb7b8abcef4f)
Features =
Prefix =/usr
Executables =/usr/sbin
Man pages =/usr/share/man
Libraries =/usr/lib64
Header files =/usr/include
Arch-independent files =/usr/share
Documentation =/usr/share/doc/cluster-glue
State information =/usr/var
System configuration =/usr/etc
Use system LTDL = yes
HA group name = haclient
HA user name = hacluster
CFLAGS =-g-O2-ggdb-fgnu89-inline-fstack-protector-all-Wall-Waggregate-return-Wbad-function-cast-Wcast-qual-Wcast-align-Wdeclaration-after -statement-Wendif-labels-Wfloat-equal-Wformat = 2-Wformat-security-Wformat-nonliteral-Winline-Wmissing-prototypes-Wmissing-declarations-Wmissing-format-attribute-Wnested -externs-Wno-long-Wno-strict-aliasing-Wpointer-arith-Wstrict-prototypes-Wwrite-strings-ansi-D_GNU_SOURCE-DANSI_ONLY-Werror
Libraries =-lbz2-lz-lxml2-lc-lrt-ldl/lib64/libuuid. so.1-lglib-2.0-lltdl
Stack Libraries =
# Make-j 2 & make install
Download and install Heartbeat
# Wget-O Heartbeat_3.0.6.tar.bz2 http://hg.linux-ha.org/heartbeat-STABLE_3_0/archive/958e11be8686.tar.bz2
# Tar xf Heartbeat_3.0.6.tar.bz2
# Cd Heartbeat-3-0-958e11be8686/
#./Bootstrap
#./Configure
.......
Configure: WARNING: stdocdir directory () does not exist!
Configure: WARNING: value/default "-- localstatedir =/usr/local/var" is poor.
Configure: WARNING: "/var/something" is stronugly recommended.
Configure: WARNING: We also recommend using "ConfigureMe". // use configureMe
Configure: WARNING: Sleeping for 10 seconds.
......
#./ConfigureMe configure LIBS =/lib64/libuuid. so.1
...........
Heartbeat configuration:
Version = "3.0.6"
Executables = "/usr/sbin"
Man pages = "/usr/share/man"
Libraries = "/usr/lib64"
Header files = "/usr/include"
Arch-independent files = "/usr/share"
Documentation files = "/usr/share/doc/heartbeat"
State information = "/var"
System configuration = "/etc"
Init (rc) scripts = "/etc/rc. d/init. d"
Init (rc) defaults = "/etc/sysconfig"
Use system LTDL = "yes"
HA group name = "haclient"
HA group id = "499"
HA user name = "hacluster"
HA user id = "498"
Build dopd plugin = "yes"
Enable times kludge = "yes"
CC_WARNINGS = "-Wall-Wmissing-prototypes-Wmissing-declarations-Wstrict-prototypes-Wdeclaration-after-statement-Wpointer-arith-Wwrite-strings-Wcast-qual-Wcast-align- wbad-function-cast-Winline-Wmissing-format-attribute-Wformat = 2-Wformat-security-Wformat-nonliteral-Wno-long-Wno-strict-aliasing-Werror"
Mangled CFLAGS = "-g-O2-Wall-Wmissing-prototypes-Wmissing-declarations-Wstrict-prototypes-Wdeclaration-after-statement-Wpointer-arith-Wwrite-strings-Wcast-qual -Wcast-align-Wbad-function-cast-Winline-Wmissing-format-attribute-Wformat = 2-Wformat-security-Wformat-nonliteral-Wno-long-Wno-strict -aliasing-Werror-ggdb3-funsigned-char"
Libraries = "-lbz2-lz-lc-lrt-ldl-lltdl"
RPATH enabled = "no"
Distro-style RPMs = "no"
Note: If you use the 'Make install' method for installation you
Also need to adjust '/etc/passwd' and '/etc/group' manually.
# Make-j 2 & make install
///// // Make
/Usr/bin/xsltproc \
-Xinclude \
Http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl hb_report.xml
Error: Operation in progress
Warning: failed to load external entity "http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl"
Cannot parse http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl
Gmake [2]: *** [hb_report.8] Error 4
Gmake [2]: Leaving directory '/heartbeat/Reusable-Cluster-Components-glue-5e06b2ddd24b/doc'
Yum install docbook-style-xsl-y
# Make-j 2 & make install
Download and install Agents
# Wget-O Resource_Agents_3.9.6.tar.gz
# Tar xf Resource_Agents_3.9.6.tar.gz
# Cd resource-agents-3.9.6/
#./Autogen. sh
Autoreconf: Entering directory '.'
Autoreconf: configure. ac: not using Gettext
Autoreconf: running: aclocal
Autoreconf: configure. ac: tracing
Autoreconf: configure. ac: not using Libtool
Autoreconf: running:/usr/bin/autoconf
Autoreconf: running:/usr/bin/autoheader
Autoreconf: running: automake -- add-missing -- copy -- no-force
Configure. ac: 102: installing './compile'
Configure. ac: 33: installing './config. guess'
Configure. ac: 33: installing './config. sub'
Configure. ac: 83: installing './install-Sh'
Configure. ac: 83: installing './missing'
Heartbeat/Makefile. am: installing './depcomp'
Autoreconf: Leaving directory '.'
Now run./configure and make
#./Configure LIBS = '/lib64/libuuid. so.1'
# Make-j 2 & make install
So far, installation is complete
--------------------------------------------------------------------------------
Configure Heartbeat
# Tree/etc/ha. d/
/Etc/ha. d/
── Harc
── Rc. d
│ ── Ask_resources
│ ── Hb_takeover
│ ── Ip-request
│ ── Ip-request-resp
│ ── Status
── README. config
── Resource. d
│ ── Apache
│ ├ ── AudibleAlarm
│ ── Db2
│ ── Delay
│ ── Filesystem
│ ── Hto-mapfuncs
│ ── ICP
│ ── Ids
│ ── IPaddr
│ ── IPaddr2
│ ── IPsrcaddr
│ ── IPv6addr
│ ── Ldirectord->/usr/sbin/ldirectord
│ ── LinuxSCSI
│ ── LVM
│ ── MailTo
│ ── OCF
│ ── Portblock
│ ── Raid1
│ ── SendArp
│ ── ServeRAID
│ ── WAS
│ ── WinPopup
│ ── Xinetd
└ ── Shellfuncs
2 directories, 32 files
README. config describes the three most important files: ha. cf, haresources, and authkeys.
Note: The authkeys permission is 600.
# Cd/usr/share/doc/heartbeat/
# Cp ha. cf haresources authkeys/etc/ha. d/
Ha. cf main configuration file
Logfile/var/log/ha-log
Logfacility local0 # Log Level
Keepalive 5 # specifies the heartbeat frequency. The default value is 2 seconds.
Deadtime 30 # default death timeout value: 30 seconds
Warntime 10 # alert time
Initdead 150 # maximum network initialization time, 120 seconds by default
Udpport 694 # udp port for heartbeat Detection
Ucast eth1 10.1.1.1 # I select unicast here to check that the IP address of eth1 is the IP address of the Peer heartbeat port.
Auto_failback on # If the master node is restored, the master node will seize the resources to restore the service. If it is off, the master node will be restored only when the slave node is down.
Watchdog/dev/watchdog # Monitoring Device
Node heartbeat_73 ### node and Host Name (the node host name must be the same as the uname-n result)
Node heartbeat_72 ### node and Host Name (the node host name must be the same as the uname-n result)
Haresources master-slave node configuration file
[Root @ heartbeat_73/etc/ha. d] # grep-v "^ #" haresources
Master IPaddr: 211.162.174.74/24/eth0: 1/nginx # the backend must follow the service name
Usage of the haresources file:
Resource file (/etc/ha. d/haresources)
The Haresources file is used to specify cluster resources such as the master node, cluster IP address, subnet mask, broadcast address, and startup service of the dual-machine system. Each row of the file can contain one or more resource script names, resources are separated by spaces, and parameters are separated by two colons. The files must be identical on the two HA nodes. The general format of this file is:
Node-name network <resource-group>
Node-name indicates the Host name of the master node, which must be consistent with the node name specified in the ha. cf file. Network is used to set the IP address, subnet mask, and network device ID of the cluster. Note that the IP address specified here is the IP address of the Cluster's external services. resource-group is used to specify the services to be managed by Heartbeat, that is, these services can be started and closed by Heartbeat. If you want to host these services, you must write the services as steps to start and close them through start/stop and put them in/etc/init. d/or/etc/ha. d/resource. in the d/directory, Heartbeat will automatically go to/etc/init according to the script name. d or/etc/ha. d/resource. d/directory.
The following describes the configuration methods:
Node1 IPaddr: 192.168.60.200/24/eth0/Filesystem:/dev/sdb5:/webdata: ext3 httpd tomcat
Node1 is the master node of the HA cluster, and IPaddr is an execution step that comes with heartbeat. Heartbeat will first execute/etc/ha. d/resource. d/IPaddr 192.168.60.200/24 start operation, that is, a virtual subnet mask of 255.255.255.0 and IP address of 192.168.60.200. This IP address is the network address that Heartbeat provides external services, and the network interface used by this IP address is also specified as eth0. Then, Heartbeat will mount the shared disk partition. "Filesystem:/dev/sdb5:/webdata: ext3" is equivalent to executing the mount operation under the command line, that is, "mount-t ext3/dev/sdb5/webdata", and start the httpd and Tomcat services in sequence.
Note: The source file haresources must be identical between the master node and the backup node.
Authkeys heartbeat key verification file
[Root @ heartbeat_73/etc/ha. d] # grep-v "^ #" authkeys
Auth 1
1 sha1 HI!
Note: Make sure that the authkeys file has 600 permissions.
Now, the configuration file is basically configured.
(The preceding configurations must be configured on both the master and slave servers)
--------------------------------------------------------------------------------
Start heartbeat
Before that, there are four areas to be set:
1. the IP address of the server must be configured with the business network card and heartbeat network card. And plan the VIP address.
2. Modify the name resolution of the hosts file on the master and slave nodes (and check whether the network is accessible)
3. Because the -- prefix option is not used to specify the installation directory when installing heartbeat, perform the following operations:
# Cd/etc/ha. d/
# Mkdir/usr/etc/ha. d/
# Cp-R./*/usr/etc/ha. d/
(Operations are required on both the master and slave servers)
4. If the heartbeat network is a dedicated Nic, open the limitations in iptables.
-------------------------------------- Split line --------------------------------------
Hot Standby for Web Services Based on Heartbeat V1
Heartbeat enables high-availability clusters of Web Services
Heartbeat + LVS + Ldirectord high-availability Load Balancing Solution
DRBD + Heartbeat + NFS High Availability Configuration notes
Heartbeat high availability for MySQL using NFS based on CRM
Heartbeat high-availability httpd simple configuration based on Resources
-------------------------------------- Split line --------------------------------------
To test heartbeat, we now install nginx (or httpd), and make a small change to the corresponding index.html) on the master and slave servers.
This is the homepage of the backup server.
This is the homepage of the master server.
After completing the preceding operations, run the heartbeat STARTUP script. By default, the script is installed in/etc/init. the heartbeat STARTUP script is created in the d/directory, but does not appear in the chkconfig startup list.
Chkconfig -- add heartbeat
Chkconfig -- list // check whether it is set to boot.
Service heartbeat stop // make sure the instance is not started
For more details, please continue to read the highlights on the next page: