当前位置:网站首页>7. Swarm builds clusters
7. Swarm builds clusters
2020-11-06 22:38:00 【Taizhu-yj】
Use dokcer Problems that will come up :
- How to manage so many containers ?
- How to easily expand horizontally
- If the container down 了 , How can I resume the boot ?
- How to update the container without affecting the business ?
- How to monitor and track these containers ?
- How to schedule container creation ?
- Protect private data ?
Docker It comes with a container arrangement tool :Swarm Mode

Manager Node as manager , To maintain high availability , You can't deploy just one , If there are multiple deployment, there is a problem of how to synchronize the state .docker Built in distributed database , adopt raft Agreement assurance Manager Information is synchronized , There's no cleft brain .
Worker Nodes are work nodes , It also needs to be with other Worker Node data synchronization , Use Gossip The protocol synchronizes the information .

We go through swarm manager Node to deploy a service, We don't know about this service Which container nodes will eventually run on .swarm manager According to some strategies , For example, memory. , Hard disk resources, etc , take service Deployed in some container node in .

3 nodes swarm cluster setup
1. On the first machine , establish docker swarm manager command
docker swarm init --advertise-addr=192.168.8.117 This machine IP
Create success , Returns the docker swarm join --token SWMTKN-1-1aud6ztpiwgujisqn20gb9lfldziidj0dz7lww3puod36t5j5d-c6azyl8d0rhhzd8c25u9laxxp 192.168.8.117:2377 For others docker swarm join This machine , Build clusters .

2. On the second machine , establish docker swarm And add the first machine , command
docker swarm join --token SWMTKN-1-1aud6ztpiwgujisqn20gb9lfldziidj0dz7lww3puod36t5j5d-c6azyl8d0rhhzd8c25u9laxxp 192.168.8.117:2377
Something goes wrong
Error response from daemon: rpc error: code = Unavailable desc = all SubConns are in TransientFailure, latest connection error: connection error: desc = "transport: Error while dialing dial tcp 192.168.8.117:2377: connect: no route to host"
reason
If you want to use swarm function , Need at all manager node Turn on the node 2377 port .
terms of settlement
Open designated port firewall-cmd --zone=public --add-port=2377/tcp --permanent
Restart the firewall to take effect systemctl restart firewalld
see swarm node
docker node ls
ID HOSTNAME STATUS AVAILABILITY MANAGER STATUS ENGINE VERSION
5xeakkex0klrezwb1p5y0pcja localhost.localdomain Ready Active 19.03.13
rk1pu6zgxkh278262d5yprzqi localhost.localdomain Ready Active 19.03.13
ulms2qb8gvnehsmgx7d7dcx9a * localhost.localdomain Ready Active Leader 19.03.13
Steps to build :
1、 Environmental preparation :
1.1、 Three are ready to be installed docker engine Of centos/Ubuntu System host (docker Version must be in
1.12 Version above , The old version does not support swarm)
1.2、docker Container host ip Fixed address , All work nodes in the cluster must have access to the management node
1.3、 The cluster management node must use the appropriate protocol and ensure that the port is available
Cluster management communication :TCP, port 2377
Node communication :TCP and UDP, port 7946
Overlay networks (docker The Internet ):UDP, port 4789 overlay drive
explain : Three container hosts ip The addresses are :
192.168.200.162( The management node )
192.168.200.163( Work node )
192.168.200.158( Work node )
The host names are :manager1、work1 as well as work2
vim /etc/hostname ( You need to restart after the modification )
2、 establish docker swarm
2.1、 stay manager1 Create... On the machine docker swarm colony
docker swarm init ‐‐advertise‐addr 192.168.200.162
(‐‐advertise‐addr Will be IP The address of the machine is set as the cluster management node ; If it's a single node , There is no need to refer to
Count )
2.2、 View management node cluster information :
docker node ls
3、 towards docker swarm Add a work node in the : Execute the following commands in the two work nodes respectively ,ip The address is
manager Node
3.1、 Add two work node
docker swarm join ‐‐token xxx 192.168.200.138:2377 (worker1)
docker swarm join ‐‐token xxx 192.168.200.138:2377 (worker2)
(‐‐token xxx: Add authentication information of work nodes to the specified cluster ,xxx Authentication information is creating docker
swarm When the )
3.2、 Continue to view the differences between the management node cluster information and the previous one
docker node ls
4、 stay docker swarm Deploy services in
stay Docker Swarm When deploying services in a cluster , Both available Docker Hub Start the service with a self-contained image on the , also
You can use self access Dockerfile Build the image to start the service . If you use yourself through Dockerfile Built
To start a service, you must first push the image to Docker Hub Central warehouse . In order to facilitate the study of readers , here
To use the Docker Hub Bring your own alpine Image as an example to deploy cluster services
4.1、 Deployment Services
docker service create ‐‐replicas 1 ‐‐name helloworld alpine ping
docker.com
docker service create Instructions : Used in Swarm Create a cluster based on alpine Mirror service
‐‐replicas Parameters : Specifies that the service has only one replica instance
‐‐name Parameters : Specify the service name after successful creation as helloworld
ping docker.com Instructions : Represents the command to be executed after the service is started
5. see docker swarm Services in the cluster
View the list of services :docker service ls
View details of deploying specific services :docker service inspect The service name
View the allocation and operation of services on cluster nodes :docker service ps The service name
6、 Change the number of copies
stay manager1 On , Change the number of service copies ( The created copies are randomly assigned to different nodes )
docker service scale helloworld=5
7、 Delete service ( At the management node )
docker service rm The service name
8、 Access the service
8.1、 View the network list in the cluster environment :docker network ls
8.2、 stay manager1 Create a overlay For driven networks ( Network connection used by default ingress)
docker network create ‐d=overlay my‐multi‐host‐network
8.3、 In the cluster management node manager1 Put a nginx service
docker service create \
‐‐network my‐multi‐host‐network \
‐‐name my‐web \
‐p 8080:80 \
‐‐replicas 2 \
nginx
8.3、 View the running status of the service in the management node :
docker service ps my‐web
8.4、 Access test
版权声明
本文为[Taizhu-yj]所创,转载请带上原文链接,感谢
边栏推荐
- 7.Swarm搭建集群
- Stickinengine architecture 12 communication protocol
- Design of NAND flash interface control
- Nanjing logo design and production, guide VI system design
- 三步轻松理解Kerberos协议
- A concise tutorial for Nacos, ribbon and feign
- Jenkins installation and deployment process
- STM32F030K6T6兼容替换灵动MM32F031K6T6
- 消防器材RFID固定资产管理系统
- Message queue - Analysis
猜你喜欢

Web API interface design: swaggerui document / unified response format / unified exception handling / unified authority verification

Logo design company, Nanjing

QT audio and video development 46 video transmission UDP version

NAND FLASH的接口控制设计
![[learning] interface test case writing and testing concerns](/img/3b/00bc81122d330c9d59909994e61027.jpg)
[learning] interface test case writing and testing concerns

Nodejs中使用jsonwebtoken(JWT)生成token的场景使用

Practice of Xiaoxiong school development board: real equipment access of smart street lamp sandbox experiment

August 30, 2020: naked write algorithm: the nearest common ancestor of two nodes in a binary tree.

Unexpected element.. required element

条形码识别性能低,如何优化Dynamsoft Barcode Reader解码性能
随机推荐
Unexpected element.. required element
Detailed software engineering -- the necessary graphs in each stage
August 30, 2020: naked write algorithm: the nearest common ancestor of two nodes in a binary tree.
Git SSH bad permissions
The first choice for lightweight GPU applications is the NVIDIA vgpu instance launched by Jingdong Zhilian cloud
Plug in bilibilibili new version 0.5.5
JVM memory allocation - xms128m - xmx512m - XX: permsize = 128M - XX: maxpermsize = 512M
DC-1 target
In 2020, how can wechat seal numbers be quickly lifted?
A good thing for working people -- to temper the will of iron and steel requires such an efficient computer
Application of UHF RFID medical blood management system
python3操作Jenkins模块api
Google browser realizes video playback acceleration function
Bluetooth broadcast chip for Shanghai giant micro
August 18, 2020: introduce Mr process?
Windows 10 Bluetooth management page 'add Bluetooth or other devices' option click no response solution
Composition of MRAM cache
Qt音视频开发46-视频传输UDP版
How to start the hidden preferences in coda 2 on the terminal?
如何使用甘特图图层和筛选器