In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces "how to create a Docker Swarm cluster". In the daily operation, I believe many people have doubts about how to create a Docker Swarm cluster. The editor consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful to answer the doubts about "how to create a Docker Swarm cluster". Next, please follow the editor to study!
Docker Swarm is one of the official Docker three Musketeers projects. It provides Docker container cluster service, which is the core solution of Docker official support for container cloud ecology. With it, users can encapsulate multiple Docker hosts into a single large virtual Docker host, and quickly create a set of container cloud platform.
Create a swarm cluster
With such a simple command:
$docker swarm init
It is enough to create a Swarm (although it is a Swarm with only simple management nodes, it is already the simplest collection of Swarm clusters).
$docker node lsID HOSTNAME MEMBERSHIP STATUS AVAILABILITY MANAGER STATUS7sytb3zk0yswdfky6mbh7nzk2 * moby Accepted Ready Active Leader
Let's take a look at multi-nodes! Swarm with only one node is of limited use, so let's create a Swarm with two management nodes (manager nodes) and two work nodes (worker nodes). First, let's create four Docker hosts. Docker Machine is an ideal tool for this task, so we use it.
$docker-machine lsNAME ACTIVE DRIVER STATE URL SWARM DOCKER ERRORSmanager1-virtualbox Running tcp://192.168.99.100:2376 v1.12.0-rc3manager2-virtualbox Running tcp://192.168.99.101:2376 v1.12.0-rc3worker1-virtualbox Running tcp://192.168.99.102:2376 v1.12.0-rc3worker2-virtualbox Running tcp://192.168.99.103:2376 v1.12.0-rc3
If you don't have any other hosts created in Machine, your display information needs to be close to the example given below when displaying cluster nodes.
$docker-machine lsNAME ACTIVE DRIVER STATE URL SWARM DOCKER ERRORSmanager1-virtualbox Running tcp://192.168.99.100:2376 v1.12.0-rc3manager2-virtualbox Running tcp://192.168.99.101:2376 v1.12.0- Rc3worker1-virtualbox Running tcp://192.168.99.102:2376 v1.12.0-rc3worker2-virtualbox Running tcp://192.168.99.103:2376 v1.12.0-rc3 initializes Swarm
The simplest command (prompt: "docker swarm init") to create a Swarm using the 1.12 engine was introduced above, but we will also invoke several additional options here to allow cluster hosts to communicate with each other and join the cluster without permission.
$MANAGER1_IP=$ (docker-machine ip manager1) $docker-machine ssh manager1 docker swarm init-auto-accept manager-auto-accept worker-listen-addr $MANAGER1_IP:2377
Note:-listen-addr is the address where different nodes in the Swarm access each other.
Add a second management node
You also need to add some options to the Docker Swarm command:
* join: indicates that a new node will be added to the Swarm
*-manager: indicates the nature of the node (manager vs worker)
*-listen-addr: allows a newly added node to access other nodes in the Swarm
* the last parameter is the address of the first management node (that is, the node to which this command will be sent)
* * Note: * since the-auto-accept manager option is provided during Swarm initialization, the second management node is automatically accepted. If this option is not available, the second management node needs to be manually accepted by the first management node.
$MANAGER2_IP=$ (docker-machine ip manager2) docker-machine ssh manager2 docker swarm join-- manager-- listen-addr $MANAGER2_IP:2377 $MANAGER1_IP:2377
Add a work node
Adding a worker node to a cluster is almost the same as adding a management node:
$WORKER1_IP=$ (docker-machine ip worker1) $docker-machine ssh worker1 docker swarm join-- listen-addr $WORKER1_IP:2377 $MANAGER1_IP:2377 $WORKER2_IP=$ (docker-machine ip worker2) $docker-machine ssh worker2 docker swarm join-- listen-addr $WORKER2_IP:2377 $MANAGER1_IP:2377
* * Note: * since the-auto-accept worker option is provided during Swarm initialization, the worker node is automatically accepted. If this option is not available, the worker node needs to be manually accepted by the management node.
What does our Swarm look like? Let's see.
$docker-machine ssh manager1 docker node lsID HOSTNAME MEMBERSHIP STATUS AVAILABILITY MANAGER STATUS109a5ufy8e3ey17unqa16wbj7 manager2 Accepted Ready Active Reachable4chbn8uphm1tidr93s64zknbq * manager1 Accepted Ready Active Leader8nw7g1q0ehwq1jrvid1axtg5n worker2 Accepted Ready Active8rrdjg4uf9jcj0ma2uy8rkw5v worker1 Accepted Ready Active
Now each node belongs to Swarm and is in standby state. Management Node 1 is the leader, everything is in its own place, well organized, what makes it so special? This Swarm is guaranteed by secure Transport layer Protocol (TLS) and can be automatically authenticated and upgraded outside the device.
Similarly, it no longer needs key-value storage such as Consul and Zookeeper, and everything is under control.
At this point, the study on "how to create a Docker Swarm cluster" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un