Keepalived 安装与配置
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Keepalived 安装与配置相关的知识,希望对你有一定的参考价值。
下载:http://www.keepalived.org/
what is keepalived?
Keepalived is a routing software written in C. The main goal of this project is to provide simple and robust facilities for loadbalancing and high-availability to Linux system and Linux based infrastructures. Loadbalancing framework relies on well-known and widely used Linux Virtual Server (IPVS) kernel module providing Layer4 loadbalancing. Keepalived implements a set of checkers to dynamically and adaptively maintain and manage loadbalanced server pool according their health. On the other hand high-availability is achieved by VRRP protocol. VRRP is a fundamental brick for router failover. In addition, Keepalived implements a set of hooks to the VRRP finite state machine providing low-level and high-speed protocol interactions. Keepalived frameworks can be used independently or all together to provide resilient infrastructures.
下载源代码
./configure --prefix=/opt/keepalived
报错
configure: error: Popt libraries is required
安装popt开发包
yum install popt-devel
安装后configure输出信息
Keepalived configuration
------------------------
Keepalived version : 1.1.10
Compiler : gcc
Compiler flags : -g -O2
Extra Lib : -lpopt -lssl -lcrypto
Use IPVS Framework : No
IPVS sync daemon support : No
Use VRRP Framework : Yes
Use LinkWatch : No
Use Debug flags : No
我上面的IPVS都是no,为no不支持LVS.
看网上的说法
- Use IPVS Framework : Yes #使用ipvs框架,如果是做keepalive+ha可不要
- IPVS sync daemon support : Yes #对ipvs同步的支持
- Use VRRP Framework : Yes #keepalive的核心,必须有!
看网上说法要想IPVS为yes,要带上
--with-kernel-dir=/usr/src/kernels/2.6.18-164.el5-i686/
- #ln -s /usr/src/kernels/2.6.18-53.el5PAE-i686/ /usr/src/linux //生成一个链接文件
- 如果/usr/src/kernels没有2.6.18-194.el5,则需要编译
- #yum -y install kernel-devel
- #yum -y update kernel
- #cp /usr/src/kernels/2.6.18-274.el5/include/net/ip_vs.h /usr/inclide/net/ //这个很重要,否则在安装ipvsadm的时候会提示缺少*.h文件
我暂时没有支持IPVS.
- 安装完成之后,方了方便起见,请执行以下操作:
- 1、将安装目录里的/usr/local/keepalive/etc/rc.d/init.d/keepalived 复制到/etc/init.d (这里的安装目录改成自己的)
- 2、将安装目录里的配置文件/usr/local/keepalive/etc/keepalived/keepalived.conf 复制到/etc/keepalived/里。
keepalived默认配置文件
! Configuration File for keepalived global_defs { notification_email { 通知email [email protected] [email protected] [email protected] } notification_email_from [email protected] smtp_server 192.168.200.1 smtp_connect_timeout 30 router_id LVS_DEVEL
#节点名标识,主要用于通知中
} vrrp_instance VI_1 {
state MASTER
#配置为主服务器
interface eth0
#通讯网卡
virtual_router_id 100
#路由标识
priority 200
#优先级,0-254
advert_int 5
#通知间隔,实际部署时可以设置小一点,减少延时
authentication {
auth_type PASS
auth_pass 123456
#验证密码,用于通讯主机间验证
}
virtual_ipaddress { 192.168.200.16 192.168.200.17 192.168.200.18 } } virtual_server 192.168.200.100 443 { delay_loop 6 lb_algo rr lb_kind NAT nat_mask 255.255.255.0 persistence_timeout 50 protocol TCP real_server 192.168.201.100 443 { weight 1 SSL_GET { url { path / digest ff20ad2481f97b1754ef3e12ecd3a9cc } url { path /mrtg/ digest 9b3a0c85a887a256d6939da88aabd8cd } connect_timeout 3 nb_get_retry 3 delay_before_retry 3 } } } virtual_server 10.10.10.2 1358 { delay_loop 6 lb_algo rr lb_kind NAT persistence_timeout 50 protocol TCP sorry_server 192.168.200.200 1358 real_server 192.168.200.2 1358 { weight 1 HTTP_GET { url { path /testurl/test.jsp digest 640205b7b0fc66c1ea91c463fac6334d } url { path /testurl2/test.jsp digest 640205b7b0fc66c1ea91c463fac6334d } url { path /testurl3/test.jsp digest 640205b7b0fc66c1ea91c463fac6334d } connect_timeout 3 nb_get_retry 3 delay_before_retry 3 } } real_server 192.168.200.3 1358 { weight 1 HTTP_GET { url { path /testurl/test.jsp digest 640205b7b0fc66c1ea91c463fac6334c } url { path /testurl2/test.jsp digest 640205b7b0fc66c1ea91c463fac6334c } connect_timeout 3 nb_get_retry 3 delay_before_retry 3 } } } virtual_server 10.10.10.3 1358 { delay_loop 3 lb_algo rr lb_kind NAT nat_mask 255.255.255.0 persistence_timeout 50 protocol TCP real_server 192.168.200.4 1358 { weight 1 HTTP_GET { url { path /testurl/test.jsp digest 640205b7b0fc66c1ea91c463fac6334d } url { path /testurl2/test.jsp digest 640205b7b0fc66c1ea91c463fac6334d } url { path /testurl3/test.jsp digest 640205b7b0fc66c1ea91c463fac6334d } connect_timeout 3 nb_get_retry 3 delay_before_retry 3 } } real_server 192.168.200.5 1358 { weight 1 HTTP_GET { url { path /testurl/test.jsp digest 640205b7b0fc66c1ea91c463fac6334d } url { path /testurl2/test.jsp digest 640205b7b0fc66c1ea91c463fac6334d } url { path /testurl3/test.jsp digest 640205b7b0fc66c1ea91c463fac6334d } connect_timeout 3 nb_get_retry 3 delay_before_retry 3 } } }
参考:
http://my.oschina.net/zyc1016/blog/138574
以上是关于Keepalived 安装与配置的主要内容,如果未能解决你的问题,请参考以下文章