In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly explains "what is the use of Docker swarm mode". The content of the explanation in the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "what is the use of Docker swarm mode"?
Docker introduced the swarm pattern from 1.12, and swarm mode is used to manage clustered docker engines, which is called swarm. You can use docker CLI to create swarm, deploy applications to swarm, manage the behavior of swarm, and so on. You can create a cluster that contains one or more docker engines, which is called swarm mode. A swarm contains multiple node,node that can be physical machines, virtual machines, and so on. Node contains two roles: managers and workers
Manager node:
Maintain cluster status
Dispatching service
HTTP API in service swarm mode
Manager communicate with each other using raft protocol, so high availability of manager can be established by deploying multiple managers, but manager must be odd.
Worker node:
Work nodes is an instance of docker engine, and its only use is to execute the container. You can create a swarm with only one manager, but you cannot create a swarm cluster with only one node and no manager.
When deploying an app container mirrored to docker's swarm schema, it is common to create a service. When you create a service, you need to specify which image will be used, and execute the above command in the image. You can also specify some other options for this service:
In swarm mode, the exposed port of the service
An overlay network is used to connect to other service under swarm
Usage quota limits for cpu and mem
A rolling upgrade strategy
The number of copies of this image at run time
There are two types of service deployment models: replicated and global
In replicated service mode, you can specify how many task you want to have running the service. For example, you can specify that a http service has three replicas, each providing the same content.
In global service mode, the service runs a task on each node. There is no need to set the number of task in advance. Whenever you add a new node to the cluster, the scheduling system will automatically deploy the service on the new node. This scenario is suitable for deploying monitoring clients on machines, and so on.
Docker allows you to create service,service and run tasks. A service is a described final state. Task is a working work,work that is dispatched to the node node through swarm. Service creation uses the following process:
Create a service using docker service create
Request arrives on the Docker manager node
The Docker manager node dispatches the request to run on a workers node
Multiple tasks instances can be started per service
Each tasks instance has its own lifecycle
A task will run until its task is completed, and if a task stops, the task will not run again. Task finishes or fails through a series of statuses. Generally, task has the following states:
NEW initializes task
PENDING blocking state
ASSIGNED assigned to node statu
ACCEPTED received by node status
PREPARING Readiness
STARTING startup status
RUNNING operational statu
COMPLETE normal operation completed status
FAILED running failure status
SHUTDOWN docker turns off the task state
REJECTED work node rejects the task status
ORPHANED node node downtime is too long
REMOVE
When you first install and start docker engine, swarm mode is disabled by default. When swarm mode is turned on, you can manage services through swarm service. There are two ways to run it in swarm mode:
Create a new swarm
Join an existing swarm
Docker engine's process for creating a swarm:
Swap current node to swarm mode
Create a swarm named default
Specifies that the current node is the leader manager of the current swarm
Name the node as the hostname
Configure manager to listen on port 2377 on this machine
Sets the current node to active state, which means that the node can receive the tasks dispatched by the cluster
Start an internal distributed data storage system
A self-signed CA certificate is generated by default
Generate a tokens and add to the swarm for subsequent worker and manager
Create an overlay network called ingress to expose services on swarm
Manager node uses advertise address to accept requests from other node to access Swarmkit API and overlay networking. Other node in swarm cluster must be able to access the advertise address of manager. If you do not specify an advertise address, docker will automatically check whether the system has a single ip address, and if so, listen on port 2377 of that address. If the system has more than one ip address, you must specify an address through-- advertise-addr.
The new node needs a token to join the existing swarm cluster. The token used by worker node is different from the token,node used by manager node. Only using join-token can join the swarm. When Rotating join token, it will not affect the node that has joined the swarm cluster. Rotation token can ensure that the old token cannot be used by all the new node to join the swarm cluster.
Here are some key points of swarm:
A swarm contains multiple docker host running under swarm mode, consisting of manager and workers, respectively. Manager manages membership and authorization, and worker runs swarm service. A docker host can be a manager, a worker, or even a manager or worker. Another big advantage is that if the container in swarm service is in standalone mode, you can modify the configuration of service (networks, volumes) without restarting service. Docker handles these automatically.
When a docker host runs in swarm mode, you can still run containers in standalone mode, but swarm can only manage swarm service.
A docer engine of node is a node. When you need to deploy an application to swarm, you need to submit a deployment job on manager node, and manager node will send task to worker node. Manager node also has an orchestration function. Worker nodes receives and executes task.
Service A service is a defined task,swarm system that executes on worker node. When you define a service, you need to define the image to use and the commands to execute in the image. In replicated services mode, swarm manager assigns a defined number of copies of replica task to task on worker node. In global services mode, swarm service runs only one task on worker node.
Tasks A task includes a docker container and commands that run inside the container. Task is automatically scheduled by swarm. Manager assigns task to worker. Once the task is assigned to a node, the task cannot be moved to another node unless the node fail.
Load balancing swarm uses ingress load balancing,swarm manager to set a PublishedPort to service. If PublishedPort is not specified, it is automatically selected in the range of 30000-32767. External requests, such as LB, can access the service through PublishedPort, but the LB service must be on the node cluster, and all nodes in the swarm cluster will connect to the running service, regardless of whether the service service is running on the node or not. There is a DNS inside the swarm, which can automatically fragment the entry,swarm manager of each service in the swarm using the internal LB to distribute the request to the service within the cluster.
Thank you for your reading, the above is the content of "what is the use of Docker swarm mode". After the study of this article, I believe you have a deeper understanding of what the use of Docker swarm mode is, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!
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
© 2024 shulou.com SLNews company. All rights reserved.