lvs+keepalived部署高可用集群
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了lvs+keepalived部署高可用集群相关的知识,希望对你有一定的参考价值。
本环境基于centos7部署,基本架构图:
client ip: 192.168.1.101
lvs1 ip: 192.168.1.173
lvs2 ip: 192.168.1.110
web1: 192.168.1.114
web2: 192.168.1.119
VIP: 192.168.1.10
部署流程:
lvs1:
# yum install ipvsadm
# ipvsadm #查看是否输出安装成功
# yum install keepalived
# vim /etc/keepalived/keepalived.conf
global_defs {
notification_email {
}
notification_email_from [email protected]
smtp_server smtp.qq.com
smtp_connect_timeout 30
router_id LVS1
}
vrrp_instance VI_1 {
state MASTER
interface ens33
virtual_router_id 51
priority 100
advert_int 1
authentication {
auth_type PASS
auth_pass 1111
}
virtual_ipaddress {
192.168.1.10
}
}
virtual_server 192.168.1.10 80 {
delay_loop 6
lb_algo rr
lb_kind DR
nat_mask 255.255.255.0
persistence_timeout 50
protocol TCP
real_server 192.168.1.114 80 {
weight 1
TCP_CHECK {
connect_timeout 3
nb_get_retry 3
delay_before_retry 3
}
}
real_server 192.168.1.119 80 {
weight 1
TCP_CHECK {
connect_timeout 3
nb_get_retry 3
delay_before_retry 3
}
}
}
# vim /etc/sysctl.conf #开启路由转发
net.ipv4.ip_forward= 1
# sysctl -p
# service keepalived start
lvs2配置跟lvs大致相同
# vim /etc/keepalived/keepalived.conf
state BACKUP
#service keepalived start
后端web服务器使用nginx即可
浏览器请求http://192.168.1.10
#ipvsadm -l #查看调度信息
本文出自 “linux技术” 博客,请务必保留此出处http://haoyonghui.blog.51cto.com/4278020/1933496
以上是关于lvs+keepalived部署高可用集群的主要内容,如果未能解决你的问题,请参考以下文章
LVS+keepalived高可用负载均衡集群部署 ----数据库的读写分离
LVS+keepalived高可用负载均衡集群部署---LAMP网站服务器与LVS服务器