[[email protected] ~]# uname -n #<===配置heartbeat时,节点的主机名必须和 uname -n 命令的结果要一致 heartbeat [[email protected] ~]# crontab -l #<===时间同步很重要 #ntpdate by root */5 * * * * /usr/sbin/ntpdate ntp1.aliyun.com &>/dev/null [[email protected] ~]# release=`grep -o "[0-9]" /etc/redhat-release | head -1` [[email protected] ~]# cat <<eof>/etc/yum.repos.d/epel.repo > [epel] > name=epelrepo > baseurl=https://mirrors.aliyun.com/epel/${release}Server/\$basearch > gpgcheck=0 > enable=1 > eof [[email protected] ~]# yum -y install heartbeat #<===centos6.x下yum默认安装heartbeat版本是3.0.4,centos7.x下只能编译安装 [[email protected] ~]# cd /usr/share/doc/heartbeat-3.0.4/ [[email protected] heartbeat-3.0.4]# cp {ha.cf,haresources,authkeys} /etc/ha.d/ [[email protected] heartbeat-3.0.4]# cd /etc/ha.d/ [[email protected] ha.d]# chmod 600 /etc/ha.d/authkeys [[email protected] ha.d]# ip addr add 10.0.0.30/24 broadcast 10.0.0.255 dev eth0 #<===添加辅助VIP [[email protected] ha.d]# cat ha.cf #configure start by root debugfile /var/log/ha-debug logfile /var/log/ha-log logfacility local1 keepalive 2 deadtime 30 warntime 10 initdead 60 #bcast eth1 mcast eth0 225.0.0.20 694 1 0 auto_failback on node heartbeat #node heartbeat2 crm no #configure end by root [[email protected] ha.d]# cat authkeys auth 1 1 sha1 LfW+BX0CQVLls1hrumK9ejVCcfk= [[email protected] ha.d]# cat haresources #config by root heartbeat IPaddr::10.0.0.30/24/eth0 #heartbeat2 IPaddr::10.0.0.60/24/eth0 [[email protected] ha.d]# ll /etc/init.d/heartbeat -rwxr-xr-x. 1 root root 10485 Dec 3 2013 /etc/init.d/heartbeat [[email protected] ~]# /etc/init.d/heartbeat start Starting High-Availability services: INFO: Resource is stopped Done. [[email protected] ~]# netstat -lntup|grep heartbeat udp 0 0 0.0.0.0:35586 0.0.0.0:* 1525/heartbeat: wri udp 0 0 225.0.0.20:694 0.0.0.0:* 1525/heartbeat: wri [[email protected] ha.d]# chkconfig --add heartbeat [[email protected] ha.d]# chkconfig --level 3 heartbeat on
以上是单台heartbeat服务器配置,生产中双机热备heartbeat配置文件{ha.cf,authkeys,haresources}内容是一样的,这里心跳线配置步骤省略....
如遇安装报错,查看 /var/log/ha-log日志排查错误即可,heartbeat相对来说还是简单的。
更多详细知识参考好友博客 http://www.cnblogs.com/f-ck-need-u/p/8587882.html
原文地址:https://www.cnblogs.com/blog-tim/p/10764280.html
时间: 2024-10-10 03:33:38