设为首页 收藏本站
查看: 1061|回复: 0

[经验分享] HA Cluster基础及heartbeat实现HA

[复制链接]
累计签到:1 天
连续签到:1 天
发表于 2016-9-26 10:32:54 | 显示全部楼层 |阅读模式
HA Cluster基础及heartbeat实现HA

配置环境
node1:192.168.1.121        CentOS6.7
node2:192.168.1.122        CentOS6.7
node3:192.168.1.123        CentOS6.7
vip 192.168.1.80

配置前准备
   # cat /etc/hosts
                127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
                ::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
                192.168.1.121           node1
                192.168.1.122           node2
                192.168.1.123           node3
   #  ssh-keygen -t rsa -P ''
   #  ssh-copy-id -i ~/.ssh/id_rsa.pub node1
   #  ssh-copy-id -i ~/.ssh/id_rsa.pub node2
   #  ssh-copy-id -i ~/.ssh/id_rsa.pub node3               
   #  rpm -ivh epel-release-latest-6.noarch.rpm
   #  yum -y ansible
   #  yum -y install ansible
   # cat /etc/ansible/hosts
                [ha]
                192.168.1.121
                192.168.1.122
                192.168.1.123
   #  ansible ha -m copy -a 'src=/etc/hosts dest=/etc'               
   #  ansible ha -m shell -a 'ntpdate 192.168.1.62'
   # ansible ha -m cron -a 'minute="*/3" job="/usr/sbin/ntpdate 192.168.1.62" name="ntpdate"'
   # ansible ha -m copy -a 'src=/root/heartbeat2 dest=/root'

   node1、node2和node3
   #yum -y install net-snmp-libs libnet PyXML perl-Time-Date
   # ls heartbeat2/
                heartbeat-2.1.4-12.el6.x86_64.rpm                                #主程序包
                heartbeat-debuginfo-2.1.4-12.el6.x86_64.rpm               
                heartbeat-devel-2.1.4-12.el6.x86_64.rpm                       
                heartbeat-gui-2.1.4-12.el6.x86_64.rpm                #提供hb-gui的包,可以先不装
                heartbeat-ldirectord-2.1.4-12.el6.x86_64.rpm        #后端健康检测的工具
                heartbeat-pils-2.1.4-12.el6.x86_64.rpm
                heartbeat-stonith-2.1.4-12.el6.x86_64.rpm        #提供仲裁设备,节点隔离的包       

        # cd heartbeat2/
        # rpm -ivh heartbeat-2.1.4-12.el6.x86_64.rpm heartbeat-pils-2.1.4-12.el6.x86_64.rpm heartbeat-stonith-2.1.4-12.el6.x86_64.rpm


        [iyunv@node1 ha.d]# cp /usr/share/doc/heartbeat-2.1.4/{ha.cf,haresources,authkeys} /etc/ha.d/
        [iyunv@node1 ha.d]# cd /etc/ha.d/
        [iyunv@node1 ha.d]# chmod 600 authkeys
        [iyunv@node1 ha.d]# openssl rand -base64 4
                nuGXcw==
        [iyunv@node1 ha.d]# vim authkeys
        修改
                #auth 1
                #2 sha1 HI!
        为
                auth 2
                2 sha1 nuGXcw==
        [iyunv@node1 ha.d]# vim ha.cf
        修改
                #logfile    /var/log/ha-log
        为
                logfile    /var/log/ha-log
        修改
                logfacility local0
        为
                #logfacility    local0
        修改
                #mcast eth0 225.0.0.1 694 1 0
        为
                mcast eth0 225.23.190.1 694 1 0
        在node   kathy(212行左右)下添加
                node node1                #指明所有的node结束
                node node2
                node node3
        在#ping 10.10.10.254(223行左右)下添加
                ping 192.168.1.1                #仲裁设备
        修改
                #compression    bz2                        #是否压缩
                #compression_threshold 2        #多大的文件才压缩
        为
                compression bz2
                compression_threshold 2
        [iyunv@node1 ha.d]# vim haresources
        在末尾添加
                node1   192.168.1.80/16/eth0/192.168.255.255 httpd
        [iyunv@node1 ha.d]# scp -p authkeys ha.cf haresources node2:/etc/ha.d
        [iyunv@node1 ha.d]# scp -p authkeys ha.cf haresources node3:/etc/ha.d
        [iyunv@node1 ~]# vim /var/www/html/index.html
                <h1>node1.magedu.com</h1>
        [iyunv@node1 ~]# service httpd stop
        Stopping httpd:                                            [  OK  ]
        [iyunv@node1 ~]# chkconfig httpd off
        [iyunv@node2 ~]# vim /var/www/html/index.html
                <h1>node2.magedu.com</h1>
        [iyunv@node2 ~]# service httpd stop
        Stopping httpd:                                            [  OK  ]
        [iyunv@node2 ~]# chkconfig httpd off       
        [iyunv@node3 ~]# vim /var/www/html/index.html
                <h1>node3.magedu.com</h1>
        [iyunv@node3 ~]# service httpd stop
        Stopping httpd:                                            [  OK  ]
        [iyunv@node3 ~]# chkconfig httpd off       
        [iyunv@node1 ha.d]# ansible ha -m service -a 'name=heartbeat state=started'

03        HA Cluster概念扩展及heartbeat实现
        使自己变成备用结点
                [iyunv@node1 heartbeat]# /usr/lib64/heartbeat/hb_standby
        使用变回主结点
                [iyunv@node1 heartbeat]# /usr/lib64/heartbeat/hb_takeover

        [iyunv@node3 ~]# mkdir /web/htdocs -pv
        [iyunv@node3 ~]# vim /web/htdocs/index.html
                <h1>Page On NFS Server</h1>
        [iyunv@node3 ~]# vim /etc/exports
                /web/htdocs     192.168.1.0/24(rw,no_root_squash)
        [iyunv@node3 ~]# service nfs start
        [iyunv@node1 heartbeat]# service heartbeat stop;ssh node2 'service heartbeat stop'
        [iyunv@node1 ~]# cd /etc/ha.d/
        [iyunv@node1 ha.d]# vim haresources
        在末尾添加
                node1   192.168.1.80/16/eth0/192.168.255.255 Filesystem::192.168.1.123::/web/htdocs::/var/www/htm::nfs httpd
        [iyunv@node1 ha.d]# service heartbeat start;ssh node2 'service heartbeat start'



运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-277644-1-1.html 上篇帖子: heartbeat配置文件详解 下篇帖子: Heartbeat配置多播方式以及heartbeat安装脚本
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表