Linux下玩转nginx系列(八)---如何使用upsync模块付诸动态负载均衡
2023-04-23 运营
3.指派 ./consul 经常出现都有电子邮件就说明装配成功
4.关机consul ,我的linux ipIP192.168.199.104
./consul agent -dev -ui -node=consul-dev -client=192.168.199.1045.临时废弃代理服务器端
systemctl stop firewalld6.Firefox会见192.168.199.104:8500,会经常出现如下网址
7.使用PostMan 申领HTTP公共服务
//此处ipIP为ConsulServer所在公共服务器端的IP // //值1 { "Datacenter": "dc1", "Node": "go-http", "Address": "192.168.199.104", //本地IP "Service": { "Id": "192.168.199.104:8080", # 8080 "Service": "helloword", "tags": [ "dev" ], "Port": 8080 } } //值2 { "Datacenter": "dc1", "Node": "go-http", "Address": "192.168.199.104", "Service": { "Id": "192.168.199.104:8081",//8081 "Service": "helloword", "tags": [ "dev" ], "Port": 8081 } }Datacenter自行决定的设备,
Address自行决定公共服务IP,
Service.Id自行决定公共服务唯一标识,
Service.Service自行决定公共服务分组,
Service.tags自行决定公共服务标签(如测试环境污染、预发环境污染等),
Service.Port自行决定公共服务端口。
8.发掘出HTTP公共服务
三、NGINX-UPSYNC-MODULE注意到:清除之前Nginx环境污染,新的装配。
NGINX-UPSYNC-MODULE概述
Upsync是博客博客源代码的基于Nginx解决疑问实时的设计的三方子系统。Nginx-Upsync-Module的机制是利取Consul的后端server的列表,并实时系统升级Nginx的链路电子邮件。此子系统不缺少于任何第三方子系统。Consul作为Nginx的DB,利用Consul的KV公共服务,每个Nginx Work进程独立自主的去利取各个upstream的的设计,并系统升级各自的链路。
NGINX-UPSYNC-MODULE装配及的设计整个流程
装配Nginx
wget #效用:解决疑问反之亦然代理、扭矩扭矩特装配consul
wget _1.13.1_linux_amd64.zip #效用:对实时扭矩渐进除此以外的设计解决疑问申领装配nginx-upsync-module
wget #效用:nginx实时提供当前upstream电子邮件 #tar装配 unzip master.zip unzip consul_1.13.1_linux_amd64.zip #如果tar经常出现该差错 -bash: unzip: 确有命令 #centos这样一来 yum -y install unzip #ubuntu这样一来 apt-get -y install unzip #装配Nginx #tarNginx tar -zxvf nginx-1.23.1.tar.gz #的设计Nginx groupadd nginx useradd -g nginx -s /sbin/nologin nginx mkdir -p /var/tmp/nginx/client/ mkdir -p /usr/local/nginx编译器Nginx
cd nginx-1.23.1 ./configure 便是prefix=/usr/local/nginx 便是user=nginx 便是group=nginx 便是with-http_ssl_module 便是with-http_flv_module 便是with-http_stub_status_module 便是with-http_gzip_static_module 便是with-http_realip_module 便是http-client-body-temp-path=/var/tmp/nginx/client/ 便是http-proxy-temp-path=/var/tmp/nginx/proxy/ 便是http-fastcgi-temp-path=/var/tmp/nginx/fcgi/ 便是http-uwsgi-temp-path=/var/tmp/nginx/uwsgi 便是http-scgi-temp-path=/var/tmp/nginx/scgi 便是with-pcre 便是add-module=../nginx-upsync-module-master make && make install 编译器的是报错 ./configure: error: SSL modules require the OpenSSL library. centos这样一来 yum -y install openssl openssl-devel ubuntu这样一来 apt-get -y install openssl openssl-devel创建upsync_dump_path
mkdir /usr/local/nginx/conf/servers/ #upsync_dump_path自行决定从consul利取的上游公共服务器端后长久化到的前面,这样即使consul公共服务器端出疑问了,本地还有一个备份。Upstream 实时的设计
http { upstream helloworld{ server 127.0.0.1:1111; #连接起来Consul Server 实时提供 的设计扭矩渐进电子邮件,间隙0.5s提供电子邮件 upsync 192.168.199.104:8500/v1/kv/upstreams/helloworld upsync_timeout=6m upsync_interval=500ms upsync_type=consul strong_dependency=off; #实时的利去ConsulServer 相关扭矩渐进电子邮件长久化到硬盘上 upsync_dump_path /usr/local/nginx/conf/servers/servers_test.conf; } server { listen 80; server_name localhost; location / { proxy_pass ; index index.html index.htm; } } }1.upsync指令自行决定从consul哪个偏移利取上游公共服务器端的设计;
upsync_timeout的设计从consul利取上游公共服务器端的设计的超时时间段;upsync_interval的设计从consul利取上游公共服务器端的设计的间隙;upsync_type自行决定使用consul的设计公共服务器端;
strong_dependency的设计nginx在关机时是否强制缺少的设计公共服务器端,如果的设计为on,则利取的设计最终时nginx关机或多或少最终。
upsync_dump_path自行决定从consul利取的上游公共服务器端后长久化到的前面,这样即使consul公共服务器端出疑问了,本地还有一个备份。
2.注意到:取而代之 consul 申领中会心IP
关机consul
临时废弃代理服务器端systemctl stop firewalld 我的linux IpIP192.168.199.104 ./consul agent -dev -ui -node=consul-dev -client=192.168.199.104添加nginx Upstream公共服务
1.使用linux命令方法发送put请求 curl -X PUT curl -X PUT 2.使用postmen 发送put请求 扭矩渐进电子邮件值 {"weight":1, "max_fails":2, "fail_timeout":10, "down":0}关机Nginx
参考PDFnginx-proxy_pass官方
Full Example Configuration
nginx-upsync-module
【NGINX】基于CONSUL+UPSYNC+NGINX解决疑问实时扭矩渐进
。如何促进伤口快速愈合中度肝纤维化吃什么药
江中多维元素片
宝宝拉肚子吃什么药好
肠胃型感冒的中医疗法,建议收藏
- 02-10赵本山儿子:你们算哪根葱,我家的钱十辈子也大花不完,还敢批评我
- 02-10警告!这个办法还可以买到返程火车票
- 02-1061岁刘德华观看女儿学校演出,穿搭时髦状态年轻,和朱丽倩恩爱几位
- 02-10时隔5年李咏死因被揭开,妻子哈文道破真相,遗体为何不运转赴
- 02-10网传举报高速公路违章一分钟花钱3000元,实际奖励标准为30元/起
- 02-10如何正确封阳台?4种简单易行的方法有,让你拥有安全保障的小家
- 02-10爆料!姐弟恋实锤,新娘怀孕了,在别墅养胎?是真实的么
- 02-10幸福马在大嫂
- 02-1049.9买一送一得2套,素色显瘦保暖套装,高品质,高颜值!在家也要精致到却是!
- 02-10啥是光明会?从杨颖佩戴的指环来科普下光明会!