etcd租约机制
新建租约
新建一个过期时间为120s的租约
# etcdctl lease grant
lease 018f6d7bb11aba0d granted with TTL(120s)
查看新建的租约信息
# etcdctl lease list
found leases
018f6d7bb11aba0d
# etcdctl lease timetolive 018f6d7bb11aba0d --keys
lease 018f6d7bb11aba0d granted with TTL(120s), remaining(99s), attached keys([])
新建key,并为该key指定租约
# etcdctl put name alice --lease="018f6d7bb11aba0d"
OK
# etcdctl put name1 tina --lease="018f6d7bb11aba0d"
OK # etcdctl lease timetolive 018f6d7bb11aba0d --keys
lease 018f6d7bb11aba0d granted with TTL(120s), remaining(60s), attached keys([name name1])
# etcdctl get --prefix ""
name
alice
name1
tina
等到租约过期后,再次查看租约已经过期,对应的key也已经被自动删除
# etcdctl lease timetolive 018f6d7bb11aba0d --keys
lease 018f6d7bb11aba0d already expired
续约
新建租约并赋予key值
# etcdctl lease grant
lease 018f6d7bd032c117 granted with TTL(30s)
# etcdctl put name alice --lease=018f6d7bd032c117
OK
在租约即将过期时进行续约,命令不会自动结束,会一直显示该窗口
# etcdctl lease keep-alive 018f6d7bd032c117
lease 018f6d7bd032c117 keepalived with TTL()
lease 018f6d7bd032c117 keepalived with TTL()
lease 018f6d7bd032c117 keepalived with TTL()
......
重新打开一个窗口,查看该租约续约信息,可以看到该租约会自动续约,相应key值也不会被删除
# etcdctl lease timetolive 018f6d7bd032c117 --keys
lease 018f6d7bd032c117 granted with TTL(30s), remaining(23s), attached keys([name])
# etcdctl lease timetolive 018f6d7bd032c117 --keys
lease 018f6d7bd032c117 granted with TTL(30s), remaining(22s), attached keys([name])
# etcdctl lease timetolive 018f6d7bd032c117 --keys
lease 018f6d7bd032c117 granted with TTL(30s), remaining(21s), attached keys([name])
# etcdctl lease timetolive 018f6d7bd032c117 --keys
lease 018f6d7bd032c117 granted with TTL(30s), remaining(20s), attached keys([name])
# etcdctl lease timetolive 018f6d7bd032c117 --keys
lease 018f6d7bd032c117 granted with TTL(30s), remaining(29s), attached keys([name])
# etcdctl lease timetolive 018f6d7bd032c117 --keys
lease 018f6d7bd032c117 granted with TTL(30s), remaining(28s), attached keys([name])
# etcdctl lease timetolive 018f6d7bd032c117 --keys
lease 018f6d7bd032c117 granted with TTL(30s), remaining(27s), attached keys([name])
# etcdctl lease timetolive 018f6d7bd032c117 --keys
lease 018f6d7bd032c117 granted with TTL(30s), remaining(27s), attached keys([name])
# etcdctl lease timetolive 018f6d7bd032c117 --keys
lease 018f6d7bd032c117 granted with TTL(30s), remaining(26s), attached keys([name])
# etcdctl lease timetolive 018f6d7bd032c117 --keys
lease 018f6d7bd032c117 granted with TTL(30s), remaining(25s), attached keys([name])
# etcdctl lease timetolive 018f6d7bd032c117 --keys
lease 018f6d7bd032c117 granted with TTL(30s), remaining(25s), attached keys([name])
# etcdctl lease timetolive 018f6d7bd032c117 --keys
lease 018f6d7bd032c117 granted with TTL(30s), remaining(24s), attached keys([name])
# etcdctl lease timetolive 018f6d7bd032c117 --keys
lease 018f6d7bd032c117 granted with TTL(30s), remaining(23s), attached keys([name])
# etcdctl lease timetolive 018f6d7bd032c117 --keys
lease 018f6d7bd032c117 granted with TTL(30s), remaining(22s), attached keys([name])
# etcdctl lease timetolive 018f6d7bd032c117 --keys
lease 018f6d7bd032c117 granted with TTL(30s), remaining(22s), attached keys([name])
# etcdctl lease timetolive 018f6d7bd032c117 --keys
lease 018f6d7bd032c117 granted with TTL(30s), remaining(20s), attached keys([name])
# etcdctl lease timetolive 018f6d7bd032c117 --keys
lease 018f6d7bd032c117 granted with TTL(30s), remaining(29s), attached keys([name])
回收租约
回收租约会自动删除与该租约关联的key
# etcdctl lease revoke 018f6d7bd032c117
lease 018f6d7bd032c117 revoked
# etcdctl lease timetolive 018f6d7bd032c117 --keys
lease 018f6d7bd032c117 already expired
# etcdctl get name
etcd租约机制的更多相关文章
- ETCD核心机制解析
ETCD整体机制 etcd 是一个分布式的.可靠的 key-value 存储系统,它适用于存储分布式系统中的关键数据. etcd 集群中多个节点之间通过Raft算法完成分布式一致性协同,算法会选举出一 ...
- HDFS租约机制
https://www.cnblogs.com/cssdongl/p/6699919.html
- 从零开始入门 K8s | 手把手带你理解 etcd
作者 | 曾凡松(逐灵) 阿里云容器平台高级技术专家 本文整理自<CNCF x Alibaba 云原生技术公开课>第 16 讲. 导读:etcd 是用于共享配置和服务发现的分布式.一致性的 ...
- [转帖]从零开始入门 K8s | 手把手带你理解 etcd
从零开始入门 K8s | 手把手带你理解 etcd https://zhuanlan.zhihu.com/p/96721097 导读:etcd 是用于共享配置和服务发现的分布式.一致性的 KV 存储系 ...
- 第16 章 : 深入理解 etcd:基于原理解析
深入理解 etcd:基于原理解析 本文将主要分享以下三方面的内容: 第一部分,会为大家介绍 etcd 项目发展的整个历程,从诞生至今 etcd 经历的那些重要的时刻: 第二部分,会为大家介绍 etcd ...
- etcd的使用
etcd的使用 什么是etcd etcd的特点 etcd的应用场景 服务注册与发现 消息发布和订阅 负载均衡 分布式通知与协调 分布式锁 分布式队列 集群监控与Leader竞选 参考 etcd的使用 ...
- 长篇图解etcd核心应用场景及编码实战
大家好啊,我是字母哥,今天写一篇关于etcd的文章,其实网上也有很多关于etcd的介绍,我就简明扼要,总结提炼,期望大家通过这一篇文章掌握etcd的核心知识以及编码技能! 本文首先用大白话给大家介绍一 ...
- PacificA中的租约与失效检测解读
PacificA是微软的在基于log的分布式存储系统中的复制技术. 由于配置管理器维护着当前配置的真实情况,因此主节点不必保持不变. 这是因为配置的本地视图在不同服务器上是不必同步的. 特别是,我们必 ...
- Golang etcd服务注册与发现
//sevice.go package discovery import ( "context" "errors" "sync" " ...
随机推荐
- electron限制只启动一个应用
electron限制只启动一个应用 // ========================================================== // 限制只可以打开一个应用,2.x的文 ...
- java文件断点续传上传下载解决方案
这里只写后端的代码,基本的思想就是,前端将文件分片,然后每次访问上传接口的时候,向后端传入参数:当前为第几块文件,和分片总数 下面直接贴代码吧,一些难懂的我大部分都加上注释了: 上传文件实体类: 看得 ...
- css grid 随笔
原文出自Arien的博客https://www.w3cplus.com/css3/line-base-placement-layout.html 首先定义一个网格 1.可以给父容器的display属性 ...
- python实现一个层次聚类方法
层次聚类(Hierarchical Clustering) 一.概念 层次聚类不需要指定聚类的数目,首先它是将数据中的每个实例看作一个类,然后将最相似的两个类合并,该过程迭代计算只到剩下一个类为止,类 ...
- [VIJOS2053][SDOI2019]世界地图:最小生成树+虚树
分析 可以发现第一列和最后一列永远不会被删除,于是我们可以想到维护前后缀最小生成树,但是直接维护的话显然时间空间两爆炸.(通过上网找题解)可以发现我们关心的只是最左边和最右边两列,而不关心内部的连边情 ...
- LeetCode 第 3 题:无重复字符的最长子串(滑动窗口)
LeetCode 第 3 题:无重复字符的最长子串 (滑动窗口) 方法:滑动窗口 滑动窗口模板问题:右指针先走,满足了一定条件以后,左指针向前走,直到不满足条件. 特点:左右指针的方向是一致的,并且是 ...
- AOI 设计
http://blog.csdn.net/zhanghefu/article/details/25833535 云风的Blog 并进行整理而写. AOI(Area Of Interest),中文就是感 ...
- C++入门经典-例6.1-一维数组元素
1:代码如下: // 6.1.cpp : 定义控制台应用程序的入口点. // #include "stdafx.h" #include <iostream> using ...
- C++入门经典-例5.17-右值引用的定义
1:右值引用的定义: 类型 && i=被引用的对象: 左值与右值的区别在于,右值是临时变量,例如,函数的返回值,并且无法被改变. 当右值引用被初始化后,临时变量消失. 代码如下: // ...
- grep家族、sed、awk
一.grep家族 grep是一种强大的文本搜索工具,它能使用正则表达式搜索文本,并把匹配的行打印出来. 在上一次的博客中已经使用过egrep通过正则表达式来匹配正确IP地址,这里的用法就不多说了. f ...