日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

ETCD命令集合

發布時間:2025/7/25 编程问答 22 豆豆
生活随笔 收集整理的這篇文章主要介紹了 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命令集合的全部內容,希望文章能夠幫你解決所遇到的問題。

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