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

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

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

相关推荐
段帅龙呀1 小时前
Redis构建缓存服务器
服务器·redis·缓存
乌鸦不像写字台1 小时前
【docker部署】在服务器上使用docker
服务器·docker·容器
牧以南歌〆3 小时前
在Ubuntu主机中修改ARM Linux开发板的根文件系统
linux·arm开发·驱动开发·ubuntu
Antonio9154 小时前
【音视频】HLS简介与服务器搭建
运维·服务器·音视频
夜月yeyue4 小时前
设计模式分析
linux·c++·stm32·单片机·嵌入式硬件
kfepiza4 小时前
Debian的`/etc/network/interfaces`的`allow-hotplug`和`auto`对比讲解 笔记250704
linux·服务器·网络·笔记·debian
无妄-20245 小时前
软件架构升级中的“隐形地雷”:版本选型与依赖链风险
java·服务器·网络·经验分享
R.X. NLOS5 小时前
VS Code远程开发新方案:使用SFTP扩展解决Remote-SSH连接不稳定问题
运维·服务器·ssh·debug·vs code
cuijiecheng20185 小时前
Ubuntu下布署mediasoup-demo
linux·运维·ubuntu
独行soc7 小时前
2025年渗透测试面试题总结-2025年HW(护网面试) 33(题目+回答)
linux·科技·安全·网络安全·面试·职场和发展·护网