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

Detailed explanation of the available environment variables in Docker Compose

Several parts of Compose deal with environment va...

WeChat applet uses canvas to draw clocks

This article shares the specific code of using ca...

Mysql experiment: using explain to analyze the trend of indexes

Overview Indexing is a skill that must be mastere...

Multi-service image packaging operation of Dockerfile under supervisor

Writing a Dockerfile Configure yum source cd /tmp...

Vue makes a simple random roll call

Table of contents Layout part: <div id="a...

The whole process of realizing website internationalization using Vite2 and Vue3

Table of contents Preface Install vue-i18n Config...

HTML Basics Must-Read - Comprehensive Understanding of CSS Style Sheets

CSS (Cascading Style Sheet) is used to beautify H...

Quickly solve the problem of slow startup after Tomcat reconfiguration

During the configuration of Jenkins+Tomcat server...

MySQL series 6 users and authorization

Table of contents Tutorial Series 1. User Managem...

The difference between float and position attributes in CSS layout

CSS Layout - position Property The position attri...

Detailed example of deploying Nginx+Apache dynamic and static separation

Introduction to Nginx dynamic and static separati...

iframe parameters with instructions and examples

<iframe src=”test.jsp” width=”100″ height=”50″...

Detailed examples of Linux disk device and LVM management commands

Preface In the Linux operating system, device fil...

How to Completely Clean Your Docker Data

Table of contents Prune regularly Mirror Eviction...