[root@localhost src]# ll
total 8
drwxr-xr-x 7 root root 4096 Mar 1 03:01 redhat
[root@localhost src]#
因为在装系统的时候没有装kernels的开发包这时候需要自己装
yum install kernel*
cd ipvsadm-1.24
make && make install
------------------------
Keepalived version : 1.1.17
Compiler : gcc
Compiler flags : -g -O2
Extra Lib : -lpopt -lssl -lcrypto
Use IPVS Framework : Yes
IPVS sync daemon support : Yes
Use VRRP Framework : Yes
Use LinkWatch : No
Use Debug flags : No
cp /usr/local/etc/sysconfig/keepalived /etc/sysconfig/
mkdir /etc/keepalived
cp /usr/local/etc/keepalived/keepalived.conf /etc/keepalived/
cp /usr/local/sbin/keepalived /usr/sbin/
! Configuration File for keepalived
real_server 192.168.1.117 80 {
! Configuration File for keepalived
real_server 192.168.1.117 80 {
如果在执行service keepalived start,启动不起来需要看日志
# tail /var/log/messages
Mar 30 12:05:15 localhost Keepalived_vrrp: bogus VRRP packet received on eth0 !!!
Mar 30 12:05:15 localhost Keepalived_vrrp: VRRP_Instance(VI_1) Dropping received VRRP packet...
Mar 30 12:05:16 localhost Keepalived_vrrp: ip address associated with VRID not present in received packet : -939415360
Mar 30 12:05:16 localhost Keepalived_vrrp: one or more VIP associated with VRID mismatch actual MASTER advert
#######如果是以上日志就是因为你所在的环境还有其他人在做keepalived,需要修改虚拟路由标识,因为默认是51.
#######如果还启动不了,那么你要是用的虚拟机做的实验的话,看看你虚拟机的时间date,这一点对虚拟机很重要的哟。
! Configuration File for keepalived
notification_email { ###定义接收信息的邮件地址
acassen@firewall.loc
failover@firewall.loc
sysadmin@firewall.loc
}
notification_email_from Alexandre.Cassen@firewall.loc
smtp_server 192.168.200.1 ####定义用于监控的smtp地址
smtp_connect_timeout 30
router_id LVS_DEVEL ###定义lvs负载均衡标示
}
state MASTER ###本机在该组中的所属的角色,只有MASTER和BACKUP两种状态,并且需要大写这些单词。
interface eth0 ###对外提供服务的网络接口
virtual_router_id 51 ###虚拟路由标识
priority 100 ###本机的在vrrp组的优先级
advert_int 1 ###主备同步检查时间间隔
authentication { ###主备之间通信验证设置
auth_type PASS
auth_pass 1111
}
virtual_ipaddress { ###虚拟ip地址,也就是vip地址。
192.168.200.16
}
}
delay_loop 6 ###健康检查时间间隔,单位是秒。
lb_algo rr ###负载均衡调度算法,互联网应用常使用wlc。
lb_kind NAT ###负载均衡转发规则,一般包括DR、NAT、TUN3种。常用DR模型。
nat_mask 255.255.255.0 ###DR模式这项没有
persistence_timeout 50 ###会话保持时间,单位是秒。
protocol TCP ###转发协议
weight 1 ###该realserver的权重
SSL_GET {
url {
path /
digest ff20ad2481f97b1754ef3e12ecd3a9cc
}
url {
path /mrtg/
digest 9b3a0c85a887a256d6939da88aabd8cd
}
connect_timeout 3
nb_get_retry 3
delay_before_retry 3
}
}
}