소스 검색

Documentation: add documentation for single node docker etcd

Fixes #7843
Anthony Romano 8 년 전
부모
커밋
b8f08d400d
1개의 변경된 파일44개의 추가작업 그리고 15개의 파일을 삭제
  1. 44 15
      Documentation/op-guide/container.md

+ 44 - 15
Documentation/op-guide/container.md

@@ -68,6 +68,35 @@ Production clusters which refer to peers by DNS name known to the local resolver
 
 
 In order to expose the etcd API to clients outside of Docker host, use the host IP address of the container. Please see [`docker inspect`](https://docs.docker.com/engine/reference/commandline/inspect) for more detail on how to get the IP address. Alternatively, specify `--net=host` flag to `docker run` command to skip placing the container inside of a separate network stack.
 In order to expose the etcd API to clients outside of Docker host, use the host IP address of the container. Please see [`docker inspect`](https://docs.docker.com/engine/reference/commandline/inspect) for more detail on how to get the IP address. Alternatively, specify `--net=host` flag to `docker run` command to skip placing the container inside of a separate network stack.
 
 
+### Running a single node etcd
+
+Use the host IP address when configuring etcd:
+
+```
+export NODE1=192.168.1.21
+```
+
+Run the latest version of etcd:
+
+```
+docker run --net=host \
+    --volume=${DATA_DIR}:/etcd-data \
+    --name etcd quay.io/coreos/etcd:latest \
+	/usr/local/bin/etcd \
+    --data-dir=/etcd-data --name node1 \
+    --initial-advertise-peer-urls http://${NODE1}:2380 --listen-peer-urls http://${NODE1}:2380 \
+    --advertise-client-urls http://${NODE1}:2379 --listen-client-urls http://${NODE1}:2379 \
+    --initial-cluster node1=http://${NODE1}:2380
+```
+
+List the cluster member:
+
+```
+etcdctl --endpoints=http://${NODE1}:2379 member list
+```
+
+### Running a 3 node etcd cluster
+
 ```
 ```
 # For each machine
 # For each machine
 ETCD_VERSION=latest
 ETCD_VERSION=latest
@@ -85,41 +114,41 @@ DATA_DIR=/var/lib/etcd
 # For node 1
 # For node 1
 THIS_NAME=${NAME_1}
 THIS_NAME=${NAME_1}
 THIS_IP=${HOST_1}
 THIS_IP=${HOST_1}
-sudo docker run --net=host \
+docker run --net=host \
     --volume=${DATA_DIR}:/etcd-data \
     --volume=${DATA_DIR}:/etcd-data \
     --name etcd quay.io/coreos/etcd:${ETCD_VERSION} \
     --name etcd quay.io/coreos/etcd:${ETCD_VERSION} \
 	/usr/local/bin/etcd \
 	/usr/local/bin/etcd \
     --data-dir=/etcd-data --name ${THIS_NAME} \
     --data-dir=/etcd-data --name ${THIS_NAME} \
-	--initial-advertise-peer-urls http://${THIS_IP}:2380 --listen-peer-urls http://${THIS_IP}:2380 \
-	--advertise-client-urls http://${THIS_IP}:2379 --listen-client-urls http://${THIS_IP}:2379 \
-	--initial-cluster ${CLUSTER} \
-	--initial-cluster-state ${CLUSTER_STATE} --initial-cluster-token ${TOKEN}
+    --initial-advertise-peer-urls http://${THIS_IP}:2380 --listen-peer-urls http://${THIS_IP}:2380 \
+    --advertise-client-urls http://${THIS_IP}:2379 --listen-client-urls http://${THIS_IP}:2379 \
+    --initial-cluster ${CLUSTER} \
+    --initial-cluster-state ${CLUSTER_STATE} --initial-cluster-token ${TOKEN}
 
 
 # For node 2
 # For node 2
 THIS_NAME=${NAME_2}
 THIS_NAME=${NAME_2}
 THIS_IP=${HOST_2}
 THIS_IP=${HOST_2}
-sudo docker run --net=host \
+docker run --net=host \
     --volume=${DATA_DIR}:/etcd-data \
     --volume=${DATA_DIR}:/etcd-data \
     --name etcd quay.io/coreos/etcd:${ETCD_VERSION} \
     --name etcd quay.io/coreos/etcd:${ETCD_VERSION} \
 	/usr/local/bin/etcd \
 	/usr/local/bin/etcd \
     --data-dir=/etcd-data --name ${THIS_NAME} \
     --data-dir=/etcd-data --name ${THIS_NAME} \
-	--initial-advertise-peer-urls http://${THIS_IP}:2380 --listen-peer-urls http://${THIS_IP}:2380 \
-	--advertise-client-urls http://${THIS_IP}:2379 --listen-client-urls http://${THIS_IP}:2379 \
-	--initial-cluster ${CLUSTER} \
-	--initial-cluster-state ${CLUSTER_STATE} --initial-cluster-token ${TOKEN}
+    --initial-advertise-peer-urls http://${THIS_IP}:2380 --listen-peer-urls http://${THIS_IP}:2380 \
+    --advertise-client-urls http://${THIS_IP}:2379 --listen-client-urls http://${THIS_IP}:2379 \
+    --initial-cluster ${CLUSTER} \
+    --initial-cluster-state ${CLUSTER_STATE} --initial-cluster-token ${TOKEN}
 
 
 # For node 3
 # For node 3
 THIS_NAME=${NAME_3}
 THIS_NAME=${NAME_3}
 THIS_IP=${HOST_3}
 THIS_IP=${HOST_3}
-sudo docker run --net=host \
+docker run --net=host \
     --volume=${DATA_DIR}:/etcd-data \
     --volume=${DATA_DIR}:/etcd-data \
     --name etcd quay.io/coreos/etcd:${ETCD_VERSION} \
     --name etcd quay.io/coreos/etcd:${ETCD_VERSION} \
 	/usr/local/bin/etcd \
 	/usr/local/bin/etcd \
     --data-dir=/etcd-data --name ${THIS_NAME} \
     --data-dir=/etcd-data --name ${THIS_NAME} \
-	--initial-advertise-peer-urls http://${THIS_IP}:2380 --listen-peer-urls http://${THIS_IP}:2380 \
-	--advertise-client-urls http://${THIS_IP}:2379 --listen-client-urls http://${THIS_IP}:2379 \
-	--initial-cluster ${CLUSTER} \
-	--initial-cluster-state ${CLUSTER_STATE} --initial-cluster-token ${TOKEN}
+    --initial-advertise-peer-urls http://${THIS_IP}:2380 --listen-peer-urls http://${THIS_IP}:2380 \
+    --advertise-client-urls http://${THIS_IP}:2379 --listen-client-urls http://${THIS_IP}:2379 \
+    --initial-cluster ${CLUSTER} \
+    --initial-cluster-state ${CLUSTER_STATE} --initial-cluster-token ${TOKEN}
 ```
 ```
 
 
 To run `etcdctl` using API version 3:
 To run `etcdctl` using API version 3: