- 论坛徽章:
- 0
|
keepalived.conf配置就如上,从/var/log/keepalived.log日志看到master/slave是有效的
master keepalived日志- Dec 5 16:29:56 ubuntu-lvs-74 Keepalived[1155]: Starting Keepalived v1.2.13 (12/02,2014)
- Dec 5 16:29:56 ubuntu-lvs-74 Keepalived[1156]: Starting Healthcheck child process, pid=1158
- Dec 5 16:29:56 ubuntu-lvs-74 Keepalived[1156]: Starting VRRP child process, pid=1159
- Dec 5 16:29:56 ubuntu-lvs-74 Keepalived_vrrp[1159]: Netlink reflector reports IP 172.18.8.74 added
- Dec 5 16:29:56 ubuntu-lvs-74 Keepalived_vrrp[1159]: Netlink reflector reports IP fe80::5054:ff:feee:2149 added
- Dec 5 16:29:56 ubuntu-lvs-74 Keepalived_vrrp[1159]: Registering Kernel netlink reflector
- Dec 5 16:29:56 ubuntu-lvs-74 Keepalived_vrrp[1159]: Registering Kernel netlink command channel
- Dec 5 16:29:56 ubuntu-lvs-74 Keepalived_vrrp[1159]: Registering gratuitous ARP shared channel
- Dec 5 16:29:56 ubuntu-lvs-74 Keepalived_vrrp[1159]: Opening file '/etc/keepalived/keepalived.conf'.
- Dec 5 16:29:56 ubuntu-lvs-74 Keepalived_healthcheckers[1158]: Initializing ipvs 2.6
- Dec 5 16:29:56 ubuntu-lvs-74 Keepalived_vrrp[1159]: Configuration is using : 61452 Bytes
- Dec 5 16:29:56 ubuntu-lvs-74 Keepalived_vrrp[1159]: Using LinkWatch kernel netlink reflector...
- Dec 5 16:29:56 ubuntu-lvs-74 Keepalived_vrrp[1159]: VRRP sockpool: [ifindex(2), proto(112), unicast(0), fd(10,11)]
- Dec 5 16:29:56 ubuntu-lvs-74 Keepalived_healthcheckers[1158]: Netlink reflector reports IP 172.18.8.74 added
- Dec 5 16:29:56 ubuntu-lvs-74 Keepalived_healthcheckers[1158]: Netlink reflector reports IP fe80::5054:ff:feee:2149 added
- Dec 5 16:29:56 ubuntu-lvs-74 Keepalived_healthcheckers[1158]: Registering Kernel netlink reflector
- Dec 5 16:29:56 ubuntu-lvs-74 Keepalived_healthcheckers[1158]: Registering Kernel netlink command channel
- Dec 5 16:29:56 ubuntu-lvs-74 Keepalived_healthcheckers[1158]: Opening file '/etc/keepalived/keepalived.conf'.
- Dec 5 16:29:56 ubuntu-lvs-74 Keepalived_healthcheckers[1158]: Configuration is using : 13705 Bytes
- Dec 5 16:29:56 ubuntu-lvs-74 Keepalived_healthcheckers[1158]: Using LinkWatch kernel netlink reflector...
- Dec 5 16:29:56 ubuntu-lvs-74 Keepalived_healthcheckers[1158]: Activating healthchecker for service [172.18.8.74]:6379
- Dec 5 16:29:56 ubuntu-lvs-74 Keepalived_healthcheckers[1158]: Activating healthchecker for service [172.18.8.73]:6379
- Dec 5 16:29:57 ubuntu-lvs-74 Keepalived_vrrp[1159]: VRRP_Instance(VI_1{) Transition to MASTER STATE
- Dec 5 16:29:58 ubuntu-lvs-74 Keepalived_vrrp[1159]: VRRP_Instance(VI_1{) Entering MASTER STATE
- Dec 5 16:30:05 ubuntu-lvs-74 Keepalived_vrrp[1159]: VRRP_Instance(VI_1{) Received lower prio advert, forcing new election
复制代码 从keepalived日志- Dec 5 16:30:04 ubuntu-lvs-73 Keepalived[1153]: Starting Keepalived v1.2.13 (12/02,2014)
- Dec 5 16:30:04 ubuntu-lvs-73 Keepalived[1154]: Starting Healthcheck child process, pid=1156
- Dec 5 16:30:04 ubuntu-lvs-73 Keepalived[1154]: Starting VRRP child process, pid=1157
- Dec 5 16:30:04 ubuntu-lvs-73 Keepalived_vrrp[1157]: Netlink reflector reports IP 172.18.8.73 added
- Dec 5 16:30:04 ubuntu-lvs-73 Keepalived_vrrp[1157]: Netlink reflector reports IP fe80::5054:ff:fe6d:9c66 added
- Dec 5 16:30:04 ubuntu-lvs-73 Keepalived_vrrp[1157]: Registering Kernel netlink reflector
- Dec 5 16:30:04 ubuntu-lvs-73 Keepalived_vrrp[1157]: Registering Kernel netlink command channel
- Dec 5 16:30:04 ubuntu-lvs-73 Keepalived_vrrp[1157]: Registering gratuitous ARP shared channel
- Dec 5 16:30:04 ubuntu-lvs-73 Keepalived_vrrp[1157]: Opening file '/etc/keepalived/keepalived.conf'.
- Dec 5 16:30:04 ubuntu-lvs-73 Keepalived_vrrp[1157]: Configuration is using : 61452 Bytes
- Dec 5 16:30:04 ubuntu-lvs-73 Keepalived_vrrp[1157]: Using LinkWatch kernel netlink reflector...
- Dec 5 16:30:04 ubuntu-lvs-73 Keepalived_vrrp[1157]: VRRP sockpool: [ifindex(2), proto(112), unicast(0), fd(10,11)]
- Dec 5 16:30:04 ubuntu-lvs-73 Keepalived_healthcheckers[1156]: Initializing ipvs 2.6
- Dec 5 16:30:04 ubuntu-lvs-73 Keepalived_healthcheckers[1156]: Netlink reflector reports IP 172.18.8.73 added
- Dec 5 16:30:04 ubuntu-lvs-73 Keepalived_healthcheckers[1156]: Netlink reflector reports IP fe80::5054:ff:fe6d:9c66 added
- Dec 5 16:30:04 ubuntu-lvs-73 Keepalived_healthcheckers[1156]: Registering Kernel netlink reflector
- Dec 5 16:30:04 ubuntu-lvs-73 Keepalived_healthcheckers[1156]: Registering Kernel netlink command channel
- Dec 5 16:30:04 ubuntu-lvs-73 Keepalived_healthcheckers[1156]: Opening file '/etc/keepalived/keepalived.conf'.
- Dec 5 16:30:04 ubuntu-lvs-73 Keepalived_healthcheckers[1156]: Configuration is using : 13705 Bytes
- Dec 5 16:30:04 ubuntu-lvs-73 Keepalived_healthcheckers[1156]: Using LinkWatch kernel netlink reflector...
- Dec 5 16:30:04 ubuntu-lvs-73 Keepalived_healthcheckers[1156]: Activating healthchecker for service [172.18.8.74]:6379
- Dec 5 16:30:04 ubuntu-lvs-73 Keepalived_healthcheckers[1156]: Activating healthchecker for service [172.18.8.73]:6379
- Dec 5 16:30:05 ubuntu-lvs-73 Keepalived_vrrp[1157]: VRRP_Instance(VI_1{) Transition to MASTER STATE
- Dec 5 16:30:05 ubuntu-lvs-73 Keepalived_vrrp[1157]: VRRP_Instance(VI_1{) Received higher prio advert
- Dec 5 16:30:05 ubuntu-lvs-73 Keepalived_vrrp[1157]: VRRP_Instance(VI_1{) Entering BACKUP STATE
复制代码 参考文章:heylinux.com/archives/1942.html
现在遇到的问题:
1、keepalived主备都会监听虚拟IP?
VIP创建代码:- #!/bin/bash
- vip=172.18.8.100
- ifconfig lo:0 $vip netmask 255.255.255.255 broadcast $vip up
- route add -host $vip dev lo:0 #add router
- #echo "0" >/proc/sys/net/ipv4/ip_forward #close real server ip forward
- echo "1" >/proc/sys/net/ipv4/conf/lo/arp_ignore
- echo "2" >/proc/sys/net/ipv4/conf/lo/arp_announce
- echo "1" >/proc/sys/net/ipv4/conf/all/arp_ignore
- echo "2" >/proc/sys/net/ipv4/conf/all/arp_announce
复制代码 root@ubuntu-lvs-73:/var/lock# ip a #执行查看VIP绑定,结果主备都一样
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet 172.18.8.100/32 brd 172.18.8.100 scope global lo:0
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2、keepalived.conf中vrrp_script,vrrp_instance中的shell脚本不执行(sh脚本运行会输出日志,但实际没有发现日志文件)- vrrp_script chk_redis {
- script "/etc/keepalived/scripts/redis_check.sh"
- interval 2
- }
- vrrp_instance VI_1{
- state MASTER
- interface eth0
- virtual_router_id 51
- priority 101
- authentication{
- auth_type PASS
- auth_pass redis
- }
- track_script{
- chk_redis
- }
- virtual_ipaddress{
- 172.18.8.100
- }
- notify_master /etc/keepalived/scripts/redis_master.sh
- notify_backup /etc/keepalived/scripts/redis_backup.sh
- notify_fault /etc/keepalived/scripts/redis_fault.sh
- notify_stop /etc/keepalived/scripts/redis_stop.sh
- }
复制代码 |
|