在stop docker leader node后,如何发现当前谁是manager node?

发布于 2022-09-06 03:08:06 字数 1997 浏览 16 评论 0

我当前集群环境如下:

~ $ docker node ls
ID                            HOSTNAME            STATUS              AVAILABILITY        MANAGER STATUS
czn1ts6u2o24pcyeojlsr9ai7     node4               Ready               Active              
lrlhx7smzo9rafckep5b05fgw     node3               Ready               Active              
s38rdi1wlxqbvtfl1sa3ne17r *   node1               Ready               Active              Leader
uubznl6kas1mpd5evpqamtr9x     node5               Ready               Active              
z4otpoy5a8m8px2e3bh9jy5jd     node2               Ready               Active              

然后我promote node2 , node3

~ $ docker node promote node2 node3
Node node2 promoted to a manager in the swarm.
Node node3 promoted to a manager in the swarm.

再次查看当前的node情况

 ~ $ docker node ls
ID                            HOSTNAME            STATUS              AVAILABILITY        MANAGER STATUS
czn1ts6u2o24pcyeojlsr9ai7     node4               Ready               Active              
lrlhx7smzo9rafckep5b05fgw     node3               Ready               Active              Reachable
s38rdi1wlxqbvtfl1sa3ne17r *   node1               Ready               Active              Leader
uubznl6kas1mpd5evpqamtr9x     node5               Ready               Active              
z4otpoy5a8m8px2e3bh9jy5jd     node2               Ready               Active              Reachable

然后我开始STOP leader node (manager)

 ~ $ docker-machine stop node1
Stopping "node1"...
Machine "node1" was stopped.

再次执行下面的命令

 ~ $ docker node ls
error during connect: Get https://192.168.99.100:2376/v1.30/nodes: dial tcp 192.168.99.100:2376: getsockopt: no route to host

那么问题来了,我此时如何知道谁是 leader node?, 因为我只有知道leader node,才开始进行

eval $(docker-machine env 'leader node name')

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

微暖i 2022-09-13 03:08:06

找到了

~ $ docker node ls
error during connect: Get https://192.168.99.100:2376/v1.30/nodes: dial tcp 192.168.99.100:2376: getsockopt: no route to host
 ~ $ docker-machine ssh node2
                        ##         .
                  ## ## ##        ==
               ## ## ## ## ##    ===
           /"""""""""""""""""\___/ ===
      ~~~ {~~ ~~~~ ~~~ ~~~~ ~~~ ~ /  ===- ~~~
           \______ o           __/
             \    \         __/
              \____\_______/
 _                 _   ____     _            _
| |__   ___   ___ | |_|___ \ __| | ___   ___| | _____ _ __
| '_ \ / _ \ / _ \| __| __) / _` |/ _ \ / __| |/ / _ \ '__|
| |_) | (_) | (_) | |_ / __/ (_| | (_) | (__|   <  __/ |
|_.__/ \___/ \___/ \__|_____\__,_|\___/ \___|_|\_\___|_|
Boot2Docker version 17.10.0-ce, build HEAD : 34fe485 - Wed Oct 18 17:16:34 UTC 2017
Docker version 17.10.0-ce, build f4ffd25
docker@node2:~$ docker node ls
ID                            HOSTNAME            STATUS              AVAILABILITY        MANAGER STATUS
s38rdi1wlxqbvtfl1sa3ne17r     node1               Down                Active              Unreachable
z4otpoy5a8m8px2e3bh9jy5jd *   node2               Ready               Active              Reachable
lrlhx7smzo9rafckep5b05fgw     node3               Ready               Active              Leader
czn1ts6u2o24pcyeojlsr9ai7     node4               Ready               Active              
uubznl6kas1mpd5evpqamtr9x     node5               Ready               Active              
docker@node2:~$ 
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文