Methods and steps for Etcd distributed deployment based on Docker

Methods and steps for Etcd distributed deployment based on Docker

1. Environmental Preparation

1.1 Basic Environment

NTP configuration: omitted #It is recommended to configure the NTP service to ensure time consistency

etcd version: v3.3.9

Firewall and SELinux: Disable firewall and SELinux

name
address
Hostname
Remark
etcd1
172.24.8.71
etcd1.example.com
Used to save relevant IP information
docker01
172.24.8.72
docker01.example.com
docker02
172.24.8.73
docker02.example.com

# hostnamectl set-hostname etcd1.example.com
# hostnamectl set-hostname docker01.example.com
# hostnamectl set-hostname docker02.example.com

Tip: The host name is not required.

1.2 Docker environment

All the above nodes have Docker installed. For details, see 002.Docker version and installation.

2. etcd node deployment

Tip: This environment is all dockerized, that is, the etcd service also exists in docker form.

2.1 etcd basic configuration

# mkdir -p /var/log/etcd/ #It is recommended to create a directory for saving etcd logs# mkdir -p /data/etcd #It is recommended to create a separate etcd data directory# export HOST_1=172.24.8.71 #Set the IP address of the etcd node
# export DATA_DIR=/data/etcd #Set the cluster etcd data node # REGISTRY=quay.io/coreos/etcd #It is recommended to use this warehouse # ETCD_VERSION=latest #Set etcd version # export NAME_1=etcd1 #Set the name of the etcd node
# docker volume create --name etcd-data

Tip: All the above operations need to be performed on all nodes.

2.3 Start the docker etcd cluster

[root@etcd1 ~]# docker run \
 -p 2379:2379 \
 -p 2380:2380 \
 --volume=${DATA_DIR}:/etcd-data \
 --name etcd ${REGISTRY}:${ETCD_VERSION} \
 /usr/local/bin/etcd \
 --data-dir=/etcd-data --name ${NAME_1} \
 --initial-advertise-peer-urls http://${HOST_1}:2380 --listen-peer-urls http://0.0.0.0:2380 \
 --advertise-client-urls http://${HOST_1}:2379 --listen-client-urls http://0.0.0.0:2379 \
 --initial-cluster ${NAME_1}=http://${HOST_1}:2380

Tip: The quay.io/coreos/etcd image may not be pulled in China, but can be pulled from a foreign node and then scp to the cluster node.

2.4 Confirmation and Verification

 [root@etcd1 ~]# docker ps 

 

 [root@etcd1 ~]# docker exec -it bcb96fb0f987 /usr/local/bin/etcdctl cluster-health 

[root@etcd1 ~]# docker exec -it bcb96fb0f987 /usr/local/bin/etcdctl --endpoints=http://${HOST_1}:2379 member list 

Three Docker host node configuration

3.1 docker01 configuration

[root@docker01 ~]# vi /etc/sysconfig/docker
OPTIONS='--cluster-store=etcd://172.24.8.71:2379 --cluster-advertise=172.24.8.72:2379'
[root@docker01 ~]# systemctl restart docker

3.2 docker02 configuration

[root@docker02 ~]# vi /etc/sysconfig/docker
OPTIONS='--cluster-store=etcd://172.24.8.71:2379 --cluster-advertise=172.24.8.73:2379'
[root@docker02 ~]# systemctl restart docker

3.3 Creating an overlay network

[root@docker01 ~]# docker network create -d overlay overlaynet1
418654e0092f5d1c3e4bf2b9ee73cdd22932dd60fecf12d7a3b024818118244b
[root@docker01 ~]# docker network inspect overlaynet1 

[root@docker02 ~]# docker network inspect overlaynet1 

Tip: Check the overlay network created on docker01 on both docker01 and docker02 hosts. If both exist, it means that the network data is distributed instead of local through etcd.

3.4 Test Network

[root@docker01 ~]# docker run -d --name Container01 --network overlaynet1 training/webapp python app.py
[root@docker02 ~]# docker run -d --name Container02 --network overlaynet1 training/webapp python app.py
[root@docker01 ~]# docker exec -it 73e984a5528a /bin/bash
root@73e984a5528a:/opt/webapp# ifconfig 

root@73e984a5528a:/opt/webapp# route -n 


[root@docker02 ~]# docker exec -it 89eac9521743 /bin/bash
root@89eac9521743:/opt/webapp# ifconfig 

illustrate:

  • All container pairs will have two network cards, eth0 and eth1;
  • The network of eth1 is an internal network segment, that is, the ordinary NAT mode;
  • eth0 is the IP address assigned to the overlay network segment, i.e. the overlay network, and the MTU is 1450 instead of 1500.
  • Only communications between containers in the same overlay network go through eth0, and all other communications go through eth1.
[root@docker01 ~]# brctl show 

[root@docker01 ~]# docker network ls 


Other references:

  • Docker creates two Linux bridges on each node, one for the overlay network and one for the non-overlay NAT network (docker_gwbridge);
  • The network traffic from the container to other containers in the overlay network goes through the container's overlay network card (eth0), and other network traffic goes through the container's NAT network card (eth1).
  • Currently, the ID range of the vxlan tunnel created by Docker is 256 to 1000, so a maximum of 745 networks can be created. Therefore, the ID used for this vxlan tunnel in this example is 256.
  • The Docker vxlan driver uses UDP port 4789;
  • The underlying layer of the overlay network model requires a KV storage system similar to consul or etcd for message synchronization;
  • Docker overlay does not use multicast;
  • The containers in the Overlay network are in a virtual large Layer 2 network.

The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM.

You may also be interested in:
  • Practical way to build selenium grid distributed environment with docker
  • How to use selenium+testng to realize web automation in docker
  • Briefly describe the installation of influxDB distributed time series database and related operations in Docker
  • Example of using Docker Swarm to build a distributed crawler cluster
  • Tutorial on how to use Docker to implement distributed application functions
  • Detailed explanation of how to deploy surging distributed microservice engine based on Docker
  • Detailed explanation of using docker to build a Hadoop distributed cluster
  • Building a selenium distributed environment based on docker

<<:  Win10 installation of MySQL5.7.18winX64 failed to start the server and no error message

>>:  Detailed example of getting the maximum value of each group after grouping in MySQL

Recommend

Vue implements a draggable tree structure diagram

Table of contents Vue recursive component drag ev...

Vue implements the question answering function

1. Request answer interface 2. Determine whether ...

How to receive binary file stream in Vue to realize PDF preview

Background Controller @RequestMapping("/getP...

Detailed explanation of Nginx configuration required for front-end

Nginx (engine x) is a lightweight, high-performan...

Forever+nginx deployment method example of Node site

I recently bought the cheapest Tencent cloud serv...

The use and methods of async and await in JavaScript

async function and await keyword in JS function h...

How to enable remote access in Docker

Docker daemon socket The Docker daemon can listen...

CSS to achieve Cyberpunk 2077 style visual effects in a few steps

background Before starting the article, let’s bri...

Intellij IDEA quick implementation of Docker image deployment method steps

Table of contents 1. Docker enables remote access...

mysql join query (left join, right join, inner join)

1. Common connections for mysql INNER JOIN (inner...

How to set up a deployment project under Linux system

1. Modify the firewall settings and open the corr...

Brief analysis of centos 7 mysql-8.0.19-1.el7.x86_64.rpm-bundle.tar

Baidu Cloud Disk: Link: https://pan.baidu.com/s/1...

How to set a fixed IP address for a VMware virtual machine (graphic tutorial)

1. Select Edit → Virtual Network Editor in the me...

Steps to build MHA architecture deployment in MySQL

Table of contents MAH 1. Introduction to MAH Arch...