1.安装必要的依赖
sudo apt update
sudo apt upgrade -y
sudo apt install build-essential procps curl file git -y
2. 安装 Homebrew
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
3. 设置环境变量
vim ~/.profile
#下面这句添加到profile中
eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"
export PATH="/home/linuxbrew/.linuxbrew/bin:$PATH"
wq!退出~/.profile
4.环境变量生效,检查版本
source ~/.profile
brew --version
5.更新 Homebrew
brew update
6.安装etcd
brew install etcd
然后检查安装情况
其余系统安装步骤在官网Install | etcd
7.etcdctl命令行工具安装
7.1克隆 etcd
仓库并构建 etcdctl
# 克隆 etcd 仓库
git clone https://github.com/etcd-io/etcd.git
cd etcd
构建出可执行文件使用go
go build
如果你已经配置好了go的全局环境,他仍旧出现下载别的版本的go的信息。
解决方案:检查 go.mod: 查看 etcd/etcdctl/go.mod
文件中指定的 Go 版本。
cat go.mod
可以看到mod文件中指定的go版本。按照自己的想法换go版本或是其他。
7.2移动 etcdctl
可执行文件到系统路径
sudo mv etcdctl /usr/local/bin/
验证是否安装成功
etcdctl version
如下图所示
然后看自己的需求,移动完可执行文件到bin目录后就可以删除源码了。