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
4.免去了window下编译nginx的步骤
1.修改nginx.conf
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.html2.注意:如果你在本机上(Nginx与SqlServer都在同一机器上)做测试,server的端口不要为1433,不然会SqlServer的端口冲突
3.如果是生产环境,负载均衡服务器与SqlServer不在同一机器,可以为1433
4.启动nginx,启动sqlserver
5.你可以使用命令行来查看端口占用,查看nginx是否运行成功
netstat -ano|findstr "1444"
使用nginx的地址与端口,直接连接sqlserver,查看是否连接成功
127.0.0.1,1444
使用SQLServert管理工具进行连接测试
SqlServer的负载均衡
1.以上测试,只使用了一台SqlServer服务器,真正的负载均衡可不会
2.还要做以下的工作,创建SqlServer的集群,将SqlServer的数据同步。
相关文章
- sql 分组取最新的数据sqlserver巧用row_number和partition by分组取top数据
- 关于weblogic配置pg和sqlserver数据源的注意事项
- Sqlserver 命令行方式修改 用户密码的方法
- SQLSERVER sa 用户密码修改的方法
- Oracle与SQLSERVER修改数据文件的路径
- [读书笔记]SQLSERVER企业级平台管理实践读书笔记02
- 安装Windows 2012域控(For SQLServer 2014 AlwaysOn)
- 【sqlserver】添加定时作业
- sqlserver更新表脚本
- 原生sqlServer数据库连接
- SQLServer 错误: 15404,无法获取有关 Windows NT 组 用户
- 如何将sqlserver的windows验证模式改为SQL Server 和 Windows 混合身份验证模式
- SQLSERVER中如何快速比较两张表的不一样
- 我是如何在SQLServer中处理每天四亿三千万记录的
- SQLserver提权