http://www.keepalived.org/software/
首先检查安装openssl-devel
# ./configure --prefix=/usr/local/keepalived --with-kernel-dir=/usr/src/kernels/2.6.32-279.el6.x86_64
Keepalived configuration------------------------Keepalived version : 1.2.19Compiler : gccCompiler flags : -g -O2Extra Lib : -lssl -lcrypto -lcryptUse IPVS Framework : YesIPVS sync daemon support : YesIPVS use libnl : Nofwmark socket support : YesUse VRRP Framework : YesUse VRRP VMAC : YesSNMP support : NoSHA1 support : NoUse Debug flags : No
执行安装命令
设置keepalived开机启动脚本
cp /usr/local/keepalived/etc/rc.d/init.d/keepalived /etc/rc.d/init.d/
cp /usr/local/keepalived/etc/sysconfig/keepalived /etc/sysconfig/
cp /usr/local/keepalived/sbin/keepalived /usr/sbin/
chkconfig keepalived on
新建一个配置文件,默认keepalived启动会去/etc/keepalived目录下寻找配置文件
# mkdir /etc/keepalived
# vi /etc/keepalived/keepalived.conf
global_defs {
notification_email {
test@163.com
}
notification_email_from root@localhost
smtp_server 127.0.0.1
smtp_connect_timeout 30
router_id LVS_DEVEL
}
vrrp_instance VI_1 {
state MASTER # 备份服务器上将 MASTER 改为 BACKUP
interface eth0 # HA 监测网络接口
virtual_router_id 51 # 主、备机的 virtual_router_id 必须相同
priority 100 # 主、备机取不同的优先级,主机值较大,备份机值较小
advert_int 2 # VRRP Multicast 广播周期秒数
authentication {
auth_type PASS #VRRP 认证方式
auth_pass 1111 #VRRP 口令字
}
virtual_ipaddress {
192.168.30.20 # VRRP HA 虚拟地址 如果有多个VIP,继续换行填写
}
}
virtual_server 192.168.30.20 80 {
delay_loop 2 # 每隔 6 秒查询 realserver 状态
lb_algo rr #lvs 算法
lb_kind DR # Direct Route
persistence_timeout 50 # 同一IP 的连接60 秒内被分配到同一台realserver
protocol TCP # 用 TCP 协议检查 realserver 状态
real_server 192.168.30.12 80 {
weight 3 #(权重)
TCP_CHECK {
connect_timeout 10 #(10秒无响应超时)
nb_get_retry 3
delay_before_retry 3
connect_port 80
}
}
real_server 192.168.30.13 80 {
weight 3 #(权重)
TCP_CHECK {
connect_timeout 10 #(10秒无响应超时)
nb_get_retry 3
delay_before_retry 3
connect_port 80
}
}
}
配置完成后启动keepalived,
keepalived+LVS超时设置产生的realserver的tcp连接不释放问题:
怎么样让 LVS 和 realserver 工作在同一台机器上
by 刘迎光@萤火虫工作室
OpenBI交流群:495266201
MicroService 微服务交流群:217722918
mail: liuyg#liuyingguang.cn
博主首页(==防止爬虫==):http://blog.liuyingguang.cn