Skip to content

Instantly share code, notes, and snippets.

@bcwaldon
Last active August 29, 2015 14:08
Show Gist options
  • Save bcwaldon/73ddc7537e9d71fa587f to your computer and use it in GitHub Desktop.
Save bcwaldon/73ddc7537e9d71fa587f to your computer and use it in GitHub Desktop.
$ ; start up the discovery service
$ etcd -name discovery -addr 127.0.0.1:4000 -peer-addr 127.0.0.1:7000
...
$ ; choose the discovery token
$ export UUID=$(uuidgen)
$ echo $UUID
40134540-b53c-46b3-b34f-33b4f0ae3a9c
$ ; start three nodes
$ etcd -name node1 -addr 127.0.0.1:4001 -peer-addr 127.0.0.1:7001 -discovery http://127.0.0.1:4000/v2/keys/$UUID
...
$ etcd -name node2 -addr 127.0.0.1:4002 -peer-addr 127.0.0.1:7002 -discovery http://127.0.0.1:4000/v2/keys/$UUID
...
$ etcd -name node3 -addr 127.0.0.1:4003 -peer-addr 127.0.0.1:7003 -discovery http://127.0.0.1:4000/v2/keys/$UUID
...
$ ; prove the cluster came up
$ curl localhost:7001/v2/admin/machines
[{"name":"node1","state":"leader","clientURL":"http://127.0.0.1:4001","peerURL":"http://127.0.0.1:7001"},{"name":"node2","state":"follower","clientURL":"http://127.0.0.1:4002","peerURL":"http://127.0.0.1:7002"},{"name":"node3","state":"follower","clientURL":"http://127.0.0.1:4003","peerURL":"http://127.0.0.1:7003"}]
$ ; check the state of the discovery service
$ curl localhost:4000/v2/keys/40134540-b53c-46b3-b34f-33b4f0ae3a9c?recursive=true
{"action":"get","node":{"key":"/40134540-b53c-46b3-b34f-33b4f0ae3a9c","dir":true,"nodes":[{"key":"/40134540-b53c-46b3-b34f-33b4f0ae3a9c/node1","value":"http://127.0.0.1:7001","expiration":"2014-10-31T23:05:50.268605238Z","ttl":604595,"modifiedIndex":19,"createdIndex":19},{"key":"/40134540-b53c-46b3-b34f-33b4f0ae3a9c/node2","value":"http://127.0.0.1:7002","expiration":"2014-10-31T23:05:55.335074504Z","ttl":604600,"modifiedIndex":21,"createdIndex":21},{"key":"/40134540-b53c-46b3-b34f-33b4f0ae3a9c/node3","value":"http://127.0.0.1:7003","expiration":"2014-10-31T23:06:11.718215655Z","ttl":604616,"modifiedIndex":22,"createdIndex":22}],"modifiedIndex":19,"createdIndex":19}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment