Consul 入门(二)

KV 存储

通过命令行操作

$ consul kv put hello world  # 设置数据
Success! Data written to: hello
$ consul kv get hello  # 获取数据
world
$ consul kv get -detailed  hello # 获取详细数据
CreateIndex      1466
Flags            0
Key              hello
LockIndex        0
ModifyIndex      1466
Session          -
Value            world
$ consul kv get -recurse # 获取所有的数据
foo:bar
hello:world
$ consul kv delete hello # 删除数据
Success! Deleted key: hello

同时也可通过 HTTP 操作

// http://192.168.56.101:8500/v1/kv/foo

[
  {
    "LockIndex": 0,
    "Key": "foo",
    "Flags": 0,
    "Value": "YmFy",
    "CreateIndex": 1254,
    "ModifyIndex": 1326
  }
]
// http://192.168.56.101:8500/v1/kv/?keys

[
  "foo",
  "hello"
]

Consul Web UI

在启动命令加上 -ui ,默认地址为 http://localhost:8500/ui, 官方 demo 例子 here

posted @ 2018-07-01 17:23  lzyer  阅读(227)  评论(0编辑  收藏  举报