标签:blog http io ar os 使用 sp 文件 div
之前使用nginx做过web反向代理,没有做过负载均衡,今天有个同学需要做tomcat的负载均衡,我也研究下。
一共是2个机器,一个物理机(win7)上面部署2个tomcat,使用不同的端口启动。vm中的虚拟机放(centos)nginx,给tomcat做负载均衡.
首先保证两个主机可以互ping,响应的端口开放。
然后开始配置nginx:
[root@localhost conf]# cat /etc/nginx/nginx.conf
#user nobody;worker_processes 1;events { worker_connections 1024;} http { include mime.types; default_type application/octet-stream; upstream localhost{ server 192.168.37.1:8080 weight=2; server 192.168.37.1:8081 weight=1; #ip_hash; } sendfile on; keepalive_timeout 65; server { listen 80; server_name localhost; location / { proxy_connect_timeout 3; #proxy_redirect off; proxy_send_timeout 30; proxy_read_timeout 30; proxy_pass http://localhost; } error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } }}这怎么重启nginx都没生效,最后发现是因为启动的配置文件不对,可以通过 nginx -c /etc/nginx/nginx.conf 来指定陪配置文件的路径。
当然这里是最简单的轮询,没有其他策略,实验来说基本成功。
本文出自 “orangleliu笔记本” 博客,转载请务必保留此出处http://blog.csdn.net/orangleliu/article/details/41251397
作者: orangleliu
标签:blog http io ar os 使用 sp 文件 div
原文地址:http://www.cnblogs.com/shengs/p/4106673.html