|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
欢迎大家来到仓酷云论坛!负载平衡(LoadBalancing)负载平衡创建在现有收集布局之上,它供应了一种便宜无效通明的***扩大收集装备和办事器的带宽、增添吞吐量、增强收集数据处置才能、进步收集的天真性和可用性。
比来在自学负载平衡手艺,收集上有很多文章,但写的都不是很了然,现把测试的条记日志宣布出来,以供人人进修利用;本文只先容进门级的负载平衡,进阶还在进修中……
1、基本信息
操纵体系:CentOS6.0
办事器:三台办事器(LoadBalancing、WEB1、WEB2)
负载平衡手艺:Nginx
web办事手艺:apache
IP地点:Nginx192.168.1.113、Web1192.168.1.77、Web2192.168.1.78
2、Web办事器的装置与设置
请参考本博客的apache办事器搭建文章:http://523514.blog.51cto.com/513514/1350015
3、负载平衡办事器(Nginx)的装置与设置
3.1装置基本撑持套件
yum-yinstallgccopensslopenssl-develpcrepcre-devel
3.2装置nginx
cd
wgethttp://nginx.org/download/nginx-1.5.8.tar.gz
tarxzvfnginx-1.5.8.tar.gz
cdnginx-1.5.8
./cofnigure--prefix=/usr/local/nginx
make
makeinstall
3.3设置nginx
编纂/usr/local/nginx/conf/nginx.conf
cd/usr/local/nginx/conf/
mvnginx.confnginx.conf.bak
vimnginx.conf
新增以下内容
userapache;
worker_processes10;
pidlogs/nginx.pid;
events{
useepoll;
worker_connections2048;
}
http{
includemime.types;
default_typeapplication/octet-stream;
log_formatmain$remote_addr-$remote_user[$time_local]"$request"
$status$body_bytes_sent"$http_referer"
"$http_user_agent""$http_x_forwarded_for";
access_loglogs/access.logmain;
sendfileon;
tcp_nopushon;
upstream63638790{
server192.168.1.77:80;
server192.168.1.78:80;
}
keepalive_timeout65;
server{
listen80;
server_namewww.63638790.cn;
access_loglogs/63638790.access.logmain;
location/{
proxy_passhttp://63638790;
proxy_set_headerHost$host;
proxy_set_headerX-Real-IP$remote_addr;
proxy_set_headerX-Forwarded-For$proxy_add_x_forwarded_for;
}
error_page500502503504/50x.html;
location=/50x.html{
roothtml;
}
}
}
注:白色字体局部,可依据本人的实践情形举行变动便可;
4、启动Nginx
4.1考证nginx设置是不是一般
#/usr/local/nginx/sbin/nginx-t
注:前往以下内容便可,不然依据提醒变动;
nginx:theconfigurationfile/usr/local/nginx/conf/nginx.confsyntaxisok
nginx:configurationfile/usr/local/nginx/conf/nginx.conftestissuccessful
4.2启动Nginx
#/usr/local/nginx/sbin/nginx
4.3中断Nginx
#killall-9nginx
4.4DNS域名剖析
有域名的同砚能够上DNS办事商长进行剖析设置;我是变动当地电脑hosts文件来举行测试的,编纂C:WindowsSystem32driversetchosts,在最初一行新增以下内容:
192.168.1.113www.63638790.cn
4.5测试会见
翻开扫瞄器输出http://www.63638790.cn即能显现出web办事器的网站内容,停失落个中一台web办事器也不影响用户的一般利用;
停止词:Nginx完成负载平衡就是如许复杂,给一万个赞,进阶设置进修中……
本文出自“方寸小山”博客,请务必保存此出处http://523514.blog.51cto.com/513514/1353548
欢迎大家来到仓酷云论坛! |
|