zoukankan      html  css  js  c++  java
  • 运维小知识之nginx---nginx配置Jboss集群负载均衡

     

     
    codyl 2016-01-26 00:53:00 浏览385 评论0

    负载均衡

    转自

    运维小知识之nginx---nginx配置Jboss集群负载均衡-博客-云栖社区-阿里云
    https://yq.aliyun.com/articles/17925

     

    运维小知识之nginx---nginx配置Jboss集群负载均衡

     

     

             背景

             紧接着上一篇博客《运维小知识---CentOS6.5安装nginx配置nginx sticky》安装完成之后剩下的工作就是配置了,其实如果我们想要去做负载均衡session共享是一个绕不过去的问题,而解决session共享的方法有很多,我这里介绍的事使用nginx sticky,方便易用。

             具体配置

             由于目前的项目中会出现什么情况还不清楚,所以目前只是做了最简单的配置,如下:

    http {
       include       mime.types;
       default_type application/octet-stream;
             #Proxy_cache_path    /usr/local/nginx/NginxTestImgLoglevels=1:2  keys_zone=cache_one:200minactive=1d max_size=30g;
       #log_format  main  '$remote_addr - $remote_user [$time_local]"$request" '
       #                  '$status$body_bytes_sent "$http_referer" '
       #                 '"$http_user_agent" "$http_x_forwarded_for"';
     
       #access_log  logs/access.log  main;
       sendfile        on;
       #tcp_nopush     on;
     
       #keepalive_timeout  0;
       keepalive_timeout  65;    #gzip on;
     
        #服务器的集群
        upstream  jboss6.2 { #服务器集群名字
                    #server   172.16.21.13:8081 weight=1;#服务器配置 weight是权重的意思,权重越大,分配的概率越大。
           sticky;   #配置session共享
           server      xxx.xx.xx.25:80weight=1;
    server      xxx.xx.xx.26:80weight=1;
    server      xxx.xx.xx.27:80weight=1;   
    }  
     
             #当前的Nginx的配置
       server {
           listen       80;
           server_name  yyy.yy.yyy.121;
     
           rewrite_log on;
           #charset koi8-r;
     
           #access_log logs/host.access.log  main;
     
           location / { 
               proxy_pass http://jboss6.2; 
           } 
     
           #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   html;
           }
     
           # proxy the PHP scripts to Apache listening on 127.0.0.1:80
           #
           #location ~ .php$ {
           #    proxy_pass   http://127.0.0.1;
           #}
     
           # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
           #
           #location ~ .php$ {
           #    root           html;
           #    fastcgi_pass   127.0.0.1:9000;
           #    fastcgi_index  index.php;
           #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
           #    include        fastcgi_params;
           #}
     
           # deny access to .htaccess files, if Apache's document root
           # concurs with nginx's one
           #
           #location ~ /.ht {
           #    deny  all;
           #}
        }

             目前只使用了一台nginx服务器,如果其宕机了就无法怎么办这个问题也暂时没有考虑(配置一个nginx集群,当然这些都是后话了),笔者一直坚信最好的开发是按需而为,不是炫技,不是过度设计。在技术这条路上,听过,看过,最重要的是做过!

             最后还想强调的一句话是——不解决session共享的负载均衡其实是耍流氓。笔者初步接触nginx文中如有纰漏之处,还望您能不吝赐教!

  • 相关阅读:
    XML文件的操作说明
    IIS中如何应用程序启用https协议
    sql server中的数据类型转换函数
    sql语句中的join连接(左连接、右连接、全连接、内连接)
    sql语句中日期相减的操作
    C# NameValueCollection集合
    json的两种表示结构(对象和数组).。
    ASP.NET中一般处理程序报的错误:由于代码已经过优化或者本机框架位于调用堆栈之上,无法计算表达式的值
    C#中类的实例是不能 获取到类中的静态方法和静态变量(Static)的,及原因
    《好好学Java 从零基础到项目实战》姗姗而来
  • 原文地址:https://www.cnblogs.com/paul8339/p/6956321.html
Copyright © 2011-2022 走看看