我是靠谱客的博主 顺心飞机,最近开发中收集的这篇文章主要介绍Linux sed安装etcd集群,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

P8-Etcd-Node01-Master
P8-Etcd-Node02-Slave-01
P8-Etcd-Node03-Slave-02

10.0.0.30
10.0.0.31
10.0.0.32

操作基本
systemctl start etcd
systemctl stop etcd
systemctl restart etcd
etcdctl member list

30

hostnamectl set-hostname P8-Etcd-Node01-Master
#修改ip 10.0.0.30
cd /etc/sysconfig/network-scripts
sed -i '/.*BOOTPROTO=*/cBOOTPROTO="static"' ifcfg-ens33
sed -i '/.*IPADDR=*/cIPADDR=10.0.0.30' ifcfg-ens33
systemctl restart network


firewall-cmd --zone=public --add-port=2379/tcp --permanent
firewall-cmd --zone=public --add-port=2380/tcp --permanent
firewall-cmd --reload

yum install -y etcd
rpm -qa etcd
etcdctl -v

cp /etc/etcd/etcd.conf /etc/etcd/etcd.conf.bak
cd /etc/etcd/
sed -i 's/#ETCD_LISTEN_PEER_URLS="http://localhost:2380"/ETCD_LISTEN_PEER_URLS="http://10.0.0.30:2380"/' etcd.conf
sed -i 's/ETCD_LISTEN_CLIENT_URLS="http://localhost:2379"/ETCD_LISTEN_CLIENT_URLS="http://10.0.0.30:2379,http://127.0.0.1:2379"/' etcd.conf
sed -i 's/ETCD_NAME="default"/ETCD_NAME="Master"/' etcd.conf
sed -i 's/#ETCD_INITIAL_ADVERTISE_PEER_URLS="http://localhost:2380"/ETCD_INITIAL_ADVERTISE_PEER_URLS="http://10.0.0.30:2380"/' etcd.conf
sed -i 's/ETCD_ADVERTISE_CLIENT_URLS="http://localhost:2379"/ETCD_ADVERTISE_CLIENT_URLS="http://10.0.0.30:2379"/' etcd.conf
sed -i 's/#ETCD_INITIAL_CLUSTER="default=http://localhost:2380"/ETCD_INITIAL_CLUSTER="Master=http://10.0.0.30:2380,Node02=http://10.0.0.31:2380,Node03=http://10.0.0.32:2380"/' etcd.conf
sed -i 's/#ETCD_INITIAL_CLUSTER_TOKEN="etcd-cluster"/ETCD_INITIAL_CLUSTER_TOKEN="etcd-cluster"/' etcd.conf
sed -i 's/#ETCD_INITIAL_CLUSTER_STATE="new"/ETCD_INITIAL_CLUSTER_STATE="new"/' etcd.conf


systemctl start etcd
etcdctl member list

31

hostnamectl set-hostname P8-Etcd-Node02-Slave-01
#修改ip 10.0.0.31
cd /etc/sysconfig/network-scripts
sed -i '/.*BOOTPROTO=*/cBOOTPROTO="static"' ifcfg-ens33
sed -i '/.*IPADDR=*/cIPADDR=10.0.0.31' ifcfg-ens33
systemctl restart network


firewall-cmd --zone=public --add-port=2379/tcp --permanent
firewall-cmd --zone=public --add-port=2380/tcp --permanent
firewall-cmd --reload

yum install -y etcd
rpm -qa etcd
etcdctl -v



cp /etc/etcd/etcd.conf /etc/etcd/etcd.conf.bak
cd /etc/etcd/
sed -i 's/#ETCD_LISTEN_PEER_URLS="http://localhost:2380"/ETCD_LISTEN_PEER_URLS="http://10.0.0.31:2380"/' etcd.conf
sed -i 's/ETCD_LISTEN_CLIENT_URLS="http://localhost:2379"/ETCD_LISTEN_CLIENT_URLS="http://10.0.0.31:2379,http://127.0.0.1:2379"/' etcd.conf
sed -i 's/ETCD_NAME="default"/ETCD_NAME="Node02"/' etcd.conf
sed -i 's/#ETCD_INITIAL_ADVERTISE_PEER_URLS="http://localhost:2380"/ETCD_INITIAL_ADVERTISE_PEER_URLS="http://10.0.0.31:2380"/' etcd.conf
sed -i 's/ETCD_ADVERTISE_CLIENT_URLS="http://localhost:2379"/ETCD_ADVERTISE_CLIENT_URLS="http://10.0.0.31:2379"/' etcd.conf
sed -i 's/#ETCD_INITIAL_CLUSTER="default=http://localhost:2380"/ETCD_INITIAL_CLUSTER="Master=http://10.0.0.30:2380,Node02=http://10.0.0.31:2380,Node03=http://10.0.0.32:2380"/' etcd.conf
sed -i 's/#ETCD_INITIAL_CLUSTER_TOKEN="etcd-cluster"/ETCD_INITIAL_CLUSTER_TOKEN="etcd-cluster"/' etcd.conf
sed -i 's/#ETCD_INITIAL_CLUSTER_STATE="new"/ETCD_INITIAL_CLUSTER_STATE="new"/' etcd.conf

systemctl start etcd
etcdctl member list

32

hostnamectl set-hostname P8-Etcd-Node03-Slave-02
#修改ip 10.0.0.32
cd /etc/sysconfig/network-scripts
sed -i '/.*BOOTPROTO=*/cBOOTPROTO="static"' ifcfg-ens33
sed -i '/.*IPADDR=*/cIPADDR=10.0.0.32' ifcfg-ens33
systemctl restart network


firewall-cmd --zone=public --add-port=2379/tcp --permanent
firewall-cmd --zone=public --add-port=2380/tcp --permanent
firewall-cmd --reload


yum install -y etcd
rpm -qa etcd
etcdctl -v

cp /etc/etcd/etcd.conf /etc/etcd/etcd.conf.bak
cd /etc/etcd/
sed -i 's/#ETCD_LISTEN_PEER_URLS="http://localhost:2380"/ETCD_LISTEN_PEER_URLS="http://10.0.0.32:2380"/' etcd.conf
sed -i 's/ETCD_LISTEN_CLIENT_URLS="http://localhost:2379"/ETCD_LISTEN_CLIENT_URLS="http://10.0.0.32:2379,http://127.0.0.1:2379"/' etcd.conf
sed -i 's/ETCD_NAME="default"/ETCD_NAME="Node03"/' etcd.conf
sed -i 's/#ETCD_INITIAL_ADVERTISE_PEER_URLS="http://localhost:2380"/ETCD_INITIAL_ADVERTISE_PEER_URLS="http://10.0.0.32:2380"/' etcd.conf
sed -i 's/ETCD_ADVERTISE_CLIENT_URLS="http://localhost:2379"/ETCD_ADVERTISE_CLIENT_URLS="http://10.0.0.32:2379"/' etcd.conf
sed -i 's/#ETCD_INITIAL_CLUSTER="default=http://localhost:2380"/ETCD_INITIAL_CLUSTER="Master=http://10.0.0.30:2380,Node02=http://10.0.0.31:2380,Node03=http://10.0.0.32:2380"/' etcd.conf
sed -i 's/#ETCD_INITIAL_CLUSTER_TOKEN="etcd-cluster"/ETCD_INITIAL_CLUSTER_TOKEN="etcd-cluster"/' etcd.conf
sed -i 's/#ETCD_INITIAL_CLUSTER_STATE="new"/ETCD_INITIAL_CLUSTER_STATE="new"/' etcd.conf

systemctl start etcd
etcdctl member list

测试结果
一主一从
在这里插入图片描述

三个服务都启动了

Master停止后,从机重选
在这里插入图片描述

报错
配置文件逗号后面加了空格(习惯性的加空格,但是这里不支持)
/etc/etcd/etcd.conf
ETCD_LISTEN_CLIENT_URLS=“http://10.0.0.30:2379,http://127.0.0.1:2379”
ETCD_INITIAL_CLUSTER=“Master=http://10.0.0.30:2380,Node02=http://10.0.0.31:2380,Node03=http://10.0.0.32:2380”
在这里插入图片描述

[root@p8-etcd-node01-master etcd]# journalctl -xe
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- 
-- Unit etcd.service has begun starting up.
Jun 11 03:38:21 p8-etcd-node01-master etcd[7776]: recognized and used environment variable ETCD_ADVERTISE_CLIENT_URLS=http://10.0.0.30:2379
Jun 11 03:38:21 p8-etcd-node01-master etcd[7776]: recognized and used environment variable ETCD_INITIAL_ADVERTISE_PEER_URLS=http://10.0.0.30:2380
Jun 11 03:38:21 p8-etcd-node01-master etcd[7776]: recognized and used environment variable ETCD_INITIAL_CLUSTER=Master=http://10.0.0.30:2380,Node02=http://10.0.0.30:2380,Node03=http:/
Jun 11 03:38:21 p8-etcd-node01-master etcd[7776]: recognized and used environment variable ETCD_INITIAL_CLUSTER_STATE=new
Jun 11 03:38:21 p8-etcd-node01-master etcd[7776]: recognized and used environment variable ETCD_INITIAL_CLUSTER_TOKEN=etcd-cluster
Jun 11 03:38:21 p8-etcd-node01-master etcd[7776]: recognized and used environment variable ETCD_LISTEN_PEER_URLS=http://10.0.0.30:2380
Jun 11 03:38:21 p8-etcd-node01-master etcd[7776]: recognized environment variable ETCD_NAME, but unused: shadowed by corresponding flag
Jun 11 03:38:21 p8-etcd-node01-master etcd[7776]: recognized environment variable ETCD_DATA_DIR, but unused: shadowed by corresponding flag
Jun 11 03:38:21 p8-etcd-node01-master etcd[7776]: recognized environment variable ETCD_LISTEN_CLIENT_URLS, but unused: shadowed by corresponding flag
Jun 11 03:38:21 p8-etcd-node01-master etcd[7776]: etcd Version: 3.3.11
Jun 11 03:38:21 p8-etcd-node01-master etcd[7776]: Git SHA: 2cf9e51
Jun 11 03:38:21 p8-etcd-node01-master etcd[7776]: Go Version: go1.10.3
Jun 11 03:38:21 p8-etcd-node01-master etcd[7776]: Go OS/Arch: linux/amd64
Jun 11 03:38:21 p8-etcd-node01-master etcd[7776]: setting maximum number of CPUs to 4, total number of available CPUs is 4
Jun 11 03:38:21 p8-etcd-node01-master etcd[7776]: the server is already initialized as member before, starting as etcd member...
Jun 11 03:38:21 p8-etcd-node01-master etcd[7776]: listening for peers on http://10.0.0.30:2380
Jun 11 03:38:21 p8-etcd-node01-master etcd[7776]: listening for client requests on 10.0.0.30:2379
Jun 11 03:38:21 p8-etcd-node01-master etcd[7776]: listening for client requests on 127.0.0.1:2379
Jun 11 03:38:21 p8-etcd-node01-master etcd[7776]: initial cluster Master=http://10.0.0.30:2380,Node02=http://10.0.0.30:2380,Node03=http://10.0.0.30:2380 has duplicate url
Jun 11 03:38:21 p8-etcd-node01-master systemd[1]: etcd.service: main process exited, code=exited, status=1/FAILURE
Jun 11 03:38:21 p8-etcd-node01-master systemd[1]: Failed to start Etcd Server.
-- Subject: Unit etcd.service has failed
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- 
-- Unit etcd.service has failed.
-- 
-- The result is failed.
Jun 11 03:38:21 p8-etcd-node01-master systemd[1]: Unit etcd.service entered failed state.
Jun 11 03:38:21 p8-etcd-node01-master systemd[1]: etcd.service failed.
Jun 11 03:38:21 p8-etcd-node01-master systemd[1]: etcd.service holdoff time over, scheduling restart.
Jun 11 03:38:21 p8-etcd-node01-master systemd[1]: Stopped Etcd Server.
-- Subject: Unit etcd.service has finished shutting down
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- 
-- Unit etcd.service has finished shutting down.
Jun 11 03:38:21 p8-etcd-node01-master systemd[1]: start request repeated too quickly for etcd.service
Jun 11 03:38:21 p8-etcd-node01-master systemd[1]: Failed to start Etcd Server.
-- Subject: Unit etcd.service has failed
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- 
-- Unit etcd.service has failed.
-- 
-- The result is failed.
Jun 11 03:38:21 p8-etcd-node01-master systemd[1]: Unit etcd.service entered failed state.
Jun 11 03:38:21 p8-etcd-node01-master systemd[1]: etcd.service failed.

[root@p8-etcd-node01-master etcd]# 
[root@p8-etcd-node01-master etcd]# 
[root@p8-etcd-node01-master etcd]# sed -i 's/#ETCD_LISTEN_PEER_URLS="http://localhost:2380"/ETCD_LISTEN_PEER_URLS="http://10.0.0.30:2380"/' etcd.conf
etcd.conf
sed -i 's/ETCD_NAME="default"/ETCD_NAME="Master"/' etcd.conf
sed -i 's/#ETCD_INITIAL_ADVERTISE_PEER_URLS="http://localhost:2380"/ETCD_INITIAL_ADVERTISE_PEER_URLS="http://10.0.0.30:2380"/' etcd.conf
sed -i 's/ETCD_ADVERTISE_CLIENT_URLS="http:[root@p8-etcd-node01-master etcd]# sed -i 's/ETCD_LISTEN_CLIENT_URLS="http://localhost:2379"/ETCD_LISTEN_CLIENT_URLS="http://10.0.0.30:2379, http://127.0.0.1:2379"/' etcd.conf
[root@p8-etcd-node01-master etcd]# sed -i 's/ETCD_NAME="default"/ETCD_NAME="Master"/' etcd.conf
[root@p8-etcd-node01-master etcd]# sed -i 's/#ETCD_INITIAL_ADVERTISE_PEER_URLS="http://localhost:2380"/ETCD_INITIAL_ADVERTISE_PEER_URLS="http://10.0.0.30:2380"/' etcd.conf
[root@p8-etcd-node01-master etcd]# sed -i 's/ETCD_ADVERTISE_CLIENT_URLS="http://localhost:2379"/ETCD_ADVERTISE_CLIENT_URLS="http://10.0.0.30:2379"/' etcd.conf
[root@p8-etcd-node01-master etcd]# sed -i 's/#ETCD_INITIAL_CLUSTER="default=http://localhost:2380"/ETCD_INITIAL_CLUSTER="Master=http://10.0.0.30:2380, Node02=http://10.0.0.31:2380, Node03=http://10.0.0.32:2380"/' etcd.conf
[root@p8-etcd-node01-master etcd]# sed -i 's/#ETCD_INITIAL_CLUSTER_TOKEN="etcd-cluster"/ETCD_INITIAL_CLUSTER_TOKEN="etcd-cluster"/' etcd.conf
[root@p8-etcd-node01-master etcd]# sed -i 's/#ETCD_INITIAL_CLUSTER_STATE="new"/ETCD_INITIAL_CLUSTER_STATE="new"/' etcd.conf
[root@p8-etcd-node01-master etcd]# 
[root@p8-etcd-node01-master etcd]# 
[root@p8-etcd-node01-master etcd]# systemctl restart ectd
Failed to restart ectd.service: Unit not found.
[root@p8-etcd-node01-master etcd]# systemctl retart ectd
Unknown operation 'retart'.
[root@p8-etcd-node01-master etcd]# systemctl stop ectd
Failed to stop ectd.service: Unit ectd.service not loaded.
[root@p8-etcd-node01-master etcd]# systemctl start ectd
Failed to start ectd.service: Unit not found.
[root@p8-etcd-node01-master etcd]# systemctl start etcd





Job for etcd.service failed because a timeout was exceeded. See "systemctl status etcd.service" and "journalctl -xe" for details.
[root@p8-etcd-node01-master etcd]# 

最后

以上就是顺心飞机为你收集整理的Linux sed安装etcd集群的全部内容,希望文章能够帮你解决Linux sed安装etcd集群所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(43)

评论列表共有 0 条评论

立即
投稿
返回
顶部