nginxkeepalived实现高可用负载均衡方案

nginxkeepalived实现高可用负载均衡方案

ID:35478227

大小:63.58 KB

页数:9页

时间:2019-03-25

nginxkeepalived实现高可用负载均衡方案_第1页
nginxkeepalived实现高可用负载均衡方案_第2页
nginxkeepalived实现高可用负载均衡方案_第3页
nginxkeepalived实现高可用负载均衡方案_第4页
nginxkeepalived实现高可用负载均衡方案_第5页
资源描述:

《nginxkeepalived实现高可用负载均衡方案》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库

1、学习文档1.弓I言32.环境说明33.Nginx安装配置34.Keepalived安装酉己置55.验证9木学习文档主要介绍了采用Nginx负载均衡,通过keepalived实现Nginx双机互备,保证实现的WEB服务高可用方案。2.环境说明主nginx负载均衡器:172.20.52.20端口81(CentOSrelease5.8)副nginx负载均衡器:172.20.52.21端口81(CentOSrelease5.8)Tomcatl:172.20.52.193030Tomcat2:172.20.52.20端口4040VIP:172.20.52.22软件:keepalive

2、d-1.2.12nginx-1.4.4说明:keepalived是一个基于VRRP协议来实现的WEB服务高可用方案,可以利用其来避免单点故障。一个WEB服务至少会有2台服务器运行Keepalived,一台为主服务器(MASTER),一台为备份服务器(BACKUP),但是对外表现为一个虚拟IP,主服务器会发送特定的消息给备份服务器,当备份服务器收不到这个消息的时候,即主服务器宕机的时候,备份服务器就会接管虚拟IP,继续提供服务,从而保证了高可用性。3.Nginx安装配置1•安装Nginx获取Nginx稳定版,把Nginx安装到/usr/local/nginx目录下(两台机器都

3、安装)的详细步骤:yum-yinstallgccopenssl-develpcre-develzlib-devel(安装相关组件)tarzxvfnginx-1.4.4.tar.gzcdnginx-1.4.4・/configure—prefix=/usr/local/nginx—with-http_ssl_module—with-http_flv_module—with-http_gzip_static_module—with-http_stub_status_modulemake&&makeinstall2.分别在两台服务器编写配置文件vim/usr/local/nginx

4、/conf/nginx.conf#usernobody;worker_processes1;#pidlogs/nginx.pid;events{worker_connections1024;http{includedefault_typesendfile#tcp_nopushmimcetypes;application/octet-stream;on;on;keepalive_dnieout65;upstreamcart{server172.20.52.19:3030weight=l;server172.20.52.20:4040weight=l;#ip_hash;#在没有

5、做共享session的情况下ip_hash可以解决session问题}server{listen81;server_name172.20.52.20;#另外一台填写另外IPcharsetutf-8;location/cart{roothtml;indexindex.htmlindex.htm;proxy_next_upstreamerrortimeouthttp_500http_502http_504;proxy_read_timeout10s;proxy_passhttp://cart;proxy_set_headerproxy_set_headerproxy_set_h

6、eaderHost$host:81;#没用默认80端口需要加入X-Real-IP$remote_addr;X・Foi*warded・For$proxy_add_x_forwarded_for;error_page500502503504/50x.html;location=/SOx.html{roothtml;}log_formataccess_log'$remote_addr・$remote_user[$time_local]$requestM,$statusH$body_bytes_sentH$http_refererH*M,$http_user_agentnM$htt

7、p_x_forwarded_forM,;access」og/usr/local/nginx/logs/access.logaccessjog;}}2.验证配置文件正确性/usr/local/nginx/sbin/nginx-t显示以下信息为正确的theconfigurationfile/usr/local/nginx/conf/nginx.confsyntaxisokconfigurationfile/usr/local/nginx/conf/nginx.conftestissuccessful3.启动/usr/l

当前文档最多预览五页,下载文档查看全文

此文档下载收益归作者所有

当前文档最多预览五页,下载文档查看全文
温馨提示:
1. 部分包含数学公式或PPT动画的文件,查看预览时可能会显示错乱或异常,文件下载后无此问题,请放心下载。
2. 本文档由用户上传,版权归属用户,天天文库负责整理代发布。如果您对本文档版权有争议请及时联系客服。
3. 下载前请仔细阅读文档内容,确认文档内容符合您的需求后进行下载,若出现内容与标题不符可向本站投诉处理。
4. 下载文档时可能由于网络波动等原因无法下载或下载错误,付费完成后未能成功下载的用户请联系客服处理。