Tengine TCP 负载均衡
tar jxvf jemalloc-3.5.1.tar.bz2
cd jemalloc-3.5.1
./configure
make && make install
echo '/usr/local/lib' > /etc/ld.so.conf.d/local.conf
ldconfig
cd ..
下载 http://tengine.taobao.org/download/tengine-2.1.1.tar.gz
tar zxvf tengine-2.1.1.tar.gz
wget https://github.com/yaoweibin/nginx_tcp_proxy_module/archive/master.zip
unzip master.zip
yum -y install patch
cd tengine-2.1.1
patch -p1 < /opt/software/nginx_tcp_proxy_module-master/tcp.patch
-----------------------------------------------------------------------
patching file src/core/ngx_log.c
Hunk #1 succeeded at 69 (offset 3 lines).
patching file src/core/ngx_log.h
Hunk #1 succeeded at 30 (offset 1 line).
Hunk #2 succeeded at 38 (offset 1 line).
patching file src/event/ngx_event_connect.h
Hunk #1 succeeded at 33 (offset 1 line).
Hunk #2 succeeded at 45 (offset 2 lines).
-------------------------------------------------------------------------
./configure --user=upload --group=upload --prefix=/opt/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-http_realip_module --with-http_image_filter_module --with-ld-opt="-ljemalloc" --add-module=/opt/software/nginx_tcp_proxy_module-master
make && make install
cd /opt/local/nginx/conf
vi nginx.conf
--------------------------------------------------------------------------------------------
user upload upload;
worker_processes 8;
error_log /opt/local/nginx/logs/nginx_error.log crit;
pid /opt/local/nginx/nginx.pid;
#Specifies the value for maximum file descriptors that can be opened by this process.
worker_rlimit_nofile 65535;
events
{
use epoll;
worker_connections 65535;
}
http
{
include mime.types;
default_type application/octet-stream;
#charset gb2312;
server_names_hash_bucket_size 128;
client_header_buffer_size 32k;
large_client_header_buffers 4 32k;
client_max_body_size 100m;
sendfile on;
server_tokens off;
tcp_nopush on;
keepalive_timeout 120;
tcp_nodelay on;
fastcgi_connect_timeout 300;
fastcgi_send_timeout 300;
fastcgi_read_timeout 300;
fastcgi_buffer_size 64k;
fastcgi_buffers 4 64k;
fastcgi_busy_buffers_size 128k;
fastcgi_temp_file_write_size 128k;
gzip on;
gzip_min_length 1k;
gzip_buffers 4 16k;
gzip_http_version 1.0;
gzip_comp_level 2;
gzip_types text/plain application/x-javascript text/css application/xml;
gzip_vary on;
#limit_zone crawler $binary_remote_addr 10m;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" $http_x_forwarded_for "$request_time"';
}
tcp
{
include vhost/*.conf;
include upstream.conf;
}
--------------------------------------------------------------------------------------------
vi upstream.conf
upstream mysql {
server 172.16.32.20:3306;
server 172.16.32.24:3306;
server 172.16.32.27:3306;
server 172.16.32.33:3306;
check interval=3000 rise=2 fall=3 timeout=1000;
}
mkdir vhost/
cd vhost/
vi mysql.conf
server {
listen 3306;
proxy_pass mysql;
}
Tengine TCP 负载均衡的更多相关文章
- Nginx 的 TCP 负载均衡介绍
Nginx除了以前常用的HTTP负载均衡外,Nginx增加基于TCP协议实现的负载均衡方法. HTTP负载均衡,也就是我们通常所有“七层负载均衡”,工作在第七层“应用层”.而TCP负载均衡,就是我们通 ...
- [转帖]Nginx 的 TCP 负载均衡介绍
Nginx 的 TCP 负载均衡介绍 https://www.cnblogs.com/felixzh/ 前几天同事问 nginx的代理 当时以为只有http的 现在看起来还有tcp的可以使用tcp 代 ...
- Nginx作为TCP负载均衡
参考文档:https://www.cnblogs.com/stimlee/p/6243055.html Nginx在1.9版本以后支持TCP负载均衡,模块默认是没有编译的,需要编译时添加—with-s ...
- 【精选】Nginx负载均衡学习笔记(一)实现HTTP负载均衡和TCP负载均衡(官方和OpenResty两种负载配置)
说明:很简单一个在HTTP模块中,而另外一个和HTTP 是并列的Stream模块(Nginx 1.9.0 支持) 一.两个模块的最简单配置如下 1.HTTP负载均衡: http { include m ...
- nginx基于tcp负载均衡
官方参考文档:http://nginx.org/en/docs/stream/ngx_stream_core_module.html 只有nginx1.9以上的版本才支持tcp负载均衡 配置必须出现在 ...
- Nginx 反向代理功能-实现Nginx tcp负载均衡
Nginx 反向代理功能-实现Nginx tcp负载均衡 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任.
- 使用tengine解决负载均衡的session问题
事情的经过时这样的~~,我看了好多好多百度中nginx负载均衡中解决session问题的方式,我选择了研究url_hash的方式.经过一番配置之后,我越发觉得这百度搜出来的帖子也太过久远了吧,去htt ...
- 利用nginx做tcp负载均衡
当前nginx-13.1已经支持tcp,ucp,unix域套接字三种负载均衡模式(http肯定支持,这个不用说).最近有需求需要对后端服务做负载均衡,因此考虑使用nginx来做. 1. 下载nginx ...
- HAproxy四层TCP负载均衡配置及测试
--------------------------------------------------centos 7 处理--------------------------------------- ...
随机推荐
- wpf绑定之格式化日期
只显示年月日: StringFormat='{}{0:yyyy/MM/dd}' 又或者: StringFormat='{}{0:yyyy年MM月dd日 dddd HH:mm:ss}',Converte ...
- linux跨主机复制文件或文件夹
复制文件基本格式:(本地到远程) scp 文件名 用户名@ip:文件全目录 如果是文件夹加上参数 -r scp -r 基础目录 用户名@ip:目录 栗子: scp local_file remote_ ...
- Day02——widow对象
window - 计时器 1、setTimeout()可以用来在指定的时间之后单次调用函数. setTimeount(f,1000);//一秒后调用函数f clearTimeout();取消函数的执行 ...
- Apache + PHP in Windows XP (to add SQLite)
Firstly, Winxp do not support VC11+, so choose Apache packs compiled under VC10-. Before installatio ...
- gradle 构建spring源码时候报错
这是使用jdk1.7报的错,我卸载1.7后使用1.8 ,就可以了
- 命令行调试smali
am start -D -n com.agilebits.onepassword/.activity.LoginActivity ps | grep passu0_a126 1107 217 5107 ...
- cocos2d-x3.x Vector
auto sp0 = Sprite::create(); sp0->setTag(); auto sp1 = Sprite::create(); sp1->setTag(); //这里使用 ...
- mysql HA-keepalived
关于MySQL-HA,目前有多种解决方案,比如heartbeat.drbd.mmm.共享存储,但是它们各有优缺点.heartbeat.drbd配置较为复杂,需要自己写脚本才能实现MySQL自动切换,对 ...
- itext操作PDF文件添加水印
功能描述:添加图片和文字水印 /** * * [功能描述:添加图片和文字水印] [功能详细描述:功能详细描述] * @param srcFile 待加水印文件 * @param destFile 加水 ...
- maven 教程一 入门
摘要: (1)maven是项目管理工具,类似makefile.主要的生命阶段有 validate:验证工程是否正确,所有需要的资源是否可用. compile:编译项目的源代码. test:使用 ...