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 处理--------------------------------------- ...
随机推荐
- JQuery获取input type="text"中的值的各种方式
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...
- libc.so.6重做链接,删除导致的缺失问题(后期需要深入研究),未能成功升级
中间件启动,提示/lib64/libc.so.6版本过低,升级glibc后,修改临时环境变量,结果导致sgment fault错误,根据报错 ll /lib64/ |grep libc -rwxr-x ...
- Application的多种值判断测试程序
Application.Contents.Remove("FriendLink") Response.Write("Application.Contents.Remove ...
- Json.net对数据的解析
在官网下载Json.net文件后,解压完将Net20下面的DLL复制到Assets目录下. using UnityEngine; using System.Collections; using New ...
- thinkphp整合系列之rbac的升级版auth权限管理系统demo
权限管理基本是作为网站的标配了: 除非是像博客这类个人使用的:否则权限管理的重要性不言而喻: 今个就来写写auth权限管理: thinkphp已经内置了auth权限类位于:/ThinkPHP/Libr ...
- C++头文件#include<bits/stdc++.h>
一句话的事,直截了当——#include<bits/stdc++.h>包含C++的所有头文件 参考网站(点击):http://www.tuicool.com/articles/m6neUj ...
- 2016青岛网络赛 Sort
Sort Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Problem Des ...
- 快速掌握 Android Studio 中 Gradle 的使用方法
快速掌握 Android Studio 中 Gradle 的使用方法 Gradle是可以用于Android开发的新一代的 Build System, 也是 Android Studio默认的build ...
- 使用nginx负载平衡
1. 介绍 在许多应用中,负载平衡是一种常用的技术来优化利用资源最大化吞吐量,减少等待时间,并确保容错. 可以使用nginx的作为一种非常高效的HTTP负载平衡器,将流量分配到多个应用服务器上提高性能 ...
- PAT (Advanced Level) 1071. Speech Patterns (25)
简单题. #include<cstdio> #include<cstring> #include<cmath> #include<vector> #in ...