[root@h104 ~]# curl http://127.0.0.1:2379/v2/keys/message -XPUT -d value="set by h104"
{"action":"set","node":{"key":"/message","value":"set by h104","modifiedIndex":11,"createdIndex":11},"prevNode":{"key":"/message","value":"abc","modifiedIndex":10,"createdIndex":10}}
[root@h104 ~]# curl http://127.0.0.1:2379/v2/keys/message
{"action":"get","node":{"key":"/message","value":"set by h104","modifiedIndex":11,"createdIndex":11}}
[root@h104 ~]#
----------
[root@h102 tmp]# curl http://127.0.0.1:2379/v2/keys/message
{"action":"get","node":{"key":"/message","value":"set by h104","modifiedIndex":11,"createdIndex":11}}
[root@h102 tmp]#
----------
[root@docker etcd-v2.2.4-linux-amd64]# curl http://127.0.0.1:2379/v2/keys/message
{"action":"get","node":{"key":"/message","value":"set by h104","modifiedIndex":11,"createdIndex":11}}
[root@docker etcd-v2.2.4-linux-amd64]#
在h104上设定的数据自动同步到了h102和docker上,简单测试通过
实际使用场景中,必然会遇到添加删除节点的情况
etcdctl 可以帮忙完成相关工作
[root@h104 etcd-v2.2.4-linux-amd64]# curl http://localhost:2379/v2/members
{"members":[{"id":"1b80a88a471eb4b8","name":"h104","peerURLs":["http://192.168.100.104:2380"],"clientURLs":["http://192.168.100.104:2379"]},{"id":"84099faad6d56427","name":"h102","peerURLs":["http://192.168.100.102:2380"],"clientURLs":["http://192.168.100.102:2379"]},{"id":"940f6e83e019a03f","name":"docker","peerURLs":["http://192.168.100.103:2380"],"clientURLs":["http://192.168.100.103:2379"]}]}
[root@h104 etcd-v2.2.4-linux-amd64]# ./etcdctl member list
1b80a88a471eb4b8: name=h104 peerURLs=http://192.168.100.104:2380 clientURLs=http://192.168.100.104:2379
84099faad6d56427: name=h102 peerURLs=http://192.168.100.102:2380 clientURLs=http://192.168.100.102:2379
940f6e83e019a03f: name=docker peerURLs=http://192.168.100.103:2380 clientURLs=http://192.168.100.103:2379
[root@h104 etcd-v2.2.4-linux-amd64]#
本文系转载,前往查看
如有侵权,请联系 cloudcommunity@tencent.com 删除。
本文系转载,前往查看
如有侵权,请联系 cloudcommunity@tencent.com 删除。