Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Specific steps of building Docker Swarms across host clusters

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces "the concrete steps of building Docker Swarms cross-host cluster". In the daily operation, I believe many people have doubts about the specific steps of building Docker Swarms cross-host cluster. The editor consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful to answer the doubts about "the concrete steps of building Docker Swarms cross-host cluster". Next, please follow the editor to study!

Problem solved

You want to build a cluster on multiple physical or virtual machines rather than on one machine.

Due to the use of windows10 + VirtualBox, and installation of linux series systems in VirtualBox, and stuck in the document "docker-machine create-driver virtualbox myvm1"

Build an environment

Build time: 2019.8.16

Equipment system: windows10

Virtual software: VirtualBox

Virtual system: Ubuntu 18.04LTS

Background

Why would I want to build a cluster on multiple physical hosts or virtual machines? There are two reasons: the performance limit of a single equipment and disaster preparedness. The first reason is easy to understand, the performance limit of a single device. The starting point of disaster recovery is not the downtime of a single service in the container, but the physical category of disaster recovery. It is often reported that domestic cloud service providers with 99.99% reliability go down from time to time, but have we ever heard of the simultaneous downtime of two or more cloud services at the same time?

Theoretical analysis, by 99.99% as the standard, this figure does seem foolproof at first glance, but the absolute time is: 52.56 minutes / year. What if we deploy the service on two different cloud service providers at the same time? The service theory downtime is 0.31 seconds / year. Of course, this is only a theoretical analysis, but is it a better solution to improve the reliability of services by purchasing hosts distributed in two or more cloud service providers to build clusters under the same budget?

Train of thought

The Docker document creates a virtual node within the host system through the "docker-machine create-driver virtualbox myvm1" command in the Swarms section, but this command cannot be successfully executed in a ubuntu system that is already created by a virtual machine, see JerryWang's Blog. There are many ways to solve this problem, dual systems, the use of Mac are feasible, but limited by some objective reasons, and want to try to build a cluster across the main organization, so the following solutions are adopted: three sets of ubuntu systems are virtualized in VirtualBox: a, B, C. Where An is equivalent to the host operating system in the tutorial, and B and C are equivalent to two nodes in the host operating system in the tutorial. By connecting A, B, C to achieve the same effect as the tutorial there, but also to achieve the construction of cross-host clusters.

Concrete steps

Pre-install docker in host A (see the official website tutorial), B, C virtual machines only need to install ssh server. (B and C can be virtual hosts of cloud service providers)

Use the following instruction to obtain the IP address of the B and C virtual machines.

Ifconfig / / if the message is too long, use ifconfig > > output to output a large file and use vim to open and view it.

Host B and C configure ssh to allow direct login using the root account: in the / etc/ssh/sshd_config file, add

PermitRootLogin yes

Execute the following command in A to generate the key file (all operations at the beginning of this step need only be done in A)

Ssh-keygen

Copy the public key to B, C

Ssh-copy-id IP

/ / execute twice to replace IP with IP of B and C respectively

Use the instructions to verify that the configuration is successful

Ssh IP / / launch login using logout after success

Use the following instructions to install docker for B and C in A. (at the same time, links between An and B, C will be established)

/ / docker-machine is not required to be installed before the docker documentation arrives here. See the official documentation for installation.

/ / this command needs to be executed twice. The official IP,NodeName documents of B and C are named myvm1 and myvm2, respectively. Here I name them docker1 and docker2.

Docker-machine create-d generic- generic-ip-address=IP NodeName

Use the following instructions to check that the connection is complete

Docker-machine ls

Explain and explain

The effect achieved by the above steps can connect multiple independent physical hosts or virtual machines located on different platforms. At the same time, it is also equivalent to the following two instructions in the official document, which can be linked to the following tutorial content.

Docker-machine create-driver virtualbox myvm1docker-machine create-driver virtualbox myvm2

With regard to IP, in the same scenario as mine (except for hosts and CVMs with a fixed IP), it is not recommended to spend time configuring static IP in the LAN, because you also need to configure subnet mask, gateway and DNS server in the configuration file of / etv/netplan (enabled later), so it is easy to make errors. The time spent is not cost-effective compared to what you have learned, and the IP will change, but in practice, the time difference is enough to complete the exercise.

Why do you need to modify the ssh configuration file in B and C? Since ssh cannot log in with a root account by default, we usually use the account created by ourselves, such as ubuntu login, and then use sudo su to switch to the root account. However, in this scenario, the host needs to allow login directly using the root account.

Postscript

The screenshot of completing the docker swarms tutorial is as follows

The results of completing all docker get-star tutorials are as follows

At this point, the study of "concrete steps for building Docker Swarms cross-host clusters" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

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.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report