Etcd是什麼

最近在把服務遷移到雲上(docker+k8s)的時候,發現k8s是基於etcd做分佈式資源管理的,etcd和zk在的核心都是做分佈式服務的註冊中心(統一資源配置),用法上略有不同。

從官網上來看:

ETCD:

etcd is a strongly consistent, distributed key-value store that provides a reliable way to store data that needs to be accessed by a distributed system or cluster of machines. It gracefully handles leader elections during network partitions and can tolerate machine failure, even in the leader node.

Applications of any complexity, from a simple web app to Kubernetes, can read data from and write data into etcd.

Your applications can read from and write data into etcd. A simple use case is storing database connection details or feature flags in etcd as key-value pairs. These values can be watched, allowing your app to reconfigure itself when they change. Advanced uses take advantage of etcd’s consistency guarantees to implement database leader elections or perform distributed locking across a cluster of workers.

etcd is open source, available on GitHub, and backed by the Cloud Native Computing Foundation.

etcd是爲一個需要被分佈式系統或集羣提供了強一致性分佈式鍵值數據庫,它優雅的處理了當出現網路阻斷也能容忍機器宕機(哪怕是leader結點)。

任何複雜度的應用,一個簡單的web界面到k8s,都可以在etcd上讀寫數據。

你的應用可以再etcd上讀寫數據。一個簡單的例子就是保存數據庫連接信息或者特殊的數據的鍵值在etcd上。這些值可以被監聽,當配置變化的時候你的app可以重新配置。適當的採用etcd的一致性優勢可以用來保證數據庫選舉或者對一組工作施加分佈式鎖。

ETCD提供https協議的的restful風格的接口,1000併發,選舉採用raft算法。

 

ZK:

Apache ZooKeeper is an effort to develop and maintain an open-source server which enables highly reliable distributed coordination.

ZK是一個致力於開發和維護一個開源高可用可信賴的分佈式一致服務。

ZK解決了一個痛點,在zk出來之前,大量不同形式的分佈式系統都有各自的分佈式同步工具,不同的配置中心,比較混亂而且難以維護。ZK用了一套簡單的接口實現了中心化的一致性服務。

ZKClient和ZKServer之間採用Socket連接(四層協議)

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章