LNMP+Tomcat+Keepalived+LVS 多端口负载均衡
2017-09-26 17:44
316 查看
摘要: Keepalived配置文件.....
应用场景:Keepalived+LVS高可+负载均衡集群架构中rs同时跑httpd(80端口)和Java(8080端口)服务,使用Keepalived负载均衡多个端口。 如果想全部由80端口提供服务,则Keepalived+LVS负载均衡层就只开启80端口,内部节点使用nginx代理8080端口。
在dir2上执行同样的操作,lvs多端口负载均衡,需要注意的是dir2机器上state改为BACKUP,priority设为90。
此时Keepalived+LVS只需监听80端口即可:
应用场景:Keepalived+LVS高可+负载均衡集群架构中rs同时跑httpd(80端口)和Java(8080端口)服务,使用Keepalived负载均衡多个端口。 如果想全部由80端口提供服务,则Keepalived+LVS负载均衡层就只开启80端口,内部节点使用nginx代理8080端口。
多端口负载均衡
[root@director sbin]# yum install -y keepalived [root@Centos-1 sbin]# vim /etc/keepalived/keepalived.conf vrrp_instance VI_1 { state BACKUP interface ens192 virtual_router_id 51 priority 100 advert_int 1 authentication { auth_type PASS auth_pass password } virtual_ipaddress { 192.168.14.13 } } virtual_server 192.168.14.13 80 { delay_loop 10 lb_algo wlc lb_kind DR persistence_timeout 180 protocol TCP real_server 192.168.14.127 80 { weight 100 TCP_CHECK { connect_timeout 10 nb_get_retry 3 delay_before_retry 3 connect_port 80 } } real_server 192.168.14.128 80 { weight 100 TCP_CHECK { connect_timeout 10 nb_get_retry 3 delay_before_retry 3 connect_port 80 } } real_server 192.168.14.129 80 { weight 100 TCP_CHECK { connect_timeout 10 nb_get_retry 3 delay_before_retry 3 connect_port 80 } } } virtual_server 192.168.14.13 8080 { delay_loop 10 lb_algo wlc lb_kind DR persistence_timeout 180 protocol TCP real_server 192.168.14.127 8080 { weight 100 TCP_CHECK { connect_timeout 10 nb_get_retry 3 delay_before_retry 3 connect_port 80 } } real_server 192.168.14.128 8080 { weight 100 TCP_CHECK { connect_timeout 10 nb_get_retry 3 delay_before_retry 3 connect_port 80 } } real_server 192.168.14.129 8080 { weight 100 TCP_CHECK { connect_timeout 10 nb_get_retry 3 delay_before_retry 3 connect_port 80 } } }
在dir2上执行同样的操作,lvs多端口负载均衡,需要注意的是dir2机器上state改为BACKUP,priority设为90。
nginx反向代理Tomcat
在rs上创建nginx代理虚拟主机,名为zrlog.conf,然后配置内容如下:[root@128rs2 ~]# vim /usr/local/nginx/conf/vhosts/zrlog.conf server { listen 80; server_name www.3zuzrlog.com; location / { proxy_pass http://localhost:8080; proxy_redirect default; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; }
此时Keepalived+LVS只需监听80端口即可:
[root@Centos-1 sbin]# vim /etc/keepalived/keepalived.conf vrrp_instance VI_1 { state BACKUP interface ens192 virtual_router_id 51 priority 100 advert_int 1 authentication { auth_type PASS auth_pass password } virtual_ipaddress { 192.168.14.13 } } virtual_server 192.168.14.13 80 { delay_loop 10 lb_algo wlc lb_kind DR persistence_timeout 180 protocol TCP real_server 192.168.14.127 80 { weight 100 TCP_CHECK { connect_timeout 10 nb_get_retry 3 delay_before_retry 3 connect_port 80 } } real_server 192.168.14.128 80 { weight 100 TCP_CHECK { connect_timeout 10 nb_get_retry 3 delay_before_retry 3 connect_port 80 } } real_server 192.168.14.129 80 { weight 100 TCP_CHECK { connect_timeout 10 nb_get_retry 3 delay_before_retry 3 connect_port 80 } } }
相关文章推荐
- LVS + keepalived + nginx + tomcat 实现主从热备 + 负载均衡
- [置顶] centos部署lvs+keepalived+apache/tomcat实现高性能高可用负载均衡
- centos部署lvs+keepalived+apache/tomcat实现高性能高可用负载均衡
- LVS:keepalived + lvs +tomcat 实现 主从热备+负载均衡
- LVS:keepalived + nginx + tomcat 实现主从热备 + 负载均衡
- LVS+Keepalived+Nginx+Tomcat高可用负载均衡集群配置(DR模式,一个VIP,多个端口)
- linux复盘:老款终极蛇皮怪之lnmp+tomcat+jdk+keepalived+lvs+zabbix+nfs
- LVS+Keepalived+Nginx+Tomcat高可用集群搭建
- Linux服务器下LVS+Keepalived 高可用负载均衡集群架构实现
- 转载--CentOS 6.3下部署LVS(NAT)+keepalived实现高性能高可用负载均衡
- LVS+keepalived+Nginx(前后端故障处理)全自动化负载均衡配置
- keepalived+LVS搭建高可用负载均衡系统
- CENTOS5下采用LVS +KEEPALIVED实现负载均衡
- LVS+Keepalived做Red5高可用和负载均衡
- 【大型网站技术实践】初级篇:借助LVS+Keepalived实现负载均衡
- 借助LVS+Keepalived实现负载均衡
- 虚拟机virtualBox 搭建 Keepalived+lvs dr+httpd 负载均衡
- lvs+keepalived+vsftp配置FTP服务器负载均衡
- keepalived+lvs实现高可用负载均衡集群