五、部署 Nginx 1.4.3 实现负载均衡
用Nginx做为负载均衡器,配置简单。而且通过Nginx访问到无响应的主机时,Nginx会自动将客户的请转到另一台主机,而无需客户重新提交请求。因此对于客户来讲,只要Nginx指向的主机中有一台有响应,客户就能访问到相应的数据。
1、安装 nginx 1.4.3
[iyunv@nginx 桌面]# rpm -ivh nginx-1.4.3-1.e16.ngx.x86_64.rpmwarning nginx-1.4.3-1.el6.ngx.x86_64.rpm:Header V4 RSA/SHA1 Signature, key ID 7bd9bf62: NOKEYPreparing... #####################################[100%] 1:nginx #####################################[100%]------------------------------------------------------------Thanks for using nginx!Please find the official documentation for nginx here:* http://nginx.org/en/docs/Commercial subscriptions for nginx are available on:* http://nginx.com/products/------------------------------------------------------------
2、修改配置文件 /etc/nginx/conf.d/default.conf 使得来自 80 端口的请求转发到5台solr主机的 80 端口(即项目的网址),来自 9888 端口的请求转发至5台solr主机的9888端口(即SolrCloud的网址)
[iyunv@nginx 桌面]# vi /etc/nginx/conf.d/default.confupstream SolrCloud{server solr1.jyga.com:9998 max_fails=3 fail_timeout=5h;server solr2.jyga.com:9998 max_fails=3 fail_timeout=5h;server solr3.jyga.com:9998 max_fails=3 fail_timeout=5h;server solr4.jyga.com:9998 max_fails=3 fail_timeout=5h;server solr5.jyga.com:9998 max_fails=3 fail_timeout=5h;}upstream JYGA{server solr1.jyga.com:80 max_fails=3 fail_timeout=5h;server solr2.jyga.com:80 max_fails=3 fail_timeout=5h;server solr3.jyga.com:80 max_fails=3 fail_timeout=5h;server solr4.jyga.com:80 max_fails=3 fail_timeout=5h;server solr5.jyga.com:80 max_fails=3 fail_timeout=5h;}server { listen 9998; server_name localhost; #access_log /var/log/nginx/log/host.access.log main; location / { root /usr/share/nginx/html; index index.html index.htm; proxy_pass http://SolrCloud; } #error_page 404 /404.html; # redirect server error pages to the static page /50x.html # error_page 500 502 503 504 /50x.html; location = /50x.html { root /usr/share/nginx/html; }}server { listen 80; server_name localhost; #access_log /var/log/nginx/log/host.access.log main; location / { root /usr/share/nginx/html; index index.html index.htm; proxy_pass http://JYGA; } #error_page 404 /404.html; # redirect server error pages to the static page /50x.html # error_page 500 502 503 504 /50x.html; location = /50x.html { root /usr/share/nginx/html; }}
3、启动 nginx
[iyunv@nginx 桌面]# nginx
4、访问项目和SolrCloud的网址
http://nginx.jyga.com/jyga #项目的网址,实际是哪台服务器在提示Web服务,不得而知
http://nginx.jyga.com:9998/solr #SolrCloud的访问网址
运维网声明
1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网 享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com