主T800 eth0 192.168.2.32
备T600 eth1 192.168.2.33
安装nginx

yum install -y nginx

关闭主备的防火墙iptables、selinux

iptables -F ; service iptables save
setenforce
vim /etc/sysconfig/selinux
SELINUX=disabled

修改两台机的hosts文件

cat >> /etc/hosts << “EOF”
192.168.2.32 T800
192.168.2.33 T600
EOF

安装heartbeat、libnet

yum install -y heartbeat libnet

拷贝配置文件主机配置

cd /usr/share/doc/heartbeat-3.0.4/
cp authkeys ha.cf haresources /etc/ha.d/
chmod 600 /etc/ha.d/authkeys
cat >> /etc/ha.d/authkeys << “EOF”

auth
md5 hello!
EOF
cat >> /etc/ha.d/haresources << “EOF”
T800 192.168.2.132//eth0: nginx
EOF
cat > /etc/ha.d/ha.cf << “EOF”
debugfile /var/log/ha-debug
logfile /var/log/ha-log
logfacility local0
keepalive
deadtime
warntime
initdead
udpport
ucast eth0 192.168.2.33
auto_failback on
node T800
node T600
ping 192.168.2.1
respawn hacluster /usr/lib64/heartbeat/ipfail
EOF

备机配置

cd /usr/share/doc/heartbeat-3.0.4/
cp authkeys ha.cf haresources /etc/ha.d/
chmod 600 /etc/ha.d/authkeys
cat >> /etc/ha.d/authkeys << “EOF”

auth
md5 hello!
EOF
cat >> /etc/ha.d/haresources << “EOF”

T800 192.168.2.132//eth1: nginx
EOF
cat > /etc/ha.d/ha.cf << “EOF”

debugfile /var/log/ha-debug
logfile /var/log/ha-log
logfacility local0
keepalive
deadtime
warntime
initdead
udpport
ucast eth1 192.168.2.32
auto_failback on
node T800
node T600
ping 192.168.2.1
respawn hacluster /usr/lib64/heartbeat/ipfail
EOF

也可以用scp从主机拷贝到备机

scp authkeys haresources ha.cf T600:/etc/ha.d/

开启服务注意先后顺序先主后备

/etc/init.d/heartbeat start

区分两台主机名

echo T800 > /usr/share/nginx/html/index.html

测试

curl 192.168.2.132

测试

ifconfig

看是否有 eth0:0

ps aux |grep nginx

看是否有nginx进程

测试1
主上故意禁ping

iptables -I INPUT -p icmp -j DROP

测试2

主上停止heartbeat服务

service heartbeat stop

测试脑裂

主和从上都down掉eth0网卡

ifdown eth0

配置说明

debugfile /var/log/ha-debug #排障日志
logfile /var/log/ha-log #日志
logfacility local0 #日志的级别
keepalive 2 #多久去探测一次对面是否存活 2秒
deadtime 30 #30秒没反应,就认为挂掉了
warntime 10 #等待时间10秒
initdead 60 #防止对方服务器在重启 预留60秒
udpport 694 #心跳线通信端口
ucast eth0 192.168.2.33 #对方的ip
auto_failback on #如果备启动了,当主恢复备自动放弃
node T800
node T600
ping 192.168.2.1 #仲裁者 网关或者交换机
respawn hacluster /usr/lib64/heartbeat/ipfail #检测网络联通信

HA配置的更多相关文章

  1. Spark进阶之路-Spark HA配置

    Spark进阶之路-Spark HA配置 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 集群部署完了,但是有一个很大的问题,那就是Master节点存在单点故障,要解决此问题,就要借 ...

  2. 第九章 搭建Hadoop 2.2.0版本HDFS的HA配置

    Hadoop中的NameNode好比是人的心脏,非常重要,绝对不可以停止工作.在hadoop1时代,只有一个NameNode.如果该NameNode数据丢失或者不能工作,那么整个集群就不能恢复了.这是 ...

  3. 企业级hbase HA配置

    1 HBase介绍HBase是一个分布式的.面向列的开源数据库,就像Bigtable利用了Google文件系统(File System)所提供的分布式数据存储一样,HBase在Hadoop之上提供了类 ...

  4. Nchan 实时消息ha 配置

    备注:      Nchan 的数据持久化,以及ha 都是通过redis实现的,如果要做到无单点可以使用redis cluster     同对于Nchan server 进行多副本   1. 安装 ...

  5. hadoop-2.2.0 HA配置

    采用的是4台真实机器: namenode:qzhong  node27 datanode:qzhong node27 node100 node101 操作系统环境:qzhong(Ubuntu-14.0 ...

  6. 第7章 YARN HA配置

    目录 7.1 yarn-site.xm文件配置 7.2 测试YARN自动故障转移 ResourceManager (RM)负责跟踪集群中的资源,以及调度应用程序(例如,MapReduce作业).在Ha ...

  7. 第6章 HDFS HA配置

    目录 6.1 hdfs-site.xml文件配置 6.2 core-site.xml文件配置 6.3 启动与测试 6.4 结合ZooKeeper进行自动故障转移 在Hadoop 2.0.0之前,一个H ...

  8. Spark master节点HA配置

    Spark master节点HA配置 1.介绍 Spark HA配置需要借助于Zookeeper实现,因此需要先搭建ZooKeeper集群. 2.配置 2.1 修改所有节点的spark-evn.sh文 ...

  9. 使用QJM实现HDFS的HA配置

    使用QJM实现HDFS的HA配置 1.背景 hadoop 2.0.0之前,namenode存在单点故障问题(SPOF,single point of failure),如果主机或进程不可用时,整个集群 ...

  10. hadoop-2.3.0-cdh5.1.0完全分布式集群配置HA配置

    一.安装前准备: 操作系统:CentOS 6.5 64位操作系统 环境:jdk1.7.0_45以上,本次采用jdk-7u55-linux-x64.tar.gz master01 10.10.2.57  ...

随机推荐

  1. 【Windows、SVN】在Windows服务器下安装SVN,并在客户端能维护代码版本

    1.分别在客户端和服务器端安装软件 在网上搜索一下安装包的下载地址(这里暂不介绍) 得到2个安装文件 Server是装在服务器端的,另外一个装在客户端 2.安装SVN服务器端 基本一致下一步即可 特殊 ...

  2. 公司-ofo:ofo

    ylbtech-公司-ofo:ofo ofo小黄车是一个无桩共享单车出行平台,缔造了“无桩单车共享”模式,致力于解决城市出行问题.用户只需在微信公众号或App扫一扫车上的二维码或直接输入对应车牌号,即 ...

  3. generate ascii table

    $ cat ascii.sh dec_count=0 while [ $dec_count -lt 256 ] do echo -e "\x$(echo "ibase=10;oba ...

  4. 打开myeclipse出现这个错是为什么

  5. 转 loadrunner11 录制 chrome 浏览器

    chrome不设置代理的原始状态 图1 [LoadRunner]解决LR11无法录制Chrome浏览器脚本问题   LoadRunner录制脚本时,遇到高版本的IE.FireFox,或者Chrome浏 ...

  6. docker安装及使用

    一.简介 说起docker,大多数人第一时间想起来的应该有虚拟化.云计算,这三者有什么区别呢? 对比: 我们所熟知的虚拟化有KVM.xen.Hyper-V等,这些虚拟化虚拟出来的服务器会产生一个新的操 ...

  7. android中读取SD卡上的数据

    通过Context的openFileInput或者openFileOutput打开的文件输入输出流是操作应用程序的数据文件夹里的文件,这样存储的大小比较有限,为了更好的存取应用程序的大文件数据,应用程 ...

  8. js转义符

    \0 :null(\u0000) \b :后退键(\u0008) \f :换页符(\u000C) \n :换行符(\u000A) \r :回车键(\u000D) \t :制表符(\u0009) \v ...

  9. LeetCode Array Medium 11. Container With Most Water

    Description Given n non-negative integers a1, a2, ..., an , where each represents a point at coordin ...

  10. redis Set相关命令