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

Use vue2+elementui for hover prompts

Vue2+elementui's hover prompts are divided in...

How to run py files directly in linux

1. First create the file (cd to the directory whe...

Implementation of installing and uninstalling CUDA and CUDNN in Ubuntu

Table of contents Preface Install the graphics dr...

Sharing some details about MySQL indexes

A few days ago, a colleague asked me a question a...

Install Apache2.4+PHP7.0+MySQL5.7.16 on macOS Sierra

Although Mac systems come with PHP and Apache, so...

100 ways to change the color of an image using CSS (worth collecting)

Preface “When it comes to image processing, we of...

CSS World--Code Practice: Image Alt Information Presentation

Using the <img> element with the default sr...

Implementation of adding remark information to mysql

Preface Some people have asked me some MySQL note...

Windows Server 2016 Standard Key activation key serial number

I would like to share the Windows Server 2016 act...

Goodbye Docker: How to Transform to Containerd in 5 Minutes

Docker is a very popular container technology. Th...

Docker container log analysis

View container logs First, use docker run -it --r...

How to generate Hive table creation statement comment script in MySQL metadata

Preface This article mainly introduces the releva...

How to use docker to deploy spring boot and connect to skywalking

Table of contents 1. Overview 1. Introduction to ...