当前位置:网站首页>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]所创,转载请带上原文链接,感谢
边栏推荐
- image operating system windows cannot be used on this platform
- 细数软件工程----各阶段必不可少的那些图
- [elastic search engine]
- 轻量型 GPU 应用首选 京东智联云推出 NVIDIA vGPU 实例
- Novice guidance and event management system in game development
- How to add modules to nginx image?
- The memorandum model of behavior model
- August 18, 2020: introduce Mr process?
- How does varhart xgantt represent working days on a calendar
- What are the highlights of Huawei mate 40 series with HMS?
猜你喜欢
2020-08-29: process thread differences, in addition to the inclusion relationship, the underlying details?
Ora-02292: complete constraint violation (midbjdev2.sys_ C0020757) - subrecord found
非易失性MRAM存储器应用于各级高速缓存
Markdown tricks
The 4th China BIM (digital construction) manager Summit Forum will be held in Hangzhou in 2020
What are the highlights of Huawei mate 40 series with HMS?
FreeSWITCH视频会议“标准”解决方案
September 3, 2020: naked writing algorithm: loop matrix traversal.
消防器材RFID固定资产管理系统
Stm32f030k6t6 compatible replacement smart mm32f031k6t6
随机推荐
How does varhart xgantt represent working days on a calendar
Nodejs中使用jsonwebtoken(JWT)生成token的场景使用
[doodling the footprints of Internet of things] Introduction to Internet of things
Countdown | 2020 PostgreSQL Asia Conference - agenda arrangement of Chinese sub Forum
实验一
August 24, 2020: what are small documents? What's wrong with a lot of small files? How to solve many small files? (big data)
【涂鸦物联网足迹】物联网基础介绍篇
2020-08-15: under what circumstances should data tasks be optimized?
Characteristics of magnetic memory chip STT-MRAM
win7 APPCRASH(解决方法)(转)
迅为-iMX6ULL开发板上配置AP热点
条形码识别器Dynamsoft Barcode Reader v7.5全新上线!
python3操作Jenkins模块api
Cloudquery v1.2.0 release
2020 database technology conference helps technology upgrade
PHP后门隐藏技巧
The first choice for lightweight GPU applications is the NVIDIA vgpu instance launched by Jingdong Zhilian cloud
2020年新规,微信封号怎么快速解除?
Introduction to Huawei cloud micro certification examination
[learning] interface test case writing and testing concerns