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 > Servers >
Share
Shulou(Shulou.com)06/01 Report--
How to use Shipyard to deploy Docker Swarm clusters and cross-host Overlay networks, I believe that many inexperienced people do not know what to do. Therefore, this paper summarizes the causes and solutions of the problem. Through this article, I hope you can solve this problem.
Several deployment methods of Docker Swarm clusters are given on the official website, which are based on Docker ToolBox and Amazon AWS.
Shipyard is a very powerful docker cluster management system with a very friendly Web interface. What is more abnormal is that Shipyard has a powerful one-click automatic deployment script, but the service discovery and registration in it uses etcd instead of consul, but consul is recommended by docker's official website. This article mainly introduces the use of shipyard and consul to manually deploy Swarm clusters.
Environmental preparation
The lab environment consists of three servers, and the roles and configurations of each server are shown in the following table:
IP operating system role 192.168.0.47Ubuntu 14.04 Kernel 3.16.0consul Node 192.168.0.56Ubuntu 14.04 Kernel 3.16.0swarm manager Node 192.168.0.57Ubuntu 14.04 Kernel 3.16.0swarm agent Node installation Docker
The official docker installation manual for each platform is available for readers to refer to. In order to be lazy and convenient, here we use the one-click installation script provided by Docker to install docker.
Curl-sSL https://get.docker.io/ubuntu/ | sudo sh
After installation, we also need to modify the default startup parameters of docker and modify the following files:
Vi / etc/default/docker
Add this line:
DOCKER_OPTS= "- H tcp://0.0.0.0:2375-H unix:///var/run/docker.sock"
Then restart the Docker service
Service start docker deploys Consul nodes
On 192.168.0.47, the consul node, run the following command to deploy the service discovery module
Docker run-d\-p 8300 8600:53/udp 8300\-p 8301 docker run 8301\-p 8301:8301/udp\-p 8302 8302:8302/udp\-p 8400 8302:8302/udp\-p 8500 8600:53/udp 53\-p 8600:53/udp\-- restart=always\-- name=consul progrium/consul-server-bootstrap-ui-dir=/ui-advertise 192.168.0.47-client 0.0.0.0
Explain the parameters:
-d container runs in the background, detached mode
-- restart=always restart mode. Always means forever.
-p 8400 8400 maps consul's rpc port 8400
-p 8500 is mapped to public IP so that we can use the UI interface conveniently.
-p 53:53/udp binds udp port 53 (default DNS port) on docker0 bridge address
-the IP published by advertise 192.168.0.47 consul service, which is specially set to 0.47. otherwise, the service will be displayed as the IP address of the internal container, so that it cannot be accessed.
-address of client 0.0.0.0 consul snooping
Deploy Swarm Manager node Step 1
First install the rethinkdb database on 192.168.0.56, that is, the swarm manager node
Docker run-d-- restart=always-- name shipyard-rethinkdb rethinkdbStep 2
Then continue to install swarm manager, note that 192.168.0.47 is replaced with the ip address of the actual consul node
Docker run-d-p 3375 name shipyard-swarm-manager swarm:latest manage 3375-restart=always-- name shipyard-swarm-manager swarm:latest manage-- host tcp://0.0.0.0:3375 consul://192.168.0.47:8500Step 3
Then install swarm agent on the manager node. Note here that 192.168.0.47 is the IP address of the consul node and 192.168.0.56 is the IP address of manager. Replace both with the node address in your actual environment.
Docker run-d-restart=always-name shipyard-swarm-agent swarm:latest join-addr 192.168.0.56 consul://192.168.0.47:8500Step 2375 consul://192.168.0.47:8500Step 4
Finally, deploy the shipyard management module
Docker run-d-- restart=always-- name shipyard-controller-- link shipyard-rethinkdb:rethinkdb-- link shipyard-swarm-manager:swarm-p 9090 name shipyard-controller 8080 shipyard/shipyard:latest server-d tcp://swarm:3375
After deployment, you can visit http://192.168.0.56:9090 in the browser, and you can see the login page of shipyard. The default account is admin and the password is shipyard.
Deploy Swam Agent nodes
The deployment of node agent is relatively simple, you only need to refer to step 3 on the manager node.
Docker run-d-- restart=always-- name shipyard-swarm-agent swarm:latest join-- addr 192.168.0.57 consul://192.168.0.47:8500
Similarly, 192.168.0.47 is the IP address of the consul node, and 192.168.0.57 is the IP address of the agent node, replacing both with the node address in your actual environment
Deploy the Overlay network
In order to be able to use a cross-host Overlay network on a Docker Swarm cluster, some configuration changes need to be made. On manager nodes and agent nodes
Vi / etc/default/docker
Put this line of work
DOCKER_OPTS= "- H tcp://0.0.0.0:2375-H unix:///var/run/docker.sock"
Modify to
DOCKER_OPTS= "- H tcp://0.0.0.0:2375-H unix:///var/run/docker.sock-- cluster-store=consul://192.168.0.47:8500-- cluster-advertise=eth0:2375"
Here 192.168.0.47 is the IP address of the consul node, and eth0 is the name of the network card where 192.168.0.56 and 57 is located on the manager/agent node. Then restart the Docker service
Service start docker
Let's create an overlay network
Docker-H 192.168.0.56 overlay test-net 3375 network create-d overlay test-net
Note: you need to specify the address of the cluster when using the docker client to operate on the docker swarm cluster. The exposed IP and port of the cluster created in our experiment is 192.168.0.56 IP 3375, while port 2375 is used to operate on a single docker host.
View all the networks in the swarm cluster
$docker-H 192.168.0.56 purl 3375 network ls NETWORK ID NAME DRIVER 1abc3888c68f node1/bridge bridge 7c21108c289f node1/docker_gwbridge bridge fd7873463f44 node1/host host 61808ed752b3 node1/none null 3239dd516cb5 node2/ Bridge bridge 049b996b6ec0 node2/docker_gwbridge bridge 045824d9569c node2/host host 2a0ec5e15ce8 node2/none null 33df13f850c5 test-net overlay
You can see that the test-net network is created on both 56 and 57, so let's create a container on this network
$docker-H 192.168.0.56 name test4 ubuntu:14.04 db7113bae6d06922a133cef92f01701c0f35156b374ae14e31e13ac54500e979 3375 run-itd-- net test-net-- name test4 ubuntu:14.04 db7113bae6d06922a133cef92f01701c0f35156b374ae14e31e13ac54500e979 $docker-H 192.168.0.56 net test-net 3375 run-itd-- net test-net-- name test5 ubuntu:14.04 dbea32bd623ce225af426470f1f30f5f76d5f5148a63893e2f9f84b4628cb171
See two containers distributed on two nodes
Docker-H 192.168.0.56 aCONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMESdbea32bd623c ubuntu:14.04 3375 ps-aCONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMESdbea32bd623c ubuntu:14.04 "/ bin/bash" 2 minutes ago Up About a minute Node1/test5db7113bae6d0 ubuntu:14.04 "/ bin/bash" 2 minutes ago Up 2 minutes node2/test4da671da259ce swarm:latest "/ swarm join-addr 1" 2 hours ago Up 2 hours 2375/tcp Node2/shipyard-swarm-agent4d9725a9f0de shipyard/shipyard:latest "/ bin/controller serv" 2 hours ago Up 2 hours 192.168.0.56 hours 9090-> 8080/tcp node1/shipyard-controllerd994169e39c7 rethinkdb "rethinkdb-- bind all" 2 hours ago Up 2 hours 8080/tcp 28015/tcp, 29015/tcp node1/shipyard-rethinkdb,node1/shipyard-controller/rethinkdb5f5b793a358d swarm:latest "/ swarm join-- addr 1" 2 hours ago Up 2 hours 2375/tcp node1/shipyard-swarm-agent7f20411fc504 swarm:latest "/ swarm manage-- host" 2 hours ago Up 2 hours 2375/tcp 192.168.0.56 purl 3375-> 3375/tcp node1/shipyard-swarm-manager,node1/shipyard-controller/swarm
Next, we test the connectivity of the cross-host network. We verify the network connectivity of the containers scattered on different nodes by attach to ping test5 on the test4 container.
$docker-H 192.168.0.56 bytes of data.64 bytes from test5.test-net 3375 attach test4root@db7113bae6d0:/# root@db7113bae6d0:/# ping-c 4 test5PING test5 (10.0.0.8) 56 (84) bytes of data.64 bytes from test5.test-net (10.0.0.8): icmp_seq=1 ttl=64 time=0.283 ms64 bytes from test5.test-net (10.0.0.8): icmp_seq=2 ttl=64 time=0.285 ms64 bytes from test5.test-net (10.0.0.8): icmp_seq=3 Ttl=64 time=0.295 ms64 bytes from test5.test-net (10.0.0.8): icmp_seq=4 ttl=64 time=0.221 ms--- test5 ping statistics-4 packets transmitted 4 received, 0 packet loss, time 2998msrtt min/avg/max/mdev = 0.221 packet loss, 0.271 ms, 0.295 ms Have you learned how to deploy Docker Swarm clusters and cross-host Overlay networks using Shipyard? If you want to learn more skills or want to know more about it, you are welcome to follow the industry information channel, thank you for reading!
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.