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

本文涉及的产品
传统型负载均衡 CLB,每月750个小时 15LCU
RDS SQL Server Serverless,2-4RCU 50GB 3个月
推荐场景:
云数据库 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的数据同步。

相关实践学习
SLB负载均衡实践
本场景通过使用阿里云负载均衡 SLB 以及对负载均衡 SLB 后端服务器 ECS 的权重进行修改,快速解决服务器响应速度慢的问题
负载均衡入门与产品使用指南
负载均衡(Server Load Balancer)是对多台云服务器进行流量分发的负载均衡服务,可以通过流量分发扩展应用系统对外的服务能力,通过消除单点故障提升应用系统的可用性。 本课程主要介绍负载均衡的相关技术以及阿里云负载均衡产品的使用方法。
目录
相关文章
|
23天前
|
负载均衡 应用服务中间件 Linux
"揭晓nginx的神秘力量:如何实现反向代理与负载均衡,拯救服务器于水火?"
【8月更文挑战第20天】在Linux环境下,nginx作为高性能HTTP服务器与反向代理工具,在网站优化及服务器负载均衡中扮演重要角色。本文通过电商平台案例,解析nginx如何解决服务器压力大、访问慢的问题。首先介绍反向代理原理,即客户端请求经由代理服务器转发至内部服务器,隐藏真实服务器地址;并给出配置示例。接着讲解负载均衡原理,通过将请求分发到多个服务器来分散负载,同样附有配置实例。实践表明,采用nginx后,不仅服务器压力得到缓解,还提升了访问速度与系统稳定性。
39 3
|
23天前
|
负载均衡 算法 应用服务中间件
在Linux中,nginx反向代理和负载均衡实现原理是什么?
在Linux中,nginx反向代理和负载均衡实现原理是什么?
|
25天前
|
负载均衡 应用服务中间件 nginx
Nginx怎么去做负载均衡?
Nginx的负载均衡器配置就完成了,而且由于Nginx的配置文件结构清晰而且简洁,调整和维护也相对方便。通过上述步骤,你可以将Nginx设置为一款强大的负载均衡器,提升服务器集群的处理能力及高可用性。
32 4
|
1月前
|
域名解析 负载均衡 网络协议
双重神器合璧,流量洪流中的稳如磐石:揭秘Bind+Nginx负载均衡的超级力量!
【8月更文挑战第9天】在现代网站架构中,负载均衡至关重要,它通过分散客户端请求至多台服务器,确保了系统的高可用性和稳定性。本文介绍如何结合Bind与Nginx实现高效负载均衡。Bind作为DNS服务器,可为单一域名解析出多个IP地址;Nginx作为高性能HTTP服务器,则在这些IP对应的服务器间智能分配流量。通过配置Bind的A记录与Nginx的`upstream`和`proxy_pass`指令,我们能够构建一个既稳定又易扩展的负载均衡系统,显著提升用户体验与系统可靠性。
42 11
|
1月前
|
负载均衡 监控 算法
Nginx:负载均衡小专题(二)
Nginx:负载均衡小专题(二)
35 2
|
1月前
|
负载均衡 监控 网络协议
Nginx:负载均衡小专题(三)
Nginx:负载均衡小专题(三)
70 1
|
1月前
|
负载均衡 监控 算法
Nginx:负载均衡小专题(一)
Nginx:负载均衡小专题(一)
62 1
|
1月前
|
JavaScript 应用服务中间件 nginx
Windows安装hexo并配置nginx
Windows安装hexo并配置nginx
|
19天前
|
负载均衡 应用服务中间件 Linux
在Linux中,Nginx如何实现负载均衡分发策略?
在Linux中,Nginx如何实现负载均衡分发策略?
|
2月前
|
负载均衡 算法 应用服务中间件
nginx自定义负载均衡及根据cpu运行自定义负载均衡
nginx自定义负载均衡及根据cpu运行自定义负载均衡
29 1