基础环境:
0 1 2 3 4 5 6 7 8 9 10 11 12 13 |
[root@Heartbeat-Master tools]# uname -a Linux Heartbeat-Master 2.6.32-358.el6.x86_64 #1 SMP Fri Feb 22 00:31:26 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux [root@Heartbeat-Master ~]# ifconfig |grep "inet addr" inet addr:1.1.1.80 Bcast:1.1.1.255 Mask:255.255.255.0 inet addr:10.10.10.80 Bcast:10.10.10.255 Mask:255.255.255.0 #心跳线 [root@Heartbeat-Slave ~]# cat /etc/redhat-release CentOS release 6.4 (Final) [root@Heartbeat-Slave ~]# ifconfig | grep "inet addr" inet addr:1.1.1.81 Bcast:1.1.1.255 Mask:255.255.255.0 inet addr:10.10.10.81 Bcast:10.10.10.255 Mask:255.255.255.0 [root@Heartbeat-Master ~]# route add -host 10.10.10.81 dev eth1 [root@Heartbeat-Master ~]# echo "route add -host 10.10.10.801 dev eth1" >>/etc/rc.local [root@Heartbeat-Slave ~]# route add -host 10.10.10.80 dev eth1 [root@Heartbeat-Slave ~]# echo "route add -host 10.10.10.80 dev eth1" >>/etc/rc.local |
yum搭建:
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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
[root@Heartbeat-Master tools]# echo "1.1.1.80 Heartbeat-Master" >>/etc/hosts [root@Heartbeat-Master tools]# echo "1.1.1.81 Heartbeat-Slave" >>/etc/hosts [root@Heartbeat-Master tools]# tail -2 /etc/hosts 1.1.1.80 Heartbeat-Master 1.1.1.81 Heartbeat-Slave [root@Heartbeat-Master ~]# yum install epel-release -y [root@Heartbeat-Master ~]# yum install heartbeat #heartbeat会默认安装下面的软件 [root@Heartbeat-Master ~]# yum install PyXML keyutils libevent libgssglue libnl libtalloc libtdb libtevent libtirpc libtool-ltdl pkgconfig quota resource-agents cluster-glue cluster-glue-libs perl-TimeDate Dependencies Resolved ===================================================================================================================================== Package Arch Version Repository Size ===================================================================================================================================== Installing: heartbeat x86_64 3.0.4-2.el6 epel 161 k Installing for dependencies: PyXML x86_64 0.8.4-19.el6 base 892 k cifs-utils x86_64 4.8.1-20.el6 base 65 k cluster-glue x86_64 1.0.5-6.el6 base 71 k cluster-glue-libs x86_64 1.0.5-6.el6 base 116 k heartbeat-libs x86_64 3.0.4-2.el6 epel 263 k keyutils x86_64 1.4-5.el6 base 39 k libevent x86_64 1.4.13-4.el6 base 66 k libgssglue x86_64 0.1-11.el6 base 23 k libnl x86_64 1.1.4-2.el6 base 121 k libtalloc x86_64 2.1.5-1.el6_7 updates 26 k libtdb x86_64 1.3.8-1.el6_7 updates 43 k libtevent x86_64 0.9.26-2.el6_7 updates 29 k libtirpc x86_64 0.2.1-10.el6 base 79 k libtool-ltdl x86_64 2.2.6-15.5.el6 base 44 k nfs-utils x86_64 1:1.2.3-64.el6 base 331 k nfs-utils-lib x86_64 1.1.5-11.el6 base 68 k perl-TimeDate noarch 1:1.16-13.el6 base 37 k pkgconfig x86_64 1:0.23-9.1.el6 base 70 k python-argparse noarch 1.2.1-2.1.el6 base 48 k quota x86_64 1:3.17-23.el6 base 202 k resource-agents x86_64 3.9.5-24.el6_7.1 updates 365 k rpcbind x86_64 0.2.0-11.el6_7 updates 51 k samba-common x86_64 3.6.23-30.el6_7 updates 10 M samba-winbind x86_64 3.6.23-30.el6_7 updates 2.2 M samba-winbind-clients x86_64 3.6.23-30.el6_7 updates 2.0 M tcp_wrappers x86_64 7.6-57.el6 base 61 k Updating for dependencies: keyutils-libs x86_64 1.4-5.el6 base 20 k Transaction Summary ===================================================================================================================================== Install 27 Package(s) Upgrade 1 Package(s) Total download size: 18 M [root@Heartbeat-Master ~]# cd /usr/share/doc/heartbeat-3.0.4/ [root@Heartbeat-Master heartbeat-3.0.4]# cp ha.cf haresources authkeys /etc/ha.d/ |
配置文件:
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 28 |
[root@Heartbeat-01 ha.d]# chmod 600 authkeys [root@Heartbeat-01 ha.d]# cp ha.cf ha.cf.bk [root@Heartbeat-01 ha.d]# cp haresources haresources.bk [root@Heartbeat-01 ha.d]# cp authkeys authkeys.bk [root@Heartbeat-Master ~]# cat /etc/ha.d/authkeys auth 1 1 sha1 635b557bdcbfcdfb9c7e0e32c537e95aa192d02f [root@Heartbeat-Master ~]# cat /etc/ha.d/ha.cf # Heartbeat Config debugfile /var/log/ha_debug #调试日志 logfile /var/log/ha_log #生产日志 logfacility local1 #syslog日志通过local1设备来接收日志 keepalive 2 #指定心跳间隔 deadtime 30 #备用如果设置30是没有收到心跳信号,则接管设备 warntime 10 #指定心跳延时为10s,当10s内收不到主节点心跳信号,则在日志打印警告信息 initdead 60 #指定在heartbeat首次运行后,需要等待120s才启动主服务器的资源,用于解决一般取值为deadtime的两倍 #bcast eth1 mcast eth1 225.0.0.99 695 1 0 #广播端口。694为默认端口号 auto_failback on #用来定义主节点恢复后,是否将服务自动切回 node Heartbeat-Master #主节点主机名 node Heartbeat-Slave #备用节点主机名 crm no #是否开启crm集群资源管理功能 [root@Heartbeat-Master ~]# cat /etc/ha.d/haresources # Heartberat services Heartbeat-Master IPaddr::1.1.1.180/24/eth0 httpd Heartbeat-Slave IPaddr::1.1.1.181/24/eth0 |
haresources默认配置:
0 1 2 3 4 |
[root@Heartbeat-01 ~]# cat /etc/ha.d/haresources #Heartbeat-01的vip地址为200 Heartbeat-01 IPaddr::1.1.1.200/24/eth0 #Heartbeat-02的vip地址为201,当Heartbeat-02不启动的时候,则vip漂移到01服务上,当02启动则飘回02上 Heartbeat-02 IPaddr::1.1.1.201/24/eth0 |
haresources自启动http服务案例:
0 1 2 3 4 5 6 7 |
[root@Heartbeat-01 ~]# chkconfig httpd off #禁止httpd开机自启动,交由heartbeat负责 [root@Heartbeat-01 ~]# cp /etc/init.d/httpd /etc/ha.d/resource.d/ [root@Heartbeat-01 ~]# /etc/init.d/httpd stop #ResourceManager(default)[5871]: 2015/09/05_09:29:57 info: Running /etc/ha.d/resource.d/httpd start [root@Heartbeat-01 ~]# cat /etc/ha.d/haresources #vip和httpd服务是绑定关系哟。。vip漂移,则服务也漂移 Heartbeat-01 IPaddr::1.1.1.200/24/eth0 httpd # Heartbeat-02 IPaddr::1.1.1.201/24/eth0 |
防火墙:
0 1 |
[root@Heartbeat-Master ~]# iptables -A INPUT -s 10.10.10.81/32 -p udp --dport 695 -j ACCEPT [root@Heartbeat-Slave ~]# iptables -A INPUT -i eth1 -p udp -s 10.10.10.80 --dport 695 -m comment --comment "heartbeat-Master" -j ACCEPT |
错误:
0 |
Error: Cannot retrieve metalink for repository: epel. Please verify its path and try again |
解决:
0 1 2 3 4 |
[root@Heartbeat-Master ~]# head -4 /etc/yum.repos.d/epel.repo [epel] name=Extra Packages for Enterprise Linux 6 - $basearch baseurl=http://download.fedoraproject.org/pub/epel/6/$basearch #mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-6&arch=$basearch |
错误:Failure: (127) Device minor not allocated
0 1 2 3 4 5 |
[root@Heartbeat-Master ~]# /etc/init.d/heartbeat start Starting High-Availability services: 0: Failure: (127) Device minor not allocated additional info from kernel: unknown minor Command 'drbdsetup role 0' terminated with exit code 10 INFO: Resource is stopped |
解决:
0 |
[root@Heartbeat-Slave ~]# drbdadm create-md data |
[root@Heartbeat-01 tools]# 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.20 Bcast:10.162.47.255 Mask:255.255.240.0 eth1
inet addr:10.128.0.10 Bcast:10.255.255.255 Mask:255.0.0.0 eth2
inet addr:127.0.0.1 Mask:255.0.0.0 lo
[root@Heartbeat-01 tools]# tail -2 /etc/hosts
1.1.1.110 Heartbeat-01
1.1.1.111 Heartbeat-02
[root@Heartbeat-01 tools]# route add -host 10.162.32.21 dev eth1 SourceByrd's Weblog-https://note.t4x.org/service/high-availability-services-heartbeat-install/
[root@Heartbeat-02 tools]# 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.21 Bcast:10.162.47.255 Mask:255.255.240.0 eth1
inet addr:10.128.0.11 Bcast:10.255.255.255 Mask:255.0.0.0 eth2
inet addr:127.0.0.1 Mask:255.0.0.0 lo
[root@Heartbeat-02 tools]# tail -2 /etc/hosts
1.1.1.110 Heartbeat-01
1.1.1.111 Heartbeat-02
[root@Heartbeat-02 tools]# route add -host 10.162.32.20 dev eth1 SourceByrd's Weblog-https://note.t4x.org/service/high-availability-services-heartbeat-install/
0 1 2 3 4 5 6 7 8 |
[root@Heartbeat-01 tools]# tar jxf 958e11be8686.tar.bz2 [root@Heartbeat-01 tools]# cd Heartbeat-3-0-958e11be8686/ groupadd -r haclient -g 497 #建立系统组haclient useradd -r hacluster -u 497 -g haclient -d /var/lib/heartbeat/cores/hacluster -s /sbin/nologin [root@Heartbeat-01 Heartbeat-3-0-958e11be8686]# yum install autoconf automake libtool glib2-devel libxml2-devel bzip2-devel e2fsprogs-devel libxslt-devel libtool-ltdl-devel libtool-ltdl cmake asciidoc [root@Heartbeat-01 Heartbeat-3-0-958e11be8686]# ./bootstrap [root@Heartbeat-01 Heartbeat-3-0-958e11be8686]# export CFLAGS="$CFLAGS -I/usr/local/heartbeat/include -L/usr/local/heartbeat/lib" [root@Heartbeat-01 Heartbeat-3-0-958e11be8686]# ./configure --prefix=/byrd/service/heartbeat --with-daemon-user=hacluster --with-daemon-group=haclient --enable-fatal-warnings=no LIBS='/lib64/libuuid.so.1' [root@Heartbeat-01 Heartbeat-3-0-958e11be8686]# make && make install |
错误:
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 28 29 30 31 32 33 34 35 36 37 38 39 |
Q: configure: error: in `/byrd/tools/Heartbeat-3-0-958e11be8686': configure: error: Core development headers were not found See `config.log' for more details. A: [root@Heartbeat-01 tools]# wget http://hg.linux-ha.org/glue/archive/0a7add1d9996.tar.bz2 [root@Heartbeat-01 tools]# cd Reusable-Cluster-Components-glue--0a7add1d9996/ [root@Heartbeat-01 Reusable-Cluster-Components-glue--0a7add1d9996]# ./autogen.sh [root@Heartbeat-01 Reusable-Cluster-Components-glue--0a7add1d9996]# ./configure --prefix=/byrd/service/heartbeat --with-daemon-user=hacluster --with-daemon-group=haclient --enable-fatal-warnings=no LIBS='/lib64/libuuid.so.1' [root@Heartbeat-01 Heartbeat-3-0-958e11be8686]# ln -s /byrd/service/heartbeat /usr/local/heartbeat [root@Heartbeat-01 Reusable-Cluster-Components-glue--0a7add1d9996]# make && make install [root@Heartbeat-01 tools]# wget https://github.com/ClusterLabs/resource-agents/archive/v3.9.6.tar.gz [root@Heartbeat-01 tools]# cd resource-agents-3.9.6 [root@Heartbeat-01 resource-agents-3.9.6]# ./autogen.sh [root@Heartbeat-01 resource-agents-3.9.6]# make Q: ./.libs/libplumb.so: undefined reference to `uuid_parse' ./.libs/libplumb.so: undefined reference to `uuid_generate' ./.libs/libplumb.so: undefined reference to `uuid_copy' ./.libs/libplumb.so: undefined reference to `uuid_is_null' ./.libs/libplumb.so: undefined reference to `uuid_unparse' ./.libs/libplumb.so: undefined reference to `uuid_clear' ./.libs/libplumb.so: undefined reference to `uuid_compare' collect2: ld returned 1 exit status gmake[2]: *** [ipctest] Error 1 gmake[2]: Leaving directory `/byrd/tools/Reusable-Cluster-Components-glue--0a7add1d9996/lib/clplumbing' gmake[1]: *** [all-recursive] Error 1 gmake[1]: Leaving directory `/byrd/tools/Reusable-Cluster-Components-glue--0a7add1d9996/lib' make: *** [all-recursive] Error 1 A: [root@Heartbeat-01 Reusable-Cluster-Components-glue--0a7add1d9996]# make clean [root@Heartbeat-01 Reusable-Cluster-Components-glue--0a7add1d9996]# ./configure LIBS='/lib64/libuuid.so.1' Q: gmake[2]: a2x: Command not found A: [root@Heartbeat-01 Reusable-Cluster-Components-glue--0a7add1d9996]# yum install asciidoc Q: ../heartbeat/IPv6addr: error while loading shared libraries: libplumb.so.2: cannot open shared object file: No such file or directory gmake[1]: *** [metadata-IPv6addr.xml] Error 127 A:YUM INSTALL cluster-glue-libs -y |
cankao:http://wangzhijian.blog.51cto.com/6427016/1708694SourceByrd's Weblog-https://note.t4x.org/service/high-availability-services-heartbeat-install/ SourceByrd's Weblog-https://note.t4x.org/service/high-availability-services-heartbeat-install/