zoukankan      html  css  js  c++  java
  • nginx添加sticky cookie 分流模块

    需要下载nginx源码和sticky,在nginx配置文件中添加sticky模块,然后重新编译nginx。

    #准备安装基础环境:
    yum install gcc openssl-devel pcre-devel zlib-devel

    #下载nginx1.6.3
    wget http://nginx.org/download/nginx-1.6.3.tar.gz

    #解压缩nginx
    tar xvf nginx-1.6.3.tar.gz

    #安装依赖的库
    yum -y install libxml2 libxml2-dev
    yum -y install libxslt-devel
    yum -y install gd-devel
    yum -y install perl-devel perl-ExtUtils-Embed
    yum -y install GeoIP GeoIP-devel GeoIP-data
    yum -y install gperftools-devel

    #查看nginx的配置
    nginx -V

    #加入sticky模块
    cd nginx-1.6.3

    ./configure --prefix=/usr/share/nginx --sbin-path=/usr/sbin/nginx --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --http-client-body-temp-path=/var/lib/nginx/tmp/client_body --http-proxy-temp-path=/var/lib/nginx/tmp/proxy --http-fastcgi-temp-path=/var/lib/nginx/tmp/fastcgi --http-uwsgi-temp-path=/var/lib/nginx/tmp/uwsgi --http-scgi-temp-path=/var/lib/nginx/tmp/scgi --pid-path=/run/nginx.pid --lock-path=/run/lock/subsys/nginx --user=nginx --group=nginx --with-file-aio --with-ipv6 --with-http_ssl_module --with-http_spdy_module --with-http_realip_module --with-http_addition_module --with-http_xslt_module --with-http_image_filter_module --with-http_geoip_module --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_mp4_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_random_index_module --with-http_secure_link_module --with-http_degradation_module --with-http_stub_status_module --with-http_perl_module --with-mail --with-mail_ssl_module --with-pcre --with-pcre-jit --with-google_perftools_module --with-debug --with-cc-opt='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -m64 -mtune=generic' --with-ld-opt='-Wl,-z,relro -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -Wl,-E' --add-module=/root/nginx-sticky

    #编译
    make

    make install

    #停止nginx
    service nginx stop

    #替换nginx
    cp /usr/sbin/nginx /usr/sbin/nginx.bak.20161009
    cp ./objs/nginx  /usr/sbin/nginx


    #修改nginx配置:

    upstream test_server {
            server 10.2.118.48:8002;
            server 10.2.118.49:8002;
            sticky;
    }

    #重启nginx

    service nginx restart

    参考资料:

    https://my.oschina.net/766/blog/156693

    http://www.xuebuyuan.com/2184929.html

    http://blog.chinaunix.net/uid-24625974-id-2894092.html

  • 相关阅读:
    DOM-DOMTree-查找

    用sql语句操作数据库
    数据查询基础
    【案例】城市地址三级联动
    【案例】城市地址二级联动
    【案例】高仿百度注册页
    【案例】自由运动小球
    【案例】使用上下左右键控制元素的移动
    事件
  • 原文地址:https://www.cnblogs.com/lavezhang/p/5940756.html
Copyright © 2011-2022 走看看