我们可以通过添加 _ 的前缀来创建隐藏的键值对
[root@docker ~]# curl http://127.0.0.1:2379/v2/keys/_message -XPUT -d value="Hello hidden"
{"action":"set","node":{"key":"/_message","value":"Hello hidden","modifiedIndex":103,"createdIndex":103}}
[root@docker ~]# curl http://127.0.0.1:2379/v2/keys/message -XPUT -d value="Hello world"
{"action":"set","node":{"key":"/message","value":"Hello world","modifiedIndex":104,"createdIndex":104}}
[root@docker ~]# curl http://127.0.0.1:2379/v2/keys/
{"action":"get","node":{"dir":true,"nodes":[{"key":"/queue","dir":true,"modifiedIndex":55,"createdIndex":55},{"key":"/dir","dir":true,"modifiedIndex":77,"createdIndex":77},{"key":"/message","value":"Hello world","modifiedIndex":104,"createdIndex":104},{"key":"/keytest","value":"hello world for etcd test","modifiedIndex":4,"createdIndex":4},{"key":"/testdir","dir":true,"modifiedIndex":98,"createdIndex":98},{"key":"/abc","value":"jkjkj","modifiedIndex":16,"createdIndex":16}]}}
[root@docker ~]# curl http://127.0.0.1:2379/v2/keys/_message
{"action":"get","node":{"key":"/_message","value":"Hello hidden","modifiedIndex":103,"createdIndex":103}}
[root@docker ~]# 可以使用etcd来存储小型的配置文件
JAON 文件,XML文件可以进行直接存储
[root@docker ~]# echo "Hello\nWorld" > testfile.txt
[root@docker ~]# curl http://127.0.0.1:2379/v2/keys/testfile -XPUT --data-urlencode value@testfile.txt
{"action":"set","node":{"key":"/testfile","value":"Hello\\nWorld\n","modifiedIndex":105,"createdIndex":105}}
[root@docker ~]# 本文系转载,前往查看
如有侵权,请联系 cloudcommunity@tencent.com 删除。
本文系转载,前往查看
如有侵权,请联系 cloudcommunity@tencent.com 删除。