HA Cluster基础及heartbeat实现HA

配置环境

node1:192.168.1.121CentOS6.7

node2:192.168.1.122CentOS6.7

node3:192.168.1.123CentOS6.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

[root@node1 ha.d]# cp /usr/share/doc/heartbeat-2.1.4/{ha.cf,haresources,authkeys} /etc/ha.d/

[root@node1 ha.d]# cd /etc/ha.d/

[root@node1 ha.d]# chmod 600 authkeys

[root@node1 ha.d]# openssl rand -base64 4

nuGXcw==

[root@node1 ha.d]# vim authkeys 

修改

#auth 1

#2 sha1 HI!

auth 2

2 sha1 nuGXcw==

[root@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

[root@node1 ha.d]# vim haresources 

在末尾添加

node1   192.168.1.80/16/eth0/192.168.255.255 httpd

[root@node1 ha.d]# scp -p authkeys ha.cf haresources node2:/etc/ha.d

[root@node1 ha.d]# scp -p authkeys ha.cf haresources node3:/etc/ha.d

[root@node1 ~]# vim /var/www/html/index.html

<h1>node1.magedu.com</h1>

[root@node1 ~]# service httpd stop

Stopping httpd:                                            [  OK  ]

[root@node1 ~]# chkconfig httpd off

[root@node2 ~]# vim /var/www/html/index.html

<h1>node2.magedu.com</h1>

[root@node2 ~]# service httpd stop

Stopping httpd:                                            [  OK  ]

[root@node2 ~]# chkconfig httpd off

[root@node3 ~]# vim /var/www/html/index.html

<h1>node3.magedu.com</h1>

[root@node3 ~]# service httpd stop

Stopping httpd:                                            [  OK  ]

[root@node3 ~]# chkconfig httpd off

[root@node1 ha.d]# ansible ha -m service -a 'name=heartbeat state=started'

03HA Cluster概念扩展及heartbeat实现

使自己变成备用结点

[root@node1 heartbeat]# /usr/lib64/heartbeat/hb_standby

使用变回主结点

[root@node1 heartbeat]# /usr/lib64/heartbeat/hb_takeover 

[root@node3 ~]# mkdir /web/htdocs -pv

[root@node3 ~]# vim /web/htdocs/index.html

<h1>Page On NFS Server</h1>

[root@node3 ~]# vim /etc/exports 

/web/htdocs     192.168.1.0/24(rw,no_root_squash)

[root@node3 ~]# service nfs start

[root@node1 heartbeat]# service heartbeat stop;ssh node2 'service heartbeat stop'

[root@node1 ~]# cd /etc/ha.d/

[root@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

[root@node1 ha.d]# service heartbeat start;ssh node2 'service heartbeat start'

转载于:https://blog.51cto.com/sihua/1856054

34补1-2_3 HA Cluster基础及heartbeat实现HA相关推荐

  1. 在haoodp-2.7.3 HA的基础上安装Hbase HA

    前提安装好hadoop基于QJM的高可用 node1 HMaster node2 HMaster.HRegionServer node3 HRegionServer node4 HRegionServ ...

  2. 2015年10月18日-10月24日课程作业(HA Cluster)

    1.阐述Linux HA Cluster的使用背景: HA Cluster基础理论及配置 2.总结Linux HA Cluster的系统组成,HA Cluster的工作模型: HA Cluster基础 ...

  3. Linux HA Cluster高可用集群之HeartBeat2

    一.阐述Linux HA Cluster的使用背景: 1.1 高可用集群定义: 高可用集群全称:High Availability Cluster,简单的说,集群就是一组高可扩展.高可用性.高性价比的 ...

  4. Redhat Ha Cluster -(转)

    Redhat Ha Cluster LinuxUla   2009-06-25 23:50 一 集群概念 1 集群:集群是一组协同工作的服务实体,用来提供比单一服务实体更具扩展性以及可用性的服务平台. ...

  5. VMware HA实战攻略之四VMware HA安装及配置

    [IT168 专稿]在前面三篇文章中(点击1.2.3),不但讲述了如何准备适合虚拟化的硬件.软件,以及如何使用现有的硬件.软件搭建一套实验环境,还讲述了通过VC Server如何添加主机和ISCSI存 ...

  6. CentOS6安装NFS HA架构部署(NFS + Heartbeat + DRBD)

    因业务需求,使用NFS共享服务,为了避免硬件故障导致的服务不可用,使用NFS + Heartbeat + DRBD架构实现NFS高可用.(我当时在测试环境操作的/dev/sdb 有时候写成了/dev/ ...

  7. oracle rac和ha对比,双机热备(HA),dg和RAC区别

    Data Guard 是Oracle的远程复制技术,它有物理和逻辑之分,但是总的来说,它需要在异地有一套独立的系统,这是两套硬件配置可以不同的系统,但是这两套系统的软件结构保持一致,包括软件的版本,目 ...

  8. 此HA非彼HA!FusionSphere这两种HA你分清楚了吗?

    华为FusionSphere中有两个HA的概念,分别是主机组​​(Host Aggregate)​​​和高可用​​(Highly Available)​​. 一.Host Aggregate ​​Fu ...

  9. android 自动补全方法,Android零基础入门|自动完成文本框AutoCompleteTextView

    原标题:Android零基础入门|自动完成文本框AutoCompleteTextView 上一期学习的Spinner的使用,掌握的怎么样?本期一起来学习AutoCompleteTextView的使用. ...

最新文章

  1. MapReduce编程初体验
  2. 获得 DataSet中的记录总数
  3. 二叉树的前中后序遍历之迭代法(非统一风格迭代方式)
  4. python扫描ip的端口打开情况
  5. 【转】面试题:将多个集合合并成没有交集的集合
  6. 基于Qt语音识别功能
  7. 调用新浪微博显示用户信息
  8. 全国大数据分析系统基于vue echarts
  9. 年薪10万的人,都是怎么努力的?
  10. cisco route;0x2142和0x2102模式
  11. 用Auto.js批量删除空间说说
  12. ACE_Message_QueueACE_MT_SYNCH::putq ()使用时需要注意的地方
  13. 全键盘 linux 手机,当年青葱的岁月:10佳全键盘智能手机盘点
  14. 已知点的经纬度坐标计算/读取DEM高程信息/海拔高度
  15. 自学anaconda的正确姿势
  16. Mac如何查找m3u8视频链接,并下载
  17. 微信小程序使用crypto.js加密解密
  18. c/c++编程学习:空指针是什么?
  19. 新媒体短视频运营哪些内容
  20. 相机中的光 —— 什么是F数,快门速度,感光度

热门文章

  1. 深入理解 JavaScript 中的 replace 方法
  2. 在SQL Server 2008中配置文件流(FILESTREAM)
  3. JSON.stringify()
  4. android 每个块半径不同的扇形图,自定义view
  5. 菜鸟学习之linux用户行为日志审计方案
  6. Android中修改弹出dialog背景无色透明,弹出时有遮罩
  7. 'libxml/tree.h' file not found
  8. Android安卓游戏引擎大搜罗
  9. linux常用运维工具uptime、iostat、vmstat、sar
  10. 上交2017计算机专业就业,上海交通大学计算机科学与工程系(CSE)