httpd或Nginx负载均衡tomcat
2021-06-08 16:04
阅读:465
YPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
标签:负载 curl als thread name dev color prot port
实验环境:CentOS7
#两台tomcat的基本配置如下: [root@webapps localhost]#setenforce 0 [root@webapps localhost]#iptables -F [root@webapps localhost]#yum -y install java-1.8.0-openjdk-devel tomcat tomcat-webapps tomcat-admin-webapps [root@webapps localhost]#chown tomcat.tomcat /usr/share/tomcat/webapps/test/* [root@webapps localhost]#chown tomcat.tomcat test [root@webapps localhost]#vim /etc/tomcat/server.xmlconnectionTimeout="60000" address="172.16.252.142" redirectPort="8443" /> [root@webapps localhost]#vim /usr/share/tomcat/webapps/test/index.jsp tomcat1 mini out.println("tomcat1 mini"); %> [root@webapps localhost]#vim /usr/share/tomcat/conf/tomcat-users.xml
#第三台主机安装Nginx:172.16.253.177
#ngixn做负载均衡:
[root@~ localhost]#setenforce 0 [root@~ localhost]#iptables -F [root@~ localhost]#yum -y install nginx-1.10.2-1.el7.ngx.x86_64.rpm [root@~ localhost]#vim /etc/nginx/nginx.conf http { #定义:集群tomcatsr upstream tomcatsr { server 172.16.252.142:8081; server 172.16.254.47:8081; } include /etc/nginx/conf.d/*.conf; } #引用 [root@~ localhost]#vim /etc/nginx/conf.d/default.conf server { location / { proxy_pass http://tomcatsr; root /usr/share/nginx/html; index index.html index.htm; }
#httpd做负载均衡:
[root@~ localhost]#yum -y install httpd
[root@~ localhost]#httpd -M
proxy_balancer_module (shared)#负载均衡模块
[root@~ localhost]#vi /etc/httpd/conf.d/tomcat-httpd.conf//tomcatsr> BalancerMember http://172.16.252.142:8081 BalancerMember http://172.16.254.47:8081 ProxySet lbmethod=byrequests ServerName linux.io ProxyVia On ProxyRequests Off ProxyPreserveHost On Require all granted ProxyPass / balancer://tomcatsr/ ProxyPassReverse / balancer://tomcatsr/Require all granted
#测试:
[root@~ localhost]#for i in {1..10};do curl http://172.16.253.177/test/;donetomcat2 mini1 tomcat2 mini1tomcat1 mini tomcat1 minitomcat2 mini1 tomcat2 mini1tomcat1 mini tomcat1 minitomcat2 mini1 tomcat2 mini1tomcat1 mini tomcat1 minitomcat2 mini1 tomcat2 mini1tomcat1 mini tomcat1 minitomcat2 mini1 tomcat2 mini1tomcat1 mini tomcat1 mini
httpd或Nginx负载均衡tomcat
标签:负载 curl als thread name dev color prot port
原文地址:http://www.cnblogs.com/wzhuo/p/7137701.html
下一篇:net 视图的调用和开发
文章来自:搜素材网的编程语言模块,转载请注明文章出处。
文章标题:httpd或Nginx负载均衡tomcat
文章链接:http://soscw.com/index.php/essay/92287.html
文章标题:httpd或Nginx负载均衡tomcat
文章链接:http://soscw.com/index.php/essay/92287.html
评论
亲,登录后才可以留言!