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. 洛谷2051 [AHOI2009]中国象棋

    题目链接 题意概述:n行m列棋盘放若干个棋子每行每列最多两个求方案总数,答案对9999973取模. 可以比较容易看出这是个dp,设f[i][j][k]表示前i行j列放1个棋子k列放2个棋子的方案总数. ...

  2. 前端零基础入门:页面结构层HTML(3)

    搭建网页HTML结构 标签 标签 块级标签 和 行内标签 标签嵌套规则 和 div css 标签是一个区块容器标记, 之间是一个容器,可以包含段落,表格,图片等各种HTML元素. 标签没有实际意义,为 ...

  3. windows cmd编辑文本

    echo创建一个空的txt文件:echo.>1.txt这里>表示输出到...echo.表示输出一个空行(即换行)>命令可以扩展为>>表示的意思为附加到...例子:1.tx ...

  4. Centos pip 安装uwsgi 报错“fatal error: Python.h: No such file or directory”

    解决方法: 安装python-devel即可,注意,不是python-dev yum -y install python-devel

  5. 在itop4412移植linux4.14和设备树遇到的问题及解决

    Linux4.14的设备树下已经对itop4412做了支持,本来应该很容易进行移植,可是在使用讯为给的资料中,对exynos4412-itop-scp-core.dtsi中原本的代码全部进行了注释,并 ...

  6. 【CSP膜你赛】柠檬的密码(manacher 二分 单调性 st表)

    题目描述 Lemon觉得他需要一个复杂的密码来保证他的帐号的安全.他经过多日思考,决定使用一个长度为奇数的回文串来作为他的密码.  但是这个回文串太长了,Lemon记不住,于是Lemon决定把它记在本 ...

  7. 关于redis为什么不支持回滚操作.

    redis 不支持会滚操作的说明.

  8. 【深入学习linux】git的使用

    git的安装 官网下载地址:https://git-scm.com/downloads 安装完成后,还需要最后一步设置,在命令行输入: $ git config --global user.name ...

  9. [linux]查看进程占用内存

    1.top -p 进程ID PID:进程的ID USER:进程所有者 PR:进程的优先级别,越小越优先被执行 NInice:值 VIRT:进程占用的虚拟内存 RES:进程占用的物理内存 SHR:进程使 ...

  10. MongoTemplate进行增删改查

    转载自:https://blog.csdn.net/sinat_35821285/article/details/83511203#commentBox 1.首先pom.xml <!-- spr ...