Docker swarm error while deploying zabbix

Hello , im facing an issue with swarm i set 3 managers and 1 worker in order to deploy a zabbix server ,
When i join tge nodes everything is okay , but when i use docker stack deploy - c compose file yml
I go check with docker node ls i got this error and nothing work i got this error :

Error response from daemon: rpc error: code = Unknown desc = The swarm does not have a leader. It’s possible that too few managers are online. Make sure more than half of the managers are online

If use docker stack without joining the nodes its works normally , but if add nodes and do the stack i got the error

The yaml file used :

**

version: ‘3.8’

services:
zabbix-server:
image: zabbix/zabbix-server-pgsql:alpine-5.4-latest
restart: always
environment:
- DB_SERVER_HOST=db
- POSTGRES_USER=zabbix
- POSTGRES_PASSWORD=zabbix
- POSTGRES_DB=zabbix
ports:
- “10051:10051”
deploy:
replicas: 1

zabbix-web:
image: zabbix/zabbix-web-nginx-pgsql:alpine-5.4-latest
restart: always
environment:
- DB_SERVER_HOST=db
- POSTGRES_USER=zabbix
- POSTGRES_PASSWORD=zabbix
- POSTGRES_DB=zabbix
- ZBX_SERVER_HOST=zabbix-server
- PHP_TZ=Asia/Kolkata
ports:
- “80:8080”
deploy:
replicas: 1

db:
image: postgres:13-alpine
restart: always
environment:
- POSTGRES_USER=zabbix
- POSTGRES_PASSWORD=zabbix
- POSTGRES_DB=zabbix
volumes:
- db-data:/var/lib/postgresql/data
deploy:
replicas: 1

zabbix-agent:
image: zabbix/zabbix-agent2:alpine-5.4-latest
restart: always
environment:
- ZBX_HOSTNAME={{.Node.Hostname}}
- ZBX_SERVER_HOST=zabbix-server
- ZBX_SERVER_PORT=10051
deploy:
mode: global

volumes:
db-data:

**

Ps: i used 4 virtual box machines with debian installed

Sorry for formulation the topic im still reading the how to forum

Please share the output of docker node ls.

It appears that your swarm cluster is headless, as in not able to establish quorum and therefor can not determine cluster state or perform changes on cluster state.

Never use an even number of manager nodes:
3 manager nodes: 1 unhealthy manager node can be compensated, You need two healthy nodes for quorum.
4 manager nodes: 1 unhealthy manager node can be compensated. You need three healthy nodes for quorum.
5 manager nodes: 2 unhealthy manager nodes can be compensated. You need three healthy nodes for quorum.

When i type docker node ls i got the error :

** Error response from daemon: rpc error: code = Unknown desc = The swarm does not have a leader. It’s possible that too few managers are online. Make sure more than half of the managers are online**

My bad. Of course, it’s not going to work on a headless cluster.

See for how to recover from losing quroum: Recover from losing the quorum - Mirantis Kubernetes Engine

Note: Mirants is the owner of Docker’s previous enterprise offering.

1 Like

Thank you i will retry and follow what u sent me

i tried now and it seems to be working i made 4 managers , i have no errors the servers is working ,
except one thing every one service from the compose file is on one manager is it normal !
i was expecting all services runinng in all managers node for exemple :

  1. node 1 (zabbix server + db + agent + web int)
  2. node 2 (zabbix server + db + agent + web int ) etc …

but now i have like this

  • node 1 ( agent only )

  • node 2 ( db + agent )

  • node 3 ( agent + web)

  • node 4 (server zbx)

my compose file
**version: ‘3.8’

services:
zabbix-server:
image: zabbix/zabbix-server-pgsql:alpine-5.4-latest
restart: always
environment:
- DB_SERVER_HOST=db
- POSTGRES_USER=zabbix
- POSTGRES_PASSWORD=zabbix
- POSTGRES_DB=zabbix
ports:
- “10051:10051”
deploy:
replicas: 1

zabbix-web:
image: zabbix/zabbix-web-nginx-pgsql:alpine-5.4-latest
restart: always
environment:
- DB_SERVER_HOST=db
- POSTGRES_USER=zabbix
- POSTGRES_PASSWORD=zabbix
- POSTGRES_DB=zabbix
- ZBX_SERVER_HOST=zabbix-server
- PHP_TZ=Asia/Kolkata
ports:
- “80:8080”
deploy:
replicas: 1

db:
image: postgres:13-alpine
restart: always
environment:
- POSTGRES_USER=zabbix
- POSTGRES_PASSWORD=zabbix
- POSTGRES_DB=zabbix
volumes:
- db-data:/var/lib/postgresql/data
deploy:
replicas: 1

zabbix-agent:
image: zabbix/zabbix-agent2:alpine-5.4-latest
restart: always
environment:
- ZBX_HOSTNAME={{.Node.Hostname}}
- ZBX_SERVER_HOST=zabbix-server
- ZBX_SERVER_PORT=10051
deploy:
mode: global

volumes:
db-data:**

is it possible to hava HA that means when i turn off one manager or disconnect it the zabbix continue working , and thank you

Please format your your post according How to format your forum posts.

I am not going to discuss whether it would make sense to use 4 manager nodes or not… I would use 3 manager nodes + a worker node instead. I described why 4 manager nodes has no advantage over a 3 manager node cluster.

You can use node labels use the node labels in your placement constraints to pin services to specific nodes. The forum search should yield plenty of examples for how it’s used.

You last question shows that you didn’t understand what I wrote about unhealty/healty nodes and the quorum. A turned off is treated like an unhealthy node. Deployed Containers of swarm services will keep running, even if the cluster becomes headless. They just won’t restart if a service dies and needs to schedule a new instance.