etcd 基础15

2022-01-20 11:00:43 浏览数 (1)

自身统计

代码语言:javascript复制
[root@docker ~]# curl http://127.0.0.1:2379/v2/stats/self
{"name":"default","id":"ce2a822cea30bfca","state":"StateLeader","startTime":"2016-02-02T10:16:08.734974815 08:00","leaderInfo":{"leader":"ce2a822cea30bfca","uptime":"7h10m25.17655575s","startTime":"2016-02-02T10:16:10.036154166 08:00"},"recvAppendRequestCnt":0,"sendAppendRequestCnt":0}[root@docker ~]# 

Attribute

Comment

id

成员的唯一标识

leaderInfo.leader

当前主节点的id

leaderInfo.uptime

主节点的主持时间

name

这个成员的名字

recvAppendRequestCnt

这个节点接收到请求数

recvBandwidthRate

这个节点的接收Bps(bytes per second)带宽速率 (follower only)

recvPkgRate

这个节点的rps(requests per second)请求速率 (follower only)

sendAppendRequestCnt

这个节点的发送过的请求数

sendBandwidthRate

这个节点的发送Bps(bytes per second)带宽速率 (leader only). 在单节点集群中这个属性没有定义.

sendPkgRate

这个节点的rps(requests per second)发送请求速率 (leader only). 在单节点集群中这个属性没有定义.

state

当前的 leader 或 follower 角色

startTime

这个节点的启动时间


存储统计

存储统计提供了这个节点上的各种操作的统计信息

Note: v2版本将信息保存在了内存中,节点重启后,信息会丢失

代码语言:javascript复制
[root@docker ~]# curl http://127.0.0.1:2379/v2/stats/store
{"getsSuccess":73,"getsFail":13,"setsSuccess":65,"setsFail":8,"deleteSuccess":3,"deleteFail":2,"updateSuccess":9,"updateFail":4,"createSuccess":7,"createFail":1,"compareAndSwapSuccess":2,"compareAndSwapFail":2,"compareAndDeleteSuccess":2,"compareAndDeleteFail":2,"expireCount":17,"watchers":0}[root@docker ~]# 
[root@docker ~]# 

命令汇总

  • curl -L https://github.com/coreos/etcd/releases/download/v2.2.4/etcd-v2.2.4-linux-amd64.tar.gz -o etcd-v2.2.4-linux-amd64.tar.gz
  • wget https://github.com/coreos/etcd/releases/download/v2.2.4/etcd-v2.2.4-linux-amd64.tar.gz
  • tar -zxvf etcd-v2.2.4-linux-amd64.tar.gz
  • ./etcd
  • ./etcdctl set keytest "hello world for etcd test"
  • ./etcdctl get keytest
  • ./etcd
  • netstat -ant | grep -E '(2379|2380)'
  • curl -L http://127.0.0.1:2379/version
  • curl http://127.0.0.1:2379/v2/keys/message -XPUT -d value="Hello world"
  • curl http://127.0.0.1:2379/v2/keys/abc -XPUT -d value="Hello world"
  • curl http://127.0.0.1:2379/v2/keys/abc -XPUT -d value="abc"
  • curl http://127.0.0.1:2379/v2/keys/message
  • curl http://127.0.0.1:2379/v2/keys/message -XPUT -d value="hello etcd"
  • curl http://127.0.0.1:2379/v2/keys/message -XDELETE
  • date ; curl http://127.0.0.1:2379/v2/keys/foo -XPUT -d value=bar -d ttl=6
  • date ; curl http://127.0.0.1:2379/v2/keys/foo -XPUT -d value=bar -d ttl=10
  • date; curl http://127.0.0.1:2379/v2/keys/foo -XPUT -d value=bar -d ttl= -d prevExist=true
  • date ; curl http://127.0.0.1:2379/v2/keys/foo
  • curl http://127.0.0.1:2379/v2/keys/foo?wait=true
  • curl http://127.0.0.1:2379/v2/keys/foo -XPUT -d value=abc
  • curl http://127.0.0.1:2379/v2/keys/foo -vv
  • curl http://127.0.0.1:2379/v2/keys/queue -XPOST -d value=Job1
  • curl http://127.0.0.1:2379/v2/keys/queue -XPOST -d value=Job2
  • curl http://127.0.0.1:2379/v2/keys/queue -XPOST -d value=Job3
  • curl -s 'http://127.0.0.1:2379/v2/keys/queue?recursive=true&sorted=true'
  • date %s ;curl http://127.0.0.1:2379/v2/keys/testdir -XPUT -d ttl=10 -d dir=true
  • date %s ;curl http://127.0.0.1:2379/v2/keys/testdir -XPUT -d ttl=10 -d dir=true -d prevExist=true
  • date %s ;curl http://127.0.0.1:2379/v2/keys/testdir
  • curl http://127.0.0.1:2379/v2/keys/foo -XPUT -d value=one
  • curl http://127.0.0.1:2379/v2/keys/foo?prevExist=false -XPUT -d value=three
  • curl http://127.0.0.1:2379/v2/keys/foo?prevValue=two -XPUT -d value=three
  • curl http://127.0.0.1:2379/v2/keys/foo?prevValue=one -XPUT -d value=five
  • curl http://127.0.0.1:2379/v2/keys/foo?prevIndex=99 -XPUT -d value=xxx
  • curl http://127.0.0.1:2379/v2/keys/foo?prevIndex=90 -XPUT -d value=xxx
  • curl http://127.0.0.1:2379/v2/keys/foo -XPUT -d value=one
  • curl http://127.0.0.1:2379/v2/keys/foo?prevValue=two -XDELETE
  • curl http://127.0.0.1:2379/v2/keys/foo?prevIndex=3 -XDELETE
  • curl http://127.0.0.1:2379/v2/keys/foo?prevValue=one -XDELETE
  • curl http://127.0.0.1:2379/v2/keys/foo -XPUT -d value=one
  • curl http://127.0.0.1:2379/v2/keys/foo?prevIndex=96 -XDELETE
  • curl http://127.0.0.1:2379/v2/keys/foo
  • curl http://127.0.0.1:2379/v2/keys/testdir -XPUT -d dir=true
  • curl http://127.0.0.1:2379/v2/keys/foo_dir/abc -XPUT -d dir=true
  • curl http://127.0.0.1:2379/v2/keys/
  • curl http://127.0.0.1:2379/v2/keys/?recursive=true
  • curl http://127.0.0.1:2379/v2/keys/foo_dir/abc?dir=true -XDELETE
  • curl http://127.0.0.1:2379/v2/keys/foo_dir/abc -XPUT -d value=uiuiuii
  • curl http://127.0.0.1:2379/v2/keys/foo_dir?dir=true -XDELETE
  • curl http://127.0.0.1:2379/v2/keys/foo_dir?recursive=true -XDELETE
  • curl http://127.0.0.1:2379/v2/keys/foo_dir
  • curl http://127.0.0.1:2379/v2/keys/_message -XPUT -d value="Hello hidden"
  • curl http://127.0.0.1:2379/v2/keys/message -XPUT -d value="Hello world"
  • curl http://127.0.0.1:2379/v2/keys/
  • curl http://127.0.0.1:2379/v2/keys/_message
  • echo "HellonWorld" > testfile.txt
  • curl http://127.0.0.1:2379/v2/keys/testfile -XPUT --data-urlencode value@testfile.txt
  • curl http://127.0.0.1:2379/v2/stats/leader
  • curl http://127.0.0.1:2379/v2/stats/self
  • curl http://127.0.0.1:2379/v2/stats/store

原文地址

0 人点赞