我是靠谱客的博主 风中星月,最近开发中收集的这篇文章主要介绍etcd v3版本集群搭建搭建双节点新增节点,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

搭建双节点

节点1:

修改配置文件/etc/etcd/etcd.conf

#[Member]

#ETCD_CORS=""

ETCD_DATA_DIR="/var/lib/etcd/default.etcd"

#ETCD_WAL_DIR=""

ETCD_LISTEN_PEER_URLS="http:// 1.190.246.114:2380"

ETCD_LISTEN_CLIENT_URLS="http://localhost:2379"

#ETCD_MAX_SNAPSHOTS="5"

#ETCD_MAX_WALS="5"

ETCD_NAME="etcd-114"

#ETCD_SNAPSHOT_COUNT="100000"

#ETCD_HEARTBEAT_INTERVAL="100"

#ETCD_ELECTION_TIMEOUT="1000"

#ETCD_QUOTA_BACKEND_BYTES="0"

#ETCD_MAX_REQUEST_BYTES="1572864"

#ETCD_GRPC_KEEPALIVE_MIN_TIME="5s"

#ETCD_GRPC_KEEPALIVE_INTERVAL="2h0m0s"

#ETCD_GRPC_KEEPALIVE_TIMEOUT="20s"

 

#[Clustering]

ETCD_INITIAL_ADVERTISE_PEER_URLS="http:// 1.190.246.114:2380"

ETCD_ADVERTISE_CLIENT_URLS="http://localhost:2379"

#ETCD_DISCOVERY=""

#ETCD_DISCOVERY_FALLBACK="proxy"

#ETCD_DISCOVERY_PROXY=""

#ETCD_DISCOVERY_SRV=""

ETCD_INITIAL_CLUSTER=" etcd-114=http:// 1.190.246.114:2380, etcd-125=http:// 1.190.246.125:2380"

ETCD_INITIAL_CLUSTER_TOKEN="etcd-cluster"

ETCD_INITIAL_CLUSTER_STATE="new"

#ETCD_STRICT_RECONFIG_CHECK="true"

#ETCD_ENABLE_V2="true"

 

节点2:

#[Member]

#ETCD_CORS=""

ETCD_DATA_DIR="/var/lib/etcd/default.etcd"

#ETCD_WAL_DIR=""

ETCD_LISTEN_PEER_URLS="http://1.190.246.125:2380"

ETCD_LISTEN_CLIENT_URLS="http://localhost:2379"

#ETCD_MAX_SNAPSHOTS="5"

#ETCD_MAX_WALS="5"

ETCD_NAME="etcd-125"

#ETCD_SNAPSHOT_COUNT="100000"

#ETCD_HEARTBEAT_INTERVAL="100"

#ETCD_ELECTION_TIMEOUT="1000"

#ETCD_QUOTA_BACKEND_BYTES="0"

#ETCD_MAX_REQUEST_BYTES="1572864"

#ETCD_GRPC_KEEPALIVE_MIN_TIME="5s"

#ETCD_GRPC_KEEPALIVE_INTERVAL="2h0m0s"

#ETCD_GRPC_KEEPALIVE_TIMEOUT="20s"

#

#[Clustering]

ETCD_INITIAL_ADVERTISE_PEER_URLS="http://1.190.246.125:2380"

ETCD_ADVERTISE_CLIENT_URLS="http://localhost:2379"

#ETCD_DISCOVERY=""

#ETCD_DISCOVERY_FALLBACK="proxy"

#ETCD_DISCOVERY_PROXY=""

#ETCD_DISCOVERY_SRV=""

ETCD_INITIAL_CLUSTER="etcd-114=http://1.190.246.114:2380,etcd-125=http://1.190.246.125:2380"

ETCD_INITIAL_CLUSTER_TOKEN="etcd-cluster"

ETCD_INITIAL_CLUSTER_STATE="new"

#ETCD_STRICT_RECONFIG_CHECK="true"

#ETCD_ENABLE_V2="true”

 

注意防火墙需要开放集群节点之前的心跳2380端口

 

[root@localhost log]# etcdctl member list

1cdbf6e961ad312d, started, etcd-114, http://1.190.246.114:2380, http://localhost:2379

fd7abcbc8685f45b, started, etcd-125, http://1.190.246.125:2380, http://localhost:2379

 

两个节点同时启动systemctl start etcd

 

新增节点

老节点:

需要配置环境变量ETCDCTL_API=3

[root@localhost member]# etcdctl member add etcd-39 --peer-urls="http://10.2.21.39:2380"

Member 52307e3bebedb683 added to cluster d6d6ab50173a3088

 

ETCD_NAME="etcd-39"

ETCD_INITIAL_CLUSTER="etcd-41=http://10.2.21.41:2380,etcd-39=http://10.2.21.39:2380"

ETCD_INITIAL_ADVERTISE_PEER_URLS="http://10.2.21.39:2380"

ETCD_INITIAL_CLUSTER_STATE="existing"

[root@localhost member]# etcdctl member list

dae86100308fd5, started, etcd-41, http://10.2.21.41:2380, http://localhost:2379

52307e3bebedb683, started, etcd-39, http://10.2.21.39:2380, http://localhost:2379

 

新节点:

修改配置文件

#[Clustering]

ETCD_INITIAL_ADVERTISE_PEER_URLS="http://10.2.21.39:2380"

ETCD_ADVERTISE_CLIENT_URLS="http://localhost:2379"

#ETCD_DISCOVERY=""

#ETCD_DISCOVERY_FALLBACK="proxy"

#ETCD_DISCOVERY_PROXY=""

#ETCD_DISCOVERY_SRV=""

ETCD_INITIAL_CLUSTER="etcd-39=http://10.2.21.39:2380,etcd-41=http://10.2.21.41:2380"

ETCD_INITIAL_CLUSTER_TOKEN="etcd-cluster"

ETCD_INITIAL_CLUSTER_STATE="existing"

 

各个节点需要一起重新启动 systemctl start etcd

[root@localhost member]# etcdctl member list

dae86100308fd5, started, etcd-41, http://10.2.21.41:2380, http://localhost:2379

52307e3bebedb683, started, etcd-39, http://10.2.21.39:2380, http://localhost:2379

最后

以上就是风中星月为你收集整理的etcd v3版本集群搭建搭建双节点新增节点的全部内容,希望文章能够帮你解决etcd v3版本集群搭建搭建双节点新增节点所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(42)

评论列表共有 0 条评论

立即
投稿
返回
顶部