日韩av黄I国产麻豆传媒I国产91av视频在线观看I日韩一区二区三区在线看I美女国产在线I麻豆视频国产在线观看I成人黄色短片

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 >

ETCD命令集合

發布時間:2025/7/25 31 豆豆
生活随笔 收集整理的這篇文章主要介紹了 ETCD命令集合 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
本文由劉藝凌整理完成: from : http://www.itshouce.com.cn/other/etcd-command.html
ETCD 命令

存儲:
??? curl http://127.0.0.1:4001/v2/keys/testkey -XPUT -d value='testvalue'
??? curl -s http://127.0.0.1:4001/v2/keys/message2 -XPUT -d value='hello etcd' -d ttl=5

獲取:
??? curl http://127.0.0.1:4001/v2/keys/testkey

查看版本:
??? curl? http://127.0.0.1:4001/version

刪除:
??? curl -s http://127.0.0.1:4001/v2/keys/testkey -XDELETE

監視:
??? 窗口1:curl -s http://127.0.0.1:4001/v2/keys/message2 -XPUT -d value='hello etcd 1'
????????? curl -s http://127.0.0.1:4001/v2/keys/message2?wait=true
??? 窗口2:
????????? curl -s http://127.0.0.1:4001/v2/keys/message2 -XPUT -d value='hello etcd 2'

自動創建key:
??? curl -s http://127.0.0.1:4001/v2/keys/message3 -XPOST -d value='hello etcd 1'
??? curl -s 'http://127.0.0.1:4001/v2/keys/message3?recursive=true&sorted=true'

創建目錄:
??? curl -s http://127.0.0.1:4001/v2/keys/message8 -XPUT -d dir=true

刪除目錄:
??? curl -s 'http://127.0.0.1:4001/v2/keys/message7?dir=true' -XDELETE
??? curl -s 'http://127.0.0.1:4001/v2/keys/message7?recursive=true' -XDELETE

查看所有key:
??? curl -s http://127.0.0.1:4001/v2/keys/?recursive=true

存儲數據:
??? curl -s http://127.0.0.1:4001/v2/keys/file -XPUT --data-urlencode value@upfile


使用etcdctl客戶端:
存儲:
??? etcdctl set /liuyiling/testkey "610" --ttl '100'
???????????????????????????????????????? --swap-with-value value

獲取:
??? etcdctl get /liuyiling/testkey

更新:
??? etcdctl update /liuyiling/testkey "world" --ttl '100'
?????? ?
刪除:
??? etcdctl rm /liuyiling/testkey

目錄管理:
??? etcdctl mk /liuyiling/testkey "hello"??? 類似set,但是如果key已經存在,報錯

??? etcdctl mkdir /liuyiling

??? etcdctl setdir /liuyiling ?

??? etcdctl updatedir /liuyiling???? ?

??? etcdctl rmdir /liuyiling?? ?

查看:
??? etcdctl ls --recursive

監視:
??? etcdctl watch mykey? --forever???????? +??? etcdctl update mykey "hehe"
??? ?
??? #監視目錄下所有節點的改變

??? etcdctl exec-watch --recursive /foo -- sh -c "echo hi"

??? etcdctl exec-watch mykey -- sh -c 'ls -al'??? +??? etcdctl update mykey "hehe"

??? etcdctl member list


集群啟動步驟

1.啟動一個etcd,任意機器,如192.168.1.1:2379

2.curl -X PUT http://192.168.1.1:2379/v2/keys/discovery/6c007a14875d53d9bf0ef5a6fc0257c817f0f222/_config/size -d value=3

3.etcd -name machine1 -initial-advertise-peer-urls http://127.0.0.1:2380 -listen-peer-urls http://127.0.0.1:2380 -discovery http://192.168.1.1:2379/v2/keys/discovery/6c007a14875d53d9bf0ef5a6fc0257c817f0f222

4.如果是在三臺不同的服務器上,則重復上面的命令3次,否則重復上面的命令1次+下面的命令2次
etcd -name machine2 -discovery http://192.168.1.1:2379/v2/keys/discovery/6c007a14875d53d9bf0ef5a6fc0257c817f0f222 -addr 127.0.0.1:2389 -bind-addr 127.0.0.1:2389 -peer-addr 127.0.0.1:2390 -peer-bind-addr 127.0.0.1:2390

etcd -name machine3 -discovery http://192.168.1.1:2379/v2/keys/discovery/6c007a14875d53d9bf0ef5a6fc0257c817f0f222 -addr 127.0.0.1:2409 -bind-addr 127.0.0.1:2409 -peer-addr 127.0.0.1:2490 -peer-bind-addr 127.0.0.1:2490

5.curl -L http://localhost:2379/v2/members | python -m json.tool
???????????????

總結

以上是生活随笔為你收集整理的ETCD命令集合的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。