You need to enable JavaScript to run this app.
最新活动
大模型
产品
解决方案
定价
生态与合作
支持与服务
开发者
了解我们

HAProxy服务未运行且backend无可用服务器问题排查求助

HAProxy服务未运行且backend无可用服务器问题排查求助

我现在碰到了HAProxy的故障,服务处于停止状态,日志里还反复提示backend apiserverbackend has no server available!,下面是我收集到的所有相关信息,麻烦各位帮忙看看哪里出问题了,该怎么让HAProxy正常跑起来?

当前HAProxy服务状态

执行sudo systemctl status haproxy.service得到的输出:

root@k8s-eu-1-control-plane-node-1:~# sudo systemctl status haproxy.service

○ haproxy.service - HAProxy Load Balancer

Loaded: loaded (/lib/systemd/system/haproxy.service; enabled; vendor preset: enabled)

Active: inactive (dead) since Tue 2023-11-28 13:21:35 CET; 47min ago

Docs: man:haproxy(1)

file:/usr/share/doc/haproxy/configuration.txt.gz

Process: 744 ExecStart=/usr/sbin/haproxy -Ws -f $CONFIG -p $PIDFILE $EXTRAOPTS (code=exited, status=0/SUCCESS)

Main PID: 744 (code=exited, status=0/SUCCESS)

CPU: 264ms

Nov 28 13:21:10 k8s-eu-1-control-plane-node-1 haproxy[771]: backend apiserverbackend has no server available!

Nov 28 13:21:10 k8s-eu-1-control-plane-node-1 haproxy[771]: backend apiserverbackend has no server available!

Nov 28 13:21:35 k8s-eu-1-control-plane-node-1 systemd[1]: Stopping HAProxy Load Balancer...

Nov 28 13:21:35 k8s-eu-1-control-plane-node-1 haproxy[744]: [NOTICE]   (744) : haproxy version is 2.6.15-1ppa1~jammy

Nov 28 13:21:35 k8s-eu-1-control-plane-node-1 haproxy[744]: [NOTICE]   (744) : path to executable is /usr/sbin/haproxy

Nov 28 13:21:35 k8s-eu-1-control-plane-node-1 haproxy[744]: [WARNING]  (744) : Exiting Master process...

Nov 28 13:21:35 k8s-eu-1-control-plane-node-1 haproxy[744]: [ALERT]    (744) : Current worker (771) exited with code 143 (Terminated)

Nov 28 13:21:35 k8s-eu-1-control-plane-node-1 haproxy[744]: [WARNING]  (744) : All workers exited. Exiting... (0)

Nov 28 13:21:35 k8s-eu-1-control-plane-node-1 systemd[1]: haproxy.service: Deactivated successfully.

Nov 28 13:21:35 k8s-eu-1-control-plane-node-1 systemd[1]: Stopped HAProxy Load Balancer.

HAProxy配置文件 /etc/haproxy/haproxy.cfg

# /etc/haproxy/haproxy.cfg

#---------------------------------------------------------------------
# Global settings
#---------------------------------------------------------------------
global
    log /dev/log local0
    log /dev/log local1 notice
    daemon

#---------------------------------------------------------------------
# common defaults that all the 'listen' and 'backend' sections will
# use if not designated in their block
#---------------------------------------------------------------------
defaults
    mode                    http
    log                     global
    option                  httplog
    option                  dontlognull
    option http-server-close
    option forwardfor       except 127.0.0.0/8
    option                  redispatch
    retries                 1
    timeout http-request    10s
    timeout queue           20s
    timeout connect         5s
    timeout client          20s
    timeout server          20s
    timeout http-keep-alive 10s
    timeout check           10s

#---------------------------------------------------------------------
# apiserver frontend which proxys to the control plane nodes
#---------------------------------------------------------------------
frontend apiserver
    bind *:6445
    mode tcp
    option tcplog
    default_backend apiserverbackend

#---------------------------------------------------------------------
# round robin balancing for apiserver
#---------------------------------------------------------------------
backend apiserverbackend
    option httpchk GET /healthz
    #option httpchk GET /livez
    http-check expect status 200
    mode tcp
    option ssl-hello-chk
    balance     roundrobin

    #server k8s-eu-1-control-plane-node-1 aa.aaa.aaa.aa:8443 check
    #server k8s-eu-1-control-plane-node-2 bb.bbb.bbb.bbb:8443 check
    #server k8s-eu-1-control-plane-node-3 cc.ccc.ccc.ccc:8443 check
    # [...]

    server xx.xxx.xxx.xx k82-eu-1-load-balancer-dns-1:8443 check
    server yy.yyy.yyy.yy k82-eu-1-load-balancer-dns-2:8443 check

网络配置文件 /etc/netplan/01-netcfg.yaml

network:
  version: 2
  renderer: networkd
  ethernets:
    ens18:
      match:
        macaddress: 00:50:56:4a:49:18
      addresses:
        - aa.aaa.aaa.aa/19
      #- 2a02:c206:2123:1861:0000:0000:0000:0001/64
      #gateway6: fe80::1
      routes:
        - to: 0.0.0.0/0
          via: gg.ggg.ggg.1
          on-link: true
      nameservers:
        search: [ invalid ]
        addresses:
          - xx.xxx.xxx.xx
          - yy.yyy.yyy.yy
      #- 2a02:c206:5028::1:53
      #- 2a02:c206:5028::2:53

/etc/hosts 配置内容

127.0.0.1       localhost
127.0.1.1       vmi1231861.contaboserver.net    vmi1231861

# The following lines are desirable for IPv6 capable hosts
::1     localhost ip6-localhost ip6-loopback
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters

aa.aaa.aaa.aa    vmi1231861.contaboserver.net vmi1231861
aa.aaa.aaa.aa    k8s-eu-1-control-plane-node-1
bb.bbb.bbb.bbb   k8s-eu-1-control-plane-node-2
cc.ccc.ccc.ccc   k8s-eu-1-control-plane-node-3
dd.ddd.ddd.dd    k8s-eu-1-worker-1
ee.eee.eee.ee    k8s-eu-1-worker-2
ff.fff.fff.fff   k8s-eu-1-worker-3
xx.xxx.xxx.xx    k82-eu-1-load-balancer-dns-1
yy.yyy.yyy.yy    k82-eu-1-load-balancer-dns-2

想请教下各位大佬,我哪里配置出错了?该怎么操作才能让HAProxy正常启动并运行?

备注:内容来源于stack exchange,提问作者Raphael10

火山引擎 最新活动