LVS+Keepalived 配置好 keepalived.conf 文件后, ipvsadm -ln 没有mapping的信息

Master config information:
[root@localhost keepalived]# more keepalived.conf
! Configuration File for keepalived

global_defs {
notification_email {
yan-long.jiang@hp.com
}
notification_email_from root@localhost.com
smtp_server 127.0.0.1
# smtp_connect_timeout 30
router_id LVS_DEVEL
}

# 20081013 written by :netseek
# VIP1
vrrp_instance VI_1 {
state MASTER #备份服务器上将MASTER改为BACKUP
interface eth0
virtual_router_id 51
priority 100 # 备份服务上将100改为99
advert_int 1
authentication {
auth_type PASS
auth_pass 1111
}
virtual_ipaddress {
16.158.69.108
#(如果有多个VIP,继续换行填写.)
}
}

virtual_server 16.158.69.108 80 {
delay_loop 6
lb_algo wrr
lb_kind DR
persistence_timeout 60
protocol TCP

real_server 16.158.69.199 80 {
weight 3
TCP_CHECK {
connect_timeout 10
nb_get_retry 3
delay_before_retry 3
connect_port 80
}
}
real_server 16.158.69.200 80 {
weight 3
TCP_CHECK {
connect_timeout 10
nb_get_retry 3
delay_before_retry 3
connect_port 80
}
}
}
Backup information:
[root@localhost keepalived]# more keepalived.conf
! Configuration File for keepalived

global_defs {
notification_email {
yan-long.jiang@hp.com
}
notification_email_from root@localhost.com
smtp_server 127.0.0.1
# smtp_connect_timeout 30
router_id LVS_DEVEL
}

# 20081013 written by :netseek
# VIP1
vrrp_instance VI_1 {
state BACKUP #备份服务器上将MASTER改为BACKUP
interface eth0
virtual_router_id 51
priority 99 # 备份服务上将100改为99
advert_int 1
authentication {
auth_type PASS
auth_pass 1111
}
virtual_ipaddress {
16.158.69.108
#(如果有多个VIP,继续换行填写.)
}
}

virtual_server 16.158.69.108 80 {
delay_loop 6
lb_algo wrr
lb_kind DR
persistence_timeout 60
protocol TCP

real_server 16.158.69.199 80 {
weight 3
TCP_CHECK {
connect_timeout 10
nb_get_retry 3
delay_before_retry 3
connect_port 80
}
}
real_server 16.158.69.200 80 {
weight 3
TCP_CHECK {
connect_timeout 10
nb_get_retry 3
delay_before_retry 3
connect_port 80
}
}
}
[root@localhost keepalived]#

[root@localhost keepalived]# service keepalived restart
停止 keepalived: [ 确定 ]
启动 keepalived: [ 确定 ]
[root@localhost keepalived]# ipvsadm -ln
IP Virtual Server version 1.2.0 (size=4096)
Prot LocalAddress:Port Scheduler Flags
-> RemoteAddress:Port Forward Weight ActiveConn InActConn
[root@localhost keepalived]#

不可以转发连接信息,不知道那里整错了,请高手指点一下...

Backup 日志信息到下面就不动了
[root@localhost keepalived]# tail -f /var/log/messages
May 13 05:55:08 localhost Keepalived_vrrp: Using MII-BMSR NIC polling thread...
May 13 05:55:08 localhost Keepalived_vrrp: Registering Kernel netlink reflector
May 13 05:55:08 localhost Keepalived_vrrp: Registering Kernel netlink command channel
May 13 05:55:08 localhost Keepalived_vrrp: Registering gratutious ARP shared channel
May 13 05:55:08 localhost Keepalived: Starting VRRP child process, pid=3350
May 13 05:55:08 localhost Keepalived_vrrp: Opening file '/etc/keepalived/keepalived.conf'.
May 13 05:55:08 localhost keepalived: keepalived 启动 succeeded
May 13 05:55:08 localhost Keepalived_vrrp: Configuration is using : 36168 Bytes
May 13 05:55:08 localhost Keepalived_vrrp: VRRP_Instance(VI_1) Entering BACKUP STATE
May 13 05:55:08 localhost Keepalived_vrrp: VRRP sockpool: [ifindex(2), proto(112), fd(7,8)]

Mater 的日志
[root@localhost keepalived]# tail -f /var/log/messages
May 13 05:50:21 localhost Keepalived_vrrp: Registering gratutious ARP shared channel
May 13 05:50:21 localhost Keepalived_vrrp: Opening file '/etc/keepalived/keepalived.conf'.
May 13 05:50:21 localhost Keepalived_vrrp: Configuration is using : 36168 Bytes
May 13 05:50:21 localhost Keepalived_vrrp: VRRP sockpool: [ifindex(2), proto(112), fd(7,8)]
May 13 05:50:21 localhost Keepalived: Starting VRRP child process, pid=3327
May 13 05:50:21 localhost keepalived: keepalived startup succeeded
May 13 05:50:22 localhost Keepalived_vrrp: VRRP_Instance(VI_1) Transition to MASTER STATE
May 13 05:50:23 localhost Keepalived_vrrp: VRRP_Instance(VI_1) Entering MASTER STATE
May 13 05:50:23 localhost Keepalived_vrrp: VRRP_Instance(VI_1) setting protocol VIPs.
May 13 05:50:23 localhost Keepalived_vrrp: VRRP_Instance(VI_1) Sending gratuitous ARPs on eth0 for 16.158.69.108

[root@localhost keepalived]#

Forums:

没有人顶呀...自己顶一家伙..

你的设置应该如下:

(1)真实服务器是linux,写下面的脚本,然后运行
#!/bin/bash
#description : start realserver
VIP=16.158.69.108
/etc/rc.d/init.d/functions
case "$1" in
start)
echo " start LVS of REALServer"
/sbin/ifconfig lo:0 $VIP broadcast $VIP netmask 255.255.255.255 up
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
;;
stop)
/sbin/ifconfig lo:0 down
echo "close LVS Directorserver"
echo "0" >/proc/sys/net/ipv4/conf/lo/arp_ignore
echo "0" >/proc/sys/net/ipv4/conf/lo/arp_announce
echo "0" >/proc/sys/net/ipv4/conf/all/arp_ignore
echo "0" >/proc/sys/net/ipv4/conf/all/arp_announce
;;
*)
echo "Usage: $0 {start|stop}"
exit 1
esac

(2)真是服务器是freebsd ,这脚本用这个:
#!/usr/local/bin/bash
#description : start realserver
VIP_OUT=16.158.69.108
case "$1" in
start)
echo " start LVS of REALServer"
/sbin/ifconfig lo0 $VIP_OUT netmask 255.255.255.255 alias -arp up
;;

stop)
/sbin/ifconfig lo0 alias down
echo "close LVS Directorserver"
/sbin/ifconfig lo0 127.0.0.1 arp up
;;
*)
echo "Usage: $0 {start|stop}"
exit 1
esac

祝你好运 田逸(sery@163.com)

注意编译keepalived的时候不要加debug参数。

lvs搭建中
我也有一个问题,我现在使用lvs/tun方式搭建集群,每个机器都有公网ip:
director:58.xxx.xxx.xxx
realserver1:202.194.xxx.xxx
realserver2:202.194.xxx.yyy
我现在是在学校里面,我们学院的网关上面为每一个ip绑定mac地址。我申请了一个ip,比如202.xxx.xxx.zzz作为我的vip,网关把这个 vip绑定一个mac地址,我就让他绑定了director的mac地址。结果是,我的集群只有局域网内的ip能够访问到它,外网访问不到它了。我想知道,如何设定vip,才能让外网访问到它?????你们的vip是不是没有绑定mac地址,只是使用一个大家没有用的ip就可以??
谢谢你们。

我也是这个问题,请问你是怎么解决的?

把service keepalived restart换成
service keepalived stop
service keepalived start
我这边用restart也是出不了mapping列表,但stop和start分开执行却没有问题。原因未知,可能和backup抢资源有关系。