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;

 }

posted @ 2016-06-01 09:37  丶小炒肉  阅读(2471)  评论(0编辑  收藏  举报