Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to build a three-node swarm cluster

2025-03-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

This article introduces the knowledge of "how to build a three-node swarm cluster". In the operation of practical cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

In this section we introduce how to build a three-node swarm cluster. When you install docker, swarm is already built in. So no additional installation is required.

Prepare the environment:

Three servers with docker installed.

Swarm manager: 192.168.0.109swarm worker1: 192.168.0.107swarm worker2: 192.168.0.110

Docker swarm init-- advertise-addr means that we need to declare an address if we want to initialize a swarm, because it is a cluster and must have multiple nodes. How to let other nodes know that we exist? Need advertise-addr our local address.

We are now running on swarm manager:

Vincent@192:~$ docker swarm init-advertise-addr=192.168.0.109Swarm initialized: current node (u6bj8diva2g7yn0y0x1h7lrff) is now a manager.To add a worker to this swarm, run the following command: docker swarm join--token SWMTKN-1-0csi5bbc0dazkq3yrqrzv09aatddo5iq9e3dal5anzvbsv46r5-1eu8dt8ku0vp3dm0xv7evsfw6 192.168.0.109:2377To add a manager to this swarm, run 'docker swarm join-token manager' and follow the instructions.

Swarm manage initialization is complete, and if you need to add a worker, you need to use the following command on the worker node.

Docker swarm join-- token SWMTKN-1-0csi5bbc0dazkq3yrqrzv09aatddo5iq9e3dal5anzvbsv46r5-1eu8dt8ku0vp3dm0xv7evsfw6 192.168.0.109VR 2377

Use the command on the manage node:

Docker swarm join-token worker

You can view token

At the prompt, we run the command on swarm worker1:

Docker swarm join-token SWMTKN-1-0csi5bbc0dazkq3yrqrzv09aatddo5iq9e3dal5anzvbsv46r5-1eu8dt8ku0vp3dm0xv7evsfw6 192.168.0.109:2377This node joined a swarm as a worker.

The addition was successful.

View in swarm manager:

Docker node lsID HOSTNAME STATUS AVAILABILITY MANAGER STATUS1jh5hysrh3ii5kuhk5p0whcm6 192 Ready Activeu6bj8diva2g7yn0y0x1h7lrff * 192 Ready Active Leader

You can see that there are currently two nodes.

Run the command on swarm work2:

Docker swarm join-token SWMTKN-1-0csi5bbc0dazkq3yrqrzv09aatddo5iq9e3dal5anzvbsv46r5-1eu8dt8ku0vp3dm0xv7evsfw6 192.168.0.109:2377This node joined a swarm as a worker.

Check the cluster status at this time:

Vincent@192:~$ docker node lsID HOSTNAME STATUS AVAILABILITY MANAGER STATUS1jh5hysrh3ii5kuhk5p0whcm6 192 Ready Activeozotrf7bt5aa3taxu5479ak0y 192 Ready Activeu6bj8diva2g7yn0y0x1h7lrff * 192 Ready Active Leader

In this way, the cluster with three nodes is configured successfully.

This is the end of the content of "how to build a three-node swarm cluster". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report