如何将docker swarm的manager节点降级为worker节点?
作者:互联网
将manager降级为worker
这个问题,说来挺有意思的,我在集群里面创建了2个manager,然后,模拟将第2个manager节点,从集群中移出去,结果发现报错了:
[root@nccztsjb-node-07 ~]# docker node rm cw5bome4a9g1rzelivxejd31c Error response from daemon: rpc error: code = FailedPrecondition desc = node cw5bome4a9g1rzelivxejd31c is a cluster manager and is a member of the raft cluster. It must be demoted to worker before removal
报错信息说:在移除该节点是manager节点,在移除之前,必须首先降级为worker节点。
降级的方法也很简单:
docker node demote cw5bome4a9g1rzelivxejd31c
使用node的demote参数,后面加上node的ID 【通过docker node ls可以查看到】
[root@nccztsjb-node-07 ~]# docker node demote cw5bome4a9g1rzelivxejd31c Manager cw5bome4a9g1rzelivxejd31c demoted in the swarm.
降级后,可以看到,原来在MANAGER STATUS列中的Reachable状态已经没有了,说明是个worker节点。
[root@nccztsjb-node-07 ~]# docker node ls ID HOSTNAME STATUS AVAILABILITY MANAGER STATUS ENGINE VERSION mjktd9is5xd8d4el2awrqby5k * nccztsjb-node-07 Ready Active Leader 20.10.17 u87i9artgcnyki0osp9gvylu3 nccztsjb-node-08 Ready Active 20.10.17 z1x3ufsdxekrt6w5n37m7azfe nccztsjb-node-09 Ready Active 20.10.17 cw5bome4a9g1rzelivxejd31c nccztsjb-node-10 Ready Active 20.10.17
manger降级之后,就可以对其进行remove的操作了。当然remove之前要先drain才行。
将worker升级为manager
那反过来,将worker升级为manager 呢?
docker node promote cw5bome4a9g1rzelivxejd31c
[root@nccztsjb-node-07 ~]# docker node promote cw5bome4a9g1rzelivxejd31c Node cw5bome4a9g1rzelivxejd31c promoted to a manager in the swarm. [root@nccztsjb-node-07 ~]# docker node ls ID HOSTNAME STATUS AVAILABILITY MANAGER STATUS ENGINE VERSION mjktd9is5xd8d4el2awrqby5k * nccztsjb-node-07 Ready Active Leader 20.10.17 u87i9artgcnyki0osp9gvylu3 nccztsjb-node-08 Ready Active 20.10.17 z1x3ufsdxekrt6w5n37m7azfe nccztsjb-node-09 Ready Active 20.10.17 cw5bome4a9g1rzelivxejd31c nccztsjb-node-10 Ready Active Reachable 20.10.17 [root@nccztsjb-node-07 ~]#
这样,就将worker节点升级为manager节点了。
标签:node,worker,swarm,manager,nccztsjb,cw5bome4a9g1rzelivxejd31c,Ready,docker,节点 来源: https://www.cnblogs.com/chuanzhang053/p/16649626.html