首页 > 代码库 > lvs + keepalived + nginx + tomcat高可用负载反向代理服务器配置(二) LVS
lvs + keepalived + nginx + tomcat高可用负载反向代理服务器配置(二) LVS
一、安装lvs
sudo apt-get install ipvsadm
二、安装keepalived
sudo apt-get install keepalived
三、创建keepalived.conf文件
sudo gedit /etc/keepalived/keepalived.conf
四、配置keepalived.conf
# Global Configurationglobal_defs { lvs_id director1}# VRRP Configurationvrrp_instance LVS { state MASTER interface eth0 virtual_router_id 51 priority 150 advert_int 1 authentication { auth_type PASS auth_pass 123456 } virtual_ipaddress { 192.168.2.68 } # Virtual Server Configuration - for WWW service virtual_server 192.168.2.68 80 { delay_loop 1 lb_algo rr lb_kind DR persistence_timeout 60 protocol TCP # Real Server 1 configuration real_server 192.168.2.67 8070 { weight 3 TCP_CHECK { connection_timeout 10 nb_get_retry 3 delay_before_retry 3 } } # Real Server 2 configuration real_server 192.168.2.66 8070 { weight 1 TCP_CHECK { connection_timeout 10 nb_get_retry 3 delay_before_retry 3 } } }}
1.配置vrrp ip为68(启动keepalived之后可使用ip addr可查看)
2.配置real_server 此处是67和66的一个集群
五、启动并查看keepalived
#service keepalived start查看 keepalived状态# ps -ef | grep keepalivedroot 4783 1 0 09:49 ? 00:00:00 keepalived -Droot 4784 4783 0 09:49 ? 00:00:01 keepalived -Droot 5191 4896 0 13:43 pts/2 00:00:00 grep keepalived如果未能启动,请使用sudo启动或者检查配置文件 # tail -f /var/log/messagesFeb 21 14:18:48 localhost Keepalived_vrrp: Registering gratutious ARP shared channelFeb 21 14:18:48 localhost Keepalived_vrrp: Opening file ‘/etc/keepalived/keepalived.conf‘.Feb 21 14:18:48 localhost Keepalived_vrrp: Configuration is using : 35706 BytesFeb 21 14:18:48 localhost Keepalived_vrrp: Using LinkWatch kernel netlink reflector...Feb 21 14:18:49 localhost Keepalived_vrrp: VRRP sockpool: [ifindex(2), proto(112), fd(9,10)]Feb 21 14:18:50 localhost Keepalived_vrrp: VRRP_Instance(VI_1) Transition to MASTER STATEFeb 21 14:18:51 localhost Keepalived_vrrp: VRRP_Instance(VI_1) Entering MASTER STATEFeb 21 14:18:51 localhost Keepalived_vrrp: VRRP_Instance(VI_1) setting protocol VIPs.Feb 21 14:18:51 localhost Keepalived_vrrp: VRRP_Instance(VI_1) Sending gratuitous ARPs on eth0 for 192.168.2.150Feb 21 14:18:51 localhost avahi-daemon[2549]: Registering new address record for 192.168.2.150 on eth0. 可以看到VIP已经在主服务器上开启
到此lvs+keepalived就已经完成了,接下来就是nginx.
lvs + keepalived + nginx + tomcat高可用负载反向代理服务器配置(二) LVS
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。