etcd安装配置

下载安装包

选择不同系统的安装包,也可以自己编译
wget https://github.com/etcd-io/etcd/releases/download/v3.3.13/etcd-v3.3.13-linux-amd64.tar.gz

解压缩加入环境变量

-- 解压缩
tar -zxvf etcd-v3.3.13-linux-amd64.tar.gz
export ETCD_HOME=/opt/etcd/etcd-v3.3.13
export PATH=$PATH:$ETCD_HOME
-- 检查是否生效
etcd -version

启动单机版

etcd
etcd -listen-client-urls="http://0.0.0.0:2379" --advertise-client-urls="http://0.0.0.0:2379"
-- 查看是否生效
curl http://172.19.0.2:2379/version

配置单机多节点

配置node1.yml

name: node01
data-dir: /opt/etcd/data/node1
listen-client-urls: http://172.19.0.2:10001,http://127.0.0.1:10001
advertise-client-urls: http://172.19.0.2:10001
initial-advertise-peer-urls: http://172.19.0.2:9001
listen-peer-urls: http://172.19.0.2:9001
#初始化名称
#initial-cluster-token: token-test-cluster
#初始化群集列表
initial-cluster: node01=http://172.19.0.2:9001,node02=http://172.19.0.2:9002,node03=http://172.19.0.2:9003
#初始化状态(new|existing)
initial-cluster-state: new

配置node2.yml

name: node02
data-dir: /opt/etcd/data/node2
listen-client-urls: http://172.19.0.2:10002,http://127.0.0.1:10002
advertise-client-urls: http://172.19.0.2:10002
initial-advertise-peer-urls: http://172.19.0.2:9002
listen-peer-urls: http://172.19.0.2:9002
#初始化名称
#initial-cluster-token: token-test-cluster
#初始化群集列表
initial-cluster: node01=http://172.19.0.2:9001,node02=http://172.19.0.2:9002,node03=http://172.19.0.2:9003
#初始化状态(new|existing)
initial-cluster-state: new

配置node3.yml

name: node03
data-dir: /opt/etcd/data/node3
listen-client-urls: http://172.19.0.2:10003,http://127.0.0.1:10003
advertise-client-urls: http://172.19.0.2:10003
initial-advertise-peer-urls: http://172.19.0.2:9003
listen-peer-urls: http://172.19.0.2:9003
#初始化名称
#initial-cluster-token: token-test-cluster
#初始化群集列表
initial-cluster: node01=http://172.19.0.2:9001,node02=http://172.19.0.2:9002,node03=http://172.19.0.2:9003
#初始化状态(new|existing)
initial-cluster-state: new

启动服务

nohup etcd  --config-file=/opt/etcd/node1.yml > /opt/etcd/node1.out &
nohup etcd  --config-file=/opt/etcd/node2.yml > /opt/etcd/node2.out &
nohup etcd  --config-file=/opt/etcd/node3.yml > /opt/etcd/node3.out &
--  如果不需要日志,可以输出到/dev/null
nohup etcd  --config-file=/opt/etcd/node1.yml > /dev/null &

检测成功与否

etcdctl --endpoints http://172.19.0.2:10001,http://172.19.0.2:10002,http://172.19.0.2:10003 member list
etcdctl --endpoints http://172.19.0.2:10001,http://172.19.0.2:10002,http://172.19.0.2:10003 set /cqh muscle

UI操作界面(etcd-browser和etcdkeeper)

### Windows 上安装配置 etcd 教程 #### 一、准备工作 为了在 Windows 系统上顺利安装配置 etcd,需先确认已安装必要的工具和环境。建议使用具备 Unix 风格命令行功能的软件如 Git Bash 或者 WSL (Windows Subsystem for Linux),这有助于简化操作流程[^5]。 #### 二、下载 Etcd 访问官方 GitHub 发布页面获取最新版本的 etcd 安装包。对于 Windows 用户而言,应选择带有 `.zip` 后缀的压缩文件进行下载。解压后可获得 `etcd.exe` 和其他辅助程序文件[^2]。 #### 三、设置环境变量 为了让系统能够识别到 etcd 命令,在完成上述步骤之后还需要将 etcd 的路径添加至系统的 PATH 环境变量中去。这样就可以直接通过命令提示符或者 PowerShell 来调用 etcd 而不必每次都指定其完整路径了。 #### 四、验证安装情况 打开一个新的命令窗口输入如下指令来检验是否成功安装以及查看当前使用的 etcd 版本号: ```powershell .\etcd --version ``` #### 五、启动单节点实例 创建一个简单的配置文件用于定义集群参数(如果只需要测试的话可以省略此步),接着利用之前提到的方法之一开启服务端口监听等待客户端连接请求。例如可以通过下面这条语句实现基本的功能演示: ```bash .\etcd.exe --data-dir=data.etcd ``` 注意这里指定了数据目录的位置以便后续管理和维护工作更加方便快捷[^1]。 #### 六、停止服务进程 当不再需要运行时可通过任务管理器结束对应的 etcd 进程;也可以发送 SIGTERM 信号给目标 PID 实现优雅关闭的效果。具体做法是在另一个终端里执行 kill -SIGTERM ${PID} (适用于类 UNIX 平台下的模拟环境中)或者是 taskkill /F /IM etcd.exe (针对原生 Win32 应用场景)。不过在此之前最好确保所有未保存的信息都已经妥善处理完毕以免造成不必要的损失。
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值