基础环境:
[root@DB1 ~]# uname -a
Linux DB1.MySQL.hz.t4x.org 2.6.32-642.4.2.el6.x86_64 #1 SMP Tue Aug 23 19:58:13 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
[root@DB1 ~]# uname -n
DB1.mysql.hz.t4x.org
[root@DB1 ~]# uname -r
2.6.32-642.4.2.el6.x86_64
[root@DB1 ~]# cat /etc/redhat-release
CentOS release 6.8 (Final) SourceByrd's Weblog-https://note.t4x.org/system/heartbeat-compile-install/
IP地址规划:SourceByrd's Weblog-https://note.t4x.org/system/heartbeat-compile-install/
[root@DB1 ~]# ifconfig | grep "inet addr:"
inet addr:1.1.1.110 Bcast:1.1.1.255 Mask:255.255.255.0 eth0
inet addr:10.162.32.110 Bcast:10.162.47.255 Mask:255.255.240.0 eth1
inet addr:172.16.0.110 Bcast:172.16.255.255 Mask:255.255.0.0 eht2SourceByrd's Weblog-https://note.t4x.org/system/heartbeat-compile-install/[root@DB2 ~]# ifconfig | grep "inet addr:"
inet addr:1.1.1.111 Bcast:1.1.1.255 Mask:255.255.255.0 eth0
inet addr:10.162.32.111 Bcast:10.162.47.255 Mask:255.255.240.0 eth1
inet addr:172.16.0.111 Bcast:172.16.255.255 Mask:255.255.0.0 eht2 SourceByrd's Weblog-https://note.t4x.org/system/heartbeat-compile-install/
Heartbeat编译安装:
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
[root@DB1 ~]# yum install epel-release -y #编译安装不需要 [root@DB1 ~]# yum install autoconf automake libtool glib2-devel libxml2-devel bzip2-devel e2fsprogs-devel libxslt-devel libtool-ltdl-devel libtool-ltdl cmake asciidoc cluster-glue-libs -y [root@DB1 ~]# mkdir /byrd/tools -p [root@DB1 ~]# mkdir /byrd/service -p [root@DB1 ~]# cd /byrd/tools/ [root@DB1 ~]# groupadd -r haclient -g 497 [root@DB1 ~]# useradd -r hacluster -u 497 -g haclient -s /sbin/nologin [root@DB1 tools]# wget http://hg.linux-ha.org/glue/archive/0a7add1d9996.tar.bz2 [root@DB1 tools]# tar jxf 0a7add1d9996.tar.bz2 [root@DB1 tools]# cd Reusable-Cluster-Components-glue--0a7add1d9996/ [root@DB1 Reusable-Cluster-Components-glue--0a7add1d9996]# ./autogen.sh [root@DB1 Reusable-Cluster-Components-glue--0a7add1d9996]# ./configure --prefix=/byrd/service/heartbeat --sysconfdir=/etc --with-daemon-user=hacluster --with-daemon-group=haclient --enable-fatal-warnings=no LIBS='/lib64/libuuid.so.1' [root@DB1 Reusable-Cluster-Components-glue--0a7add1d9996]# make && make install [root@DB1 Reusable-Cluster-Components-glue--0a7add1d9996]# cd .. [root@DB1 tools]# wget http://hg.linux-ha.org/heartbeat-STABLE_3_0/archive/958e11be8686.tar.bz2 [root@DB1 tools]# tar jxf 958e11be8686.tar.bz2 [root@DB1 tools]# cd Heartbeat-3-0-958e11be8686/ [root@DB1 Heartbeat-3-0-958e11be8686]# ./bootstrap [root@DB1 Heartbeat-3-0-958e11be8686]# ln -s /byrd/service/heartbeat /usr/local/heartbeat [root@DB1 Heartbeat-3-0-958e11be8686]# export CFLAGS="$CFLAGS -I/usr/local/heartbeat/include -L/usr/local/heartbeat/lib" [root@DB1 Heartbeat-3-0-958e11be8686]# ./configure --prefix=/byrd/service/heartbeat --sysconfdir=/etc --with-daemon-user=hacluster --with-daemon-group=haclient --enable-fatal-warnings=no LIBS='/lib64/libuuid.so.1' [root@DB1 Heartbeat-3-0-958e11be8686]# make && make install [root@DB1 Heartbeat-3-0-958e11be8686]# cd .. [root@DB1 tools]# wget https://github.com/ClusterLabs/resource-agents/archive/v3.9.6.tar.gz [root@DB1 tools]# tar zxf v3.9.6.tar.gz #如果不安装,没有/usr/lib/ocf/lib/heartbeat/目录 [root@DB1 tools]# cd resource-agents-3.9.6/ [root@DB1 resource-agents-3.9.6]# ./autogen.sh [root@DB1 resource-agents-3.9.6]# ./configure --prefix=/byrd/service/heartbeat --sysconfdir=/etc --with-daemon-user=hacluster --with-daemon-group=haclient --enable-fatal-warnings=no LIBS='/lib64/libuuid.so.1' |
必要的配置:
0 1 2 3 4 5 |
[root@DB1 ~]# tail -2 /etc/hosts 1.1.1.110 DB1.mysql.hz.t4x.org 1.1.1.111 DB2.mysql.hz.t4x.org [root@DB1 ~]# tail -2 /etc/rc.local route add -host 1.1.1.111 dev eth1 route add -host 172.16.0.111 dev eth2 |
heartbeat配置:
0 1 2 3 4 5 6 7 8 9 10 11 12 |
[root@DB1 Heartbeat-3-0-958e11be8686]# cp /usr/local/heartbeat/share/doc/heartbeat/{authkeys,ha.cf,haresources} /etc/ha.d/ [root@DB1 Heartbeat-3-0-958e11be8686]# cd /etc/ha.d/ [root@DB1 ha.d]# route add -host 1.1.1.111 dev eth1 [root@DB1 ha.d]# echo "1.1.1.110 DB1.mysql.hz.t4x.org" >>/etc/hosts [root@DB1 ha.d]# echo "1.1.1.111 DB2.mysql.hz.t4x.org" >>/etc/hosts [root@DB1 ha.d]# mkdir -p /usr/local/heartbeat/usr/lib/ocf/lib/heartbeat/ [root@DB1 ha.d]# cp /usr/lib/ocf/lib/heartbeat/ocf-* /usr/local/heartbeat/usr/lib/ocf/lib/heartbeat/ [root@DB1 ha.d]# ln -sf /usr/local/heartbeat/lib64/heartbeat/plugins/RAExec/* /usr/local/heartbeat/lib/heartbeat/plugins/RAExec/ [root@DB1 ha.d]# ln -sf /usr/local/heartbeat/lib64/heartbeat/plugins/* /usr/local/heartbeat/lib/heartbeat/plugins/ [root@DB1 ha.d]# chmod 600 authkeys [root@DB1 ha.d]# echo "auth 1" > authkeys [root@DB1 ha.d]# echo "1 sha1 abcde" >> authkeys [root@DB1 ha.d]# mkdir /usr/share/heartbeat |
配置文件:
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
[root@DB1 ~]# cat /etc/ha.d/authkeys auth 1 1 sha1 abcde [root@DB1 ~]# cat /etc/ha.d/ha.cf # Heartbeat Config debugfile /var/log/ha_debug logfile /var/log/ha_log logfacility local0 keepalive 2 deadtime 30 warntime 10 initdead 60 #bcast eth1 mcast eth1 225.0.0.18 694 1 0 auto_failback on node DB1.mysql.hz.t4x.org node DB2.mysql.hz.t4x.org crm no [root@DB1 ~]# cat /etc/ha.d/haresources # Heartberat service DB1.mysql.hz.t4x.org IPaddr::1.1.1.200/24/eth0 |
参考文档:http://wangzhijian.blog.51cto.com/6427016/1708694SourceByrd's Weblog-https://note.t4x.org/system/heartbeat-compile-install/ SourceByrd's Weblog-https://note.t4x.org/system/heartbeat-compile-install/