博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
consul_nginx_uprsync动态负载均衡
阅读量:7048 次
发布时间:2019-06-28

本文共 2101 字,大约阅读时间需要 7 分钟。

consul_nginx_uprsync动态负载均衡

环境准备:原理描述:将Nginx的负载均衡后端服务器配置信息写入consul的接口中,upsync插件通过读取consul的配置,然后持久化到nginx的一个配置文件,nginx通过读取这个配置文件来进行负载均衡1.    重新编译安装tengine2.2.3将upsync这个插件关键插件:--add-module=/usr/local/src/nginx-upsync-module-nginx-upsync-1.8.x./configure --prefix=/usr/local/tengine-2.2.3_upsync --with-ld-opt=-Wl,-rpath, --user=daemon --group=daemon --with-http_ssl_module --with-http_realip_module --with-http_addition_module --with-http_xslt_module --with-http_sub_module --with-http_stub_status_module --with-http_dav_module --with-http_flv_module --with-http_mp4_module --with-http_gzip_static_module --with-http_geoip_module --with-http_secure_link_module --with-http_degradation_module --with-mail_ssl_module --with-http_sysguard_module --with-http_concat_module --with-pcre=/usr/local/lab/pcre-8.34 --with-zlib=/usr/local/lab/zlib-1.2.11 --add-module=/usr/local/lab/ngx_cache_purge-2.3 --with-jemalloc --with-http_upstream_check_module --with-http_lua_module --with-luajit-lib=/usr/local/lib/ --with-luajit-inc=/usr/local/include/luajit-2.0/ --with-lua-inc=/usr/local/include/luajit-2.0/ --with-lua-lib=/usr/local/lib/ --with-openssl=/usr/local/lab/openssl-1.1.0i --add-module=/usr/local/ngx_http_geoip2_module-3.2 --add-module=/usr/local/src/nginx-upsync-module-nginx-upsync-1.8.x2.启动consulconsul agent -dev -ui -node=consul-dev -client=10.11.0.210Nginx的配置:upstream itmayiedu{        server 127.0.0.1:11111;        upsync 10.11.0.210:8500/v1/kv/upstreams/itmayiedu upsync_timeout=6m upsync_interval=500ms upsync_type=consul strong_dependency=off;        upsync_dump_path /usr/local/tengine-2.2.3_upsync/conf/vhost.d/itmayiedu;    }        server {        listen       80  default_server;        server_name  localhost;        location / {        proxy_pass http://itmayiedu;        proxy_set_header  Host  $host;        proxy_set_header  X-Real-IP  $remote_addr;        proxy_set_header  X-Forwarded-For  $proxy_add_x_forwarded_for;        add_header    real $upstream_addr;        }# 其中一台后端的配置

读取到的持久化配置文件

通过接口控制后端服务器配置

注意是put方式

最终在consul中显示

转载于:https://www.cnblogs.com/reblue520/p/10910618.html

你可能感兴趣的文章
将不确定变为确定~真的是SqlDataReader引起的超时?
查看>>
TCP客户机-服务器
查看>>
Hibernate连接DB2的问题(已解决)
查看>>
I.MX6 dts 在哪里、怎么编译
查看>>
第 44 章 Chart 图表
查看>>
JQuery ztree 异步加载实践
查看>>
XOR算法的原理和实现
查看>>
EF架构~一个规范,两个实现(续)~性能可以接受的批量增删改操作
查看>>
tensorflow笔记:多层LSTM代码分析
查看>>
Selenium2(WebDriver)总结(一)---启动浏览器、设置profile&加载插件
查看>>
iOS - C 基本语法
查看>>
我的软件测试之旅:(8)困难——没有现成的测试工具
查看>>
“智慧城市”建设风生水起
查看>>
楼宇对讲防盗报警系统两大特点
查看>>
使用“伪造”数据是消除大数据隐私问题的关键
查看>>
浅谈信息安全与数据中心安全的关系
查看>>
《PostgreSQL服务器编程》一一2.7 小结
查看>>
Oracle Database 12.2新特性详解
查看>>
IBM:量子计算现在跟1940年代电脑差不多 更看重长远目标
查看>>
研究机构称独角兽更易获得融资 明后年或有大量企业IPO
查看>>