ETCD

简介

ETCD是一个开源的、分布式的键值对数据存储系统,由Go语言实现,用于存储key-value键值对,同时不仅仅是存储,主要用途是提供共享配置及服务发现,使用Raft一致性算法来管理高度可用的复制日志。有下面特点

  • 简单:定义明确,面向用户的API(gRPC)
  • 安全:具有可选客户端证书身份验证的自动TLS
  • 快速:基准测试10,000次/秒
  • 可靠:使用Raft正确分布

NOTE:

  ETCD适用于较小的原数据键值对的处理,对于大的键值对数据的处理回导致其他请求时间的增加。数据目前最大支持1M数据的RPC请求,目前来说没有办法实现更大数据的配置

使用场景:服务发现、消息定义发布、负载均衡、分布式通知与协调、分布式锁、分布式队列、集群监控与Leader竞选

安装 

环境Linux,下载安装包https://github.com/etcd-io/etcd/releases/download/v3.4.0/etcd-v3.4.0-linux-amd64.tar.gz到本地,从git中筛选版本https://github.com/etcd-io/etcd/releases

[root@centos7 ~]# wget https://github.com/etcd-io/etcd/releases/download/v3.4.0/etcd-v3.4.0-linux-amd64.tar.gz

解压

[root@centos7 ~]# tar zxvf etcd-v3.4.0-linux-amd64.tar.gz 

进入目录,启动,默认监听本地2379端口

[root@centos7 ~]# cd etcd-v3.4.0-linux-amd64
[root@centos7 etcd-v3.4.0-linux-amd64]# ./etcd

验证

[root@centos7 etcd-v3.4.0-linux-amd64]# ./etcdctl put foo bar
OK
[root@centos7 etcd-v3.4.0-linux-amd64]# ./etcdctl get foo
foo
bar

查看接口版本

[root@centos7 etcd-v3.4.0-linux-amd64]# ./etcdctl version
etcdctl version: 3.4.0
API version: 3.4

查看集群成员信息

[root@centos7 ~]# etcdctl member list
8e9e05c52164694d, started, default, http://localhost:2380, http://localhost:2379, false

简单使用

写入

[root@centos7 ~]# etcdctl put foo bar
OK
[root@centos7 ~]# etcdctl put foo1 bar1
OK

读取

[root@centos7 ~]# etcdctl get foo
foo
bar
[root@centos7 ~]# etcdctl get foo --print-value-only
bar
[root@centos7 ~]# etcdctl get --prefix foo
foo
bar
foo1
bar1

删除

[root@centos7 ~]# etcdctl del foo
1
[root@centos7 ~]# etcdctl get foo

  

租期

授权租期

[root@centos7 ~]# etcdctl lease grant 20
lease 694d6d2a9dbd8d0d granted with TTL(20s)
[root@centos7 ~]# etcdctl put --lease=694d6d2a9dbd8d0d foo bar
OK
[root@centos7 ~]# etcdctl get foo
foo
bar
[root@centos7 ~]# etcdctl get foo

撤销租期

[root@centos7 ~]# etcdctl lease grant 60
lease 694d6d2a9dbd8d1c granted with TTL(60s)
[root@centos7 ~]# etcdctl put --lease=694d6d2a9dbd8d1c foo bar
OK
[root@centos7 ~]# etcdctl lease revoke 694d6d2a9dbd8d1c
lease 694d6d2a9dbd8d1c revoked
[root@centos7 ~]# etcdctl get foo

租期保持存活

[root@centos7 ~]# etcdctl lease grant 10
lease 694d6d2a9dbd8d24 granted with TTL(10s)
[root@centos7 ~]# etcdctl lease keep-alive 694d6d2a9dbd8d24
lease 694d6d2a9dbd8d24 keepalived with TTL(10)
lease 694d6d2a9dbd8d24 keepalived with TTL(10)
lease 694d6d2a9dbd8d24 keepalived with TTL(10)
lease 694d6d2a9dbd8d24 keepalived with TTL(10)

  

 观察者

[root@centos7 ~]# etcdctl watch foo
PUT
foo
bar1
DELETE
foo

  

  

ETCD服务的更多相关文章

  1. 物联网架构成长之路(22)-Docker练习之Etcd服务搭建

    0. 前言 时隔多日,前段时间忙完一个可有可无的项目后,又进入摸鱼时间,没有办法,非互联网公司,就是闲得蛋疼.又开始了自学之路.以前入门过Docker,然后又很久没有看了,最近重新看了一下,推荐一下这 ...

  2. docker (centOS 7) 使用笔记4 - etcd服务

    本次测试的系统包含centos 7.2 64 bit,centos 7.3 64 bit 1. 安装 yum -y install etcd 2. 配置 此处一共准备了3台机器(10.10.10.10 ...

  3. 实现etcd服务注册与发现

    转载自:实现etcd服务注册与发现 0.1.目录结构 . ├── api │   └── main.go ├── common │   └── common.go ├── docker-compose ...

  4. 实例解读丨关于GaussDB ETCD服务异常

    摘要:本文通过对ETCD服务异常问题分析,代码展示解决方案. 本文分享自华为云社区<[实例状态]GaussDB ETCD服务异常>,作者:酷哥. 首先确认是否是虚拟机.网络故障 虚拟机故障 ...

  5. Golang etcd服务注册与发现

    //sevice.go package discovery import ( "context" "errors" "sync" " ...

  6. etcd服务端和客户端安装

    下载地址: 服务端:http://download.csdn.net/download/wuxun1997/9841277 客户端:http://download.csdn.net/download/ ...

  7. Docker+Jenkins持续集成环境(4):使用etcd+confd实现容器服务注册与发现

    前面我们已经通过jenkins+docker搭建了基本的持续集成环境,实现了服务的自动构建和部署,但是,我们遇到一个问题,jenkins构建出来的镜像部署后,需要通过ip:port去访问,有什么更好的 ...

  8. shipyard 管理swarm集群(附etcd发现服务方法)

    docker swarm集群 第一步:安装swarm集群 192.168.132.131----->(manger1,node) 192.168.132.132----->(manger2 ...

  9. etcd启用https服务

    目录 cfssl相关工具下载 生成etcd所需要的ssl证书 生成ca证书 生成etcd服务端证书 生成etcd客户端证书 修改etcd集群配置文件 重启etcd集群 验证集群健康情况 关于etcd的 ...

随机推荐

  1. EF core 性能调优

    Entity Framework Core performance tuning – a worked example Last Updated: February 25, 2019 | Create ...

  2. 重置GPU显存 Reset GPU memory after CUDA errors

    Sometimes CUDA program crashed during execution, before memory was flushed. As a result, device memo ...

  3. Gradle系列教程之依赖管理

    这一章我将介绍Gradle对依赖管理的强大支持,学习依赖分组和定位不同类型仓库.依赖管理看起来很容易,但是当出现依赖解析冲突时就会很棘手,复杂的依赖关系可能导致构建中依赖一个库的多个版本.Gradle ...

  4. 【技术博客】Git Flow模型管理代码版本

    参考GIT版本管理:Git Flow模型,在此基础上加入了自己的理解,增加人员分工和相应代码,并根据本次项目的实际情况进行相应修改. 在本学期的软件工程开发过程中,我们从alpha阶段就使用了git ...

  5. CloudFlare上线了新的Proxy Anything选项, 支持转发TCP连接

    https://www.nicho1as.wang/articles/cf-proxy-anything.html 申请地址:https://goo.gl/forms/Oc2jyyo0kXsrMyw3 ...

  6. Android Studio 教程

    Android Studio 超详细安装教程 http://dkylin.com/archives/2019/android-studio-installation.html Android Stud ...

  7. flask 运行 flask db init 报错,init-db 命令找不到

    flask init-db 结果是 `Error: No such command “init-db”. 那是因为init-db 已经被 flask db init 给代替了 运行 flask db ...

  8. webshot一款网页快照工具

    webshot https://github.com/brenden/node-webshot Webshot provides a simple API for taking webpage scr ...

  9. ASP.NET LinqDataSource数据绑定后,遇到[MissingMethodException: 没有为该对象定义无参数的构造函数。]问题。

    问题出现的情形:LinqDataSource数据绑定到DetailsView或GridView均出错,错误如下: “/”应用程序中的服务器错误. 没有为该对象定义无参数的构造函数. 说明: 执行当前 ...

  10. EasyDSS高性能RTMP、HLS(m3u8)、HTTP-FLV、RTSP流媒体服务器版本打包方法介绍

    EasyDSS流媒体解决方案是一套集流媒体点播.转码.管理.直播.录像.检索.时移回看于一体的一套完整的商用流媒体解决方案.EasyDSS软件以压缩包的形式提供给客户使用,同时支持Linux和 Win ...