二丫讲梵 二丫讲梵
首页
  • 最佳实践
  • 迎刃而解
  • Nginx
  • Php
  • Zabbix
  • AWS
  • Prometheus
  • Grafana
  • CentOS
  • Systemd
  • Docker
  • Rancher
  • Ansible
  • Ldap
  • Gitlab
  • GitHub
  • Etcd
  • Consul
  • RabbitMQ
  • Kafka
  • MySql
  • MongoDB
  • OpenVPN
  • KVM
  • VMware
  • Other
  • ELK
  • K8S
  • LLM
  • Nexus
  • Jenkins
  • 随写编年
  • 家人物语
  • 追忆青春
  • 父亲的朋友圈
  • 电影音乐
  • 效率工具
  • 博客相关
  • Shell
  • 前端实践
  • Vue学习笔记
  • Golang学习笔记
  • Golang编程技巧
  • 学习周刊
  • Obsidian插件周刊
关于
友链
  • 本站索引

    • 分类
    • 标签
    • 归档
  • 本站页面

    • 导航
    • 打赏
  • 我的工具

    • 备忘录清单 (opens new window)
    • json2go (opens new window)
    • gopher (opens new window)
    • 微信MD编辑 (opens new window)
    • 国内镜像 (opens new window)
    • 出口IP查询 (opens new window)
    • 代码高亮工具 (opens new window)
  • 外站页面

    • 开往 (opens new window)
    • ldapdoc (opens new window)
    • HowToStartOpenSource (opens new window)
    • vdoing-template (opens new window)
GitHub (opens new window)

二丫讲梵

行者常至,为者常成
首页
  • 最佳实践
  • 迎刃而解
  • Nginx
  • Php
  • Zabbix
  • AWS
  • Prometheus
  • Grafana
  • CentOS
  • Systemd
  • Docker
  • Rancher
  • Ansible
  • Ldap
  • Gitlab
  • GitHub
  • Etcd
  • Consul
  • RabbitMQ
  • Kafka
  • MySql
  • MongoDB
  • OpenVPN
  • KVM
  • VMware
  • Other
  • ELK
  • K8S
  • LLM
  • Nexus
  • Jenkins
  • 随写编年
  • 家人物语
  • 追忆青春
  • 父亲的朋友圈
  • 电影音乐
  • 效率工具
  • 博客相关
  • Shell
  • 前端实践
  • Vue学习笔记
  • Golang学习笔记
  • Golang编程技巧
  • 学习周刊
  • Obsidian插件周刊
关于
友链
  • 本站索引

    • 分类
    • 标签
    • 归档
  • 本站页面

    • 导航
    • 打赏
  • 我的工具

    • 备忘录清单 (opens new window)
    • json2go (opens new window)
    • gopher (opens new window)
    • 微信MD编辑 (opens new window)
    • 国内镜像 (opens new window)
    • 出口IP查询 (opens new window)
    • 代码高亮工具 (opens new window)
  • 外站页面

    • 开往 (opens new window)
    • ldapdoc (opens new window)
    • HowToStartOpenSource (opens new window)
    • vdoing-template (opens new window)
GitHub (opens new window)
  • 最佳实践

  • 迎刃而解

  • Nginx

  • Php

  • Zabbix

  • AWS

  • Prometheus

  • Grafana

  • Loki

  • CentOS

  • Supervisord

  • Systemd

  • Docker

  • Docker-Compose

  • Rancher

  • Ansible

  • OpenLdap

  • GitLab

  • GitHub

  • Etcd

    • 单机部署一个ETCD集群
      • 1,快速部署。
      • 2,查看状态。
      • 3,简单使用。
    • ETCD在使用中遇到过的报错及处理
    • ETCD配额问题处理与验证 Error etcdserver mvcc database space exceeded
  • Consul

  • RabbitMQ

  • Kafka

  • Mysql

  • MongoDB

  • OpenVPN

  • Kvm

  • VMware

  • 配置文件详解

  • Other

  • 运维观止
  • Etcd
二丫讲梵
2020-03-15
目录

单机部署一个ETCD集群

文章发布较早,内容可能过时,阅读注意甄别。

# 1,快速部署。

下载就不多说了,可以直接去 github 进行下载。

单机通过不同端口,部署一个简易集群。

node-1.sh

$ cat /mnt/etcd/node-1.sh
etcd --name infra1 --initial-advertise-peer-urls http://192.168.0.122:2381 \
    --listen-peer-urls http://192.168.0.122:2381 \
    --listen-client-urls http://192.168.0.122:2379 \
    --advertise-client-urls http://192.168.0.122:2379 \
    --initial-cluster-token etcd-cluster-1 \
    --initial-cluster infra1=http://192.168.0.122:2381,infra2=http://192.168.0.122:2382,infra3=http://192.168.0.122:2383 \
    --initial-cluster-state new &> nohup1.out &
1
2
3
4
5
6
7
8

node-2.sh

$ cat /mnt/etcd/node-2.sh
etcd --name infra2 --initial-advertise-peer-urls http://192.168.0.122:2382 \
    --listen-peer-urls http://192.168.0.122:2382 \
    --listen-client-urls http://192.168.0.122:2378 \
    --advertise-client-urls http://192.168.0.122:2378 \
    --initial-cluster-token etcd-cluster-1 \
    --initial-cluster infra1=http://192.168.0.122:2381,infra2=http://192.168.0.122:2382,infra3=http://192.168.0.122:2383 \
    --initial-cluster-state new &> nohup2.out &
1
2
3
4
5
6
7
8

node-3.sh

$ cat /mnt/etcd/node-3.sh
etcd --name infra3 --initial-advertise-peer-urls http://192.168.0.122:2383 \
    --listen-peer-urls http://192.168.0.122:2383 \
    --listen-client-urls http://192.168.0.122:2377 \
    --advertise-client-urls http://192.168.0.122:2377 \
    --initial-cluster-token etcd-cluster-1 \
    --initial-cluster infra1=http://192.168.0.122:2381,infra2=http://192.168.0.122:2382,infra3=http://192.168.0.122:2383 \
    --initial-cluster-state new &> nohup3.out &
1
2
3
4
5
6
7
8

逐一运行如上脚本,即可启动一个集群。

img

# 2,查看状态。

使用如下命令可以简单检查集群状态:

$ etcdctl --write-out=table --endpoints=http://192.168.0.122:2379,http://192.168.0.122:2377,http://192.168.0.122:2378 endpoint status
+---------------------------+------------------+---------+---------+-----------+-----------+------------+
|         ENDPOINT          |        ID        | VERSION | DB SIZE | IS LEADER | RAFT TERM | RAFT INDEX |
+---------------------------+------------------+---------+---------+-----------+-----------+------------+
| http://192.168.0.122:2379 | 13a3eecc5a072589 |  3.3.18 |   20 kB |      true |         3 |         11 |
| http://192.168.0.122:2377 | 2b3234939251977f |  3.3.18 |   20 kB |     false |         3 |         11 |
| http://192.168.0.122:2378 | ca4d20bca4cb0ff0 |  3.3.18 |   20 kB |     false |         3 |         11 |
+---------------------------+------------------+---------+---------+-----------+-----------+------------+
1
2
3
4
5
6
7
8

各个信息很清晰可以看到。

# 3,简单使用。

通过如下命令,可以设置一条信息。

$ export ETCD_CLUSTER="http://192.168.0.122:2379,http://192.168.0.122:2377,http://192.168.0.122:2378"
$ etcdctl --endpoints=$ETCD_CLUSTER put eryajf "test"
No help topic for 'put'
1
2
3

看到失败了,报错 No help topic for 'put',解决方法是设置如下环境变量:

$ export ETCDCTL_API=3
1

然后再执行如上命令,发现就可以成功了。

获取如上信息:

$ etcdctl --endpoints=$ETCD_CLUSTER get eryajf
eryajf
test
1
2
3
微信 支付宝
#etcd
上次更新: 2024/07/04, 22:40:37
VMR一个开源的通用SDK版本管理器
ETCD在使用中遇到过的报错及处理

← VMR一个开源的通用SDK版本管理器 ETCD在使用中遇到过的报错及处理→

最近更新
01
学习周刊-总第213期-2025年第22周
05-29
02
学习周刊-总第212期-2025年第21周
05-22
03
从赵心童世锦赛夺冠聊聊我的斯诺克情缘
05-16
更多文章>
Theme by Vdoing | Copyright © 2017-2025 | 点击查看十年之约 | 浙ICP备18057030号
  • 跟随系统
  • 浅色模式
  • 深色模式
  • 阅读模式