1,安装golang环境,参考连接https://blog.csdn.net/h394600493/article/details/120431561?spm=1001.2014.3001.5502https://blog.csdn.net/h394600493/article/details/120431561?spm=1001.2014.3001.5502
2,下载etcd 3.5.0版本
git clone https://github.com/etcd-io/etcd.git -b v3.5.0
cd etcd
3,编译etcd
# 在etcd目录执行
make
make install
cp ./bin/* /usr/local/bin/ -fr
执行过程中遇到问题
1,go: go.etcd.io/etcd/client/v2@v2.305.0 requires
github.com/json-iterator/go@v1.1.11: Get "https://proxy.golang.org/github.com/json-iterator/go/@v/v1.1.11.mod": dial tcp 172.217.160.81:443: i/o timeout
解决方法:
# 执行命令,换一个国内能访问的代理地址:https://goproxy.cn
go env -w GOPROXY=https://goproxy.cn
2, must be run from 'go.etcd.io/etcd/v3' module directory
在etcd目录编辑go.mod文件,加入了replace google.golang.org/grpc => google.golang.org/grpc v1.26.0,如下图,之后执行命令go mod tidy,在接着第3步编译etcd
vi go.mod
module go.etcd.io/etcd/v3
go 1.16
replace (
go.etcd.io/etcd/api/v3 => ./api
go.etcd.io/etcd/client/pkg/v3 => ./client/pkg
go.etcd.io/etcd/client/v2 => ./client/v2
go.etcd.io/etcd/client/v3 => ./client/v3
go.etcd.io/etcd/etcdctl/v3 => ./etcdctl
go.etcd.io/etcd/etcdutl/v3 => ./etcdutl
go.etcd.io/etcd/pkg/v3 => ./pkg
go.etcd.io/etcd/raft/v3 => ./raft
go.etcd.io/etcd/server/v3 => ./server
go.etcd.io/etcd/tests/v3 => ./tests
)
replace google.golang.org/grpc => google.golang.org/grpc v1.26.0
require (
github.com/bgentry/speakeasy v0.1.0
github.com/dustin/go-humanize v1.0.0
github.com/spf13/cobra v1.1.3
go.etcd.io/bbolt v1.3.6
go.etcd.io/etcd/api/v3 v3.5.0
go.etcd.io/etcd/client/pkg/v3 v3.5.0
go.etcd.io/etcd/client/v2 v2.305.0
go.etcd.io/etcd/client/v3 v3.5.0
go.etcd.io/etcd/etcdctl/v3 v3.5.0
go.etcd.io/etcd/etcdutl/v3 v3.5.0
go.etcd.io/etcd/pkg/v3 v3.5.0
go.etcd.io/etcd/raft/v3 v3.5.0
go.etcd.io/etcd/server/v3 v3.5.0
go.etcd.io/etcd/tests/v3 v3.5.0
go.uber.org/zap v1.17.0
golang.org/x/time v0.0.0-20210220033141-f8bda1e9f3ba
google.golang.org/grpc v1.38.0
gopkg.in/cheggaaa/pb.v1 v1.0.28
)