|
vi ha.cf //改为如下内容:
debugfile /var/log/ha-debug
logfile /var/log/ha-log
logfacility local0
keepalive 2 2秒打一次招呼
deadtime 30
warntime 10
initdead 60
initdead 120
udpport 694
ucast eth1 10.0.11.12 心跳线对方的ip
auto_failback on 如果为on 主节点故障修复后上线,会抢占主的位置。
node zhu
node cong
ping 10.0.11.88 ping 仲裁
respawn hacluster /usr/lib/heartbeat/ipfail ping检测的工具
7. 把主上的三个配置拷贝到从上:
cd /etc/ha.d/
scp authkeys ha.cf haresources cong:/etc/ha.d/
8. 到从上(cong) 编辑ha.cf
vi /etc/ha.d/ha.cf //只需要更改一个地方
ucast eth1 10.0.11.12 改为 ucast eth1 10.0.11.11
9. 启动heartbeat :
先主,后从
/etc/init.d/heartbeat start
此时 报错了:
Starting High-Availability services: INFO: Running OK
CRITICAL: Resource 192.168.2.3/24/eth0:0 is active, and should not be!
CRITICAL: Non-idle resources can affect data integrity!
info: If you don't know what this means, then get help!
info: Read the docs and/or source to /usr/share/heartbeat/ResourceManager for more details.
CRITICAL: Resource 192.168.2.3/24/eth0:0 is active, and should not be!
CRITICAL: Non-idle resources can affect data integrity!
info: If you don't know what this means, then get help!
info: Read the docs and/or the source to /usr/share/heartbeat/ResourceManager for more details.
CRITICAL: Non-idle resources will affect resource takeback!
CRITICAL: Non-idle resources may affect data integrity!
Heartbeat failure [rc=6]. Failed.
heartbeat: udpport setting must precede media statementsheartbeat: baudrate setting must precede media statementsheartbeat[2371]: 2015/06/03_23:27:41 info: Pacemaker support: false
heartbeat[2371]: 2015/06/03_23:27:41 ERROR: Current node [di03] not in configuration!
heartbeat[2371]: 2015/06/03_23:27:41 info: By default, cluster nodes are named by `uname -n` and must be declared with a 'node' directive in the ha.cf file.
heartbeat[2371]: 2015/06/03_23:27:41 info: See also: http://linux-ha.org/wiki/Ha.cf#node_directive
heartbeat[2371]: 2015/06/03_23:27:41 WARN: Logging daemon is disabled --enabling logging daemon is recommended
heartbeat[2371]: 2015/06/03_23:27:41 ERROR: Configuration error, heartbeat not started.
这是因为当前的主机名和/etc/hosts里面定义不一样,在主从上执行 hostname zhu ;bash
在从节点上执行 hostname cong ;bash 在启动就能正常启动,当然这个时候充当仲裁的XP 得先启动好。
当然此时也可以先检查/etc/hosts里的是否有和此节点冲突的其他域名,此时网络误把相同的节点的ip的主机认为其他主机了。
比如在/etc/hosts下有
192.168.1.104 www.123.com
192.168.1.104 master
192.168.1.102 slave
10. 检查测试
ifconfig 看是否有 eth0:0
ps aux |grep nginx 看是否有nginx进程
现在开始测试
正常情况下 我们访问用nginx搭建的网站,假装我是用户,直接在浏览器输入网站的ip 192.168.2.60访问
|
|