健康检查功能不会更新后端服务器

健康检查功能不会更新后端服务器域名解析

 

我的后端服务器使用动态域名,当动态域名的地址变了之后就会不断出现以下错误:

2013/03/23 16:27:37 [error] 21253#0: check time out with peer: 113.96.37.249:60080 
2013/03/23 16:27:37 [error] 21257#0: check time out with peer: 113.96.37.249:60080 
2013/03/23 16:27:43 [error] 21253#0: check time out with peer: 113.96.37.249:60080 
2013/03/23 16:27:43 [error] 21257#0: check time out with peer: 113.96.37.249:60080 
2013/03/23 16:27:49 [error] 21253#0: check time out with peer: 113.96.37.249:60080

并且只有重启tengine之后才能解决。

我的配置如下:

upstream mygroup {
    server server1.dynamic.dns:60080;
    server server2.dynamic.dns:60080;

    check interval=3000 rise=2 fall=2 timeout=3000 type=http;
    check_http_send "GET /upstream_check HTTP/1.0

";
    check_http_expect_alive http_2xx;
}

当然即使不用动态域名,后端服务器域名解析也有可能变动,建议tengine能够定时更新域名解析。

 

你好,这个问题不仅仅是健康检查的问题,就算健康检查能更新,upstream块里面的server地址也不会更新。

后端服务器动态更新模块我们正在开发 (https://github.com/yzprofile/ngx_http_dyups_module ),但是可能跟你的想法有点不一样,我们的做法是动态更新服务器,而不需要reload。

你们的需求或许可以通过正向代理的方法来解决,比如类似这样:

location / {
     resolver 8.8.8.8;
     proxy_pass http://$host;
}

它可以定期查询后端的DNS服务器,动态更新服务器的IP。

原文地址:https://www.cnblogs.com/zenghui940/p/5050521.html