• 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

  • 相关阅读:
    【转】浅谈一个网页打开的全过程(涉及DNS、CDN、Nginx负载均衡等)
    【转】1.2 CDN的基本工作过程
    【转】 最新版chrome谷歌浏览器Ajax跨域调试问题
    【转】网段,子网掩码,网络标识,IP划分
    【转】默认网关有什么用?我应当怎么填写默认网关和DNS呢
    【转】DHCP工作过程详解
    【转】WINS服务器与DNS服务器有什么区别?
    46. Permutations 排列数
    30. Substring with Concatenation of All Words
    29. Divide Two Integers
  • 原文地址:https://www.cnblogs.com/lavezhang/p/5940756.html
Copyright © 2020-2023  润新知