Compilation and installation configuration of HeartBeat

1. Preparations

Heartbeat 3.0.6:

#wget http://hg.linux-ha.org/heartbeat-STABLE_3_0/archive/958e11be8686.tar.bz2

Cluster Glue 1.0.12:< /p>

#wget http://hg.linux-ha.org/glue/archive/0a7add1d9996.tar.bz2

Resource Agents 3.9 .6:

#wget https://github.com/ClusterLabs/resource-agents/archive/v3.9.6.tar.gz

# yum install gcc gcc-c++ autoconf automake libtool glib2-devel libxml2-devel bzip2 bzip2-devel e2fsprogs-devel libxslt-devel libtool-ltdl-devel asciidoc#groupaddhaclient#useradd-ghaclienthacluster#yuminstallhttpd

2. Compile Cluster Glue

#tar-jxvf cluster-clue-1.0. 12.tar.bz2 #cd Reusable-Cluster-Components-glue--0a7add1d99 96/#./autogen.sh#./configure--prefix=/usr/local/heartbeat--with-daemon-user=hacluster--with-daemon-group=haclient--enable-fatal-warnings=no LIBS ='/lib64/libuuid.so.1' ##Note: 32-bit systems remove 64# make# make install

Compilation error 1:

Making all in libltdlgmake[1]: Enter the directory "/root/Reusable-Cluster-Components-glue--0a7add1d9996/libltdl" gmake[1]: *** No The rule can create a target "all". stop. gmake[1]: Leaving the directory "/root/Reusable-Cluster-Components-glue--0a7add1d9996/libltdl" make: *** [all-recursive] error 1

Resolve:

< pre class="brush:bash;toolbar:false">#yum install libtool-ltdl-devel

Compilation error 2:

collect2: error: ld returned 1 exit statusgmake[2]: [ipctest] error 1gmake[2]: leave the directory "/root/Reusable-Cluster-Components-glue-- 0a7add1d9996/lib/clplumbing"gmake[1]: *** [all-recursive] error 1gmake[1]: Leaving the directory "/root/Reusable-Cluster-Components-glue--0a7add1d9996/lib" make:***[ all-recursive] Error 1

Solution:

#./configure--prefix=/usr/local/heartbeat--with -daemon-user=hacluster--with-daemon-group=haclient--enable-fatal-warnings=no LIBS='/lib64/libuuid.so.1'

Note: If using a 32-bit system When, change LIBS to LIBS=’/lib/libuuid.so.1′

Compilation error 3:

gmake[2]: a2x: command not found gmake[2]: [hb_report.8] error 127 gmake[2]: leave the directory "/root/Reusable-Cluster-Components-glue- -0a7ad d1d9996/doc"gmake[1]: *** [all-recursive] Error 1gmake[1]: Leaving the directory "/root/Reusable-Cluster-Components-glue--0a7add1d9996/doc" make: *** [all- recursive] Error 1

Solution:

#yuminstall asciidoc


Three, compile Resource Agents< /p>

# tar-zxvf resource-agents-3.9.6.tar.gz# cd resource-agents-3.9.6#./autogen.sh#./ configure--prefix=/usr/local/heartbeat--with-daemon-user=hacluster--with-daemon-group=haclient--enable-fatal-warnings=no LIBS='/lib64/libuuid.so.1' #Make#make install

Four. Compile Heartbeat

#tar-jxvf heartbeat-3.0.6.tar.bz2# cd Heartbeat-3-0-958e11be8686/#./bootstrap# export CFLAGS="$CFLAGS-I/usr/local/heartbeat/include-L/usr/local/heartbeat /lib"#./configure--prefix=/usr/local/heartbeat--with-daemon-user=hacluster--with-daemon-group=haclient--enable-fatal-warnings=no LIBS='/lib64/ libuuid.so.1'#make#make install

#cpdoc/{ha.cf,haresources, authkeys} /usr/local/heartbeat/etc/ha.d/# chkconfig--add heartbeat# chkconfig heartbeat on# chmod 600 /usr/local/heartbeat/etc/ha.d/authkeys#mkdir-pv/usr/local /heartbeat/usr/lib/ocf/lib/heartbeat/# cp /usr/lib/ocf/lib/heartbeat/ocf-* /usr/local/heartbeat/usr/lib/ocf/lib/heartbeat/#ln-svf /usr/local/heartbeat/lib64/heartbeat/plugins/RAExec/* /usr/local/heartbeat/lib/heartbeat/plugins/RAExec/#ln-svf/usr/local/heartbeat/lib64/heartbeat/plugins/*/ usr/local/heartbeat/lib/heartbeat/plugins/

Compilation error 1:

checking heartbeat/glue_config.h usability...nochecking heartbeat/glue_config.hpresence...nochecking for heartbeat/glue_config.h...noconfigure:error:in`/root /Heartbeat-3-0-958e11be8686':configure: error: Core development headers were not foundSee `config.log' for more detailschecking heartbeat/glue_config.h usability...nochecking heartbeat/glue_config.hpresence...nochecking for heartbeat /glue_config.h... noconfigure: error: in `/root/Heartbeat-3-0-958e11be8686':configure: error: Core development headers were not foundSee `config.log' for more details

Solution:

#exportCFLAGS="$CFLAGS-I/usr/local/heartbeat/include-L/usr/local/heartbeat/lib"

pre>


Compilation error 2:

In file included from../include/lha_internal.h: 41:0, from uuid_parse.c:25:/usr/local/heartbeat/include/heartbeat/glue_config.h:105:0: error: "HA_HBCONF_DIR" redefined [-Werror] #define HA_HBCONF_DIR"/usr/local/heartbeat /etc/ha.d/" ^In file included from../include/lha_internal.h:38:0, from uuid_parse.c:25:../include/config.h:390:0: note: this is the lo cation of the previous definition #define HA_HBCONF_DIR "/usr/local/heartbeat/etc/ha.d" ^uuid_parse.c:36:26: fatal error: replace_uuid.h: No such file or directory #include  ^cc1: all warnings being treated as errorscompilation terminated.gmake[1]: [uuid_parse.lo] error 1gmake[1]: leaving the directory "/root/Heartbeat-3-0-958e11be8686/replace" make: ** * [All-recursive] Error 1

Resolve:

#./configure--prefix=/usr/local/heartbeat- -with-daemon-user=hacluster--with-daemon-group=haclient--enable-fatal-warnings=no LIBS='/lib64/libuuid.so.1'

5. Heartbeat configuration

Heartbeat’s configuration is mainly It involves three files: ha.cf, haresources, and authkeys. Among them, ha.cf is the main configuration file, haresource is used to configure the service to be hosted by Heartbeat, and authkey is used to specify the authentication method of Heartbeat.


1. Configuration ha.cf----Main configuration file

#cat/usr/local/heartbeat/etc/ha.d/ha.cf|grep^[^#]debugfile/var/log/ha-debug# #Used to record the heartbeat debugging information logfile/var/log/ha-log ##Used to record the heartbeat log information logfacilitylocal0 ##Set the heartbeat log, here is the system log keepalive #2 The time is 2 seconds deadtime 30 ##Specify that if the standby node does not receive the primary node's heartbeat signal within 30 seconds, it will take over the primary server resource warntime 10 ##Specify the heartbeat delay time is 10 seconds, and the standby node cannot receive it within 10 seconds The heartbeat signal of the master node, that is, the warning log is written to the log, but the service is not switched to initdead 120 ## The ignored time period reserved after the system is started or restarted, and the value is at least twice the deadtime udpport/#694 Udp port used for communication bcast eno16777736 #Linux #用网卡eno16777 736 Send heartbeat detection #mcast eth0 225.0.0.1 694 1 0 ##Udp multicast of the network card eth0 is used to organize the heartbeat, which is generally used when there is more than one standby node. Bcast, ucast, and mcast respectively represent broadcast, unicast and multicast, which are ways to organize heartbeats. Choose one of them. #ucast eno16777736 192.168.10.133 ##Using the udp unicast of the network card eno16777736 to organize the heartbeat, followed by the IP address Auto_failback on the other party's IP address ##Defines whether the service will be automatically switched back to #watchdog/dev/watchdog ##watchdog/dev/watchdog after the master node recovers##Optional configuration, and monitor the system running status through Heartbeat. node node1 ##Master node name, consistent with uname -n display node node2 ##Alternative node name ping 192.168.10.1 Heartbeat/heartbeat/heartbeat/heartbeat/ pinging only to detect whether the gateway is normal or not the heartbeat/heartbeat/ ping ha #passed local /heartbeat/ipfail##Specify the process to be started and closed together with heartbeat, optional #apiauth ipfail gid=haclient uid=hacluster##Set the user and group to start IPfail

Note:

①watchdog /dev/watchdog: optional configuration, monitoring system running status through Heartbeat. This feature needs to load the "softdog" kernel module in the kernel to generate the actual device file. If the module does not exist in the system, specify it and recompile the kernel. After compiling, enter "insmod softdog" to load the module, then enter "grep misc /proc/devices", enter "cat /proc/misc |grep watchdog", and finally generate a device file: "mknod /dev/watchdog c 10 130". Use

②espawn hacluster /usr/lib/heartbeat/ipfail: Specify the process to be started and closed together with heartbeat, optional. These processes are generally plug-ins integrated with heartbeat, which can be automatically restarted in case of failure. The IPfail process is used to detect and handle network failures. It needs to be used with a ping statement to specify a ping node to detect network connectivity; hacluster represents the user who started the IPfail process.

2. Configure haresources-----resource files

Haresources file is used to specify the master node, cluster IP, subnet mask, broadcast address, and start service cluster resources of the dual-system system,

Each line of the file can contain one or more resource script names. The resources are separated by spaces, and the parameters are separated by two colons. The resource file haresources in the primary node and the backup node must be exactly the same.

The general format is:

node-name network

node-name represents the primary node The host name must be the same as the node name specified in the ha.cf file. network is used to set the cluster's

IP address, subnet mask, network device identification, etc. resource-group is used to specify the services to be hosted by Heartbeat (that is, these

services can be started and closed by Heartbeat).

Note: The IP address specified here is the IP address of the cluster’s external services;

If you want to host these services, you must write the services as available Scripts that are started or closed by start/stop are placed in the /etc/init.d/

or /etc/ha.d/resource.d/ directory, and Heartbeat will automatically go to the /etc/ha.d/resource.d/ directory according to the script name etc/init.d or

Find the corresponding script in the /etc/ha.d/resource.d directory to start or shut down.

#cat/usr/local/heartbeat/etc/ha.d/haresources|grep-v"#"node1 IPaddr::192.168.10.222/24 /eno16777736

node1 is the master node of the HA cluster, IPaddr is the execution script that comes with heartbeat, heartbeat will first execute /etc/ha.d/resource.d /IPaddr 192.168.10.222/24 start operation, that is, a virtual subnet mask of 255.255.255.0, and an IP address of 192.168.10.222. This IP is the network address for heartbeat to provide services to the outside world, and the network interface used by this IP is specified at the same time

Note: There is a detailed Chinese explanation of haresources as follows

http://blog.chinaunix. net/uid-20788470-id-1841644.html

3. Configure authkeys- ----Heartbeat key verification file

#grep-v"#"/usr/local/heartbeat/etc/ha.d /authkeys auth 22 sha1 HI!

Note: Fill in the serial number after auth, which can be filled in arbitrarily, but the first line of the second line must be the serial number name, and then it is the verification method. Three (crc md5 sha1) verification methods are supported , The last is the custom key.

Six. Configure mutual trust between two machines (optional) and copy files to the standby machine

HA-01(192.168.10.132):

ssh-keygen-trsa-f~/.ssh/id_rsa-P''ssh-copy-id-i.ssh/[email protected] .10.133

HA-02(192.168.10.133):

ssh-keygen -t rsa -f~/.ssh/id_rsa -P''ssh-copy-id -i.ssh/id_rsa.pub [email protected]

Copy the configuration file to the standby machine:

#scp /usr/local/heartbeat/etc/ha.d/* [email protected]:/usr/local/heartbeat/etc/ha.d/

Seven. Test

#systemctlstarthttpd#/etc/init.d/heartbeatstartstart##openheartbeat#getenforce0#systemctlsto p firewalld

View log information

#tail/var/log/ ha-logOct 26 10:07:18 node1 heartbeat: [2063]: ERROR: Illegal directive [ucast] in /usr/local/heartbeat/etc/ha.d//ha.cfOct 26 10:07:18 node1 heartbeat: [2063]: ERROR: Illegal directive [ping] in /usr/local/heartbeat/etc/ha.d//ha.cfOct 26 10:07:18 node1 heartbeat: [2063]: ERROR: Client child command [/usr /lib/heartbeat/ipfail] is not executableOct 26 10:07:18 node1 heartbeat: [2063]: ERROR: Heartbeat not started: configuration error. Oct 26 10:07:18 node1 heartbeat: [2063]: ERROR: Configuration error , Heartbeat not started.

Problem solving:

Change IPfail path:

respawn hacluster/ usr/local/heartbeat/libexec/heartbeat/ipfail

Create a plugin soft link:

#ln-svf/usr/local/ heartbeat/lib64/heartbeat/plugins/RAExec/* /usr/local/heartbeat/lib/heartbeat/plugins/RAExec/#ln-svf/usr/local/heartbeat/lib64/heartbeat/ plugins/* /usr/local/heartbeat/lib/heartbeat/plugins/

Continue to view log information

#tail/var/ log/ha-logOct 26 13:11:46 node1 heartbeat: [9744]: info: remote resource transition completed. Oct 26 13:11:46 node1 heartbeat: [9744]: info: node1 wants to go standby [foreign]Oct 26 13:11:46 node1 heartbeat: [9744]: info: standby: node2 can take our foreign resources Oct 26 13:11:46 node1 heartbeat: [11892]: info: give up foreign HA resources (standby). Oct 26 :11:46 node1 heartbeat: [11892]: info: foreign HA resource release completed (standby).Oct 26 13:11:46 node1 heartbeat: [9744]: info: Local standby process completed [foreign].Oct 26 13: 11:47 node1 heartbeat: [9744]: WARN: 1 lost packet(s) for [node2] [11:13]Oct 26 13:11:47 node1 heartbeat: [9744]: info: remote resource transition completed.Oct 26 13:11:47 node1 heartbeat: [9744]: info: No pkts missing from node2! Oct 26 13:11:47 node1 heartbeat: [9744]: info: Other node completed standby takeover of fore ign resources.

Problem solving:

#vi/usr/local/heartbeat/ etc/ha.d/haresourcesnode1 IPaddr::192.168.10.222/24/eno16777736

Note: IPaddr:: should be added under haresources

Question:

#tail /var/log/ha-log Oct 26 17:01:55 node1 heartbeat: [1755]: WARN: Message his queue is filling up (425 messages in queue) Oct 26 17:01:56 node1 heartbeat: [1755]: WARN: Message hisist queue is filling up (426 messages in queue) Oct 26 17:01:57 node1 heartbeat: [1755]: WARN: Message his queue is filling up (427 messages in queue) Oct 26 17:01:57 node1 Heartbeat: [1755]: WARN: Message his queue is filling up (428 messages in queue) Oct 26 17:01:01 heartbeat: [1755]: WARN: Message hisist queue is filling up (429 messages in queue) Oct 26 17:01:59 node1 Heartbeat: [1755]: WARN: Message hisist queue is filling Oct 26 17:01:59 node1 heartbeat: [1755]: WARN: Message hisist queue is filling up (431 messages in queue) Oct 26 17:02:00 node1 heartbeat: [1755]: WARN: Message his queue is filling up (432 messages in queue) Oct 26 17:02:01 node1 heartbeat: [1755]: WARN: Message hist queue is filling up (433 messages in queue) Oct 26 17:02:01 node1 heartbeat: [1755]: WARN: Message his queue is filling up (434 messages in queue)

Solution: node2 is not closed Firewall, systemctl stop firewalld closes the firewall to solve the problem

Problem:

#tail/var /log/ha-logIPaddr(IPaddr_192.168.10.222)[6854]:2015/10/26_17:20:58 ERROR: Setup problem: couldn't find command: ifconfig/usr/lib/ocf/resource.d// heartbeat/IPaddr(IPaddr_192.168.10.222)[6828]:2015/10/26_17:20:58 ERROR: Program is not installed

Solution: You can use the ifconfig command after yum install net-tools< /p>

Restart heartbeat and continue to view log information:

#systemctlrestarthearbeat#tail/var /log/ha-logOct 26 19:25:36 node1 heartbeat: [1783]: info: Configuration validated. Starting heartbeat 3.0.6 Oct 26 19:25:3 7 node1 heartbeat: [1783]: info: heartbeat: version 3.0.6Oct 26 19:25:37 node1 heartbeat: [1783]: info: Heartbeat generation: 1445827146Oct 26 19:25:37 node1 heartbeat: [1783]: info: glib: UDP Broadcast heartbeat started on port 694 (694) interface eno16777736Oct 26 19:25:37 node1 heartbeat: [1783]: info: glib: UDP Broadcast heartbeat closed on port 694 interface eno16777736: 25 Status: Oct 2619 node1 heartbeat: [1783]: info: glib: ping heartbeat started.Oct 26 19:25:37 node1 heartbeat: [1783]: info: Local status now set to:'up'Oct 26 19:25:37 node1 heartbeat: [1783]: info: Link 192.168.10.1:192.168.10.1 up.Oct 26 19:25:37 node1 heartbeat: [1783]: info: Status update for node 192.168.10.1: status pingOct 26 19:25:37 node1 heartbeat : [1783]: info: Link node1:eno16777736 up.

Use the ifconfig command to view

wKioL1Yu3K6QuGLSAALi7x5itoM08 9.jpg

Enter http://localhost to view in the browser

wKiom1Yu4FXw_lgMAABE- eS3Ubo658.jpg

Down the node1 node and check if it will drift to node2

node1:

#systemctlstop heartbeat

node2:

#tail /var/log/ha-logmach_down(default)[1937]:2015/10/26_20:03:58 info: Taking over resource group IPaddr::192.168.10.222/24/eno16777736ResourceManager (default)[1964]:2015/10/26_20:03:58 info: Acquiring resource group: node1 IPaddr::192.168.10.222/24/eno16777736/usr/lib/ocf/resource.d//heartbeat/IPaddr(IPaddr_192 .168.10.222)[1992]:2015/10/26_20:03:58 INFO: Resource is stoppedResourceManager(default)[1964]:2015/10/26_20:03:58 info: Running /usr/local/heartbeat/etc /ha.d//resource.d/IPaddr 192.168.10.222/24/eno167 77736 startIPaddr(IPaddr_192.168.10.222)[2083]:2015/10/26_20:03:58 INFO: Using calculated netmask for 192.168.10.222: 255.255.255.0 IPaddr(IPaddr_192.168.10.222)[2083]:2015/10 /26_20:03:58 INFO: eval ifconfig eno16777736:0 192.168.10.222 netmask 255.255.255.0 broadcast 192.168.10.255/usr/lib/ocf/resource.d//heartbeat/IPaddr(IPaddr_192.168.10.222)[2057]: 2015/10/26_20:03:58 INFO: Successmach_down(default)[1937]:2015/10/26_20:03:58 Info: /usr/local/heartbeat/share/heartbeat/mach_down: nice_failback: foreign resourcesacquiredmach_down(default )[1937]:2015/10/26_20:03:58 info: mach_down takeover complete for node node1.Oct 26 20:03:58 node2 heartbeat: [1711]: info: mach_down takeover complete.mach_down(default)[1937] :2015/10/26_20:03:58 info: mach_down takeover complete for node node1.Oct 26 20:03:58 node2 heartbeat: [1711]: info: mach_down takeover complete.Oct 26 20:04:29 node2 heartbeat: [ 1711]: WARN: node node1: is deadOct 26 20:04:29 node2 heartbeat: [1711]: info: Dead node node1 gave u p resources.Oct 26 20:04:29 node2 heartbeat: [1711]: info: Link node1:eno16777736 dead.Oct 26 20:04:29 node2 ipfail: [1737]: info: Status update: Node node1 now has ct status 26 20:04:29 node2 ipfail: [1737]: info: NS: We are still alive! Oct 26 20:04:29 node2 ipfail: [1737]: info: Link Status update: Link node1/eno16777736 now has status deadOct 26 20:04:30 node2 ipfail: [1737]: info: Asking other side for ping node count.Oct 26 20:04:30 node2 ipfail: [1737]: info: Checking remote count of ping nodes.

Use the ifconfig command to check whether the IP has drifted to node2:

wKiom1Yu4mmQb47VAALJszKx6RM575.jpg

< p>IP has drifted to node2, use the browser to enter http://localhost to view

wKioL1Yu4vTTM9viAABC6oIoJU0661.jpg

OK!


Attach: heartbeat official website:

http://www.linux- ha.org/wiki/Main_Page

Leave a Comment

Your email address will not be published.