当前位置:网站首页>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]所创,转载请带上原文链接,感谢
边栏推荐
- Application insights application insights use application maps to build request link views
- Epu360: all the H5 templates you want are here, e-book, big turntable, red envelope rain, questionnaire survey
- August 24, 2020: what are small documents? What's wrong with a lot of small files? How to solve many small files? (big data)
- The 4th China BIM (digital construction) manager Summit Forum will be held in Hangzhou in 2020
- C calls SendMessage to refresh the taskbar icon (the icon does not disappear at the end of forcing)
- Js字符串-String字符串对象方法
- Js数组-数组的用法全在这里(数组方法的重构、数组的遍历、数组的去重,数组的判断与转换)
- 2020年新规,微信封号怎么快速解除?
- Utility class functions (continuous update)
- Stm32f030f4p6 compatible with smart micro mm32f031f4p6
猜你喜欢
细数软件工程----各阶段必不可少的那些图
How to manage the authority of database account?
Getting started with varhart xgantt
MRAM高速缓存的组成
非易失性MRAM存储器应用于各级高速缓存
20个XR项目路演,近20个资本机构出席!诚邀您参加2020 Qualcomm XR生态合作伙伴大会
迅为-iMX6ULL开发板上配置AP热点
Common syntax corresponding table of mongodb and SQL
win7 APPCRASH(解决方法)(转)
RFID fixed assets management system for fire equipment
随机推荐
DC-1 target
STM32F030K6T6兼容替换灵动MM32F031K6T6
Big data processing black Technology: revealing the parallel computing technology of Pb level data warehouse gaussdb (DWS)
JS string - string string object method
The advantages and functions of psychological counseling app
7.Swarm搭建集群
条形码识别性能低,如何优化Dynamsoft Barcode Reader解码性能
Reserved battery interface, built-in charge and discharge circuit and electricity meter, quickly help easily handle hand-held applications
2020 database technology conference helps technology upgrade
2020-08-14:数据任务的执行引擎用的哪些?
Epu360: all the H5 templates you want are here, e-book, big turntable, red envelope rain, questionnaire survey
Two dimensional code location and alarm system of Expressway
Stm32f030f4p6 compatible with smart micro mm32f031f4p6
Novice guidance and event management system in game development
高速公路二维码定位报警系统
Message queue - Analysis
Win7 AppCrash (solution)
Stm32f030k6t6 compatible replacement smart mm32f031k6t6
Using JSON webtoken (JWT) to generate token in nodejs
RFID fixed assets management system for fire equipment