5步完成etcd单机集群部署

xmge · · 768 次点击 · 开始浏览    置顶
这是一个创建于 的主题,其中的信息可能已经有所发展或是发生改变。

## 一、下载 etcd 相关版本在:https://github.com/etcd-io/etcd/releases/ 这里以ubuntu x64举例: ``` wget https://github.com/etcd-io/etcd/releases/download/v3.4.0-rc.3/etcd-v3.4.0-rc.3-linux-amd64.tar.gz ``` ## 二、创建如下目录结构 ![image](https://xmge-img.oss-cn-beijing.aliyuncs.com/etcd%E9%9B%86%E7%BE%A4%E6%96%87%E4%BB%B6%E7%9B%AE%E5%BD%95.png) ## 三、新增三个配置文件 etcd1/etcd.conf 配置文件: ``` name: etcd-1 data-dir: /home/xmge/show/etcd_cluster/etcd1/data // 需要指定自己目录下的位置 listen-client-urls: http://0.0.0.0:2379 advertise-client-urls: http://127.0.0.1:2379 listen-peer-urls: http://0.0.0.0:2380 initial-advertise-peer-urls: http://127.0.0.1:2380 initial-cluster: etcd-1=http://127.0.0.1:2380,etcd-2=http://127.0.0.1:2480,etcd-3=http://127.0.0.1:2580 initial-cluster-token: etcd-cluster-my initial-cluster-state: new ``` etcd2/etcd.conf 配置文件: ``` name: etcd-2 data-dir: /home/xmge/show/etcd_cluster/etcd2/data // 需要指定自己目录下的位置 listen-client-urls: http://0.0.0.0:2479 advertise-client-urls: http://127.0.0.1:2479 listen-peer-urls: http://0.0.0.0:2480 initial-advertise-peer-urls: http://127.0.0.1:2480 initial-cluster: etcd-1=http://127.0.0.1:2380,etcd-2=http://127.0.0.1:2480,etcd-3=http://127.0.0.1:2580 initial-cluster-token: etcd-cluster-my initial-cluster-state: new ``` etcd3/etcd.conf 配置文件: ``` name: etcd-3 data-dir: /home/xmge/show/etcd_cluster/etcd3/data // 需要指定自己目录下的位置 listen-client-urls: http://0.0.0.0:2579 advertise-client-urls: http://127.0.0.1:2579 listen-peer-urls: http://0.0.0.0:2580 initial-advertise-peer-urls: http://127.0.0.1:2580 initial-cluster: etcd-1=http://127.0.0.1:2380,etcd-2=http://127.0.0.1:2480,etcd-3=http://127.0.0.1:2580 initial-cluster-token: etcd-cluster-my initial-cluster-state: new ``` ## 四、新增启动脚本start.sh并启动 ```shell #!/bin/bash CRTDIR=$(pwd) servers=("etcd1" "etcd2" "etcd3") for server in ${servers[@]} do cd ${CRTDIR}/$server nohup ./etcd --config-file=etcd.conf & echo $? done ``` 启动集群 ```shell chmod +x start.sh ./start.sh ``` ## 五、检验集群是否启动成功 ![image](https://xmge-img.oss-cn-beijing.aliyuncs.com/etcd%E6%A3%80%E6%B5%8B.png)

有疑问加站长微信联系(非本文作者)

入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889

768 次点击  
加入收藏 微博
暂无回复
添加一条新回复 (您需要 登录 后才能回复 没有账号 ?)
  • 请尽量让自己的回复能够对别人有帮助
  • 支持 Markdown 格式, **粗体**、~~删除线~~、`单行代码`
  • 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
  • 图片支持拖拽、截图粘贴等方式上传