Skip to content

Instantly share code, notes, and snippets.

@bcwaldon
Last active August 29, 2015 14:08

Revisions

  1. bcwaldon revised this gist Oct 24, 2014. 1 changed file with 5 additions and 1 deletion.
    6 changes: 5 additions & 1 deletion gistfile1.sh
    Original file line number Diff line number Diff line change
    @@ -17,4 +17,8 @@ $ etcd -name node3 -addr 127.0.0.1:4003 -peer-addr 127.0.0.1:7003 -discovery htt

    $ ; 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"}]
    [{"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}}
  2. bcwaldon created this gist Oct 24, 2014.
    20 changes: 20 additions & 0 deletions gistfile1.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,20 @@
    $ ; 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"}]