windows 下使用nginx对mysql进行负载均衡
来源:互联网 发布:网络变压器加工图 编辑:程序博客网 时间:2024/06/01 12:46
windows 下使用nginx对mysql进行负载均衡
1.自从nginx版本1.9之后,nginx 便增加了对tcp与udp协议的支持
官方文档
The ngx_stream_core_module module is available since version 1.9.0. This module is not built by default, it should be enabled with the –with-stream configuration parameter.
2.但是在linux下默认不安装这个模块,需要在编译时通过指定 –with-stream 参数来激活这个模块。
在windows下
1.我希望在window下做mysql的均衡
2.于是使用命令查看nginx已安装的模块
E:\nginx-1.12.1>nginx -V#版本信息nginx version: nginx/1.12.1built by cl 16.00.40219.01 for 80x86built with OpenSSL 1.0.2l 25 May 2017TLS SNI support enabled#安装的模块configure arguments: --with-cc=cl --builddir=objs.msvc8 --with-debug --prefix= --conf-path=conf/nginx.conf --pid-path=logs/nginx.pid --http-log-path=logs/access.log --error-log-path=logs/error.log --sbin-path=nginx.exe --http-client-body-temp-path=temp/client_body_temp --http-proxy-temp-path=temp/proxy_temp --http-fastcgi-temp-path=temp/fastcgi_temp --http-scgi-temp-path=temp/scgi_temp --http-uwsgi-temp-path=temp/uwsgi_temp --with-cc-opt=-DFD_SETSIZE=1024 --with-pcre=objs.msvc8/lib/pcre-8.40 --with-zlib=objs.msvc8/lib/zlib-1.2.11 --with-select_module --with-http_v2_module --with-http_realip_module --with-http_addition_module --with-http_sub_module --with-http_dav_module --with-http_stub_status_module --with-http_flv_module --with-http_mp4_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_auth_request_module --with-http_random_index_module --with-http_secure_link_module --with-http_slice_module --with-mail **--with-stream **--with-openssl=objs.msvc8/lib/openssl-1.0.2l --with-openssl-opt=no-asm --with-http_ssl_module --with-mail_ssl_module --with-stream_ssl_module
3.可以看到已经安装了,需要的模块
4.免去了window下编译nginx的步骤,感谢大佬
对mysql进行均衡负载
1.修改nginx.conf
#stream 测试mysql均衡 2017-8-23stream{ upstream mysql{ hash $remote_addr consistent; server 127.0.0.1:3306 max_fails=3 fail_timeout=30s; } server { listen 3308; proxy_connect_timeout 1s; proxy_timeout 3s; proxy_pass mysql; }}#简单的测试配置,更详细请参考官方文档#https://nginx.org/en/docs/stream/ngx_stream_core_module.html
2.注意:如果你在本机上(Nginx与mysql都在同一机器上)做测试,server的端口不要为3306,不然会与mysql的端口冲突
3.如果是生产环境,负载均衡服务器与mysql不在同一机器,可以为3306
4.启动nginx,启动mysql
5.你可以使用命令行来查看端口占用,查看nginx是否运行成功
netstat -ano|findstr “3308”
使用nginx的地址与端口,直接连接mysql,查看是否连接成功
mysql的负载均衡
1.以上测试,只使用了一台mysql服务器,真正的负载均衡可不会
2.还要做以下的工作,创建mysql的集群,将mysql的数据同步。
阅读全文
0 0
- windows 下使用nginx对mysql进行负载均衡
- windows 下使用nginx 实现负载均衡
- linux、windows下利用Nginx对Tomcat做负载均衡
- windows server中使用nginx进行负载均衡
- Windows下使用Nginx+tomcat配置负载均衡
- Windows下nginx+tomcat的负载均衡
- Windows下nginx+tomcat的负载均衡
- windows下nginx负载均衡配置
- Nginx简单介绍以及linux下使用Nginx进行负载均衡的搭建
- ubuntu下使用nginx做负载均衡
- 使用Nginx负载均衡
- nginx使用负载均衡进行压力测试得到的结论
- [随笔] docker上使用nginx进行负载均衡示例
- windows nginx -- 搭建 负载均衡
- Nginx+Tomcat在Windows下做负载均衡
- nginx+tomcat在windows下做负载均衡
- Windows下配置Nginx+Tomcat配置集群负载均衡
- windows下nginx+tomcat+memcache负载均衡集群搭建
- hadoop异常问题解决
- ps -aux|grep 详细信息
- Java 集合深入理解(9):Queue 队列
- HDOJ1024 Max Sum Plus Plus(区间DP)
- PHP实现模糊搜索中文分词
- windows 下使用nginx对mysql进行负载均衡
- 第一次机房收费系统总结
- JavaScript实现-检查字符串结尾-Confirm the Ending
- 猫捉老鼠 FZU
- 在ajax中function的三种加载方式
- ASP.NET查看当前 SQL SERVER 连接数量及各状态
- Flip Game POJ
- 剑指offer_递归与循环---跳台阶
- Java 集合深入理解(10):Deque 双端队列