etcd在同一台虚拟机搭建集群

要点,将etcd拷贝到不同的目录,每个etcd用不同的端口号,cd到etcd目录,做如下配置即可:

./etcd --name etcd00 --initial-advertise-peer-urls http://192.168.75.145:2380 \
  --listen-peer-urls http://192.168.75.145:2380 \
  --listen-client-urls http://192.168.75.145:2379,http://127.0.0.1:2379 \
  --advertise-client-urls http://192.168.75.145:2379 \
  --initial-cluster-token etcd-cluster-1 \
  --initial-cluster etcd00=http://192.168.75.145:2380,etcd01=http://192.168.75.145:3380,etcd02=http://192.168.75.145:4380 \
  --initial-cluster-state new

================================

./etcd --name etcd01 --initial-advertise-peer-urls http://192.168.75.145:3380 \
  --listen-peer-urls http://192.168.75.145:3380 \
  --listen-client-urls http://192.168.75.145:3379,http://127.0.0.1:3379 \
  --advertise-client-urls http://192.168.75.145:3379 \
  --initial-cluster-token etcd-cluster-1 \
  --initial-cluster etcd00=http://192.168.75.145:2380,etcd01=http://192.168.75.145:3380,etcd02=http://192.168.75.145:4380 \
  --initial-cluster-state new

================================

./etcd --name etcd02 --initial-advertise-peer-urls http://192.168.75.145:4380 \
  --listen-peer-urls http://192.168.75.145:4380 \
  --listen-client-urls http://192.168.75.145:4379,http://127.0.0.1:4379 \
  --advertise-client-urls http://192.168.75.145:4379 \
  --initial-cluster-token etcd-cluster-1 \
  --initial-cluster etcd00=http://192.168.75.145:2380,etcd01=http://192.168.75.145:3380,etcd02=http://192.168.75.145:4380 \
  --initial-cluster-state new


当然了,可以直接按照上面启动,也可以放到一个shell文件里面启动。


你可能感兴趣的:(Etcd)