ソースを参照

docs and cluster ID change based on name

Barak Michener 11 年 前
コミット
1347e3952f
2 ファイル変更11 行追加1 行削除
  1. 6 0
      Documentation/clustering.md
  2. 5 1
      etcdserver/cluster.go

+ 6 - 0
Documentation/clustering.md

@@ -167,3 +167,9 @@ Etcd can also do internal server-to-server communication using SSL client certs.
 To do this just change the `-*-file` flags to `-peer-*-file`.
 
 If you are using SSL for server-to-server communication, you must use it on all instances of etcd.
+
+### Bootstrapping a new cluster by name
+
+An etcd server is uniquely defined by the peer addresses it listens to. Suppose, however, that you wish to start over, while maintaining the data from the previous cluster -- that is, to pretend that this machine has never joined a cluster before.
+
+You can use `--initial-cluster-name` to generate a new unique ID for each node, as a shared token that every node understands. Nodes also take this into account for bootstrapping the new cluster ID, so it also provides a way for a machine to listen on the same interfaces, disconnect from one cluster, and join a different cluster.

+ 5 - 1
etcdserver/cluster.go

@@ -106,7 +106,11 @@ func (c *Cluster) GenID(salt []byte) {
 	for i, id := range mIDs {
 		binary.BigEndian.PutUint64(b[8*i:], id)
 	}
-	hash := sha1.Sum(append(b, salt...))
+	if len(c.name) > 0 {
+		b = append(b, []byte(c.name)...)
+	}
+	b = append(b, salt...)
+	hash := sha1.Sum(b)
 	c.id = binary.BigEndian.Uint64(hash[:8])
 }