首页 > 其他 > 详细

lnmp-nginx负载均衡

时间:2014-04-21 17:44:42      阅读:586      评论:0      收藏:0      [点我收藏+]

反向代理,实现负载均衡

##############################

nginx服务器:192.168.0.179

测试主机:192.168.0.179

192.168.0.34

#############################

设置负载均衡调度器

[root@server79 conf]# vim nginx.conf

upstream westos{

       server 192.168.0.34 weight=2;  //设置权重

       server 192.168.0.119;

       }

设置负载均衡调度器所调用的负载均衡服务器(在此以www.westos.org为例):

server {

listen          80;

server_name     www.westos.org;

location / {

               proxy_pass http://westos;

}

}

检测有无语法错误

[root@server79 conf]# nginx -t

nginx: the configuration file /usr/local/lnmp/nginx/conf/nginx.conf syntax is ok

nginx: configuration file /usr/local/lnmp/nginx/conf/nginx.conf test is successful

重新加载nginx

[root@server79 bin]# ./startup.sh  nginx -s reload

编辑测试主机34的测试页面:

[root@server34 ~]# echo server34.example.com >/var/www/html/index.html(注意刷火墙)

[root@server79html]#echoserver34.example.com>/usr/local/lnmp/nginx/html/index.html

测试:

http://www.westos.org(通过刷新以下两个页面轮询出现)

bubuko.com,布布扣bubuko.com,布布扣

当当掉server34的http时,再次刷新,一直出现server79.example.com ,而没有出现报错信息,这是因为nginx对后端具有健康检查,

[root@server34 html]# /etc/init.d/httpd stop

Stopping httpd:                                            [  OK  ]

测试:

http://www.westos.org

bubuko.com,布布扣


lnmp-nginx负载均衡,布布扣,bubuko.com

lnmp-nginx负载均衡

原文:http://cuanlf.blog.51cto.com/8241982/1399169

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!