Windows 下使用nginx对SqlServer进行负载均衡

本文涉及的产品
云数据库 RDS SQL Server,独享型 2核4GB
简介: windows 下使用nginx对SqlServer进行负载均衡

windows 下使用nginx对SqlServer进行负载均衡
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 参数来激活这个模块。
https://nginx.org/en/docs/stream/ngx_stream_core_module.html
在windows下
1.我希望在window下做mysql的均衡
D:ToolsWebServerNginxnginx-1.13.5>nginx.exe -V

版本信息

nginx version: nginx/1.13.5
built by cl 16.00.40219.01 for 80x86
built with OpenSSL 1.0.2l 25 May 2017
TLS 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.41 --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

1

4.免去了window下编译nginx的步骤
1.修改nginx.conf

stream 测试mysql均衡 2017-9-11

stream
{

upstream mssql{
    hash $remote_addr consistent;
server 127.0.0.1:49905 max_fails=3 fail_timeout=30s;
    server 127.0.0.1:1433 max_fails=3 fail_timeout=30s;

}
server {
    listen 1444;
    proxy_connect_timeout 1s;
    proxy_timeout 3s;
    proxy_pass mssql;

}

}

简单的测试配置,更详细请参考官方文档

https://nginx.org/en/docs/stream/ngx_stream_core_module.html

2

2.注意:如果你在本机上(Nginx与SqlServer都在同一机器上)做测试,server的端口不要为1433,不然会SqlServer的端口冲突
3.如果是生产环境,负载均衡服务器与SqlServer不在同一机器,可以为1433
4.启动nginx,启动sqlserver
5.你可以使用命令行来查看端口占用,查看nginx是否运行成功
netstat -ano|findstr "1444"
3

使用nginx的地址与端口,直接连接sqlserver,查看是否连接成功
127.0.0.1,1444
4
使用SQLServert管理工具进行连接测试

5
6

SqlServer的负载均衡
1.以上测试,只使用了一台SqlServer服务器,真正的负载均衡可不会
2.还要做以下的工作,创建SqlServer的集群,将SqlServer的数据同步。

相关实践学习
部署高可用架构
本场景主要介绍如何使用云服务器ECS、负载均衡SLB、云数据库RDS和数据传输服务产品来部署多可用区高可用架构。
负载均衡入门与产品使用指南
负载均衡(Server Load Balancer)是对多台云服务器进行流量分发的负载均衡服务,可以通过流量分发扩展应用系统对外的服务能力,通过消除单点故障提升应用系统的可用性。 本课程主要介绍负载均衡的相关技术以及阿里云负载均衡产品的使用方法。
目录
相关文章
|
10天前
|
负载均衡 算法 应用服务中间件
面试题:Nginx有哪些负载均衡算法?Nginx位于七层网络结构中的哪一层?
字节跳动面试题:Nginx有哪些负载均衡算法?Nginx位于七层网络结构中的哪一层?
28 0
|
8天前
|
应用服务中间件 nginx Windows
【报错】Windows下启动nginx报:bind() to 0.0.0.0:80 failed...
【报错】Windows下启动nginx报:bind() to 0.0.0.0:80 failed...
|
17天前
|
应用服务中间件 nginx Windows
windows下Nginx+RTMP部署
windows下Nginx+RTMP部署
15 0
|
1月前
|
NoSQL Java 应用服务中间件
使用innoSetup将mysql+nginx+redis+jar包打包成windows安装包
使用innoSetup将mysql+nginx+redis+jar包打包成windows安装包
使用innoSetup将mysql+nginx+redis+jar包打包成windows安装包
|
1月前
|
应用服务中间件 nginx Windows
windows下快速安装nginx 并配置开机自启动
windows下快速安装nginx 并配置开机自启动
windows下快速安装nginx 并配置开机自启动
|
1月前
|
算法 应用服务中间件 网络安全
windows下采用 nginx配置websocket支持wss流程
windows下采用 nginx配置websocket支持wss流程
|
2月前
|
负载均衡 Java 应用服务中间件
|
2月前
|
负载均衡 监控 应用服务中间件
Nginx负载均衡:你的网站流量翻倍利器
Nginx负载均衡:你的网站流量翻倍利器
42 0
|
2月前
|
消息中间件 关系型数据库 MySQL
使用Nginx的stream模块实现MySQL反向代理与RabbitMQ负载均衡
使用Nginx的stream模块实现MySQL反向代理与RabbitMQ负载均衡
60 0
|
3月前
|
应用服务中间件 nginx 网络架构
Windows系统如何修改Nginx配置实现远程访问多个本地站点
Windows系统如何修改Nginx配置实现远程访问多个本地站点
68 0