安装配置etcd
3个节点,搭建一个集群
#克隆仓库
git clone -b v3.5.0 https:///etcd-io/etcd.git
#切换目录执行安装脚本
./
#添加到环境目录
export PATH="$PATH:`pwd`/bin"
#测试
etcd --version
集群启动
### 第一台
nohup ./etcd --name infra0 --initial-advertise-peer-urls http://10.110.101.193:2380 \
--listen-peer-urls http://10.110.101.193:2380 --listen-client-urls http://10.110.101.193:2379,http://127.0.0.1:2379 \
--advertise-client-urls http://10.110.101.193:2379 --initial-cluster-token etcd-cluster-1 \
--initial-cluster infra0=http://10.110.101.193:2380,infra1=http://10.110.101.81:2380,infra2=http://10.110.101.147:2380 \
--initial-cluster-state new &
### 第二台
nohup ./etcd --name infra1 --initial-advertise-peer-urls http://10.110.101.81:2380 \
--listen-peer-urls http://10.110.101.81:2380 --listen-client-urls http://10.110.101.81:2379,http://127.0.0.1:2379 \
--advertise-client-urls http://10.110.101.81:2379 --initial-cluster-token etcd-cluster-1 \
--initial-cluster infra0=http://10.110.101.193:2380,infra1=http://10.110.101.81:2380,infra2=http://10.110.101.147:2380 \
--initial-cluster-state new &
### 第三台
nohup ./etcd --name infra2 --initial-advertise-peer-urls http://10.110.101.147:2380 \
--listen-peer-urls http://10.110.101.147:2380 --listen-client-urls http://10.110.101.147:2379,http://127.0.0.1:2379 \
--advertise-client-urls http://10.110.101.147:2379 --initial-cluster-token etcd-cluster-1 \
--initial-cluster infra0=http://10.110.101.193:2380,infra1=http://10.110.101.81:2380,infra2=http://10.110.101.147:2380 \
--initial-cluster-state new &
启动配置参数说明:
--name infra1
#成员的可读性的名字.
#默认: “default”
#环境变量: ETCD_NAME
#这个值被作为这个节点自己的入口中被引用, 在 --initial-cluster
#标记(例如, default=http://localhost:2380)中列出
--initial-advertise-peer-urls
#列出这个成员的伙伴 URL 以便通告给集群的其他成员。
#这些地方用于在集群中通讯 etcd 数据。至少有一个必须对所有集群成员可以路由的。这些 URL 可以包含域名。
#默认: “http://localhost:2380",本地集群地址
--listen-client-urls
#对面客户端的地址列表
--advertise-client-urls
#要向公众播发的此成员的客户端 URL 列表。
#通告的客户端 URL 应该可供与 etcd 集群通信的计算机访问
#。etcd 客户端库解析这些 URL 以连接到集群
#默认使用端口2379
--initial-cluster-token etcd-cluster-1
#引导期间 etcd 集群的初始集群令牌。
#指定此选项可以保护您在运行多个集群时免受意外的跨集互。
--initial-cluster infra0
#用于引导的初始群集配置。
#infra0=http://10.110.101.193:2380 则是各个成员的名字,使用端口2380
--initial-cluster-state new
#初始化集群状态,选项为new或者existing
启动完成后使用如下命令检查集群状态
etcdctl --write-out=table --endpoints=localhost:12379 member list
指标以及监控
可用使用curl命令来监控指标
curl -L http://localhost:2379/metrics | grep -v debugging #忽略debugging信息
有了这些指标,就可以通过prometheus来监控
prometheus监控
在prometehus的配置文件中增加
scrape_configs:
- job_name: test-etcd
static_configs:
- targets: ['10.240.0.32:2379','10.240.0.33:2379','10.240.0.34:2379'] #集群的地址
在prometheus上则可以进行查询
granfa图形
在granfa中配置为prometheus的数据源
增加官方指定模板
https://etcd.io/docs/v3.5/op-guide/grafana.json #官方模板地址
至此完成对etcd的图形化监控