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获得的图片,需要使用缩略图 ...
随机推荐
- 开发VS2008 AddIn 入门Sample
本文主要介绍的是VS2008插件开发 环境要求:VS2008:.Net3.5 目标:开发插件功能为“在VS中创建文本文档,并在文本开头输入//This code was created For Tes ...
- 说说M451例程讲解之定时器
关于定时器 相信很多人都不会陌生,无论是51还是32,任何微控制器,都会有定时器 定时器控制器包含 4 组 32-位定时器,TIMER0~TIMER3,提供用户便捷的计数定时功能.定时器可执行很多功能 ...
- 如何正确设置 Informix GLS 及 CSDK 语言环境
本文介绍 GLS 相关知识,说明如何正确设置 Informix GLS 语言环境相关变量(DB_LOCALE,CLIENT_LOCALE),保证 Informix 数据库服务器.客户端能正确的支持中文 ...
- Android之MessageQueue、Looper、Handler与消息循环
在android的activity中有各种各样的事件,而这些事件最终是转换为消息来处理的.android中的消息系统涉及到: * 消息发送 * 消息队列 * 消息循环 * 消息分发 * 消息 ...
- jquery做简单特效
1.点击触发消失效果 <!DOCTYPE html> <html> <head> <meta charset="utf-8"> &l ...
- IIS中,当文件夹被删除时,防止应用程序重启的解决办法
如果你曾经修改了ASP.NET应用程序(dll文件),与修改了bin文件夹或Web.config文件(添加/删除/重命名的文件等),而该网 站在运行,你可能已经注意到,这将导致在AppDomain的重 ...
- 【BZOJ3626】[LNOI2014]LCA 离线+树链剖分+线段树
[BZOJ3626][LNOI2014]LCA Description 给出一个n个节点的有根树(编号为0到n-1,根节点为0).一个点的深度定义为这个节点到根的距离+1.设dep[i]表示点i的深度 ...
- Bootstrap初学基础总结
Bootstrap 1>.Web UI 框架 可以帮助菜鸟程序员 ,迅速简便的搭建起专业级界面效果 2>如何快速掌握利用框架 1.框架的整合和搭建,让框架能够正常跑起来 2.通过复制粘贴文 ...
- Linux C 获取 文件的大小
通过Linux C库函数来获取文件的大小 #include <unistd.h> #include <sys/types.h> #include <sys/stat.h& ...
- Java23种设计模式学习笔记【目录总贴】
创建型模式:关注对象的创建过程 1.单例模式:保证一个类只有一个实例,并且提供一个访问该实例的全局访问点 主要: 饿汉式(线程安全,调用效率高,但是不能延时加载) 懒汉式(线程安全,调用效率不高,但 ...