1.环境准备

下载安装包:https://github.com/etcd-io/etcd/releases/ 这里下载的安装包为:etcd-v3.5.9-linux-amd64.tar.gz,即我们当前安装的 etcd 版本为:3.5.9

这里有 3 个节点,分别为:

10.23.0.21 ec1
10.23.0.22 ec2
10.23.0.23 ec3

2.安装配置

首先在所有机器安装 etcd 如下:

tar -xvzf etcd-v3.5.9-linux-amd64.tar.gz
cd etcd-v3.5.9-linux-amd64/
mv etcd* /usr/local/bin/
# 查看版本号
etcd --version

然后在所有机器创建 etcd 数据目录:

mkdir /data/etcd

然后为集群指定一个初始化的令牌,防止意外的跨集群交互,可以生成一个 UUID:

uuidgen

不使用 UUID 也可以使用其他字符串,只要保证唯一就好,然后我们依次前台启动 etcd 服务:

# ec1 执行
etcd --data-dir=/data/etcd --name ec1 \
--initial-advertise-peer-urls http://10.23.0.21:2380 --listen-peer-urls http://10.23.0.21:2380 \
--advertise-client-urls http://10.23.0.21:2379 --listen-client-urls http://10.23.0.21:2379 \
--initial-cluster ec1=http://10.23.0.21:2380,ec2=http://10.23.0.22:2380,ec3=http://10.23.0.23:2380 \
--initial-cluster-state new --initial-cluster-token c660d863-24b4-4003-ba9c-ca27cfadda1d
# ec2 执行
etcd --data-dir=/data/etcd --name ec2 \
--initial-advertise-peer-urls http://10.23.0.22:2380 --listen-peer-urls http://10.23.0.22:2380 \
--advertise-client-urls http://10.23.0.22:2379 --listen-client-urls http://10.23.0.22:2379 \
--initial-cluster ec1=http://10.23.0.21:2380,ec2=http://10.23.0.22:2380,ec3=http://10.23.0.23:2380 \
--initial-cluster-state new --initial-cluster-token c660d863-24b4-4003-ba9c-ca27cfadda1d
# ec3 执行
etcd --data-dir=/data/etcd --name ec3 \
--initial-advertise-peer-urls http://10.23.0.23:2380 --listen-peer-urls http://10.23.0.23:2380 \
--advertise-client-urls http://10.23.0.23:2379 --listen-client-urls http://10.23.0.23:2379 \
--initial-cluster ec1=http://10.23.0.21:2380,ec2=http://10.23.0.22:2380,ec3=http://10.23.0.23:2380 \
--initial-cluster-state new --initial-cluster-token c660d863-24b4-4003-ba9c-ca27cfadda1d

其中参数的含义如下:

--listen-peer-urls 监听用于节点间通信的地址和端口,默认端口是 2380

--initial-advertise-peer-urls 表示提供给对端用于节点间访问的 URL,通常和上面的一样,但是在多网卡的环境下配置可能不一样

--listen-client-urls 监听客户端服务的地址和端口,默认端口是 2379

--advertise-client-urls 表示提供给客户端来访问 etcd 服务的 URL,通常和监听的一致,但是在多网卡环境下配置可能会不同

--initial-cluster 这个是固定格式,指定集群的节点和具体访问地址,所有节点都需要指定一样的。

--initial-cluster-state 新建集群需要写 new ,如果是加入已经存在的集群要写 existing

--initial-cluster-token 这个是填写我们刚才生成的 token 即可。

所有机器都启动后,集群就启动成功了。

查看状态:

# 这里写几个地址就显示几个
etcdctl --write-out=table --endpoints=http://10.23.0.21:2379 endpoint status
# 检查节点是否健康
etcdctl --endpoints=http://10.23.0.21:2379 endpoint health
# 查看成员列表 但是有时候显示会有延迟
etcdctl --endpoints=http://10.23.0.21:2379 --write-out=table member list

为了方便运行,可以使用 systemd 进行管理,首先需要将这么多参数抽出配置文件,etcd 支持通过 --config-file 传递配置文件路径,创建配置文件:

# 所有节点都需要创建配置文件
mkdir /etc/etcd
touch /etc/etcd/etcd.yml

然后对于 ec1 的配置文件如下:

# This is the configuration file for the etcd server.

# Human-readable name for this member.
name: 'ec1' # Path to the data directory.
data-dir: /data/etcd # List of comma separated URLs to listen on for peer traffic.
listen-peer-urls: http://10.23.0.21:2380 # List of comma separated URLs to listen on for client traffic.
listen-client-urls: http://10.23.0.21:2379 # List of this member's peer URLs to advertise to the rest of the cluster.
# The URLs needed to be a comma-separated list.
initial-advertise-peer-urls: http://10.23.0.21:2380 # List of this member's client URLs to advertise to the public.
# The URLs needed to be a comma-separated list.
advertise-client-urls: http://10.23.0.21:2379 # Comma separated string of initial cluster configuration for bootstrapping.
# Example: initial-cluster: "infra0=http://10.0.1.10:2380,infra1=http://10.0.1.11:2380,infra2=http://10.0.1.12:2380"
initial-cluster: "ec1=http://10.23.0.21:2380,ec2=http://10.23.0.22:2380,ec3=http://10.23.0.23:2380" # Initial cluster token for the etcd cluster during bootstrap.
initial-cluster-token: 'c660d863-24b4-4003-ba9c-ca27cfadda1d' # Initial cluster state ('new' or 'existing').
initial-cluster-state: 'new'

基本配置就是上面这些,我们保存配置,然后所有节点都需要填写该配置文件,其中的主机名和 IP 要根据节点实际的进行修改,所有节点编辑无误保存。

然后每个机器都要创建服务文件:/etc/systemd/system/etcd.service,内容如下:

[Unit]
Description="etcd"
Requires=network-online.target
After=network-online.target [Service]
User=root
Group=root
ExecStart=/usr/local/bin/etcd --config-file=/etc/etcd/etcd.yml
ExecReload=/bin/kill --signal HUP $MAINPID
KillMode=process
KillSignal=SIGTERM
Restart=on-failure
LimitNOFILE=65536 [Install]
WantedBy=multi-user.target

所有机器都需要同步服务文件,同步之后我们手动结束掉之前阻塞的进程,然后启动服务:

# 所有节点都需要启动
systemctl start etcd.service
systemctl status etcd.service

检查服务状态都正常就可以了。

Reference:

  1. https://etcd.io/docs/v3.5/tutorials/how-to-setup-cluster/

etcd 集群安装的更多相关文章

  1. centos下etcd集群安装

    先仔细了解学习etcd 官方: https://github.com/etcd-io/etcd https://www.cnblogs.com/softidea/p/6517959.html http ...

  2. ETCD集群安装实验

    目录 [1.下载二进制程序] [2.安装etcd集群] [3.查询集群状态] [4.存入读取数据] [5.注意事项] [6.参考链接] 简介:     Etcd的官网文档及其在GitHub上的文档,已 ...

  3. etcd集群安装部署

    1. 集群架构 由于我们只有两个机房,所以选择的是以上图中所示的数据同步方案, 通过做镜像的方式保证两个集群的数据实时同步. 整体架构如上图所示, 整个全局元数据中心包括两套集群,廊坊集群和马驹桥集群 ...

  4. etcd集群安装

    etcd 是一个分布式一致性k-v存储系统,可用于服务注册发现与共享配置,具有以下优点:1.简单:相比于晦涩难懂的paxos算法,etcd基于相对简单且易实现的raft算法实现一致性,并通过gRPC提 ...

  5. kubernetes 集群安装etcd集群,带证书

    install etcd 准备证书 https://www.kubernetes.org.cn/3096.html 在master1需要安装CFSSL工具,这将会用来建立 TLS certificat ...

  6. 使用docker方式安装etcd集群,带TLS证书

    网上文档也多,安装的时候,还是踩了几个坑. 现在作一个安装记录吧. 1,先作自签名的证书ca-csr.json(为了和k8s共用根证书,可能将信息调为k8s). { "CN": & ...

  7. 使用k8s operator安装和维护etcd集群

    关于Kubernetes Operator这个新生事物,可以参考下文来了解这一技术的来龙去脉: https://yq.aliyun.com/articles/685522?utm_content=g_ ...

  8. Kubernetes1.91(K8s)安装部署过程(三)--创建高可用etcd集群

    这里的etcd集群复用我们测试的3个节点,3个node都要安装并启动,注意修改配置文件 1.TLS认证文件分发:etcd集群认证用,除了本机有,分发到其他node节点 scp ca.pem kuber ...

  9. yum安装etcd集群

       前一篇文章介绍了如何yum安装简单的kubernetes集群,其中etcd是单点部署.本篇我们来搭建etcd集群,方便日后搭建kubernetes HA集群架构. 1,环境配置说明 etcd1 ...

  10. etcd简介及集群安装部署使用

    目录 1. 简介 2. Linux下载安装 3. 单机模式启动 4. 指定各集群成员的方式配置集群 5. 使用discovery service的方式配置集群 6. 集群模式下客户端命令行 7. et ...

随机推荐

  1. netcore 图片缩略图

    /// <summary> /// 取小写文件名后缀 /// </summary> /// <param name="name">文件名< ...

  2. vite ts 安装 js-cookie 库,vscode找不到类型说明(有波浪线),解决方案

    vite ts 安装 js-cookie 库,vscode找不到类型说明(有波浪线),解决方案 先安装库 https://www.npmjs.com/package/js-cookie 再安装类型 h ...

  3. br 词根 分支 broad bread branch brother broom 看到abroad后查到的

    br-分支 cl-集合 pater-父亲 br/other 兄弟-br/oom笤帚-br/eed繁殖-br/ood一窝-br/eak打破-br/anch分枝 cl/ash碰撞-class/ify分类- ...

  4. 基于python中librosa的声音混音实例解析

    一 概念   1.一些概念 Librosa是一个用于音频.音乐分析.处理的python工具包,一些常见的时频处理.特征提取.绘制声音图形等功能应有尽有,功能十分强大.本文主要介绍libros的基本用法 ...

  5. 在salesforce中如何获取Security Token

    Trailhead练习Soap API使用Soap UI时,需要Security Token才能登录,在Lightning一直找不到,后来切换到Classic才找到.现在提供一个简单粗暴的方式,快速定 ...

  6. ijkplayer编译-RTSP

    1.编译平台和版本 使用操作系统 Ubuntu 18.04 使用ndk版本:android-ndk-r14b-linux-x86_64.zip (使用r17c编译会报错) AS版本:4.2.2 1.1 ...

  7. 关于linux在笔记本下耗电的解决方案(只写我实践的部分)

    PS:要转载请注明出处,本人版权所有. PS: 这个只是基于<我自己>的理解, 如果和你的原则及想法相冲突,请谅解,勿喷. 前置说明   本文发布于 2014-09-22 12:02:54 ...

  8. python基础十一(异常)

    1.什么是异常异常是程序发生错误的信号,程序一旦出错就会抛出异常,程序的运行随即终止1)异常处理的三个特征异常的追踪信息异常的类型异常的内容2.为何处理异常为了增强程序的健壮性,即便是程序运行过程中出 ...

  9. 三维模型3DTile格式轻量化的纹理压缩和质量关系分析

    三维模型3DTile格式轻量化的纹理压缩和质量关系分析 在三维模型的3DTile格式轻量化处理中,纹理压缩是一个重要环节.但是,纹理压缩和模型质量之间存在明显的关系需要权衡.以下是纹理压缩和模型质量关 ...

  10. window-命令行操作

    window命令行操作 调起命令行-win+r输入cmd 网络探活 ping www.baidu.com 快捷启动应用 打开记事本 notepad 打开画图 mspaint 打开计算器 calc 命令 ...