Nginx
Nginx
nginx-stream-upsync -module has–a brother nginx upsync -module, which provides HTTP seven-layer dynamic load balancing, dynamic update upstream server does not need to reload nginx. The current latest version is based on Nginx1.9.10 developed, so compatible .10+ version. It provides an upstream server implementation for a dynamic update based on the consul. This section demonstrates based on Nginx version 1.9.10 and the consul configuration center.
First, you need to download and add the latest version of the nginx-stream-upsync-module module.
./configure –prefix-/usr/servers –with-stream –add-module- 。/nginx-stream-upsync-module
1. upstream configuration
upstream mysql_ backend {
server 127.0.0.1:1111; #occupancy server
upsync 127.0.0.1:8500/v1/kv/upstreams/mysql_ backend upsync_ timeout -6m
upsync_ interva1=500ms upsync_ type=consul strong_ dependency=off;upsync_ dump_ path /usr/servers/nginx/conf/mysq1_ backend.conf;
}
The upsyne directive specifies which path to pull the upstream server configuration from consul: upsync_ timeout configures the timeout time to pull the upstream server configuration from consul: upsync_ interval configures the interval to pull the upstream server configuration from consul: upsyne. ; strong _dependency Configure whether Nginx is forced to depend on the configuration server at startup. If the configuration is on, then Nginx startup will also fail if the configuration fails to be pulled.
upsync. _dump_ path specifies the location where the upstream server pulled from consul is persisted to so that even if there is a problem with the consul server, there is a local backup.
2. Add an upstream server from Consul
curl -x pur -d “(\”weight\”:1。 \”max_ falls\”;2, \”fail_ _timeout\”:10)”http://127.0.0.1:8500/v1/kw/ upstreams /mysql. backend/ 10.0.0.24:3306
curl -x PUT -d “(\”weight\”:1, \”max_ fails\”:2,\”fall_ timeout\”;10}”http://127.0.0.1:8500/v1/ kv/upstreams/mysql. backend/192.168.0.11:3306
3. Remove the upstream server from Consul
curl -X DELETE http://127.0.0.1:8500/v1/kv/upstreams/mysq1_ backend / 192.168.0.11: 3306
4. upstream_ show
server {
listen 1234; upstream_ show;
}
After configuring the uptream. Show command, you can use curl hp:///7./.1:123/pstramn show to view the current dynamic load balancing upstream server list.
At this point, the configuration of dynamic load balancing is complete, and we have explained the dynamic addition/deletion of upstream servers. In actual use, please perform preassure test to evaluate its stability. In practical applications, it is more to use HaProxy for four-layer load balancing. Therefore, it is still necessary to choose a scheme according to your own scenario.

LEAVE A REPLY

Please enter your comment!
Please enter your name here