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
# 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:
[root@docker01 ~]# brctl show [root@docker01 ~]# docker network ls Other references:
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:
|
<<: 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
Several parts of Compose deal with environment va...
This article shares the specific code of using ca...
Overview Indexing is a skill that must be mastere...
1. First introduce several commonly used MySQL fu...
Writing a Dockerfile Configure yum source cd /tmp...
Table of contents Layout part: <div id="a...
Table of contents Preface Install vue-i18n Config...
CSS (Cascading Style Sheet) is used to beautify H...
During the configuration of Jenkins+Tomcat server...
Table of contents Tutorial Series 1. User Managem...
CSS Layout - position Property The position attri...
Introduction to Nginx dynamic and static separati...
<iframe src=”test.jsp” width=”100″ height=”50″...
Preface In the Linux operating system, device fil...
Table of contents Prune regularly Mirror Eviction...