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
nginx添加sticky cookie 分流模块的更多相关文章
- nginx添加sticky模块-cookie保持会话
cookie不同于session,一个存于客户端,一个存于服务端. 环境nginx 1.8.0 centos6.X sticky:1.2.5 wget https://bitbucket.org/n ...
- nginx添加未编译安装模块
链接:http://taokey.blog.51cto.com/4633273/1318719
- nginx添加nginx_mod_h264_streaming-2.2.7模块编译报错
报错ngx_http_streaming_module.c:158: 错误:‘ngx_http_request_t’ 没有名为 ‘zero_in_uri’ 的成员.这需要修改nginx_mod_h26 ...
- nginx添加 nginx_heath模块
原因?为什么会使用nginx_heath 这个模块,主要是如nginx+tomcat部署的时,tomcat挂了之后nginx->upstream 轮询是可以踢掉挂掉的tomcat服务的,如果部署 ...
- nginx添加模块 (非覆盖安装)
nginx添加模块(非覆盖安装) 原已经安装好的nginx,现在需要添加一个未被编译安装的模块: 查看原来编译时都带了哪些参数# /usr/local/nginx/sbin/nginx -V ngin ...
- nginx根据cookie分流
转载互联网 nginx根据cookie分流众所周知,nginx可以根据url path进行分流,殊不知对于cookie分流也很强大,同时这也是我上篇提到的小流量实验的基础. 二话不说,先看需求,两台服 ...
- 新安装和已安装nginx如何添加未编译安装模块/补丁
新安装和已安装nginx如何添加未编译安装模块/补丁 --http://www.apelearn.com/bbs/forum.php?mod=viewthread&tid=10485& ...
- 给已安装的NGINX添加新的模块
给已安装的NGINX添加新的模块 2018-11-16 14:02:45 Visit 0 使用 nginx -V 查看当前nginx的信息,包括版本号和configure编译配置信息 版本号 : ...
- 安装成功的nginx,如何添加未编译安装模块(非覆盖安装http_image_filter_module)
背景:1.做了图片上传小项目.2.图片上传,需要多图管理.3.图片上传,需要存储到Fastdfs.4.Fastdfs上的图片,和Nginx结合.5.Nginx从Fastdfs获得的图片,需要使用缩略图 ...
随机推荐
- ionic跳转(二)
1)网上说要想在js里跳转用,$state.go()方法,但找了大半天都没找到在ionic使用$state的方法 2)要想用js跳转,直接用原生js跳转也是可以的 location.href='#ho ...
- springboot tomcat的使用
使用自带的tomcat 以java 项目启动: 默认端口号为8080 1.必须导入此包 2.有启动类
- 有Thread1、Thread2、Thread3、Thread4四条线程分别统计C、D、E、F四个盘的大小,所有线程都统计完毕交给Thread5线程去做汇总,应当如何实现?
利用java.util.concurrent包下的CountDownLatch(减数器)或CyclicBarrier(循环栅栏) 转自:http://www.cnblogs.com/westward/ ...
- CodeForces 731A Night at the Museum
A. Night at the Museum time limit per test 1 second memory limit per test 256 megabytes input standa ...
- c# 项目文件,C#viual studio使用方法
一.项目文件 1)Properties节点下主要存放的是当前程序集相关的信息,如版本号.标题等.双击”Properties“,打开如下项目属性窗口,可以设置项目相关的一些参数. 2)引用 节点主要列出 ...
- NSUserDefault 保存自定义对象
由于NSUserDefaults 不支持保存自定类,保存的对象需要实现NSCoding协议,不过自定的类型就算实现了NSCoding也不可以保存,可以通过以下方法实现: //h文件 #import & ...
- mysql导出成execl
方法一:查询语句直接输出语法格式: Example: select * into outfile '/data/var-3307/catid.xls' from help_cat where 1 or ...
- SpringBoot 配置文件 YML/Profile
1. 全局配置文件 application.properties application.yml 配置文件名是固定的; 配置文件存放在src/main/resources目录或者类路径/config下 ...
- ssh登录服务器
ssh -i /home/zhangsuosheng/mykey.pub myusername@111.111.111.111
- 理解MySQL——并行数据库与分区(Partition)
1.并行数据库 1.1.并行数据库的体系结构并行机的出现,催生了并行数据库的出现,不对,应该是关系运算本来就是高度可并行的.对数据库系统性能的度量主要有两种方式:(1)吞吐量(Throughput), ...