网站:https://github.com/coreos/etcd

一些观点:https://yq.aliyun.com/articles/11035

1.etcd是键值存储仓库,配置共享和服务发现
2.2379用于客户端通信,2380用于节点通信。
3.etcd可以集群使用,也可以单机。不支持密码认证,但可选ssl认证,最好不要走公网。
4.数据持久化

5.开机启动

/usr/local/bin/etcd --name=test123 --data-dir=/home/wyt/bin/etcd-v3.0.15-linux-amd64/data

--listen-client-urls=http://0.0.0.0:2379 --listen-peer-urls=http://0.0.0.0:2380

--advertise-client-urls=http://0.0.0.0:2379 --initial-advertise-peer-urls=http://0.0.0.0:2380

说明:

--listen-client-urls                 list of URLs to listen on for client traffic(用户客户端数据通信端口)

--listen-peer-urls                  list of URLs to listen on for peer traffic(各个etcd节点的数据通信端口,交互,选举,数据同步等)

--advertise-client-urls           list of this member's client URLs to advertise to the public(集群参数:etcd服务器之间通讯的端口)

--initial-advertise-peer-urls    list of this member's peer URLs to advertise to the rest of the cluster(集群参数)

上面是我的理解,下面摘抄自其它地方(http://www.cnblogs.com/breg/p/5728237.html):
    —data-dir 指定节点的数据存储目录,这些数据包括节点ID,集群ID,集群初始化配置,Snapshot文件,若未指定—wal-dir,还会存储WAL文件;
    —wal-dir 指定节点的was文件的存储目录,若指定了该参数,wal文件会和其他数据文件分开存储。
    —name 节点名称
    —initial-advertise-peer-urls 告知集群其他节点url.
    — listen-peer-urls 监听URL,用于与其他节点通讯
    — advertise-client-urls 告知客户端url, 也就是服务的url
    — initial-cluster-token 集群的ID
    — initial-cluster 集群中所有节点

端口映射:

iptables -t nat -A PREROUTING  -p tcp --dport 65079 -j REDIRECT --to-port 2379

iptables -t nat -A PREROUTING  -p tcp --dport 65080 -j REDIRECT --to-port 2380

6.设置键值

etcdctl set mykey "abcdefg"

etcdctl get mykey

etcdctl rm  mykey

curl -L http://192.168.8.163:2379/version

curl -L http://192.168.8.163:65079/version

7.测试命令(来自:http://debugo.com/using-etcd/?utm_source=tuicool&utm_medium=referral)

#设置一个键的值
etcdctl set /foo/bar "hello world"
hello world
#设置一个带time to live的键
etcdctl set /foo/bar "hello world" --ttl 60
hello world
#当值为"hello world"时,替换为"Goodbye world"。
etcdctl set /foo/bar "Goodbye world" --swap-with-value "hello world"
etcdctl set /foo/bar "Goodbye world" --swap-with-value "hello world"
Goodbye world
etcdctl set /foo/bar "Goodbye world" --swap-with-value "hello world"
Error: 101: Compare failed ([hello world != Goodbye world]) [7]
#仅当不存在时创建
etcdctl mk /foo/new_bar "Hello world"
Hello world
etcdctl mk /foo/new_bar "Hello world"
Error: 105: Key already exists (/foo/new_bar) [8]
#仅当存在时更新建
etcdctl update /foo/bar "hello etcd"
hello etcd
#创建一个directory node
etcdctl mkdir /foo/dir
#创建一个directory node,或者将一个file node设置成directory node
etcdctl setDir /foo/dir
#删除file node
etcdctl rm /foo/bar
#删除directory node
etcdctl rmdir /foo/dir
etcdctl rm /foo/dir --dir
#递归删除
etcdctl rm /foo/dir --recursive
#当值为"Hello world"时删除
etcdctl rm /foo/bar --with-value "Hello world"
#获得某个键的值
etcdctl get /foo/bar
hello, etcd
#获得某个键在集群内的一致性值
etcdctl get /foo/bar --consistent
hello, etcd
#获得一些扩展的元信息
etcdctl -o extended get /foo/bar
Key: /foo/bar
Created-Index: 14
Modified-Index: 14
TTL: 0
Etcd-Index: 14
Raft-Index: 5013
Raft-Term: 0 hello, etcd
#其中,索引是一个对于etcd上任何改变中唯一、单调递增的整数。这个特殊的索引反映了etcd在某个key被创建后的时间点的etcd状态机。比如此时新建一个/foo/bar1,那么该节点的created-index和modified-index为15,代表了当前etcd的最新改变。
#列出目录的内容,-p则对directory node以/结尾
etcdctl ls
/foo
etcdctl ls /foo
/foo/bar
/foo/new_bar
/foo/dir
etcdctl ls / --recursive
/foo
/foo/bar
/foo/new_bar
/foo/dir #设置监视(watch),此时该命令会一直等待并输出下一次变化。
etcdctl watch /foo/bar
hello, etcd!
#while another terminal
etcdctl update /foo/bar "hello, etcd!"
hello, etcd!
#持续监视更新
etcdctl watch /foo/bar --forever
......
#使用Ctrl+c结束
#当反生变化时执行一个应用
etcdctl exec-watch /foo/bar -- sh -c "echo hi"
hi
hi
......
#监视目录下所有节点的改变
etcdctl exec-watch --recursive /foo -- sh -c "echo hi"

8.web界面

下载工程:https://github.com/henszey/etcd-browser

修改server.js

var etcdHost = process.env.ETCD_HOST || '127.0.0.1';
var etcdPort = process.env.ETCD_PORT || 2379;
var serverPort = process.env.SERVER_PORT || 8000;

前面2个是etcd地址和数据端口,8000是提供的web端口,在浏览器上输入:http://192.168.8.xx:8000/

etcd-v2第一集的更多相关文章

  1. NanUI for Winform 使用示例【第一集】——山寨个代码编辑器

    NanUI for Winform从昨天写博客发布到现在获得了和多朋友的关注,首先感谢大家的关注和支持!请看昨天本人的博文<NanUI for Winform发布,让Winform界面设计拥有无 ...

  2. Windows Phone开发(43):推送通知第一集——Toast推送

    原文:Windows Phone开发(43):推送通知第一集--Toast推送 好像有好几天没更新了,抱歉抱歉,最近"光荣"地失业,先是忙于寻找新去处,唉,暂时没有下文.而后又有一 ...

  3. FJUT第四周寒假作业之第一集,临时特工?(深度优先搜索)

    原网址:http://210.34.193.66:8080/vj/Contest.jsp?cid=163#P2 第一集,临时特工? TimeLimit:1000MS  MemoryLimit:128M ...

  4. Unity 图文重现官方教程视频 2droguelike 第一集

    初衷: 本人初学Unity,四处收集了一些视频和教材,学习和摸索了一段时间, 我发现官网教程简单易上手,只不过他是英文讲解不方便,我就想把他翻译翻译吧, 然后我又发现看视频学习要暂停回放好多遍,麻烦, ...

  5. 创芯Xilinx Microblaze 学习系列第一集

    创芯Xilinx Microblaze 学习系列第一集 Xilinx ISE Design Suite 13.2 The MicroBlaze™ embedded processor soft cor ...

  6. SpringBoot第一集:入门(2020最新最易懂)

    2020最新SpringBoot第一集:入门(2020最新最易懂) 学习思路: 是什么?为什么要学,有什么用?有什么特点?简单明了的总结一句话! SpringBoot推荐开发工具: Spring To ...

  7. etcd简介及集群安装部署使用

    目录 1. 简介 2. Linux下载安装 3. 单机模式启动 4. 指定各集群成员的方式配置集群 5. 使用discovery service的方式配置集群 6. 集群模式下客户端命令行 7. et ...

  8. etcd第一集

    网站:https://github.com/coreos/etcd 一些观点:https://yq.aliyun.com/articles/11035 1.etcd是键值存储仓库,配置共享和服务发现2 ...

  9. 高可用Kubernetes集群-3. etcd高可用集群

    五.部署高可用etcd集群 etcd是key-value存储(同zookeeper),在整个kubernetes集群中处于中心数据库地位,以集群的方式部署,可有效避免单点故障. 这里采用静态配置的方式 ...

  10. k8s, etcd 多节点集群部署问题排查记录

    目录 文章目录 目录 部署环境 1. etcd 集群启动失败 解决 2. etcd 健康状态检查失败 解决 3. kube-apiserver 启动失败 解决 4. kubelet 启动失败 解决 5 ...

随机推荐

  1. 利用STM32CubeMX来生成USB_HID_Mouse工程【添加ADC】(2)【非dma和中断方式】

    上回讲到怎么采集一路的adc的数据,这次我们来采集两路的数据. 现在直接修改原先的代码 /* Private variables ----------------------------------- ...

  2. repository test has failed 错误

    这里给自己一个警告,当我在idea中准备clone gitlab上的项目时,这个链接竟然一直在报:repository test has failed 错误 这个是gitlab上复制下来的原链接:ht ...

  3. 黄聪:通过 itms:services://? 在线安装ipa ,跨过appstore

    1.需要一个html文件,引导下载用户在线安装ipa <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN&quo ...

  4. pj2--图书管理系统

    这一次做得是图书管理系统. 下面是功能框图 下面是流程图 实际在做这个项目的时候根据相应的实际情况对功能流程等等做了一些小小的改变. 下面是一些值得记一笔的地方. 1.借用系统自带的导航控件(Bind ...

  5. ThinkPHP5.*版本发布安全更新

    2018 年 12 月 9 日 发布 本次版本更新主要涉及一个安全更新,由于框架对控制器名没有进行足够的检测会导致在没有开启强制路由的情况下可能的getshell漏洞,受影响的版本包括5.0和5.1版 ...

  6. 转wave 文件解析

    转 1 WAVE 文件格式分析 WAVE 文件作为多媒体中使用的声音波形文件格式之一,它是以RIFF(Resource Interchange File Format)格式为标准的.每个WAVE文件的 ...

  7. redis学习链接收藏

    1.redis命令大全--官网 2.redis命令大全--中文翻译版 3.源码(注释版):redis3.0 4.程序代码:<redis入门指南(第二版)>第五章 5.最新的redis-st ...

  8. bzoj2141排队

    /* 动态求逆序对,可以树套树来写, 将交换操作理解成插入和删除比较好理解, 里层是个区间求和的线段树就好了 或者叫 带修主席树? */ #include<cstdio> #include ...

  9. Android Studio 加载网络图片

    Android Studio是基于gradle的一个Android开发软件,在引用网络图片的时候需要连接第三方库,这里介绍 引用glide的方法. 一.在github页面搜索glide,点击第一个 二 ...

  10. 解决Tomcat启动时项目重复加载问题

    前几天一个同学项目要上线,部署到服务器时,因为客户需要通过IP直接可以访问到,所以在server.xml做了如下的配置 导致启动tomcat时候出现一个项目重复加载了两次,很容易就出现了内存溢出. 这 ...