etcd 入門教程

2021-07-25 19:37:30 字數 1759 閱讀 9429

etcd 是乙個分布式的key-value儲存系統,採用 raft 演算法選舉leader,保證集群資料不丟失。

2、解壓後,有etcd和etcdctl兩個執行檔案

用root使用者啟動etcd   ./etcd   --會在2379埠上監聽,2380埠上監聽集群訊息

3、基本操作

./etcdctl --version   --我的api版本是v2,v3的api和v2不同,有put等操作

./etcdctl ls -p /   --列出目錄下所有目錄或節點,-p引數會自動用/標識出節點還是目錄

./etcdctl set /p1/p2/v1 hello  --建立乙個節點,並給他乙個value

./etcdctl get /p1/p2/v1   --獲取乙個節點的value

還有mkdir rm update watch 等命令,還有--ttl 60, --recursive --consistent 獲取集群內最終一致值。

也可以通過url來操作

curl -s 192.168.56.102:2379/v2/keys/p1/p2/v1

4、集群搭建

在3臺機器上分別啟動3個例項。(啟動引數中,peer-urls是一組,client-url是一組,cluster是一組)

./etcd --name infra1 --initial-advertise-peer-urls \

--listen-peer-urls \

--listen-client-urls \

--advertise-client-urls \

--initial-cluster-token etcd-cluster-1 \

--initial-cluster infra1=,infra2=,infra3= \

--initial-cluster-state new

./etcd --name infra2 --initial-advertise-peer-urls \

--listen-peer-urls \

--listen-client-urls \

--advertise-client-urls \

--initial-cluster-token etcd-cluster-1 \

--initial-cluster infra1=,infra2=,infra3= \

--initial-cluster-state new

./etcd --name infra3 --initial-advertise-peer-urls \

--listen-peer-urls \

--listen-client-urls \

--advertise-client-urls \

--initial-cluster-token etcd-cluster-1 \

--initial-cluster infra1=,infra2=,infra3= \

--initial-cluster-state new    

5、驗證集群

5.1 在乙個節點設定了值之後,在其它節點上也可以查詢到。說明集群功能ok

5.2 ./etcdctl member list 列出集群內的成員以及他們當前的角色--是不是leader

5.3 ./etcdctl cluster-health 檢視每個節點的健康狀態

5.4 kill掉leader後,發現集群會重新選出新的leader

這篇blog中基本上翻譯了github官網的入門教程,寫的比較詳細。

CSS入門教程

css是 cascading style sheets 的簡稱,中文翻譯為 串接樣式表 也有人翻譯為 樣式表 css用以作為網頁的排版和風格設計,在web標準建站中,對css的熟悉和使用是相當重要的乙個內容。css的作用是彌補html的不足,讓網頁的設計更為靈活。這個文章只是為您介紹css的基礎應用...

CSS入門教程

css是 cascading style sheets 的簡稱,中文翻譯為 串接樣式表 也有人翻譯為 樣式表 css用以作為網頁的排版和風格設計,在web標準建站中,對css的熟悉和使用是相當重要的乙個內容。css的作用是彌補html的不足,讓網頁的設計更為靈活。這個文章只是為您介紹css的基礎應用...

Linux入門教程

linux下有兩種使用者 1.root使用者,提示符 2.普通使用者,提示符 在 etc目錄下有乙個inittab檔案,其中有一行配置 id 3 defualt 其中,數字3就代表一啟動進入字元終端,如果改為5則代表一啟動進入x window 修改口令 passwd 退出登入 exit 關閉機器 只...