配置
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. nginx的nginx.conf配置文件如何修改代理的路由

    方法 location /api/ { set $request_uri_new $request_uri; if ($request_uri ~ "^/api/(.*)$") { ...

  2. git从某个分支的指定历史版本中创建新分支

    git从某个分支的指定历史版本中创建新分支 前提: 有时候,我们在一个分支上做了许多修改,而这些修改因即将上线等原因不可修改.而现在有一个新任务,需要在这个分支的这些修改之前进行开发. 方案①(不推荐 ...

  3. Java流程控制之Scanner的进阶使用

    Scanner的进阶使用 import java.util.Scanner; public class Demo04 { public static void main(String[] args) ...

  4. k8s master高可用

    每台master都要部署haproxy,keepalived keepalived 配置文件:! Configuration File for keepalivedglobal_defs { rout ...

  5. 动态路由里,将component字符串改变为路由懒加载方法

    一.import写法 报错 function loadPageByRoutes(str) { // 传入的str为 '@/views/Home.vue' 这种格式 return () => im ...

  6. Text文件颜色渐变

    using UnityEngine;using System.Collections;using System.Collections.Generic;using UnityEngine.UI;usi ...

  7. spider_使用随机User-Agent库, 爬取笔趣阁万古天帝章节目录_(fake_useragent)

    """使用随机User-Agent库,爬取笔趣阁万古天帝章节目录"""import requestsfrom fake_useragent ...

  8. linux下使用bt-rm 限速删除文件

    下载限速删除工具: 链接:https://pan.baidu.com/s/1xXu4Hzr99wLlipqxVkXkBg 密码:upbe nohup ./bt-rm -l 10 ${文件地址} &am ...

  9. HTTP身份认证

    1.HTTP Basic认证 用户每次发送请求的时候,在请求头中携带能通过认证的身份信息:Authorization: <username>:<password> 1.1 交互 ...

  10. 使用SonarQube对Unity项目进行代码分析的问题记录

    1.这里不仔细描述每个步骤,只记录一些关键问题,到官网下载解压最新版的SonarQube(我用的是8.9.1). 2.下载安装jdk,这里要注意官网的说明,我一开始下的jdk16,启动Sonar后报错 ...