一、ha.cf的重要参数的说明
debugfile /var/log/ha-debug | heartbeat的调试日志存放的位置 |
logfile /var/log/ha-log | Heartbeat日志存放的位置 |
logfacility local1 | 在syslog服务中配置通过local1设备接收日志 |
keepalive 2 | 指定心跳的间隔时间为2秒(即每两秒在eth1上发送一次广播) |
deadtime 30 | 指定若备用节点在30秒内没有收到主节点的心跳信号,则立即接管主节点的服务资源。 |
warntime 10 | 指定心跳延迟的时间为10秒。当十秒盅内备份节点不能收到主节点的心跳信号的时候,就会往日志中写入一个警告日志,但是此时不会切换服务。 |
initdead 120 | 指定在heartbeat首次运行后,需要等待120秒才启动主服务器的任何资源,该选项用于解决这种情况产生的时间间隔,取值至少为deadtime的两倍,单机启动时会遇到VIP绑定很慢,为正常现想,改制设置的长的原因。 |
bcast eth1 | 指明心跳使用以太旺广播的方式在eth1接口上进行广播,如果使用两个世纪的网络来传送心跳则 bcast eth0 eth1 |
mcast eth2 225.0.0.1 694 10 | 设置广播通信使用的端口,694为默认的使用端口号 |
auto_failback on | 用来定义当主节点恢复后,是否将服务自动的切回 |
node data-1-1 | 主节点的主机名(可以用IP地址) |
node data-2-2 | 备节点的主机名(可以用IP地址) |
crm no | 是否开启cluster resource Manager(集群资源管理)功能 |
小结:mcast eth2 225.0.0.1 694 10
# Set up a multicast heartbeat medium # mcast [dev] [mcast group] [port] [ttl] [loop] # [dev] device to send/rcv heartbeats on # [mcast group] multicast group to join (class D multicast address # 224.0.0.0 - 239.255.255.255) # [port] udp port to sendto/rcvfrom (set this value to the # same value as "udpport" above) # [ttl] the ttl value for outbound heartbeats. this effects # how far the multicast packet will propagate(传播). (0-255) # Must be greater than zero. # [loop] toggles loopback for outbound multicast heartbeats. # if enabled, an outbound packet will be looped back and # received by the interface it was sent on. (0 or 1) # Set this value to zero. |
二、配置authkeys参数说明:
[root@i-3vsptbun ha.d]# cat /etc/ha.d/authkeys # Authentication file. Must be mode 600 #此处权限必须设置为600,因为是秘钥文件 # Must have exactly one auth directive at the front. #必须在前面有一个明确的认证指令 # auth send authentication using this method-id # Then, list the method and key that go with that method-id # Available methods: crc sha1, md5. Crc doesn't need/want a key. # You normally only have one authentication method-id listed in this file # Put more than one to make a smooth transition when changing auth # methods and/or keys. # sha1 is believed to be the "best", md5 next best. # crc adds no security, except from packet corruption. # Use only on physically secure networks. #auth 1 #1 crc #2 sha1 HI! #3 md5 Hello! |
/etc/ha.d/authkeys包含用于相互集群节点认证的预共享秘密。它只能被root用户读取,并且遵循以下格式:
auth <num>
<num> <algorithm> <secret>
num是一个简单的键索引,从1开始。通常,在authkeys文件中只有一个键。
algorithm是使用的签名算法。你可以使用 md5或者sha1; crc不建议使用(简单循环冗余校验,不安全)。
secret 是实际的身份验证密钥。
您可以使用生成的密钥创建authkeys文件,并使用以下shell攻击:
[root@i-70nqgk6y ~]# (echo -ne auth 1 "\n" 1 sha1 ; dd if=/dev/urandom bs=512 count=1 | openssl md5) >/etc/ha.d/authkeys
[root@i-c6eu61rg ~]#chmod 600 /etc/ha.d/authkeys