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. linux高性能服务器编程 (九) --I/O复用

    第九章 I/O复用 I/O复用就是一个线程可以同时监听多个文件描述符,提高程序性能.虽然I/O复用可以同时监听多个文件描述符,但是它本身是阻塞的,如果多个文件描述符准备就绪,如果不采取措施它仍然是串行 ...

  2. 终于明白为什么要加 final 关键字了!

    阅读本文大概需要 2.8 分钟. 来源: www.jianshu.com/p/acc8d9a67d0c 在开发过程中,由于习惯的原因,我们可能对某种编程语言的一些特性习以为常,特别是只用一种语言作为日 ...

  3. jenkins安装启动(docker)

    mkdir /opt/jenkins -pvim /opt/jenkins/Dockerfile FROM jenkins/jenkins:lts EXPOSE 8080 50000 vim /opt ...

  4. Parallel.For循环与普通的for循环

    前两天看书发现了一个新的循环Parallel.For,这个循环在循环期间可以创建多个线程并行循环,就是说循环的内容是无序的.这让我想到了我前面的牛牛模拟计算是可以用到这个循环的,我前面的牛牛模拟计算是 ...

  5. ubuntu16.04 overlay 不支持redirect_dir开关

    modinfo overlay--查看overlay版本 通过linux网站--https://elixir.bootlin.com/linux/v4.4.196/source/fs/overlayf ...

  6. Go1.13 标准库的 http 包爆出重大 bug,你的项目中招了吗? 原创: 王亚楼 Go语言中文网 今天

    Go1.13 标准库的 http 包爆出重大 bug,你的项目中招了吗? 原创: 王亚楼 Go语言中文网 今天

  7. Jenkins 使用 SonarQube 扫描 Coding

    Jenkins 使用 SonarQube 扫描 Coding   系统环境: Jenkins 版本:2.176 SonarQube 版本:7.4.0 一.SonarQube 介绍 1.SonarQub ...

  8. Java类成员初始化顺序

    类中包含7中成员:1.静态变量 static2.final静态常量 final static3.静态代码块 static{}  //多个代码块顺序执行 4.普通变量5.普通代码块 {}  //多个代码 ...

  9. Jenkins 发布项目到远程服务器上

    最近公司弄一个项目,jenkins在本地服务器,需要打包发布到远程的阿里云服务器上,弄了好一阵子. 这里记录下中间的几个坑. 这个Remote DIrectory 很重要,到时候时候会拷贝到这个目录下 ...

  10. cps在jenkins构建报错

    修改ares的版本号即可,改为2.0.1.14-20191126-RELEASE