etcd 集群安装
1.环境准备
下载安装包:https://github.com/etcd-io/etcd/releases/ 这里下载的安装包为:etcd-v3.5.9-linux-amd64.tar.gz,即我们当前安装的 etcd 版本为:3.5.9
这里有 3 个节点,分别为:
10.23.0.21 ec1
10.23.0.22 ec2
10.23.0.23 ec3
2.安装配置
首先在所有机器安装 etcd 如下:
tar -xvzf etcd-v3.5.9-linux-amd64.tar.gz
cd etcd-v3.5.9-linux-amd64/
mv etcd* /usr/local/bin/
# 查看版本号
etcd --version
然后在所有机器创建 etcd 数据目录:
mkdir /data/etcd
然后为集群指定一个初始化的令牌,防止意外的跨集群交互,可以生成一个 UUID:
uuidgen
不使用 UUID 也可以使用其他字符串,只要保证唯一就好,然后我们依次前台启动 etcd 服务:
# ec1 执行
etcd --data-dir=/data/etcd --name ec1 \
--initial-advertise-peer-urls http://10.23.0.21:2380 --listen-peer-urls http://10.23.0.21:2380 \
--advertise-client-urls http://10.23.0.21:2379 --listen-client-urls http://10.23.0.21:2379 \
--initial-cluster ec1=http://10.23.0.21:2380,ec2=http://10.23.0.22:2380,ec3=http://10.23.0.23:2380 \
--initial-cluster-state new --initial-cluster-token c660d863-24b4-4003-ba9c-ca27cfadda1d
# ec2 执行
etcd --data-dir=/data/etcd --name ec2 \
--initial-advertise-peer-urls http://10.23.0.22:2380 --listen-peer-urls http://10.23.0.22:2380 \
--advertise-client-urls http://10.23.0.22:2379 --listen-client-urls http://10.23.0.22:2379 \
--initial-cluster ec1=http://10.23.0.21:2380,ec2=http://10.23.0.22:2380,ec3=http://10.23.0.23:2380 \
--initial-cluster-state new --initial-cluster-token c660d863-24b4-4003-ba9c-ca27cfadda1d
# ec3 执行
etcd --data-dir=/data/etcd --name ec3 \
--initial-advertise-peer-urls http://10.23.0.23:2380 --listen-peer-urls http://10.23.0.23:2380 \
--advertise-client-urls http://10.23.0.23:2379 --listen-client-urls http://10.23.0.23:2379 \
--initial-cluster ec1=http://10.23.0.21:2380,ec2=http://10.23.0.22:2380,ec3=http://10.23.0.23:2380 \
--initial-cluster-state new --initial-cluster-token c660d863-24b4-4003-ba9c-ca27cfadda1d
其中参数的含义如下:
--listen-peer-urls 监听用于节点间通信的地址和端口,默认端口是 2380
--initial-advertise-peer-urls 表示提供给对端用于节点间访问的 URL,通常和上面的一样,但是在多网卡的环境下配置可能不一样
--listen-client-urls 监听客户端服务的地址和端口,默认端口是 2379
--advertise-client-urls 表示提供给客户端来访问 etcd 服务的 URL,通常和监听的一致,但是在多网卡环境下配置可能会不同
--initial-cluster 这个是固定格式,指定集群的节点和具体访问地址,所有节点都需要指定一样的。
--initial-cluster-state 新建集群需要写 new ,如果是加入已经存在的集群要写 existing
--initial-cluster-token 这个是填写我们刚才生成的 token 即可。
所有机器都启动后,集群就启动成功了。
查看状态:
# 这里写几个地址就显示几个
etcdctl --write-out=table --endpoints=http://10.23.0.21:2379 endpoint status
# 检查节点是否健康
etcdctl --endpoints=http://10.23.0.21:2379 endpoint health
# 查看成员列表 但是有时候显示会有延迟
etcdctl --endpoints=http://10.23.0.21:2379 --write-out=table member list
为了方便运行,可以使用 systemd 进行管理,首先需要将这么多参数抽出配置文件,etcd 支持通过 --config-file 传递配置文件路径,创建配置文件:
# 所有节点都需要创建配置文件
mkdir /etc/etcd
touch /etc/etcd/etcd.yml
然后对于 ec1 的配置文件如下:
# This is the configuration file for the etcd server.
# Human-readable name for this member.
name: 'ec1'
# Path to the data directory.
data-dir: /data/etcd
# List of comma separated URLs to listen on for peer traffic.
listen-peer-urls: http://10.23.0.21:2380
# List of comma separated URLs to listen on for client traffic.
listen-client-urls: http://10.23.0.21:2379
# List of this member's peer URLs to advertise to the rest of the cluster.
# The URLs needed to be a comma-separated list.
initial-advertise-peer-urls: http://10.23.0.21:2380
# List of this member's client URLs to advertise to the public.
# The URLs needed to be a comma-separated list.
advertise-client-urls: http://10.23.0.21:2379
# Comma separated string of initial cluster configuration for bootstrapping.
# Example: initial-cluster: "infra0=http://10.0.1.10:2380,infra1=http://10.0.1.11:2380,infra2=http://10.0.1.12:2380"
initial-cluster: "ec1=http://10.23.0.21:2380,ec2=http://10.23.0.22:2380,ec3=http://10.23.0.23:2380"
# Initial cluster token for the etcd cluster during bootstrap.
initial-cluster-token: 'c660d863-24b4-4003-ba9c-ca27cfadda1d'
# Initial cluster state ('new' or 'existing').
initial-cluster-state: 'new'
基本配置就是上面这些,我们保存配置,然后所有节点都需要填写该配置文件,其中的主机名和 IP 要根据节点实际的进行修改,所有节点编辑无误保存。
然后每个机器都要创建服务文件:/etc/systemd/system/etcd.service,内容如下:
[Unit]
Description="etcd"
Requires=network-online.target
After=network-online.target
[Service]
User=root
Group=root
ExecStart=/usr/local/bin/etcd --config-file=/etc/etcd/etcd.yml
ExecReload=/bin/kill --signal HUP $MAINPID
KillMode=process
KillSignal=SIGTERM
Restart=on-failure
LimitNOFILE=65536
[Install]
WantedBy=multi-user.target
所有机器都需要同步服务文件,同步之后我们手动结束掉之前阻塞的进程,然后启动服务:
# 所有节点都需要启动
systemctl start etcd.service
systemctl status etcd.service
检查服务状态都正常就可以了。
Reference:
etcd 集群安装的更多相关文章
- centos下etcd集群安装
先仔细了解学习etcd 官方: https://github.com/etcd-io/etcd https://www.cnblogs.com/softidea/p/6517959.html http ...
- ETCD集群安装实验
目录 [1.下载二进制程序] [2.安装etcd集群] [3.查询集群状态] [4.存入读取数据] [5.注意事项] [6.参考链接] 简介: Etcd的官网文档及其在GitHub上的文档,已 ...
- etcd集群安装部署
1. 集群架构 由于我们只有两个机房,所以选择的是以上图中所示的数据同步方案, 通过做镜像的方式保证两个集群的数据实时同步. 整体架构如上图所示, 整个全局元数据中心包括两套集群,廊坊集群和马驹桥集群 ...
- etcd集群安装
etcd 是一个分布式一致性k-v存储系统,可用于服务注册发现与共享配置,具有以下优点:1.简单:相比于晦涩难懂的paxos算法,etcd基于相对简单且易实现的raft算法实现一致性,并通过gRPC提 ...
- kubernetes 集群安装etcd集群,带证书
install etcd 准备证书 https://www.kubernetes.org.cn/3096.html 在master1需要安装CFSSL工具,这将会用来建立 TLS certificat ...
- 使用docker方式安装etcd集群,带TLS证书
网上文档也多,安装的时候,还是踩了几个坑. 现在作一个安装记录吧. 1,先作自签名的证书ca-csr.json(为了和k8s共用根证书,可能将信息调为k8s). { "CN": & ...
- 使用k8s operator安装和维护etcd集群
关于Kubernetes Operator这个新生事物,可以参考下文来了解这一技术的来龙去脉: https://yq.aliyun.com/articles/685522?utm_content=g_ ...
- Kubernetes1.91(K8s)安装部署过程(三)--创建高可用etcd集群
这里的etcd集群复用我们测试的3个节点,3个node都要安装并启动,注意修改配置文件 1.TLS认证文件分发:etcd集群认证用,除了本机有,分发到其他node节点 scp ca.pem kuber ...
- yum安装etcd集群
前一篇文章介绍了如何yum安装简单的kubernetes集群,其中etcd是单点部署.本篇我们来搭建etcd集群,方便日后搭建kubernetes HA集群架构. 1,环境配置说明 etcd1 ...
- etcd简介及集群安装部署使用
目录 1. 简介 2. Linux下载安装 3. 单机模式启动 4. 指定各集群成员的方式配置集群 5. 使用discovery service的方式配置集群 6. 集群模式下客户端命令行 7. et ...
随机推荐
- XAF新手入门 - XAF设计模式探讨
前言 刚接触XAF的小伙伴可能会有一个疑惑,XAF中有Model(BusinessObject).View.Controller,感觉明显是一个MVC的设计模式,但当你用MVC的设计模式与其对应时,又 ...
- 数组动态表单验证,添加数组,逆序添加,表单验证会错位,发现是key的默认index问题,还有验证trigger问题,添加数据会爆红
数组动态表单验证,添加数组,逆序添加,表单验证会错位,发现是key的默认index问题,还有验证trigger问题,添加数据会爆红 解决方案: trigger: 'blur,change' 换 tri ...
- vector的Erase相关
vector<int>Vect; Vect.insert(Vect.begin()+2, 50); for (auto it=Vect.begin();it!=Vect.end();++i ...
- C# PaddleOCR 车牌识别
效果 车牌识别测试地址 http://47.108.88.211/manual/VehPlateTest.html 通用OCR识别测试地址 http://47.108.88.211/manual/OC ...
- mybatis @Param参数 记录
报错信息 org.apache.ibatis.binding.BindingException: Parameter 'XX' not found. Available parameters are ...
- CentOS7.5安装JDK8
1.下载地址 https://www.oracle.com/java/technologies/javase-jdk8-downloads.html 2.创建文件夹 mkdir /usr/java 3 ...
- YOLOv1/v2/v3简述 | 目标检测
YOLO系列是目标检测领域里十分经典的结构,虽然目前已经出了很多更高质量更复杂的网络,但YOLO的结构依然可以给算法工程师们带来很多的启发.这3篇论文看下来,感觉像是一本调参说明书,教你如何使用各种t ...
- KingbaseES V8R6集群运维案例之---访问系统表unrecognized token- false故障
KingbaseES V8R6集群运维案例之---访问系统表'unrecognized token: "false"'故障 案例说明: KingbaseES V8R6集群在升级补丁 ...
- KingbaseES V8R6 等待事件之CLogControlLock
前言 Kingbase数据库的tuple行头部来标识这条记录的事务结束状态(未知.已提交.已回滚),在事务提交时如果并发更新100万行记录,需要对多个page的tuple进行更改,这种繁重的操作会对数 ...
- KingabseES 构造常量数据表的方式 union, values, array
背景 通用报表系统中,如果过滤条件是多选数据项,需要动态构造虚拟数据表,这里也会成为查询性能的痛点. 构造方式与执行计划 构造1000行数据的虚拟表. SQL UNION 组合多个查询的结果,需要解析 ...