etcd多实例配置

多实例进行配置,分别在多个不同端口进行监听,避免开启单机部署监听端口冲突;

查看go版本:

bash 复制代码
go version

若没有go环境,则进行下载,解压至/usr/local后进行环境配置,编辑vim ~./bashrc

bash 复制代码
vim ~./bashrc
bash 复制代码
export GOROOT=/usr/local/go
export GOPATH=$HOME/go
export PATH=$PATH:$GOROOT/bin:$GOPATH/bin

最后确保环境成功

bash 复制代码
source ~/.bashrc

随后安装goreman

Go 复制代码
go install github.com/mattn/goreman@latest
goreman help

配置文件

Go 复制代码
etcd1: etcd --name infra1 --listen-client-urls http://127.0.0.1:12379 --advertise-client-urls http://127.0.0.1:12379 --listen-peer-urls http://127.0.0.1:12380 --initial-advertise-peer-urls http://127.0.0.1:12380 --initial-cluster-token etcd-cluster-1 --initial-cluster 'infra1=http://127.0.0.1:12380,infra2=http://127.0.0.1:22380,infra3=http://127.0.0.1:32380' --initial-cluster-state new --enable-pprof --logger=zap --log-outputs=stderr

etcd2: etcd --name infra2 --listen-client-urls http://127.0.0.1:22379 --advertise-client-urls http://127.0.0.1:22379 --listen-peer-urls http://127.0.0.1:22380 --initial-advertise-peer-urls http://127.0.0.1:22380 --initial-cluster-token etcd-cluster-1 --initial-cluster 'infra1=http://127.0.0.1:12380,infra2=http://127.0.0.1:22380,infra3=http://127.0.0.1:32380' --initial-cluster-state new --enable-pprof --logger=zap --log-outputs=stderr

etcd3: etcd --name infra3 --listen-client-urls http://127.0.0.1:32379 --advertise-client-urls http://127.0.0.1:32379 --listen-peer-urls http://127.0.0.1:32380 --initial-advertise-peer-urls http://127.0.0.1:32380 --initial-cluster-token etcd-cluster-1 --initial-cluster 'infra1=http://127.0.0.1:12380,infra2=http://127.0.0.1:22380,infra3=http://127.0.0.1:32380' --initial-cluster-state new --enable-pprof --logger=zap --log-outputs=stderr

执行相关start

Go 复制代码
goreman -f local_cluster_procfile  start

启动完成之后查看集群内的成员

Go 复制代码
etcdctl --endpoints=http://localhost:22379  member list

关闭某个节点

Go 复制代码
goreman run stop etcd2

重启某个节点

Go 复制代码
goreman run restart etcd2

多节点情况下,指定添加某一节点的数据

当中止一个节点时,其他节点正常运行,可以访问,中止节点无法继续访问

相关推荐
likfishdn21 分钟前
Linux的文件与目录管理
linux·运维·服务器
渲染101专业云渲染22 分钟前
川翔云电脑优势总结
服务器·3d·电脑·blender·maya
chian-ocean40 分钟前
Linux 文件缓冲区:高效数据访问的幕后推手
linux·运维·服务器
加油=^_^=42 分钟前
【Linux】进程优先级 | 进程调度(三)
linux·运维·服务器
橘子味的茶二1 小时前
高级系统架构师--第十章:计算机网络
服务器·计算机网络·系统架构
吃汤圆的抹香鲸1 小时前
GoLand 安装包 绿色版 Win,Mac,Linux 包含IntelliJ全家桶 专为Go语言设计的集成开发环境(IDE)
linux·windows·macos·go·intellij-idea·go1.19
紫菜(Nori)1 小时前
短连接服务器压测-wrk
服务器·压力测试
追寻光1 小时前
Cannot find a valid baseurl for repo: base/7/x86_64
linux
元气满满的热码式1 小时前
Docker数据卷操作实战
linux·运维·docker·云原生·容器
陆沙2 小时前
deepseek-r1-centos-本地服务器配置方法
linux·服务器·centos