ETCD服务
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服务的更多相关文章
- 物联网架构成长之路(22)-Docker练习之Etcd服务搭建
0. 前言 时隔多日,前段时间忙完一个可有可无的项目后,又进入摸鱼时间,没有办法,非互联网公司,就是闲得蛋疼.又开始了自学之路.以前入门过Docker,然后又很久没有看了,最近重新看了一下,推荐一下这 ...
- 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 ...
- 实现etcd服务注册与发现
转载自:实现etcd服务注册与发现 0.1.目录结构 . ├── api │ └── main.go ├── common │ └── common.go ├── docker-compose ...
- 实例解读丨关于GaussDB ETCD服务异常
摘要:本文通过对ETCD服务异常问题分析,代码展示解决方案. 本文分享自华为云社区<[实例状态]GaussDB ETCD服务异常>,作者:酷哥. 首先确认是否是虚拟机.网络故障 虚拟机故障 ...
- Golang etcd服务注册与发现
//sevice.go package discovery import ( "context" "errors" "sync" " ...
- etcd服务端和客户端安装
下载地址: 服务端:http://download.csdn.net/download/wuxun1997/9841277 客户端:http://download.csdn.net/download/ ...
- Docker+Jenkins持续集成环境(4):使用etcd+confd实现容器服务注册与发现
前面我们已经通过jenkins+docker搭建了基本的持续集成环境,实现了服务的自动构建和部署,但是,我们遇到一个问题,jenkins构建出来的镜像部署后,需要通过ip:port去访问,有什么更好的 ...
- shipyard 管理swarm集群(附etcd发现服务方法)
docker swarm集群 第一步:安装swarm集群 192.168.132.131----->(manger1,node) 192.168.132.132----->(manger2 ...
- etcd启用https服务
目录 cfssl相关工具下载 生成etcd所需要的ssl证书 生成ca证书 生成etcd服务端证书 生成etcd客户端证书 修改etcd集群配置文件 重启etcd集群 验证集群健康情况 关于etcd的 ...
随机推荐
- rsync同步备份
一.服务器端.备份客户端安装 rsync 服务. 1.环境: CentOS 主 IP:172.16.3.18 备 IP:172.16.3.19 2.安装 rsync 软件 #yum install r ...
- 05-树9 Huffman Codes (30 分)
In 1953, David A. Huffman published his paper "A Method for the Construction of Minimum-Redunda ...
- go语言Mac下编译安装语言包
这两天公司成立了go语言学习兴趣小组,慕名参与了学习.目前对于go是0基础,只知道它可以做高并发.效率快.编译简单.母语是C. go的安装有多种形式,编译安装是比较慢的一个,今天我就记录一下学习go编 ...
- MVC框架模式和Javaweb经典三层架构
一.MVC设计模式 1.MVC的概念 首先我们需要知道MVC模式并不是javaweb项目中独有的,MVC是一种软件工程中的一种软件架构模式,把软件系统分为三个基本部分:模型(Model).视图(Vie ...
- 域名解析前面的前缀* @ www 分别代表什么
www 是指域名前带 www的,以百度为例,就是 www.baidu.com@ 是指前面不带任何主机名的,以百度为例,就是 baidu.com* 是指泛解析,是指除已添加的解析记录以外的所有主机都以此 ...
- “sockaddr”: “struct”类型重定义的错误的解决办法《转》
原帖地址:https://blog.csdn.net/clever101/article/details/100163301 windows.h和winsock2.h存在有类型重定义,往往体现在VC程 ...
- EChart 标题 title 样式,x轴、y轴坐标显示,调整图表位置等
示例里工作一般情况是够用了,更复杂的可以查询教程: title 官方解说:http://echarts.baidu.com/option.html#title 坐标相关: X轴:http://echa ...
- url的长度问题
url最长支持多少字符? 在http协议中,其实并没有对url长度作出限制,往往url的最大长度和用户浏览器和Web服务器有关,不一样的浏览器,能接受的最大长度往往是不一样的,当然,不一样的Web服务 ...
- Linux下SQL Server安装及数据库迁移
有客户使用Linux服务器,SQL Server从2017开始已支持Linux,从未用过,今天测试了一下,比较简单,记录一下. Linux:CentOS 7.0 首先更新源: curl -o /etc ...
- 基于realsense的深度数据分析工具