1、Linux高可用
1.1说明
高可用,当A机器内存爆满B机器无法ping通A机器,这时候B机器就会将B机器的对应的服开启。
1.2安装
yum install -y heartbeat yum install -y libnet
1.3 配置
拷贝3个配置文件
cd /usr/share/doc/heartbeat-3.0.4 cp authkeys ha.cf haresources /etc/ha.d/ cd /etc/ha.d/
authkeys 文件内容
auth 3 3 md5 Hello!
ha.cf文件内容
debugfile /var/log/ha-debug logfile /var/log/ha.log logfacility local0 # 监听机器个数 keepalive 2 #死亡时间 deadtime 30 # 警告时间 warntime 10 initdead 60 # 监听端口 udpport 694 # 通过那个网卡和其他ha机器保持通信 bcast eth0 auto_failback on #当前ha的多个节点,master需要在 /etc/hosts 中配置 node master node slave # 路由器ip ping 192.168.1.1 # 销毁ip的命令 respawn hacluster /usr/lib64/heartbeat/ipfail
haresource 文件
master 192.168.1.109/24/eth0:1 nginx # master ha主机的 hostname # 192.168.1.109 虚拟IP,用来访问的IP地址 # 24 ip地址通道 # eth0 网卡名 # :1 同一张网卡的另一个ip # nginx 监控的服务名,多个空空格隔开
启动服务
/etc/init.d/heartbeat start