In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-30 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
Swarm is a set of extremely simple tools for managing docker clusters, which makes docker clusters exposed to users as a virtual whole.
Build the environment:
Turn off the firewall and secure linux
[root@localhost ~] # systemctl stop firewalld
[root@localhost ~] # setenforce 0
Modify the hostname separately:
[root@localhost ~] # vi / etc/hostname
Swarm01
Swarm02
Restart and add a bridge card to the network
[root@swarm01 ~] # systemctl restart network
[root@swarm02 ~] # systemctl restart network
[root@swarm01 ~] # vi / etc/yum.repos.d/CentOS-Base.repo / / configure yum sources respectively
[docker-repo]
Name=Docker Repository
Baseurl= https://yum.dockerproject.org/repo/main/centos/7/
Enabled=1
Gpgcheck=1
Gpgkey= https://yum.dockerproject.org/gpg
[base]
Name=centos-$releasever-Base
Baseurl= file:///mnt
Enabled=1
Gpgcheck=0
[root@swarm02 ~] # vi / etc/yum.repos.d/CentOS-Base.repo
[docker-repo]
Name=Docker Repository
Baseurl= https://yum.dockerproject.org/repo/main/centos/7/
Enabled=1
Gpgcheck=1
Gpgkey= https://yum.dockerproject.org/gpg
[base]
Name=centos-$releasever-Base
Baseurl= file:///mnt
Enabled=1
Gpgcheck=0
Download and install docker respectively:
Yum install-y docker-engine
Systemctl enable docker
Systemctl start docker
Modify the listening port of docker
[root@swarm01 ~] # vi / lib/systemd/system/docker.service
Add the following after ExecStart:
-H tcp://0.0.0.0:2375-H unix:///var/run/docker.sock
[root@swarm01 ~] # systemctl daemon-reload / / reload the configuration file
[root@swarm01 ~] # systemctl restart docker / / restart docker
[root@swarm01 ~] # docker pull swarm
[root@swarm01 ~] # docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
Swarm latest ff454b4a0e84 7 months ago 12.7MB
[root@swarm02 ~] # docker pull swarm
[root@swarm02 ~] # docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
Swarm latest ff454b4a0e84 7 months ago 12.7MB / / download swarm successfully
Initialize Swarm
[root@swarm01] # docker swarm init-- advertise-addr 192.168.100.30
After the above command is executed, the machine automatically joins the swarm cluster. This will create a cluster token
Obtain the global unique token as the unique identity of the cluster. This token value will be used later when other nodes are added to the cluster.
View the swarm node
[root@swarm02] # docker swarm join-- token SWMTKN-1-45wi0d159hormsyptmtnve18a1sas6zfo1alxzsk60ow5ii36t-bi167goeagg6tb0yf9dnzgmcv 192.168.100.30VR 2377
After Swarm02 joins the swarm cluster, there are two nodes, and several servers can join the swarm cluster with this token value.
Create a cluster network overlay
[root@swarm01] # docker network create-- driver overlay skynet
Docker network ls view!
[root@swarm01 ~] # docker pull httpd
Deployment test
[root@swarm01 ~] # docker service create-p 80:80-- name webserver-- replicas 4 httpd / / if you want to continue to add services such as nginx, you need to change port 80 and service name
[root@swarm01 ~] # docker service ls / / View the list of services
[root@swarm01 ~] # docker service ps webserver | grep Running / / View the details of service enablement
Visit: http://192.168.100.30/
Http://192.168.100.40/
The whole swarm02 has not downloaded the httpd service.
Restart docker, systemctl restart docker if you can't access it.
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.