背景:
阅读新闻
OpenResty负载均衡MySQL
[日期:2015-12-11] 来源:Linux社区 作者:壹頁書 [字体:]
OpenResty下载地址
https://openresty.org/download/ngx_openresty-1.9.3.2.tar.gz
nginx_tcp_proxy_module模块需要单独下载
https://github.com/yaoweibin/nginx_tcp_proxy_module
首先,解压缩上述文件
[nginx@localhost~]$ll
总用量 3668
drwxrwxr-x 7 nginx nginx 4096 8月 18 23:39 nginx_tcp_proxy_module-master
-rw-r--r-- 1 nginx nginx 213069 12月 8 15:05 nginx_tcp_proxy_module-master.zip
drwxrwxr-x 5 nginx nginx 4096 12月 8 15:31 ngx_openresty-1.9.3.2
-rw-r--r-- 1 nginx nginx 3529639 11月 30 10:22 ngx_openresty-1.9.3.2.tar.gz
然后,打patch
[nginx@localhost~]$cd ngx_openresty-1.9.3.2/bundle/nginx-1.9.3
[nginx@localhost~/ngx_openresty-1.9.3.2/bundle/nginx-1.9.3]$patch -p1 < /home/nginx/nginx_tcp_proxy_module-master/tcp.patch
patching file src/core/ngx_log.c
Hunk #1 FAILED at 66.
1 out of 1 hunk FAILED -- saving rejects to file src/core/ngx_log.c.rej
patching file src/core/ngx_log.h
Hunk #1 FAILED at 29.
Hunk #2 FAILED at 36.
2 out of 2 hunks FAILED -- saving rejects to file src/core/ngx_log.h.rej
patching file src/event/ngx_event_connect.h
Hunk #1 succeeded at 33 (offset 1 line).
Hunk #2 succeeded at 45 with fuzz 2 (offset 2 lines).
最后
[nginx@localhost~]$cd ngx_openresty-1.9.3.2
[nginx@localhost~/ngx_openresty-1.9.3.2]$./configure --prefix=/home/nginx/OpenResty --add-module=/home/nginx/nginx_tcp_proxy_module-master
make -j `cat /proc/cpuinfo | grep processor| wc -l`
make install
修改配置文件
[nginx@localhost~]$cd OpenResty/nginx/conf
[nginx@localhost~/OpenResty/nginx/conf]$vim nginx.conf
tcp{
upstream MySQL {
server 172.16.1.25:3306 weight=10;
server 172.16.1.78:3306 weight=10 down;
#check interval=10000 rise=2 fall=5 timeout=10000 type=mysql;
}
server {
listen 9999;
proxy_pass mysql;
timeout 1d;
proxy_read_timeout 1d;
proxy_send_timeout 1d;
proxy_connect_timeout 3000;
so_keepalive on;
tcp_nodelay on;
}
}
注意:check要注释,否则连接不上.原因未知.
参考:
https://github.com/yaoweibin/nginx_tcp_proxy_module
MySQL 回滚 insert 语句导致 ibd 文件增大‘一倍’
相关资讯 OpenResty OpenResty负载均衡
本文评论 查看全部评论 (0)
尊重网上道德,遵守中华人民共和国的各项有关法律法规 承担一切因您的行为而直接或间接导致的民事或刑事法律责任 本站管理人员有权保留或删除其管辖留言中的任意内容 本站有权在网站内转载或引用您的评论 参与本评论即表明您已经阅读并接受上述条款
评论声明
最新资讯