配置
node1
name: etcd-1

data-dir: /data/etcd/node1

listen-client-urls: http://127.0.0.1:6701

advertise-client-urls: http://127.0.0.1:6701

listen-peer-urls: http://127.0.0.1:16701

initial-advertise-peer-urls: http://127.0.0.1:16701

initial-cluster: etcd-1=http://127.0.0.1:16701,etcd-2=http://127.0.0.1:16702,etcd-3=http://127.0.0.1:16703

initial-cluster-token: etcd-cluster-token

initial-cluster-state: new
cd /data/packages/etcd-v3.5.4-linux-amd64;./etcd --config-file=/data/etcd/node1/conf.yml
node2
name: etcd-2

data-dir: /data/etcd/node2

listen-client-urls: http://127.0.0.1:6702

advertise-client-urls: http://127.0.0.1:6702

listen-peer-urls: http://127.0.0.1:16702

initial-advertise-peer-urls: http://127.0.0.1:16702

initial-cluster: etcd-1=http://127.0.0.1:16701,etcd-2=http://127.0.0.1:16702,etcd-3=http://127.0.0.1:16703

initial-cluster-token: etcd-cluster-token

initial-cluster-state: new
cd /data/packages/etcd-v3.5.4-linux-amd64;./etcd --config-file=/data/etcd/node2/conf.yml
node3
name: etcd-3

data-dir: /data/etcd/node3

listen-client-urls: http://127.0.0.1:6703

advertise-client-urls: http://127.0.0.1:6703

listen-peer-urls: http://127.0.0.1:16703

initial-advertise-peer-urls: http://127.0.0.1:16703

initial-cluster: etcd-1=http://127.0.0.1:16701,etcd-2=http://127.0.0.1:16702,etcd-3=http://127.0.0.1:16703

initial-cluster-token: etcd-cluster-token

initial-cluster-state: new
cd /data/packages/etcd-v3.5.4-linux-amd64;./etcd --config-file=/data/etcd/node3/conf.yml
集群状态命令
# 查看节点状态
./etcdctl --endpoints='127.0.0.1:6701,127.0.0.1:6702,127.0.0.1:6703' --write-out=table endpoint status # 查看节点信息
./etcdctl --endpoints='127.0.0.1:6701,127.0.0.1:6702,127.0.0.1:6703' --write-out=table member list
数据操作命令
# 写数据
./etcdctl --endpoints='127.0.0.1:6701,127.0.0.1:6702,127.0.0.1:6703' put user 'user'
OK # 获取数据
./etcdctl --endpoints='127.0.0.1:6701,127.0.0.1:6702,127.0.0.1:6703' get user
user
user # json形式获取数据
./etcdctl --endpoints='127.0.0.1:6701,127.0.0.1:6702,127.0.0.1:6703' --write-out='json' get user
{"header":{"cluster_id":14495651392122646756,"member_id":9121633945989494648,"revision":3,"raft_term":7},"kvs":[{"key":"dXNlcg==","create_revision":2,"mod_revision":3,"version":2,"value":"amlhbmd4dQ=="}],"count":1} # 前缀方式获取数据
./etcdctl --endpoints='127.0.0.1:6701,127.0.0.1:6702,127.0.0.1:6703' --write-out='json' get user --prefix
{"header":{"cluster_id":14495651392122646756,"member_id":2265291478623953179,"revision":6,"raft_term":7},"kvs":[{"key":"dXNlcjE=","create_revision":5,"mod_revision":5,"version":1,"value":"amlhbmd4dQ=="},{"key":"dXNlcjI=","create_revision":6,"mod_revision":6,"version":1,"value":"aGFoYQ=="}],"count":2} # 删除数据
./etcdctl --endpoints='127.0.0.1:6701,127.0.0.1:6702,127.0.0.1:6703' del user
1
监视数据
# 监视数据可以看到相关key的事件
./etcdctl --endpoints='127.0.0.1:6701,127.0.0.1:6702,127.0.0.1:6703' watch user --prefix
租约
./etcdctl --endpoints='127.0.0.1:6701,127.0.0.1:6702,127.0.0.1:6703' lease list
found 0 leases
# lease创建后会分配ID
./etcdctl --endpoints='127.0.0.1:6701,127.0.0.1:6702,127.0.0.1:6703' lease grant 30
lease 211b80fe02999707 granted with TTL(30s)
./etcdctl --endpoints='127.0.0.1:6701,127.0.0.1:6702,127.0.0.1:6703' lease list
found 1 leases
211b80fe02999707
# 使用key并给key分配lease
# 如果lease在grant超时,lease和lease对应的key都会删除
./etcdctl --endpoints='127.0.0.1:6701,127.0.0.1:6702,127.0.0.1:6703' put user3 'test' --lease=211b80fe02999707

【其他】etcd的更多相关文章

  1. 一次基于etcd的分布式锁自动延时失败问题的排查

    今天在测试基于etcd的分布式锁过程中,在测试获取锁后,释放之前超出TTL时长的情况下自动延长TTL这部分功能,在延长指定key的TTL时总是返回404错误信息,在对目标KEY更新TTL时目标KEY已 ...

  2. etcd:用于服务发现的键值存储系统

    etcd是一个高可用的键值存储系统,主要用于共享配置和服务发现.etcd是由CoreOS开发并维护的,灵感来自于 ZooKeeper 和 Doozer,它使用Go语言编写,并通过Raft一致性算法处理 ...

  3. Centos7下Etcd集群搭建

    一.简介 "A highly-available key value store for shared configuration and service discovery." ...

  4. 通过docker-machine和etcd部署docker swarm集群

    本片文章介绍一下 使用docker-machine 搭建docker swarm 集群:docker swarm是docker 官方搭建的容器集群编排工具:容器编排,就是可以使你像使用一太机器一样来使 ...

  5. etcd第三集

    简单说下golang的etcd接口例子.etcd api有v2(http+json)和v3(grpc)两个版本,目前大家都用v2,所以... v2: https://github.com/coreos ...

  6. etcd第二集

    参考文章:https://github.com/coreos/etcd/blob/master/Documentation/v2/api.mdhttp://www.cnblogs.com/zhengr ...

  7. etcd第一集

    网站:https://github.com/coreos/etcd 一些观点:https://yq.aliyun.com/articles/11035 1.etcd是键值存储仓库,配置共享和服务发现2 ...

  8. etcd命令说明 etcd Version: 3.0.15

    etcd Version: 3.0.15Git SHA: fc00305Go Version: go1.6.3Go OS/Arch: linux/amd64 https://github.com/co ...

  9. etcd api 接口

    etcd api接口 基本操作api: https://github.com/coreos/etcd/blob/6acb3d67fbe131b3b2d5d010e00ec80182be4628/Doc ...

  10. Key/Value存储系统etcd的特性

    etcd 是一个高可用的Key/Value存储系统,和其他KV存储系统不同的是,它的灵感来自于 ZooKeeper 和 Doozer,主要用于分享配置和服务发现.利用 etcd 的特性,应用程序可以在 ...

随机推荐

  1. Android studio学习笔记1

    Android studio学习笔记1 20201303张奕博 2023.1.13 studio布局 1.线性布局 Android的线性布局不会换行,当组件一个挨着一个地排列到头之后,剩下的组件将不会 ...

  2. jQuery 获取鼠标点击的元素ID

    $(function(){ $(document).click(function(e) { // 在页面任意位置点击而触发此事件 var v_id = $(e.target).attr('id'); ...

  3. ES6 - 参数默认值

    1.形参初始值, 具有默认值的参数,一般位置要靠后(潜规则) function add(a,b,c=10){ return a + b + c; } let resutl = add(1,2); // ...

  4. ZSTUOJ刷题⑥:Problem 3535.--模拟简单计算器

    3535: 模拟简单计算器 Time Limit: 1 Sec  Memory Limit: 64 MBSubmit: 4634  Solved: 1652 Description 程序模拟简单运算器 ...

  5. Redis API存取

    RedisClient redisClient = new RedisClient("127.0.0.1", 6379); [HttpGet] public int RedisIn ...

  6. 【python】读取nc文件

    读取nc文件前的准备,安装一些库 1.先把几个用到的库下载 Cartopy 简介与安装(转载) - 简书 (jianshu.com) Python Extension Packages for Win ...

  7. Python 删除文件及文件夹

    2种方式: [不删除给定的目录] path1 = "D:\\dev\\workspace\\python\\pytestDemo\\222" def del_filedir(pat ...

  8. 项目实训 DAY 13

    GraphCore学习成本太高/现有资料太少,决定放弃 PlotNN用python语言生成pdf(需求:png),且不能通过仅运行python程序实现,python内生成的是tex格式,还需要加一行命 ...

  9. win10 + ubuntu 下右键新建md文件(转载)

    win10系统 由于前人的总结很不错,所以,在这里附上链接 原文链接 ubuntu系统(linux) 对于ubuntu系统下,这个操作更方便了. 原文链接 不仅是markdown文档,还有.doc.e ...

  10. qt的窗口

      1.窗口.字部件以及窗口类型(记得不牢固的) (1)#include<QtWidget> Widgets是在Qt中创建用户界面的主要元素. Widgets可以显示数据和状态信息,接收用 ...