consul_nginx_uprsync动态负载均衡

环境准备:
原理描述:
将Nginx的负载均衡后端服务器配置信息写入consul的接口中,upsync插件通过读取consul的配置,然后持久化到nginx的一个配置文件,nginx通过读取这个配置文件来进行负载均衡 . 重新编译安装tengine2..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. --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.x .启动consul
consul agent -dev -ui -node=consul-dev -client=10.11.0.210 Nginx的配置:
upstream itmayiedu{
server 127.0.0.1:;
upsync 10.11.0.210:/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 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中显示

最新文章

  1. Mac OS 下 mysql 找不到 mysql.sock 的问题
  2. php——用for循环打印半金字塔、金字塔、正方形、倒金字塔、菱形、空心图形等
  3. c++ Windows Socket实现最简单的C/S网络通信(TCP)
  4. WCF 笔记 (2) - 传输泛型 List 对象
  5. Unity3D除了在编辑器里,怎么用代码给一个Texture类型的变量赋值
  6. PL/SQL Developer 使用中文条件查询时无数据的解决方法
  7. 如何配置svn服务器(通过VisualServer服务器)
  8. php调用java类文件
  9. PHP 下载远程图片
  10. java内部发送http请求并取得返回结果,修改response的cookie
  11. B树和B+树的插入、删除图文详解
  12. IntelliJ IDEA 如何设置类头注释和方法注释
  13. json数据的处理和转化(loads/load/dump/dumps)
  14. TVTK库的安装
  15. rsync入门使用
  16. django form 的内置字段类型
  17. perl解析xml-XML::Simple/XMLin
  18. java 获取class文件所在路径
  19. POJ 3579 Median(二分答案)
  20. nginx反向代理下载文件失败处理

热门文章

  1. Javascript获取页面的各种坐标汇总
  2. LGOJ P2048 [NOI2010]超级钢琴
  3. 重装windows10系统的教程
  4. TODO : 一些新的学习计划
  5. CentOS7添加/删除用户和用户组
  6. Map的常用实现类及Entry的用法
  7. CF827D Best Edge Weight 题解
  8. php自定义函数之内部函数
  9. 012——matlab判断变量是否存在
  10. shell脚本之 operater.sh 算术运算符;比较运算符;布尔运算符;逻辑与或非运算符;字符串运算符的使用