Nginx代理MysqlCluster集群(二)

Nginx代理MySql集群
本次实验采用nginx 版本1.12以上 集合了tcp代理功能
只需在编译时明文开启指定的功能 --with-stream
--prefix=/usr/local/ngin --user=nginx --group=nginx --with-http_stub_status_module --with-stream

配置文件
stream{ #作为iweb服务器在http模块 代理tcp在stream模块中
upstream cluster {
# hash $remote_addr consistent; //保持session不变
server 192.168.1.2:3306 max_fails=3 fail_timeout=30s;
server 192.168.1.3:3306 max_fails=3 fail_timeout=30s;
}
server {
listen 1234;
proxy_pass cluster;
}
}

在较低的版本需要添加有yaowenbin 开发的模块nginx_tcp_proxy_module
wget http://nginx.org/download/nginx-1.7.4.tar.gz
wget https://codeload.github.com/yaoweibin/nginx_tcp_proxy_module/legacy.tar.gz/master

下载下来的master 是个tar包

#Yum install -y patch
#cd nginx-1.7.4
#patch -p1 < ../nginx_tcp_proxy_module/tcp.patch
#./configure --prefix=/usr/local/ngin --user=nginx --group=nginx --with-http_stub_status_module --addmodule=../
nginx_tcp_proxy_module

配置文件
tcp {
upstream proxy_name {
# simple round-robin
server 192.168.1.10:8000;
check interval=3000 rise=2 fall=5timeout=1000;
}
server {
listen 8888;
proxy_pass proxy_name;
}
}

转载于:https://www.cnblogs.com/luoyan01/p/9734158.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值