etcd安装和配置
【摘要】 1,操作系统版本[root@db04 ~]# cat /etc/redhat-releaseCentOS Linux release 7.8.2003 (Core)2,rpm软件下载地址https://centos.pkgs.org/7/centos-extras-x86_64/3,软件安装yum install etcd-3.3.11-2.el7.centos.x86_64.rpm -y...
1,操作系统版本
[root@db04 ~]# cat /etc/redhat-release
CentOS Linux release 7.8.2003 (Core)
2,rpm软件下载地址
https://centos.pkgs.org/7/centos-extras-x86_64/
3,软件安装
yum install etcd-3.3.11-2.el7.centos.x86_64.rpm -y
4,编辑配置文件
node01:
-bash-4.2# cat /etc/etcd/etcd.conf
ETCD_DATA_DIR="/var/lib/etcd/node1.etcd"
#与其他节点通信
ETCD_LISTEN_PEER_URLS="http://192.168.5.201:2380"
#对外提供的地址
ETCD_LISTEN_CLIENT_URLS="http://192.168.5.201:2379,http://127.0.0.1:2379"
ETCD_NAME="node1"
#该节点成员对等URL地址,且会通告群集的其余成员节点。
ETCD_INITIAL_ADVERTISE_PEER_URLS="http://192.168.5.201:2380"
#对外公告的该节点客户端监听地址。
ETCD_ADVERTISE_CLIENT_URLS="http://192.168.5.201:2379,http://127.0.0.1:2379"
#集群中所有节点的信息。
ETCD_INITIAL_CLUSTER="node1=http://192.168.5.201:2380,node2=http://192.168.5.202:2380,node3=http://192.168.5.203:2380"
ETCD_INITIAL_CLUSTER_TOKEN="etcd-cluster"
ETCD_INITIAL_CLUSTER_STATE="new"
node02:
[root@db03 ~]# cat /etc/etcd/etcd.conf
ETCD_DATA_DIR="/var/lib/etcd/node2.etcd"
ETCD_LISTEN_PEER_URLS="http://192.168.5.202:2380"
ETCD_LISTEN_CLIENT_URLS="http://192.168.5.202:2379,http://127.0.0.1:2379"
ETCD_NAME="node2"
ETCD_INITIAL_ADVERTISE_PEER_URLS="http://192.168.5.202:2380"
ETCD_ADVERTISE_CLIENT_URLS="http://192.168.5.202:2379,http://127.0.0.1:2379"
ETCD_INITIAL_CLUSTER="node1=http://192.168.5.201:2380,node2=http://192.168.5.202:2380,node3=http://192.168.5.203:2380"
ETCD_INITIAL_CLUSTER_TOKEN="etcd-cluster"
ETCD_INITIAL_CLUSTER_STATE="new"
node03:
[root@db04 ~]# cat /etc/etcd/etcd.conf
ETCD_DATA_DIR="/var/lib/etcd/node3.etcd"
ETCD_LISTEN_PEER_URLS="http://192.168.5.203:2380"
ETCD_LISTEN_CLIENT_URLS="http://192.168.5.203:2379,http://127.0.0.1:2379"
ETCD_NAME="node3"
ETCD_INITIAL_ADVERTISE_PEER_URLS="http://192.168.5.203:2380"
ETCD_ADVERTISE_CLIENT_URLS="http://192.168.5.203:2379,http://127.0.0.1:2379"
ETCD_INITIAL_CLUSTER="node1=http://192.168.5.201:2380,node2=http://192.168.5.202:2380,node3=http://192.168.5.203:2380"
ETCD_INITIAL_CLUSTER_TOKEN="etcd-cluster"
ETCD_INITIAL_CLUSTER_STATE="new"
5,每台服务器修改启动脚本
-bash-4.2# cat /usr/lib/systemd/system/etcd.service
[Unit]
Description=Etcd Server
After=network.target
After=network-online.target
Wants=network-online.target
[Service]
Type=notify
WorkingDirectory=/var/lib/etcd/
EnvironmentFile=-/etc/etcd/etcd.conf
User=etcd
# set GOMAXPROCS to number of processors
ExecStart=/bin/bash -c "GOMAXPROCS=$(nproc) /usr/bin/etcd \
--name=\"${ETCD_NAME}\" \
--data-dir=\"${ETCD_DATA_DIR}\" \
--listen-peer-urls=\"${ETCD_LISTEN_PEER_URLS}\" \
--listen-client-urls=\"${ETCD_LISTEN_CLIENT_URLS}\" \
--initial-advertise-peer-urls=\"${ETCD_INITIAL_ADVERTISE_PEER_URLS}\" \
--advertise-client-urls=\"${ETCD_ADVERTISE_CLIENT_URLS}\" \
--initial-cluster=\"${ETCD_INITIAL_CLUSTER}\" \
--initial-cluster-token=\"${ETCD_INITIAL_CLUSTER_TOKEN}\" \
--initial-cluster-state=\"${ETCD_INITIAL_CLUSTER_STATE}\""
Restart=on-failure
LimitNOFILE=65536
6,启动服务,并查看状态
#启动服务
systemctl start etcd.service
systemctl status etcd.service
systemctl enable etcd.service
-bash-4.2# etcdctl cluster-health
member 1b522fbd4f8c6893 is healthy: got healthy result from http://127.0.0.1:2379
member 235dfe2c4007ba42 is healthy: got healthy result from http://127.0.0.1:2379
member 2b2972666144b54d is healthy: got healthy result from http://127.0.0.1:2379
cluster is healthy
-bash-4.2# etcdctl member list
1b522fbd4f8c6893: name=node1 peerURLs=http://192.168.5.201:2380 clientURLs=http://127.0.0.1:2379,http://192.168.5.201:2379 isLeader=true
235dfe2c4007ba42: name=node2 peerURLs=http://192.168.5.202:2380 clientURLs=http://127.0.0.1:2379,http://192.168.5.202:2379 isLeader=false
2b2972666144b54d: name=node3 peerURLs=http://192.168.5.203:2380 clientURLs=http://127.0.0.1:2379,http://192.168.5.203:2379 isLeader=false
-bash-4.2#
【版权声明】本文为华为云社区用户原创内容,转载时必须标注文章的来源(华为云社区)、文章链接、文章作者等基本信息, 否则作者和本社区有权追究责任。如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱:
cloudbbs@huaweicloud.com
- 点赞
- 收藏
- 关注作者
评论(0)