Nginx逆世代MySQLケース


ケース:友達がNginxエージェントMySQL(MySQLローカルエリアネットワーク)を使用する場合、使用しない×××,NATマッピングなどは使わないで、よし、メモを取りましょう.
Nginxバージョン:1.9.x(tcpの負荷バランスを持ち、nginx_tcp_proxy_module(姚偉斌アリチームも実現可能))
Nginx公式モジュール:ngx_stream_core_module --with-stream_ssl_module(sslプロトコルサポート、例えばMySQL ssl)
公式サイト:http://nginx.org/en/docs/stream/ngx_stream_core_module.html
1、既存のコンパイルの表示
 --user=nginx --group=nginx --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-http_realip_module --with-http_flv_module --with-http_mp4_module --with-http_gzip_static_module

2、再コンパイル:
http://nginx.org/download/
--user=nginx --group=nginx --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-http_realip_module --with-http_flv_module --with-http_mp4_module --with-http_gzip_static_module --with-stream --with-stream_ssl_module

注意:--with-stream--with-stream_ssl_module
3、構成、検出、nginxの再起動:
構成:
stream {
upstream mysql {
zone myapp1 64k;
server localhost:3306 weight=1 max_fails=3 fail_timeout=30s;
#server 192.168.1.221:3306 weight=1 max_fails=2 fail_timeout=30s;   
}
server {
         listen 2188;
         proxy_connect_timeout 1s;
         proxy_timeout 3s;
         proxy_pass mysql;
}
}

検出:
[root@autoCentos67X64 conf]# 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@autoCentos67X64 conf]#

開始:
[root@autoCentos67X64 conf]# netstat -atupn|grep nginx
tcp        0      0 0.0.0.0:2188                0.0.0.0:*                   LISTEN      2359/nginx          
[root@autoCentos67X64 conf]#

4、検証:(転載は保留してください:renzhiyuan.blog.51 cto.com)
[root@log~]# mysql -uroot -prenzhiyuan -h 192.168.1.11 -P2188
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.6.21-log MySQL Community Server (GPL)
Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>

Nginx反代MySQL案例_第1张图片
注意:2188はNginxのポートで、エージェント(負荷)のバックエンドのMySQLです.他の遊び方はみんなで研究することができます.