前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >etcd3.7.2集群搭建(静态配置)

etcd3.7.2集群搭建(静态配置)

作者头像
菲宇
发布2019-06-11 17:36:32
6240
发布2019-06-11 17:36:32
举报
文章被收录于专栏:菲宇菲宇

etcd集群分为静态配置,etcd发现,dns发现三种,本文操作为手动静态配置

环境:

centos7

node-1:192.168.1.17

node-2:192.168.1.37

node-3:192.168.1.93

etcd配置项说明

--name infra1

本member的名字

--initial-advertise-peer-urls http://192.168.1.17:2380 \

建议用于节点之间通信的url,节点间将以该值进行通信。

其他member使用,其他member通过该地址与本member交互信息。一定要保证从其他member能可访问该地址。静态配置方式下,该参数的value一定要同时在--initial-cluster参数中存在。

memberID的生成受--initial-cluster-token和--initial-advertise-peer-urls影响

--data-dir /etcd_dir \

指定节点的数据存储目录,这些数据包括节点ID,集群ID,集群初始化配置,Snapshot文件,若未指定-wal-dir,还会存储WAL文件;如果不指定会用缺省目录。

--wal-dir /etcd_wal \

指定节点的was文件的存储目录,若指定了该参数,wal文件会和其他数据文件分开存储。

--debug \

输出debug信息?

--listen-peer-urls http://192.168.1.17:2380 \

监听的用于节点之间通信的url,可监听多个,集群内部将通过这些url进行数据交互(如选举,数据同步等)

本member侧使用,用于监听其他member发送信息的地址。ip为全0代表监听本member侧所有接口

--listen-client-urls http://192.168.1.17:2379,http://127.0.0.1:2379 \

监听的用于客户端通信的url,同样可以监听多个。

本member侧使用,用于监听etcd客户发送信息的地址。ip为全0代表监听本member侧所有接口

--advertise-client-urls http://192.168.1.17:2379 \

建议使用的客户端通信url,该值用于etcd代理或etcd成员与etcd节点通信。

etcd客户使用,客户通过该地址与本member交互信息。一定要保证从客户侧能可访问该地址

--initial-cluster-token etcd-cluster-1 \

节点的token值,设置该值后集群将生成唯一id,并为每个节点也生成唯一id,当使用相同配置文件再启动一个集群时,只要该token值不一样,etcd集群就不会相互影响。

用于区分不同集群。本地如有多个集群要设为不同。

--initial-cluster infra1=http://192.168.1.17:2380,infra2=http://192.168.1.37:2380,infra3=http://192.168.1.93:2380 \

也就是集群中所有的initial-advertise-peer-urls 的合集

本member侧使用。描述集群中所有节点的信息,本member根据此信息去联系其他member。

memberID的生成受--initial-cluster-token和--initial-advertise-peer-urls影响。

--initial-cluster-state new

用于指示本次是否为新建集群。有两个取值new和existing。如果填为existing,则该member启动时会尝试与其他member交互。

集群初次建立时,要填为new,经尝试最后一个节点填existing也正常,其他节点不能填为existing。

集群运行过程中,一个member故障后恢复时填为existing,经尝试填为new也正常。

在node1,nod2,node3操作

[root@k8s-master-1 ~]# cd /k8s/

[root@k8s-master-1 ~]# wget https://github.com/coreos/etcd/releases/etcd-v3.2.7-linux-amd64.tar.gz

[root@k8s-master-1 k8s]# ls

etcd-v3.2.7-linux-amd64.tar.gz

[root@k8s-master-1 k8s]# tar xvf etcd-v3.2.7-linux-amd64.tar.gz

[root@k8s-master-1 k8s]# cp etcd-v3.2.7-linux-amd64/etcd* /usr/bin/

[root@k8s-master-1 k8s]# etcd -help

[root@k8s-master-1 k8s]# nohup /k8s/etcd-3.2.7/etcd --name infra1 --initial-advertise-peer-urls http://192.168.1.17:2380 \

--data-dir /etcd_dir \

--wal-dir /etcd_wal \

--debug \

--listen-peer-urls http://192.168.1.17:2380 \

--listen-client-urls http://192.168.1.17:2379,http://127.0.0.1:2379 \

--advertise-client-urls http://192.168.1.17:2379 \

--initial-cluster-token etcd-cluster-1 \

--initial-cluster infra1=http://192.168.1.17:2380,infra2=http://192.168.1.37:2380,infra3=http://192.168.1.93:2380 \

--initial-cluster-state new /k8s/etcd.log 2>&1 &

[root@k8s-master-2 k8s]# nohup /k8s/etcd-3.2.7/etcd --name infra2 --initial-advertise-peer-urls http://192.168.1.37:2380 \

--data-dir /etcd_dir \

--wal-dir /etcd_wal \

--debug \

--listen-peer-urls http://192.168.1.37:2380 \

--listen-client-urls http://192.168.1.37:2379,http://127.0.0.1:2379 \

--advertise-client-urls http://192.168.1.37:2379 \

--initial-cluster-token etcd-cluster-1 \

--initial-cluster infra1=http://192.168.1.17:2380,infra2=http://192.168.1.37:2380,infra3=http://192.168.1.93:2380 \

--initial-cluster-state new > /k8s/etcd.log 2>&1 &

[root@k8s-node-1 k8s]# nohup /k8s/etcd-3.2.7/etcd --name infra3 --initial-advertise-peer-urls http://192.168.1.93:2380 \

--data-dir /etcd_dir \

--wal-dir /etcd_wal \

--debug \

--listen-peer-urls http://192.168.1.93:2380 \

--listen-client-urls http://192.168.1.93:2379,http://127.0.0.1:2379 \

--advertise-client-urls http://192.168.1.93:2379 \

--initial-cluster-token etcd-cluster-1 \

--initial-cluster infra1=http://192.168.1.17:2380,infra2=http://192.168.1.37:2380,infra3=http://192.168.1.93:2380 \

--initial-cluster-state new > /k8s/etcd.log 2>&1 &

----------------------------------------------------------------------------------------------------------------------------

检查etcd服务运行状态

使用curl访问:返回以下结果为正常(3个节点)

[root@k8s-master-1 /]# curl http://192.168.1.17:2379/v2/members

{"members":[{"id":"7f5748e6afb6da50","name":"infra2","peerURLs":["http://192.168.1.37:2380"],"clientURLs":["http://192.168.1.37:2379"]},{"id":"81675b26892a40fa","name":"infra3","peerURLs":["http://192.168.1.93:2380"],"clientURLs":["http://192.168.1.93:2379"]},{"id":"b4b072f84a899507","name":"infra1","peerURLs":["http://192.168.1.17:2380"],"clientURLs":["http://192.168.1.17:2379"]}]}

或者

[root@k8s-master-1 /]# etcdctl member list

7f5748e6afb6da50: name=infra2 peerURLs=http://192.168.1.37:2380 clientURLs=http://192.168.1.37:2379 isLeader=true

81675b26892a40fa: name=infra3 peerURLs=http://192.168.1.93:2380 clientURLs=http://192.168.1.93:2379 isLeader=false

b4b072f84a899507: name=infra1 peerURLs=http://192.168.1.17:2380 clientURLs=http://192.168.1.17:2379 isLeader=false

本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2018年07月16日,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
相关产品与服务
容器服务
腾讯云容器服务(Tencent Kubernetes Engine, TKE)基于原生 kubernetes 提供以容器为核心的、高度可扩展的高性能容器管理服务,覆盖 Serverless、边缘计算、分布式云等多种业务部署场景,业内首创单个集群兼容多种计算节点的容器资源管理模式。同时产品作为云原生 Finops 领先布道者,主导开源项目Crane,全面助力客户实现资源优化、成本控制。
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档