etcd集群的部署
发表于:2024-10-21 作者:千家信息网编辑
千家信息网最后更新 2024年10月21日,node1 192.168.56.173node2 192.168.56.174node3 192.168.56.200node* 为主机名称[root@node1 ~]# cat /etc/red
千家信息网最后更新 2024年10月21日etcd集群的部署
node1 192.168.56.173node2 192.168.56.174node3 192.168.56.200node* 为主机名称[root@node1 ~]# cat /etc/redhat-release CentOS Linux release 7.2.1511 (Core) [root@node1 ~]#
https://github.com/coreos/etcd/releases/download/v3.0.15/etcd-v3.0.15-linux-amd64.tar.gz tar xf etcd-v3.0.15-linux-amd64.tar.gz cd etcd-v3.0.15-linux-amd64 cp etcd /usr/bin/cp etcdctl /usr/bin/
192.168.56.173(node1)
cat /etc/systemd/system/etcd2.service
[Unit]Description=etcd2.service[Service]Type=notifyTimeoutStartSec=0Restart=alwaysExecStartPre=-/usr/bin/mkdir -p /data/etcd2ExecStart=/usr/bin/etcd \ --data-dir /data/etcd2 \ --name etcd0 \ --advertise-client-urls http://192.168.56.173:2379,http://192.168.56.173:4001 \ --listen-client-urls http://0.0.0.0:2379,http://0.0.0.0:4001 \ --initial-advertise-peer-urls http://192.168.56.173:2380 \ --listen-peer-urls http://0.0.0.0:2380 \ --initial-cluster-token etcd-cluster-1 \ --initial-cluster etcd0=http://192.168.56.173:2380,etcd1=http://192.168.56.174:2380,etcd2=http://192.168.56.200:2380[Install]WantedBy=multi-user.target
# 设置服务自启动systemctl enable /etc/systemd/system/etcd2.service# 启动etcd1 (先不要做 三个节点都部署完毕 在分别启动 否则启动会hang)systemctl restart etcd2.service
192.168.56.174(node2)
[root@node2 ~]# cat /etc/systemd/system/etcd2.service
[Unit]Description=etcd2.service[Service]Type=notifyTimeoutStartSec=0Restart=alwaysExecStartPre=-/usr/bin/mkdir -p /data/etcd2ExecStart=/usr/bin/etcd \ --data-dir /data/etcd2 \ --name etcd1 \ --advertise-client-urls http://192.168.56.174:2379,http://192.168.56.174:4001 \ --listen-client-urls http://0.0.0.0:2379,http://0.0.0.0:4001 \ --initial-advertise-peer-urls http://192.168.56.174:2380 \ --listen-peer-urls http://0.0.0.0:2380 \ --initial-cluster-token etcd-cluster-1 \ --initial-cluster etcd0=http://192.168.56.173:2380,etcd1=http://192.168.56.174:2380,etcd2=http://192.168.56.200:2380[Install]WantedBy=multi-user.target
# 设置服务自启动systemctl enable /etc/systemd/system/etcd2.service# 启动etcd2 (先不要做 三个节点都部署完毕 在分别启动 否则启动会hang)systemctl restart etcd2.service
192.168.56.200(node2)
[root@node3~]# cat /etc/systemd/system/etcd2.service
[root@node3 ~]# cat /etc/systemd/system/etcd2.service [Unit]Description=etcd2.service[Service]Type=notifyTimeoutStartSec=0Restart=alwaysExecStartPre=-/usr/bin/mkdir -p /data/etcd2ExecStart=/usr/bin/etcd \ --data-dir /data/etcd2 \ --name etcd2 \ --advertise-client-urls http://192.168.56.200:2379,http://192.168.56.200:4001 \ --listen-client-urls http://0.0.0.0:2379,http://0.0.0.0:4001 \ --initial-advertise-peer-urls http://192.168.56.200:2380 \ --listen-peer-urls http://0.0.0.0:2380 \ --initial-cluster-token etcd-cluster-1 \ --initial-cluster etcd0=http://192.168.56.173:2380,etcd1=http://192.168.56.174:2380,etcd2=http://192.168.56.200:2380[Install]WantedBy=multi-user.target
# 设置服务自启动systemctl enable /etc/systemd/system/etcd2.service# 启动etcd3 (先不要做 三个节点都部署完毕 在分别启动 否则启动会hang)systemctl restart etcd2.service
备注:启动的方式一个一个启动 否则systemctl restart etcd2.service 会hang住
查看状态
[root@node3 ~]# systemctl status etcd2.service ● etcd2.service Loaded: loaded (/etc/systemd/system/etcd2.service; enabled; vendor preset: disabled) Active: active (running) since Sat 2017-09-02 23:43:59 CST; 10min ago Process: 2673 ExecStartPre=/usr/bin/mkdir -p /data/etcd2 (code=exited, status=0/SUCCESS) Main PID: 2675 (etcd) CGroup: /system.slice/etcd2.service └─2675 /usr/bin/etcd --data-dir /data/etcd2 --name etcd2 --advertise-client-urls http://192.168.56.200:2379,http://192.168.56.200:4001 --listen-client-urls http://0.0.0.0:2379,http://0.0.0.0:4001...Sep 02 23:44:45 node3 etcd[2675]: established a TCP streaming connection with peer e37f661be0f0e44a (stream Message reader)Sep 02 23:44:45 node3 etcd[2675]: established a TCP streaming connection with peer 161efc88633d5fd4 (stream MsgApp v2 reader)Sep 02 23:44:45 node3 etcd[2675]: established a TCP streaming connection with peer 161efc88633d5fd4 (stream Message reader)Sep 02 23:44:45 node3 etcd[2675]: closed an existing TCP streaming connection with peer 161efc88633d5fd4 (stream Message writer)Sep 02 23:44:45 node3 etcd[2675]: established a TCP streaming connection with peer 161efc88633d5fd4 (stream Message writer)Sep 02 23:44:46 node3 etcd[2675]: 52aafe548d51c9ea [term: 25] received a MsgVote message with higher term from e37f661be0f0e44a [term: 26]Sep 02 23:44:46 node3 etcd[2675]: 52aafe548d51c9ea became follower at term 26Sep 02 23:44:46 node3 etcd[2675]: 52aafe548d51c9ea [logterm: 20, index: 623, vote: 0] voted for e37f661be0f0e44a [logterm: 20, index: 623] at term 26Sep 02 23:44:46 node3 etcd[2675]: 52aafe548d51c9ea [term: 26] ignored a MsgVote message with lower term from 161efc88633d5fd4 [term: 24]Sep 02 23:44:46 node3 etcd[2675]: raft.node: 52aafe548d51c9ea elected leader e37f661be0f0e44a at term 26[root@node3 ~]#
[root@node3 ~]# netstat -lntup Active Internet connections (only servers)Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 869/sshd tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 1132/master tcp6 0 0 :::2379 :::* LISTEN 2675/etcd tcp6 0 0 :::2380 :::* LISTEN 2675/etcd tcp6 0 0 :::22 :::* LISTEN 869/sshd tcp6 0 0 ::1:25 :::* LISTEN 1132/master tcp6 0 0 :::4001 :::* LISTEN 2675/etcd [root@node3 ~]#
查看相关主体的状态
[root@node1 etcd-v3.0.15-linux-amd64]# etcdctl member list161efc88633d5fd4: name=etcd0 peerURLs=http://192.168.56.173:2380 clientURLs=http://192.168.56.173:2379,http://192.168.56.173:4001 isLeader=false52aafe548d51c9ea: name=etcd2 peerURLs=http://192.168.56.200:2380 clientURLs=http://192.168.56.200:2379,http://192.168.56.200:4001 isLeader=falsee37f661be0f0e44a: name=etcd1 peerURLs=http://192.168.56.174:2380 clientURLs=http://192.168.56.174:2379,http://192.168.56.174:4001 isLeader=true[root@node1 etcd-v3.0.15-linux-amd64]#
集群的状态监控(可以结合zabbix做监控)
[root@node1 etcd-v3.0.15-linux-amd64]# etcdctl cluster-healthmember 161efc88633d5fd4 is healthy: got healthy result from http://192.168.56.173:2379member 52aafe548d51c9ea is healthy: got healthy result from http://192.168.56.200:2379member e37f661be0f0e44a is healthy: got healthy result from http://192.168.56.174:2379cluster is healthy[root@node1 etcd-v3.0.15-linux-amd64]#
etcd基本操作
[root@node1 ~]# etcdctl set testkey "hello world"hello world[root@node1 ~]# etcdctl get testkey hello world[root@node1 ~]# curl -L http://localhost:2379/v2/keys/testkey{"action":"get","node":{"key":"/testkey","value":"hello world","modifiedIndex":11,"createdIndex":11}}[root@node1 ~]# curl -L http://192.168.56.173:2379/v2/keys/testkey{"action":"get","node":{"key":"/testkey","value":"hello world","modifiedIndex":11,"createdIndex":11}}[root@node1 ~]#
三个
启动会
状态
节点
服务
监控
集群
主体
主机
名称
基本操作
备注
方式
数据库的安全要保护哪些东西
数据库安全各自的含义是什么
生产安全数据库录入
数据库的安全性及管理
数据库安全策略包含哪些
海淀数据库安全审计系统
建立农村房屋安全信息数据库
易用的数据库客户端支持安全管理
连接数据库失败ssl安全错误
数据库的锁怎样保障安全
金山区电子网络技术怎么样
青少年网络安全手抄报 慢动作
阿里云服务器浏览器
公安类专业包括网络安全与执法
领导讲话网络安全工作要求
邯郸软件开发培训机构
淮安智能软件开发项目
西交大网络安全就业
单位网络技术人员政治要求
全新的眼镜行业软件开发商
fmrs是哪种数据库
安亲托管软件开发
win10服务器链接怎么打开
数据库技术的复杂性表现
软件开发入门学什么语言
网络安全概论 视频
数据库sql抢票系统设计
计算机软件开发编程
上海海事大学校内数据库
福州 网络技术 招聘
宜兴软件开发
安卓软件开发项目经济管理分析
网络安全张威
无线网络技术导论论文
数据库的权限配置文件
建立网址数据库实验报告
第三次水资源调查评价数据库标准
贵州4u服务器散热器定制
浙江软件开发者需要什么
江西智能化软件开发收费