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

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

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

相关推荐
YXXY3137 小时前
线程的介绍(四)
linux
Snasph7 小时前
GNU Make 用户手册(中文版)
服务器·算法·gnu
广州灵眸科技有限公司7 小时前
瑞芯微RV1126B开发板(EASY-EAI-PI2) Easy-Eai编译环境准备与更新
服务器·前端·人工智能·python·深度学习
Esaka_Forever8 小时前
uv init 完整用法(Python 最快包管理器)
服务器·python·uv
溜达的大象8 小时前
服务器挂了等用户报障?我用Prometheus搭了一套监控告警,服务器出状况第一时间通知我
服务器·php·prometheus
kTR2hD1qb9 小时前
从 Responses API 到 Chat Completions:一个模型网关的设计复盘
linux·前端
姓刘的哦9 小时前
大模型祛魅
linux
闪电悠米10 小时前
黑马点评-Redisson-01_why_redisson
java·服务器·网络·数据库·缓存·wpf
hj28625110 小时前
linux下一步学习内容
linux·运维
tudoSearcher11 小时前
日志、指标、链路追踪:可观测性三支柱深度解析
运维·服务器·网络·prometheus