etcd 一些經常使用操做指令 記錄

etcd 指令

啓動

etcd --advertise-client-urls 'http://192.168.15.232:2379' --listen-client-urls 'http://0.0.0.0:2379'
  • --advertise-client-urls :
  • --listen-client-urls:暴露給用戶訪問的端口,能夠填寫多個使用分割

http restful

  • 增 >curl -L http://127.0.0.1:4001/v2/keys/message -XPUT -d value="Hello world"

    {
      "action": "set",
      "node": {
          "createdIndex": 2,
          "key": "/message",
          "modifiedIndex": 2,
          "value": "Hello world"
      }
    }
  • 刪 >curl -L http://127.0.0.1:4001/v2/keys/message -XDELETE

    {
          "action": "delete",
          "node": {
              "createdIndex": 3,
              "key": "/message",
              "modifiedIndex": 4
          },
          "prevNode": {
              "key": "/message",
              "value": "Hello etcd",
              "modifiedIndex": 3,
              "createdIndex": 3
          }
      }
  • 改 >curl -L http://127.0.0.1:4001/v2/keys/message -XPUT -d value="Hello etcd"

    {
          "action": "set",
          "node": {
              "createdIndex": 3,
              "key": "/message",
              "modifiedIndex": 3,
              "value": "Hello etcd"
          },
          "prevNode": {
              "createdIndex": 2,
              "key": "/message",
              "value": "Hello world",
              "modifiedIndex": 2
          }
      }
  • 查 >curl -L http://127.0.0.1:4001/v2/keys/message

    {
      "action": "get",
      "node": {
      "createdIndex": 2,
      "key": "/message",
      "modifiedIndex": 2,
      "value": "Hello world"
       }
    }
  • expire > curl -L http://127.0.0.1:4001/v2/keys/foo -XPUT -d value=bar -d ttl=5

    {
          "action": "set",
          "node": {
              "createdIndex": 5,
              "expiration": "2013-12-04T12:01:21.874888581-08:00",
              "key": "/foo",
              "modifiedIndex": 5,
              "ttl": 5,
              "value": "bar"
          }
      }
    • 這個 ttl 是過時時間,及 多久沒有訪問 就自動刪除, 單位是s

官網etcd-http 命令php

etcdctl

不想寫了 直接上引用吧 etcdctl 指令html

相關文章
相關標籤/搜索