nginx 负载mysql_Nginx四层负载反代MySQL

src]# wget http://nginx.org/download/nginx-1.9.4.tar.gz

--2017-04-13 10:05:08-- http://nginx.org/download/nginx-1.9.4.tar.gz

Resolving nginx.org... 206.251.255.63, 95.211.80.227, 2001:1af8:4060:a004:21::e3, ...

Connecting to nginx.org|206.251.255.63|:80... connected.

HTTP request sent, awaiting response...200OK

Length:866423 (846K) [application/octet-stream]

Saving to: “nginx-1.9.4.tar.gz”100%[=================================================================================>] 866,423 16.2K/s in36s2017-04-13 10:05:50 (23.3 KB/s) - “nginx-1.9.4.tar.gz” saved [866423/866423]

解压

[root@localhost src]# tar zxvf nginx-1.9.4.tar.gz

[root@localhost src]# cd nginx-1.9.4

配置、编译、安装

[root@localhost nginx-1.9.4]# ./configure --user=nginx --group=nginx --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-stream

[root@localhost nginx-1.9.4]# echo $?

0[root@localhost nginx-1.9.4]# make &&make install

[root@localhost nginx-1.9.4]# echo $?

0

启动服务

[root@localhost nginx-1.9.4]# ln -s /usr/local/nginx/sbin/*/usr/local/sbin/

[root@localhost nginx-1.9.4]# ll /usr/local/sbin/

total 0

lrwxrwxrwx 1 root root 27 Apr 13 13:29 nginx -> /usr/local/nginx/sbin/nginx

[root@localhost nginx-1.9.4]# /usr/local/sbin/nginx -t

nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok

nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful

[root@localhost nginx-1.9.4]# /usr/local/sbin/nginx

[root@localhost nginx-1.9.4]# netstat -nlput | grep nginx

tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 1271/nginx

[root@localhost nginx-1.9.4]# lsof -i :80

COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME

nginx 1271 root 6u IPv4 9108 0t0 TCP *:http (LISTEN)

nginx 1272 nginx 6u IPv4 9108 0t0 TCP *:http (LISTEN)

[root@localhost nginx-1.9.4]# curl -I localhost

HTTP/1.1 200 OK

Server: nginx/1.9.4

Date: Thu, 13 Apr 2017 05:37:43 GMT

Content-Type: text/html

Content-Length: 612

Last-Modified: Thu, 13 Apr 2017 03:16:08 GMT

Connection: keep-alive

ETag: "58eeed78-264"

Accept-Ranges: bytes

代理MySQL

[root@localhost nginx-1.9.4]# cd /usr/local/nginx/conf/[root@localhost conf]# echo>nginx.conf

[root@localhost conf]# vim nginx.conf

worker_processes auto;

events {

worker_connections1024;

}

error_log/var/log/nginx_error.log info;

stream {

upstream mysqld {

hash $remote_addr consistent;

server172.19.10.98:3306 weight=5 max_fails=1 fail_timeout=10s;

# server192.168.1.43:3306 weight=5 max_fails=1 fail_timeout=10s;

}

server {

listen3306;

proxy_connect_timeout 1s;

proxy_timeout 3s;

proxy_pass mysqld;

}

}

[root@localhost conf]#/usr/local/sbin/nginx -t

nginx: the configuration file/usr/local/nginx/conf/nginx.conf syntax isok

nginx: configuration file/usr/local/nginx/conf/nginx.conf test issuccessful

[root@localhost conf]# cat nginx.conf

worker_processes auto;

events {

worker_connections1024;

}

error_log/var/log/nginx_error.log info;

stream {

upstream mysqld {

hash $remote_addr consistent;

server172.19.10.98:3306 weight=5 max_fails=1 fail_timeout=10s;

# server172.19.10.94:3306 weight=5 max_fails=1 fail_timeout=10s;

}

server {

listen3306;

proxy_connect_timeout 1s;

proxy_timeout 3s;

proxy_pass mysqld;

}

}

Nginx四层负载反代MySQL

标签:sse   erro   3.3   http   mysq   make   evel   out   date

本条技术文章来源于互联网,如果无意侵犯您的权益请点击此处反馈版权投诉

本文系统来源:http://www.cnblogs.com/zzzhfo/p/6703866.html

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值