当前位置:网站首页>ETCD containerized to build a cluster
ETCD containerized to build a cluster
2022-08-11 07:05:00 【!Nine thought & & gentleman!】
系列文章目录
文章目录
前言
本文介绍使用docker搭建一个etcd集群,Comes with the corresponding build script.I strongly hope to explain the operation steps and principles in as much detail as possible,make it easier for readers to understand.
一、环境信息
使用本地的vmstation创建3个虚拟机,信息如下
节点名称 | 节点IP | 节点配置 | 操作系统 | Etcd版本 | Docker版本 |
---|---|---|---|---|---|
etcd1 | 192.168.82.128 | 1c1g 20g | CentOS7.4 | v3.5 | 13.1 |
etcd2 | 192.168.82.129 | 1c1g 20g | CentOS7.4 | v3.5 | 13.1 |
etcd3 | 192.168.82.130 | 1c1g 20g | CentOS7.4 | v3.5 | 13.1 |
说明:The server should be able to访问公网,in order to be able to download the corresponding etcd镜像
二、搭建步骤
1.Prepare preconditions
1.1 安装Docker
代码如下(示例):
# 安装docker
yum install -y docker
# 重启docker
systemctl restart docker
# 验证docker
docker ps
备注,需要关闭防火墙
systemctl stop firewalld.service
systemctl disable firewalld.service
1.2 拉取镜像
代码如下(示例):
# 拉取镜像
docker pull quay.io/coreos/etcd:v3.5.0
# 验证镜像
docker images|grep etcd
2.安装Etcd
2.1 新建目录
分别在3Create a new directory on each machine /data/etcd,Used to mount into the container,能够讲etcdThe data is persisted to the local disk.需要注意的是,Reproduce the environment as much as possibleetcdThe data directory is mounted on a separate disk,磁盘的io性能越快越好.磁盘的ioThe bandwidth needs to be guaranteed as much as possible40MByte/s以上.否则etcddue to poor disk performance,Lead to constant cutting or unable to complete the foundationwal&snapshot写入,Causes the overall cluster to be abnormal
2.2 编辑脚本
Save the following commands to the script/data/start.sh,用于搭建etcd集群
代码如下(示例):
#! /bin/sh
name="etcd1"
host="192.168.92.128"
cluster="etcd1=http://192.168.92.128:2380,etcd2=http://192.168.92.129:2380,etcd3=http://192.168.92.130:2380"
docker run -d -p 2379:2379 -p 2380:2380 -v /data/etcd:/etcd-data/ --name $name --net=host quay.io/coreos/etcd:v3.5.0 /usr/local/bin/etcd --name $name --data-dir /data/etcd/data --listen-client-urls http://$host:2379 --advertise-client-urls http://$host:2379 --listen-peer-urls http://$host:2380 --initial-advertise-peer-urls http://$host:2380 --initial-cluster $cluster --initial-cluster-token tkn --initial-cluster-state new --log-level info --logger zap --log-outputs stderr
说明:when deployed on different machines,respectively replace in the scripthost和name即可.
2.3 执行部署
分别在3个节点上,Edited and tweaked the scripthost、name配置后,执行bash /data/start.sh命令,创建etcd集群.
三、结果验证
任意选一个节点,执行如下命令,Perform cluster verification,Verify that the build is complete.
代码如下(示例):
export ETCDCTL_API=3
export ETCD_ENDPOINTS=192.168.92.128:2379,192.168.92.129:2379,192.168.92.130:2379
/usr/local/bin/etcdctl --endpoints=192.168.92.128:2379 --write-out=table member list
/usr/local/bin/etcdctl --endpoints=$ETCD_ENDPOINTS --write-out=table endpoint status
注意 member listIs to record all node information in the entire cluster.It does not reflect the current running status of the cluster
endopont statusIt reflects the running status of the current cluster,需要有Leader节点,并且datasize不为0,It means that the cluster is set up normally
总结
If a stand-alone node is runningbash /data/start.sh
后,可以通过执行docker ps -a|grep etcd
Verify that the container is created.并通过docker logs ${dockerid}
method to view the log
参考
边栏推荐
猜你喜欢
随机推荐
Memory debugging tools Electric Fence
配置dns服务
FusionCompute8.0.0 实验(2)虚拟机创建
AUTOMATION DAY07 (Ansible Vault, ordinary users use ansible)
(3) Software testing theory (understanding the knowledge of software defects)
arcgis填坑_4
No threat of science and technology - TVD vulnerability information daily - 2022-8-4
使用路由器DDNS功能+动态公网IP实现外网访问(花生壳)
uboot sets the default bootdelay
记录一个刚写的Makefile
window7开启远程桌面功能
中国移动通信集团有限公司:业务委托书
ETCD单节点故障应急恢复
SECURITY DAY01 (Monitoring Overview, Zabbix Basics, Zabbix Monitoring Services)
vnc远程桌面安装(2021-10-20日亲测可用)
Project Notes - Take Notes
buildroot嵌入式文件系统中vi显示行号
(三)软件测试理论(了解软件的缺陷知识)
SATA、SAS、SSD三种硬盘存储性能数据
Threatless Technology-TVD Daily Vulnerability Intelligence-2022-7-25