etcd 集群搭建

2022-04-11 08:52:17 字數 4185 閱讀 3000

現有三颱機器 centos7 

node1 10.2.0.10

node2 10.2.0.11

node3 10.2.0.12

1 原始碼解壓命令列方式

變化的部分 --name 、host位址

2伺服器啟動方式

$cat /usr/lib/systemd/system/etcd.service

# 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=\"$\" --data-dir=\"$\" --listen-client-urls=\"$\"

"execstart=/bin/bash -c "

gomaxprocs=$(nproc) /home/install/etcd/etcd --name=\"$\" --data-dir=\"$\" --listen-client-urls=\"$\" --initial-advertise-peer-urls=\"$\" --listen-peer-urls=\"$\" --advertise-client-urls=\"$\" --initial-cluster-token=\"$\" --initial-cluster=\"$\" --initial-cluster-state=\"$\"

"#啟動指令碼

node2 node3 根據以上相應修改

備註 log檢視 為系統日誌 tail -500f /var/log/message

集群方式啟動後不能清除資料檔案,資料檔案在第一次啟動後生成,修改配置檔案後重新系統如果不清除資料檔案新配置不生效。

注意:etcd有要求,如果--listen-client-urls被設定了,那麼就必須同時設定--advertise-client-urls,所以即使設定和預設相同,也必須顯式設定 

原理說明參考

etcd集群搭建

etcd是一種以key value形式的分布式儲存。etcd配置 name etcd1 名稱各個節點都是唯一的 client 配置 listen client urls 監聽client advertise client urls client對外提供服務 peer配置 用於節點內部通訊 liste...

etcd集群搭建

centos 192.168.3.65 node 1 centos 192.168.3.66 node 2systemctl stop firewalldyum install etcd cp etc etcd etcd.conf etc etcd etcd.conf.bak192.168.3.65...

搭建etcd集群

etcdctl 報錯收集 啟動引數說明 物理機搭建set token token host 1 192.168.0.3 mac的ip 按情況替換 this ip 按情況替換 設定值 檢視值 etcdctl.exe endpoints endpoints put foo hello world etc...