生活随笔
收集整理的這篇文章主要介紹了
etcd v3 集群——简单配置
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
2019獨(dú)角獸企業(yè)重金招聘Python工程師標(biāo)準(zhǔn)>>>
一、etcd v3安裝:
tar -axf etcd-v3.2.0-linux-amd64.tar.gz -C /usr/local/src/ chmod a+x /usr/local/src/etcd-v3.2.0-linux-amd64/etcd* cp -a /usr/local/src/etcd-v3.2.0-linux-amd64/etcd* /usr/local/bin/
?
?
?
#如果不設(shè)置 ETCDCTL_API=3,則默認(rèn)是的API版本是2
export ETCDCTL_API=3 echo 'export ETCDCTL_API=3' >> /etc/profile
二、集群配置:
??????? 單機(jī),雙點(diǎn),可根據(jù)實(shí)際情況修改端口
#node1
etcd -name perofu1 -debug \ -initial-advertise-peer-urls http://0.0.0.0:2380 \ -listen-peer-urls http://0.0.0.0:2380 \ -listen-client-urls http://0.0.0.0:2379 \ -advertise-client-urls http://0.0.0.0:2379 \ -initial-cluster-token etcd-cluster-1 \ -initial-cluster perofu1=http://0.0.0.0:2380,perofu2=http://0.0.0.0:4380 \ -initial-cluster-state new? >> /var/log/kubernetes/test-etcd.log 2>&1 &
#node2
etcd -name perofu2 -debug \ -initial-advertise-peer-urls http://0.0.0.0:4380 \ -listen-peer-urls http://0.0.0.0:4380 \ -listen-client-urls http://0.0.0.0:4379 \ -advertise-client-urls http://0.0.0.0:4379 \ -initial-cluster-token etcd-cluster-1 \ -initial-cluster perofu1=http://0.0.0.0:2380,perofu2=http://0.0.0.0:4380 \ -initial-cluster-state new? >> /var/log/kubernetes/test-etcd-1.log 2>&1 &
??????? 參數(shù)說明 :
● –data-dir 指定節(jié)點(diǎn)的數(shù)據(jù)存儲目錄,若不指定,則默認(rèn)是當(dāng)前目錄。這些數(shù)據(jù)包括節(jié)點(diǎn)ID,集群ID,集群初始化配置,Snapshot文件,若未指 定–wal-dir,還會存儲WAL文件 ● –wal-dir 指定節(jié)點(diǎn)的was文件存儲目錄,若指定了該參數(shù),wal文件會和其他數(shù)據(jù)文件分開存儲 ● –name 節(jié)點(diǎn)名稱 ● –initial-advertise-peer-urls 告知集群其他節(jié)點(diǎn)的URL,tcp 2380端口用于集群通信 ● –listen-peer-urls 監(jiān)聽URL,用于與其他節(jié)點(diǎn)通訊 ● –advertise-client-urls 告知客戶端的URL, 也就是服務(wù)的URL,tcp 2379端口用于監(jiān)聽客戶端請求 ● –initial-cluster-token 集群的ID ● –initial-cluster 集群中所有節(jié)點(diǎn) ● –initial-cluster-state 集群狀態(tài),new為新創(chuàng)建集群,existing為已存在的集群
三、實(shí)例:
[root@www ~]# curl -s http://192.168.0.211:2379/v2/machines http://0.0.0.0:2379, http://0.0.0.0:4379 [root@www ~]# [root@www ~]# etcdctl member list 25a7dd0a87b3530: name=perofu2 peerURLs=http://0.0.0.0:4380 clientURLs=http://0.0.0.0:4379 isLeader=false 2006f2ad47deea09: name=perofu1 peerURLs=http://0.0.0.0:2380 clientURLs=http://0.0.0.0:2379 isLeader=true [root@www ~]# [root@www ~]# etcdctl cluster-health member 25a7dd0a87b3530 is healthy: got healthy result from http://0.0.0.0:4379 member 2006f2ad47deea09 is healthy: got healthy result from http://0.0.0.0:2379 cluster is healthy
#設(shè)置key [root@www ~]# etcdctl --endpoints "http://127.0.0.1:2379" set api_server? http://192.168.0.211:8080 http://192.168.0.211:8080 [root@www ~]# [root@www ~]# etcdctl --endpoints "http://127.0.0.1:2379" get api_server http://192.168.0.211:8080 [root@www ~]# [root@www ~]# etcdctl --endpoints "http://127.0.0.1:4379" get api_serve rhttp://192.168.0.211:8080 [root@www ~]#
轉(zhuǎn)載于:https://my.oschina.net/fufangchun/blog/1499682
總結(jié)
以上是生活随笔 為你收集整理的etcd v3 集群——简单配置 的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
如果覺得生活随笔 網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔 推薦給好友。