为什么 Varnish 没有探测后端服务器?

为什么 Varnish 没有探测后端服务器?

我的 Varnish 配置有两个后端。第一个后端运行良好,第二个后端似乎被 Varnish 完全忽略。似乎.probe第二个后端上的 被忽略了,因为它从不尝试查询后端服务器。我这样说是因为tcpdump后端服务器上的 和 日志根本没有显示任何流量。

常规curl到第二台后端服务器运行良好。

我已经获得了 Varnish 服务器的以下配置。

vcl 4.0;

# import directors VMOD
import directors;

# define backend servers
backend apitomcat01 {
    .host = "apitomcat1";
    .port = "8080";
    .probe = {
        .timeout = 5s;
        .interval = 10s;
        .window = 10;
        .threshold = 3;
        .request =
            "HEAD /api3/health HTTP/1.1"
            "User-Agent: varnish-health"
            "Host: apitomcat1:8080"
            "Connection: Close"
            "Accept: */*"
            "Authorization: Basic ABCDEFGH";
    }

}
backend apitomcat02 {
    .host = "apitomcat2";
    .port = "8081";
    .probe = {
        .timeout = 5s;
        .interval = 10s;
        .window = 10;
        .threshold = 3;
        .request =
            "HEAD /api3/health HTTP/1.1"
            "User-Agent: varnish-health"
            "Host: apitomcat2:8081"
            "Connection: Close"
            "Accept: */*"
            "Authorization: ABCDEFGH";
    }

}

# create tomcat director
sub vcl_init {
    new tomcat = directors.round_robin();
    tomcat.add_backend(apitomcat01);
    tomcat.add_backend(apitomcat02);
}

sub vcl_recv {
    # send all traffic to the tomcat director:
    set req.backend_hint = tomcat.backend();

    # pass all traffic - do not perform any caching for now
    return (pass);
}

*apitomcat01 和 apitomcat02 有意使用不同的端口。

为什么 apitomcat02 探测器似乎从未向 apitomcat2 发送任何请求?运行时什么tcpdump -P inout | grep "apitomcat2"也没发生。我希望至少能看到探测器请求。

当我运行时backend.list,我得到以下内容。

200
Backend name                   Refs   Admin      Probe
apitomcat01(192.168.41.51,,8080) 2      probe      Healthy 10/10
apitomcat02(192.168.41.52,,8081) 1      probe      Sick 0/10

当我运行 debug.health 时,我得到以下内容。

200        
Backend apitomcat01 is Healthy
Current states  good: 10 threshold:  3 window: 10
Average responsetime of good probes: 0.068237
Oldest                                                    Newest
================================================================
4444444444444444444444444444444444444444444444444444444444444444 Good IPv4
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX Good Xmit
RRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR Good Recv
HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH Happy
Backend apitomcat02 is Sick
Current states  good:  0 threshold:  3 window: 10
Average responsetime of good probes: 0.000000
Oldest                                                    Newest
================================================================
---------------------------------------------------------------- Happy

相关内容