涓轰粈涔堥潰璇曞畼鍠滄闂?ZooKeeper 鍩烘湰鍘熺悊锛?/h1> Posted 寮€鍙戣€呮妧鏈墠绾?/a>
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了涓轰粈涔堥潰璇曞畼鍠滄闂?ZooKeeper 鍩烘湰鍘熺悊锛?/h1>
相关的知识,希望对你有一定的参考价值。
鐐瑰嚮鈥?/span>寮€鍙戣€呮妧鏈墠绾?/span>鈥濓紝閫夋嫨鈥滄槦鏍囸煍濃€?/span>
璁╀竴閮ㄥ垎寮€鍙戣€呯湅鍒版湭鏉?/span>
鏉ユ簮锛歝nblogs.com/luxiaoxun/p/4887452.html
ZooKeeper 绠€浠?/span>
ZooKeeper鏄竴涓紑鏀炬簮鐮佺殑鍒嗗竷寮忓簲鐢ㄧ▼搴忓崗璋冩湇鍔★紝瀹冨寘鍚竴涓畝鍗曠殑鍘熻闆嗭紝鍒嗗竷寮忓簲鐢ㄧ▼搴忓彲浠ュ熀浜庡畠瀹炵幇鍚屾鏈嶅姟锛岄厤缃淮鎶ゅ拰鍛藉悕鏈嶅姟绛夈€?/span>
ZooKeeper 璁捐鐩殑
1. 鏈€缁堜竴鑷存€э細client涓嶈杩炴帴鍒板摢涓猄erver锛屽睍绀虹粰瀹冮兘鏄悓涓€涓鍥撅紝杩欐槸zookeeper鏈€閲嶈鐨勬€ц兘銆?/span>
2. 鍙潬鎬э細鍏锋湁绠€鍗曘€佸仴澹€佽壇濂界殑鎬ц兘锛屽鏋滄秷鎭痬琚埌涓€鍙版湇鍔″櫒鎺ュ彈锛岄偅涔堝畠灏嗚鎵€鏈夌殑鏈嶅姟鍣ㄦ帴鍙椼€?/span>
3. 瀹炴椂鎬э細Zookeeper淇濊瘉瀹㈡埛绔皢鍦ㄤ竴涓椂闂撮棿闅旇寖鍥村唴鑾峰緱鏈嶅姟鍣ㄧ殑鏇存柊淇℃伅锛屾垨鑰呮湇鍔″櫒澶辨晥鐨勪俊鎭€?/span>
浣嗙敱浜庣綉缁滃欢鏃剁瓑鍘熷洜锛孼ookeeper涓嶈兘淇濊瘉涓や釜瀹㈡埛绔兘鍚屾椂寰楀埌鍒氭洿鏂扮殑鏁版嵁锛屽鏋滈渶瑕佹渶鏂版暟鎹紝搴旇鍦ㄨ鏁版嵁涔嬪墠璋冪敤sync()鎺ュ彛銆?/span>
4. 绛夊緟鏃犲叧锛坵ait-free锛夛細鎱㈢殑鎴栬€呭け鏁堢殑client涓嶅緱骞查蹇€熺殑client鐨勮姹傦紝浣垮緱姣忎釜client閮借兘鏈夋晥鐨勭瓑寰呫€?/span>
5. 鍘熷瓙鎬э細鏇存柊鍙兘鎴愬姛鎴栬€呭け璐ワ紝娌℃湁涓棿鐘舵€併€?/span>
6. 椤哄簭鎬э細鍖呮嫭鍏ㄥ眬鏈夊簭鍜屽亸搴忎袱绉嶏細鍏ㄥ眬鏈夊簭鏄寚濡傛灉鍦ㄤ竴鍙版湇鍔″櫒涓婃秷鎭痑鍦ㄦ秷鎭痓鍓嶅彂甯冿紝鍒欏湪鎵€鏈塖erver涓婃秷鎭痑閮藉皢鍦ㄦ秷鎭痓鍓嶈鍙戝竷锛涘亸搴忔槸鎸囧鏋滀竴涓秷鎭痓鍦ㄦ秷鎭痑鍚庤鍚屼竴涓彂閫佽€呭彂甯冿紝a蹇呭皢鎺掑湪b鍓嶉潰銆?/span>
ZooKeeper鏁版嵁妯″瀷
Zookeeper浼氱淮鎶や竴涓叿鏈夊眰娆″叧绯荤殑鏁版嵁缁撴瀯锛屽畠闈炲父绫讳技浜庝竴涓爣鍑嗙殑鏂囦欢绯荤粺锛屽鍥炬墍绀猴細
Zookeeper杩欑鏁版嵁缁撴瀯鏈夊涓嬭繖浜涚壒鐐癸細
1锛夋瘡涓瓙鐩綍椤瑰NameService閮借绉颁綔涓簔node锛岃繖涓獄node鏄瀹冩墍鍦ㄧ殑璺緞鍞竴鏍囪瘑锛屽Server1杩欎釜znode鐨勬爣璇嗕负/NameService/Server1銆?/span>
2锛墇node鍙互鏈夊瓙鑺傜偣鐩綍锛屽苟涓旀瘡涓獄node鍙互瀛樺偍鏁版嵁锛屾敞鎰廍PHEMERAL锛堜复鏃剁殑锛夌被鍨嬬殑鐩綍鑺傜偣涓嶈兘鏈夊瓙鑺傜偣鐩綍銆?/span>
3锛墇node鏄湁鐗堟湰鐨勶紙version锛夛紝姣忎釜znode涓瓨鍌ㄧ殑鏁版嵁鍙互鏈夊涓増鏈紝涔熷氨鏄竴涓闂矾寰勪腑鍙互瀛樺偍澶氫唤鏁版嵁锛寁ersion鍙疯嚜鍔ㄥ鍔犮€?/span>
4锛墇node鐨勭被鍨嬶細
-
Persistent 鑺傜偣锛屼竴鏃﹁鍒涘缓锛屼究涓嶄細鎰忓涓㈠け锛屽嵆浣挎湇鍔″櫒鍏ㄩ儴閲嶅惎涔熶緷鐒跺瓨鍦ㄣ€傛瘡涓?Persist 鑺傜偣鍗冲彲鍖呭惈鏁版嵁锛屼篃鍙寘鍚瓙鑺傜偣銆?
-
Ephemeral 鑺傜偣锛屽湪鍒涘缓瀹冪殑瀹㈡埛绔笌鏈嶅姟鍣ㄩ棿鐨?Session 缁撴潫鏃惰嚜鍔ㄨ鍒犻櫎銆傛湇鍔″櫒閲嶅惎浼氬鑷?Session 缁撴潫锛屽洜姝?Ephemeral 绫诲瀷鐨?znode 姝ゆ椂涔熶細鑷姩鍒犻櫎銆?
-
Non-sequence 鑺傜偣锛屽涓鎴风鍚屾椂鍒涘缓鍚屼竴 Non-sequence 鑺傜偣鏃讹紝鍙湁涓€涓彲鍒涘缓鎴愬姛锛屽叾瀹冨寑澶辫触銆傚苟涓斿垱寤哄嚭鐨勮妭鐐瑰悕绉颁笌鍒涘缓鏃舵寚瀹氱殑鑺傜偣鍚嶅畬鍏ㄤ竴鏍枫€?
-
Sequence 鑺傜偣锛屽垱寤哄嚭鐨勮妭鐐瑰悕鍦ㄦ寚瀹氱殑鍚嶇О涔嬪悗甯︽湁10浣?0杩涘埗鏁扮殑搴忓彿銆傚涓鎴风鍒涘缓鍚屼竴鍚嶇О鐨勮妭鐐规椂锛岄兘鑳藉垱寤烘垚鍔燂紝鍙槸搴忓彿涓嶅悓銆?
5锛墇node鍙互琚洃鎺э紝鍖呮嫭杩欎釜鐩綍鑺傜偣涓瓨鍌ㄧ殑鏁版嵁鐨勪慨鏀癸紝瀛愯妭鐐圭洰褰曠殑鍙樺寲绛夛紝涓€鏃﹀彉鍖栧彲浠ラ€氱煡璁剧疆鐩戞帶鐨勫鎴风锛岃繖涓槸Zookeeper鐨勬牳蹇冪壒鎬э紝Zookeeper鐨勫緢澶氬姛鑳介兘鏄熀浜庤繖涓壒鎬у疄鐜扮殑銆?/span>
6锛塟XID锛氭瘡娆″Zookeeper鐨勭姸鎬佺殑鏀瑰彉閮戒細浜х敓涓€涓獄xid锛圸ooKeeper Transaction Id锛夛紝zxid鏄叏灞€鏈夊簭鐨勶紝濡傛灉zxid1灏忎簬zxid2锛屽垯zxid1鍦▃xid2涔嬪墠鍙戠敓銆?/span>
ZooKeeper Session
Client鍜孼ookeeper闆嗙兢寤虹珛杩炴帴锛屾暣涓猻ession鐘舵€佸彉鍖栧鍥炬墍绀猴細
濡傛灉Client鍥犱负Timeout鍜孼ookeeper Server澶卞幓杩炴帴锛宑lient澶勫湪CONNECTING鐘舵€侊紝浼氳嚜鍔ㄥ皾璇曞啀鍘昏繛鎺erver锛屽鏋滃湪session鏈夋晥鏈熷唴鍐嶆鎴愬姛杩炴帴鍒版煇涓猄erver锛屽垯鍥炲埌CONNECTED鐘舵€併€?/span>
娉ㄦ剰锛?/strong>濡傛灉鍥犱负缃戠粶鐘舵€佷笉濂斤紝client鍜孲erver澶卞幓鑱旂郴锛宑lient浼氬仠鐣欏湪褰撳墠鐘舵€侊紝浼氬皾璇曚富鍔ㄥ啀娆¤繛鎺ookeeper Server銆俢lient涓嶈兘瀹gО鑷繁鐨剆ession expired锛宻ession expired鏄敱Zookeeper Server鏉ュ喅瀹氱殑锛宑lient鍙互閫夋嫨鑷繁涓诲姩鍏抽棴session銆?/span>
ZooKeeper Watch
Zookeeper watch鏄竴绉嶇洃鍚€氱煡鏈哄埗銆俍ookeeper鎵€鏈夌殑璇绘搷浣済etData(), getChildren()鍜?exists()閮藉彲浠ヨ缃洃瑙?watch)锛岀洃瑙嗕簨浠跺彲浠ョ悊瑙d负涓€娆℃€х殑瑙﹀彂鍣?/span>
瀹樻柟瀹氫箟濡備笅锛?/span>
a watch event is one-time trigger, sent to the client that set the watch, whichoccurs when the data for which the watch was set changes銆?/p>
Watch鐨勪笁涓叧閿偣锛?/span>
-
锛堜竴娆℃€цЕ鍙戯級One-time trigger
褰撹缃洃瑙嗙殑鏁版嵁鍙戠敓鏀瑰彉鏃讹紝璇ョ洃瑙嗕簨浠朵細琚彂閫佸埌瀹㈡埛绔€?/span>
渚嬪锛屽鏋滃鎴风璋冪敤浜唃etData(/znode1, true) 骞朵笖绋嶅悗 /znode1 鑺傜偣涓婄殑鏁版嵁鍙戠敓浜嗘敼鍙樻垨鑰呰鍒犻櫎浜嗭紝瀹㈡埛绔皢浼氳幏鍙栧埌 /znode1 鍙戠敓鍙樺寲鐨勭洃瑙嗕簨浠讹紱
鑰屽鏋?/znode1 鍐嶄竴娆″彂鐢熶簡鍙樺寲锛岄櫎闈炲鎴风鍐嶆瀵?znode1 璁剧疆鐩戣锛屽惁鍒欏鎴风涓嶄細鏀跺埌浜嬩欢閫氱煡銆?br>
-
锛堝彂閫佽嚦瀹㈡埛绔級Sent to the client
Zookeeper瀹㈡埛绔拰鏈嶅姟绔槸閫氳繃 socket 杩涜閫氫俊鐨勶紝鐢变簬缃戠粶瀛樺湪鏁呴殰锛屾墍浠ョ洃瑙嗕簨浠跺緢鏈夊彲鑳戒笉浼氭垚鍔熷湴鍒拌揪瀹㈡埛绔紝鐩戣浜嬩欢鏄紓姝ュ彂閫佽嚦鐩戣鑰呯殑銆?/span>
Zookeeper 鏈韩鎻愪緵浜嗛『搴忎繚璇?ordering guarantee)锛氬嵆瀹㈡埛绔彧鏈夐鍏堢湅鍒颁簡鐩戣浜嬩欢鍚庯紝鎵嶄細鎰熺煡鍒板畠鎵€璁剧疆鐩戣鐨剒node鍙戠敓浜嗗彉鍖?a client will never see a change for which it has set a watch until it first sees the watch event)銆?/span>
缃戠粶寤惰繜鎴栬€呭叾浠栧洜绱犲彲鑳藉鑷翠笉鍚岀殑瀹㈡埛绔湪涓嶅悓鐨勬椂鍒绘劅鐭ユ煇涓€鐩戣浜嬩欢锛屼絾鏄笉鍚岀殑瀹㈡埛绔墍鐪嬪埌鐨勪竴鍒囧叿鏈変竴鑷寸殑椤哄簭銆?/span>
-
锛堣璁剧疆 watch 鐨勬暟鎹級The data for which the watch was set
杩欐剰鍛崇潃znode鑺傜偣鏈韩鍏锋湁涓嶅悓鐨勬敼鍙樻柟寮忋€備綘涔熷彲浠ユ兂璞?Zookeeper 缁存姢浜嗕袱鏉$洃瑙嗛摼琛細鏁版嵁鐩戣鍜屽瓙鑺傜偣鐩戣(data watches and child watches) getData() 鍜宔xists()璁剧疆鏁版嵁鐩戣锛実etChildren()璁剧疆瀛愯妭鐐圭洃瑙嗐€?/span>
鎴栬€呬綘涔熷彲浠ユ兂璞?Zookeeper 璁剧疆鐨勪笉鍚岀洃瑙嗚繑鍥炰笉鍚岀殑鏁版嵁锛実etData() 鍜?exists() 杩斿洖znode鑺傜偣鐨勭浉鍏充俊鎭紝鑰実etChildren() 杩斿洖瀛愯妭鐐瑰垪琛ㄣ€?/span>
鍥犳锛宻etData() 浼氳Е鍙戣缃湪鏌愪竴鑺傜偣涓婃墍璁剧疆鐨勬暟鎹洃瑙嗭紙鍋囧畾鏁版嵁璁剧疆鎴愬姛锛夛紝鑰屼竴娆℃垚鍔熺殑create() 鎿嶄綔鍒欎細鍑哄彂褰撳墠鑺傜偣涓婃墍璁剧疆鐨勬暟鎹洃瑙嗕互鍙婄埗鑺傜偣鐨勫瓙鑺傜偣鐩戣銆?/span>
涓€娆℃垚鍔熺殑 delete鎿嶄綔灏嗕細瑙﹀彂褰撳墠鑺傜偣鐨勬暟鎹洃瑙嗗拰瀛愯妭鐐圭洃瑙嗕簨浠讹紝鍚屾椂涔熶細瑙﹀彂璇ヨ妭鐐圭埗鑺傜偣鐨刢hild watch銆?/span>
Zookeeper 涓殑鐩戣鏄交閲忕骇鐨勶紝鍥犳瀹规槗璁剧疆銆佺淮鎶ゅ拰鍒嗗彂銆傚綋瀹㈡埛绔笌 Zookeeper 鏈嶅姟鍣ㄥけ鍘昏仈绯绘椂锛屽鎴风骞朵笉浼氭敹鍒扮洃瑙嗕簨浠剁殑閫氱煡锛屽彧鏈夊綋瀹㈡埛绔噸鏂拌繛鎺ュ悗锛岃嫢鍦ㄥ繀瑕佺殑鎯呭喌涓嬶紝浠ュ墠娉ㄥ唽鐨勭洃瑙嗕細閲嶆柊琚敞鍐屽苟瑙﹀彂锛屽浜庡紑鍙戜汉鍛樻潵璇磋繖閫氬父鏄€忔槑鐨勩€?/span>
鍙湁涓€绉嶆儏鍐典細瀵艰嚧鐩戣浜嬩欢鐨勪涪澶憋紝鍗筹細閫氳繃exists()璁剧疆浜嗘煇涓獄node鑺傜偣鐨勭洃瑙嗭紝浣嗘槸濡傛灉鏌愪釜瀹㈡埛绔湪姝node鑺傜偣琚垱寤哄拰鍒犻櫎鐨勬椂闂撮棿闅斿唴涓巣ookeeper鏈嶅姟鍣ㄥけ鍘讳簡鑱旂郴锛岃瀹㈡埛绔嵆浣跨◢鍚庨噸鏂拌繛鎺?zookeeper鏈嶅姟鍣ㄥ悗涔熷緱涓嶅埌浜嬩欢閫氱煡銆?/span>
Consistency Guarantees
Zookeeper鏄竴涓珮鏁堢殑銆佸彲鎵╁睍鐨勬湇鍔★紝read鍜寃rite鎿嶄綔閮借璁捐涓哄揩閫熺殑锛宺ead姣攚rite鎿嶄綔鏇村揩銆?/span>
椤哄簭涓€鑷存€э紙Sequential Consistency锛夛細浠庝竴涓鎴风鏉ョ殑鏇存柊璇锋眰浼氳椤哄簭鎵ц銆?/span>
鍘熷瓙鎬э紙Atomicity锛夛細鏇存柊瑕佷箞鎴愬姛瑕佷箞澶辫触锛屾病鏈夐儴鍒嗘垚鍔熺殑鎯呭喌銆?/span>
鍞竴鐨勭郴缁熼暅鍍忥紙Single System Image锛夛細鏃犺瀹㈡埛绔繛鎺ュ埌鍝釜Server锛岀湅鍒扮郴缁熼暅鍍忔槸涓€鑷寸殑銆?/span>
鍙潬鎬э紙Reliability锛夛細鏇存柊涓€鏃︽湁鏁堬紝鎸佺画鏈夋晥锛岀洿鍒拌瑕嗙洊銆?/span>
鏃堕棿绾匡紙Timeliness锛夛細淇濊瘉鍦ㄤ竴瀹氱殑鏃堕棿鍐呭悇涓鎴风鐪嬪埌鐨勭郴缁熶俊鎭槸涓€鑷寸殑銆?/span>
ZooKeeper鐨勫伐浣滃師鐞?/span>
鍦▃ookeeper鐨勯泦缇や腑锛屽悇涓妭鐐瑰叡鏈変笅闈?绉嶈鑹插拰4绉嶇姸鎬侊細
-
瑙掕壊锛?/strong>leader,follower,observer
鐘舵€侊細leading,following,observing,looking
Zookeeper鐨勬牳蹇冩槸鍘熷瓙骞挎挱锛岃繖涓満鍒朵繚璇佷簡鍚勪釜Server涔嬮棿鐨勫悓姝ャ€傚疄鐜拌繖涓満鍒剁殑鍗忚鍙仛Zab鍗忚锛圸ooKeeper Atomic Broadcast protocol锛夈€俍ab鍗忚鏈変袱绉嶆ā寮忥紝瀹冧滑鍒嗗埆鏄仮澶嶆ā寮忥紙Recovery閫変富锛夊拰骞挎挱妯″紡锛圔roadcast鍚屾锛夈€?/span>
褰撴湇鍔″惎鍔ㄦ垨鑰呭湪棰嗗鑰呭穿婧冨悗锛孼ab灏辫繘鍏ヤ簡鎭㈠妯″紡锛屽綋棰嗗鑰呰閫変妇鍑烘潵锛屼笖澶у鏁癝erver瀹屾垚浜嗗拰leader鐨勭姸鎬佸悓姝ヤ互鍚庯紝鎭㈠妯″紡灏辩粨鏉熶簡銆傜姸鎬佸悓姝ヤ繚璇佷簡leader鍜孲erver鍏锋湁鐩稿悓鐨勭郴缁熺姸鎬併€?/span>
涓轰簡淇濊瘉浜嬪姟鐨勯『搴忎竴鑷存€э紝zookeeper閲囩敤浜嗛€掑鐨勪簨鍔d鍙凤紙zxid锛夋潵鏍囪瘑浜嬪姟銆傛墍鏈夌殑鎻愯锛坧roposal锛夐兘鍦ㄨ鎻愬嚭鐨勬椂鍊欏姞涓婁簡zxid銆?/span>
瀹炵幇涓瓃xid鏄竴涓?4浣嶇殑鏁板瓧锛屽畠楂?2浣嶆槸epoch鐢ㄦ潵鏍囪瘑leader鍏崇郴鏄惁鏀瑰彉锛屾瘡娆′竴涓猯eader琚€夊嚭鏉ワ紝瀹冮兘浼氭湁涓€涓柊鐨別poch锛屾爣璇嗗綋鍓嶅睘浜庨偅涓猯eader鐨勭粺娌绘椂鏈熴€備綆32浣嶇敤浜庨€掑璁℃暟銆?/span>
姣忎釜Server鍦ㄥ伐浣滆繃绋嬩腑鏈?绉嶇姸鎬侊細
LOOKING锛?/strong>褰撳墠Server涓嶇煡閬搇eader鏄皝锛屾鍦ㄦ悳瀵汇€?/span>
LEADING锛?/strong>褰撳墠Server鍗充负閫変妇鍑烘潵鐨刲eader銆?/span>
FOLLOWING锛?/strong>leader宸茬粡閫変妇鍑烘潵锛屽綋鍓峉erver涓庝箣鍚屾銆?/span>
OBSERVING锛?/strong>observer鐨勮涓哄湪澶у鏁版儏鍐典笅涓巉ollower瀹屽叏涓€鑷达紝浣嗘槸浠栦滑涓嶅弬鍔犻€変妇鍜屾姇绁紝鑰屼粎浠呮帴鍙?observing)閫変妇鍜屾姇绁ㄧ殑缁撴灉銆?/span>
Leader Election
褰搇eader宕╂簝鎴栬€卨eader澶卞幓澶у鏁扮殑follower锛岃繖鏃跺€檢k杩涘叆鎭㈠妯″紡锛屾仮澶嶆ā寮忛渶瑕侀噸鏂伴€変妇鍑轰竴涓柊鐨刲eader锛岃鎵€鏈夌殑Server閮芥仮澶嶅埌涓€涓纭殑鐘舵€併€?/span>
Zk鐨勯€変妇绠楁硶鏈変袱绉嶏細涓€绉嶆槸鍩轰簬basic paxos瀹炵幇鐨勶紝鍙﹀涓€绉嶆槸鍩轰簬fast paxos绠楁硶瀹炵幇鐨勩€?/span>
绯荤粺榛樿鐨勯€変妇绠楁硶涓篺ast paxos銆傚厛浠嬬粛basic paxos娴佺▼锛?/span>
1. 閫変妇绾跨▼鐢卞綋鍓峉erver鍙戣捣閫変妇鐨勭嚎绋嬫媴浠伙紝鍏朵富瑕佸姛鑳芥槸瀵规姇绁ㄧ粨鏋滆繘琛岀粺璁★紝骞堕€夊嚭鎺ㄨ崘鐨凷erver锛?/span>
2. 閫変妇绾跨▼棣栧厛鍚戞墍鏈塖erver鍙戣捣涓€娆¤闂紙鍖呮嫭鑷繁锛夛紱
3. 閫変妇绾跨▼鏀跺埌鍥炲鍚庯紝楠岃瘉鏄惁鏄嚜宸卞彂璧风殑璇㈤棶锛堥獙璇亃xid鏄惁涓€鑷达級锛岀劧鍚庤幏鍙栧鏂圭殑id锛坢yid锛夛紝骞跺瓨鍌ㄥ埌褰撳墠璇㈤棶瀵硅薄鍒楄〃涓紝鏈€鍚庤幏鍙栧鏂规彁璁殑leader鐩稿叧淇℃伅锛坕d,zxid锛夛紝骞跺皢杩欎簺淇℃伅瀛樺偍鍒板綋娆¢€変妇鐨勬姇绁ㄨ褰曡〃涓紱
4. 鏀跺埌鎵€鏈塖erver鍥炲浠ュ悗锛屽氨璁$畻鍑簔xid鏈€澶х殑閭d釜Server锛屽苟灏嗚繖涓猄erver鐩稿叧淇℃伅璁剧疆鎴愪笅涓€娆¤鎶曠エ鐨凷erver锛?/span>
5. 绾跨▼灏嗗綋鍓峼xid鏈€澶х殑Server璁剧疆涓哄綋鍓峉erver瑕佹帹鑽愮殑Leader锛屽鏋滄鏃惰幏鑳滅殑Server鑾峰緱n/2 + 1鐨凷erver绁ㄦ暟锛岃缃綋鍓嶆帹鑽愮殑leader涓鸿幏鑳滅殑Server锛屽皢鏍规嵁鑾疯儨鐨凷erver鐩稿叧淇℃伅璁剧疆鑷繁鐨勭姸鎬侊紝鍚﹀垯锛岀户缁繖涓繃绋嬶紝鐩村埌leader琚€変妇鍑烘潵銆?/span>
閫氳繃娴佺▼鍒嗘瀽鎴戜滑鍙互寰楀嚭锛氳浣縇eader鑾峰緱澶氭暟Server鐨勬敮鎸侊紝鍒橲erver鎬绘暟蹇呴』鏄鏁?n+1锛屼笖瀛樻椿鐨凷erver鐨勬暟鐩笉寰楀皯浜巒+1.
姣忎釜Server鍚姩鍚庨兘浼氶噸澶嶄互涓婃祦绋嬨€傚湪鎭㈠妯″紡涓嬶紝濡傛灉鏄垰浠庡穿婧冪姸鎬佹仮澶嶇殑鎴栬€呭垰鍚姩鐨剆erver杩樹細浠庣鐩樺揩鐓т腑鎭㈠鏁版嵁鍜屼細璇濅俊鎭紝zk浼氳褰曚簨鍔℃棩蹇楀苟瀹氭湡杩涜蹇収锛屾柟渚垮湪鎭㈠鏃惰繘琛岀姸鎬佹仮澶嶃€?/span>
fast paxos娴佺▼鏄湪閫変妇杩囩▼涓紝鏌怱erver棣栧厛鍚戞墍鏈塖erver鎻愯鑷繁瑕佹垚涓簂eader锛屽綋鍏跺畠Server鏀跺埌鎻愯浠ュ悗锛岃В鍐砮poch鍜寊xid鐨勫啿绐侊紝骞舵帴鍙楀鏂圭殑鎻愯锛岀劧鍚庡悜瀵规柟鍙戦€佹帴鍙楁彁璁畬鎴愮殑娑堟伅锛岄噸澶嶈繖涓祦绋嬶紝鏈€鍚庝竴瀹氳兘閫変妇鍑篖eader銆?/span>
Leader宸ヤ綔娴佺▼
Leader涓昏鏈変笁涓姛鑳斤細
-
鎭㈠鏁版嵁锛?
-
缁存寔涓巉ollower鐨勫績璺筹紝鎺ユ敹follower璇锋眰骞跺垽鏂璮ollower鐨勮姹傛秷鎭被鍨嬶紱
-
follower鐨勬秷鎭被鍨嬩富瑕佹湁PING娑堟伅銆丷EQUEST娑堟伅銆丄CK娑堟伅銆丷EVALIDATE娑堟伅锛屾牴鎹笉鍚岀殑娑堟伅绫诲瀷锛岃繘琛屼笉鍚岀殑澶勭悊銆?
璇存槑锛?/strong>
PING娑堟伅鏄寚follower鐨勫績璺充俊鎭紱REQUEST娑堟伅鏄痜ollower鍙戦€佺殑鎻愯淇℃伅锛屽寘鎷啓璇锋眰鍙婂悓姝ヨ姹傦紱
ACK娑堟伅鏄痜ollower鐨勫鎻愯鐨勫洖澶嶏紝瓒呰繃鍗婃暟鐨刦ollower閫氳繃锛屽垯commit璇ユ彁璁紱
REVALIDATE娑堟伅鏄敤鏉ュ欢闀縎ESSION鏈夋晥鏃堕棿銆?/span>
Follower宸ヤ綔娴佺▼
Follower涓昏鏈夊洓涓姛鑳斤細
-
鍚慙eader鍙戦€佽姹傦紙PING娑堟伅銆丷EQUEST娑堟伅銆丄CK娑堟伅銆丷EVALIDATE娑堟伅锛夛紱
-
鎺ユ敹Leader娑堟伅骞惰繘琛屽鐞嗭紱
-
鎺ユ敹Client鐨勮姹傦紝濡傛灉涓哄啓璇锋眰锛屽彂閫佺粰Leader杩涜鎶曠エ锛?
-
杩斿洖Client缁撴灉銆?
Follower鐨勬秷鎭惊鐜鐞嗗涓嬪嚑绉嶆潵鑷狶eader鐨勬秷鎭細
-
PING娑堟伅锛氬績璺虫秷鎭?
-
PROPOSAL娑堟伅锛歀eader鍙戣捣鐨勬彁妗堬紝瑕佹眰Follower鎶曠エ
-
COMMIT娑堟伅锛氭湇鍔″櫒绔渶鏂颁竴娆℃彁妗堢殑淇℃伅
-
UPTODATE娑堟伅锛氳〃鏄庡悓姝ュ畬鎴?
-
REVALIDATE娑堟伅锛氭牴鎹甃eader鐨凴EVALIDATE缁撴灉锛屽叧闂緟revalidate鐨剆ession杩樻槸鍏佽鍏舵帴鍙楁秷鎭?
-
SYNC娑堟伅锛氳繑鍥濻YNC缁撴灉鍒板鎴风锛岃繖涓秷鎭渶鍒濈敱瀹㈡埛绔彂璧凤紝鐢ㄦ潵寮哄埗寰楀埌鏈€鏂扮殑鏇存柊銆?
Zab: Broadcasting State Updates
Zookeeper Server鎺ユ敹鍒颁竴娆equest锛屽鏋滄槸follower锛屼細杞彂缁檒eader锛孡eader鎵ц璇锋眰骞堕€氳繃Transaction鐨勫舰寮忓箍鎾繖娆℃墽琛屻€?/span>
Zookeeper闆嗙兢濡備綍鍐冲畾涓€涓猅ransaction鏄惁琚玞ommit鎵ц锛熼€氳繃鈥滀袱娈垫彁浜ゅ崗璁€濓紙a two-phase commit锛夛細
-
Leader缁欐墍鏈夌殑follower鍙戦€佷竴涓狿ROPOSAL娑堟伅銆?
-
涓€涓猣ollower鎺ユ敹鍒拌繖娆ROPOSAL娑堟伅锛屽啓鍒扮鐩橈紝鍙戦€佺粰leader涓€涓狝CK娑堟伅锛屽憡鐭ュ凡缁忔敹鍒般€?
-
褰揕eader鏀跺埌娉曞畾浜烘暟锛坬uorum锛夌殑follower鐨凙CK鏃跺€欙紝鍙戦€乧ommit娑堟伅鎵ц銆?
Zab鍗忚淇濊瘉锛?/span>
-
濡傛灉leader浠1鍜孴2鐨勯『搴忓箍鎾紝閭d箞鎵€鏈夌殑Server蹇呴』鍏堟墽琛孴1锛屽啀鎵цT2銆?
-
濡傛灉浠绘剰涓€涓猄erver浠1銆乀2鐨勯『搴廲ommit鎵ц锛屽叾浠栨墍鏈夌殑Server涔熷繀椤讳互T1銆乀2鐨勯『搴忔墽琛屻€?
鈥滀袱娈垫彁浜ゅ崗璁€濇渶澶х殑闂鏄鏋淟eader鍙戦€佷簡PROPOSAL娑堟伅鍚巆rash鎴栨殏鏃跺け鍘昏繛鎺ワ紝浼氬鑷存暣涓泦缇ゅ鍦ㄤ竴绉嶄笉纭畾鐨勭姸鎬侊紙follower涓嶇煡閬撹鏀惧純杩欐鎻愪氦杩樻槸鎵ц鎻愪氦锛夈€?/span>
Zookeeper杩欐椂浼氶€夊嚭鏂扮殑leader锛岃姹傚鐞嗕篃浼氱Щ鍒版柊鐨刲eader涓婏紝涓嶅悓鐨刲eader鐢变笉鍚岀殑epoch鏍囪瘑銆傚垏鎹eader鏃讹紝闇€瑕佽В鍐充笅闈袱涓棶棰橈細
1. Never forget delivered messages
Leader鍦–OMMIT鎶曢€掑埌浠讳綍涓€鍙癴ollower涔嬪墠crash锛屽彧鏈夊畠鑷繁commit浜嗐€傛柊Leader蹇呴』淇濊瘉杩欎釜浜嬪姟涔熷繀椤籧ommit銆?/span>
2. Let go of messages that are skipped
Leader浜х敓鏌愪釜proposal锛屼絾鏄湪crash涔嬪墠锛屾病鏈塮ollower鐪嬪埌杩欎釜proposal銆傝server鎭㈠鏃讹紝蹇呴』涓㈠純杩欎釜proposal銆?/span>
Zookeeper浼氬敖閲忎繚璇佷笉浼氬悓鏃舵湁2涓椿鍔ㄧ殑Leader锛屽洜涓?涓笉鍚岀殑Leader浼氬鑷撮泦缇ゅ鍦ㄤ竴绉嶄笉涓€鑷寸殑鐘舵€侊紝鎵€浠ab鍗忚鍚屾椂淇濊瘉锛?/span>
-
鍦ㄦ柊鐨刲eader骞挎挱Transaction涔嬪墠锛屽厛鍓峀eader commit鐨凾ransaction閮戒細鍏堟墽琛屻€?
-
鍦ㄤ换鎰忔椂鍒伙紝閮戒笉浼氭湁2涓猄erver鍚屾椂鏈夋硶瀹氫汉鏁帮紙quorum锛夌殑鏀寔鑰呫€?
杩欓噷鐨剄uorum鏄竴鍗婁互涓婄殑Server鏁扮洰锛岀‘鍒囩殑璇存槸鏈夋姇绁ㄦ潈鍔涚殑Server锛堜笉鍖呮嫭Observer锛夈€?
鎬荤粨
绠€鍗曚粙缁嶄簡Zookeeper鐨勫熀鏈師鐞嗭紝鏁版嵁妯″瀷锛孲ession锛學atch鏈哄埗锛屼竴鑷存€т繚璇侊紝Leader Election锛孡eader鍜孎ollower鐨勫伐浣滄祦绋嬪拰Zab鍗忚銆?/span>
--- END ---
鍦ㄨ繖閲岋紝鎴戜负澶у鍑嗗浜嗕竴浠?020骞存渶鏂版渶鍏ㄧ殑銆奐ava闈㈣瘯棰樺強绛旀V3.0銆嬶紝杩欏鐢靛瓙涔︽兜鐩栦簡璇稿鍚庣鎶€鏈爤鐨勯潰璇曢鍜岀瓟妗堬紝鐩镐俊鍙互甯姪澶у鍦ㄦ渶鐭殑鏃堕棿鍐呭涔燡ava鍚庣鐨勫ぇ澶氭暟闈㈣瘯棰橈紝浠庤€屾嬁鍒拌嚜宸卞績浠殑offer銆?
鎴簡寮犲浘锛屽ぇ瀹跺彲浠ヤ粩缁嗘煡鐪嬪乏杈圭殑鑿滃崟鏍忥紝瑕嗙洊鐨勭煡璇嗛潰鐪熺殑寰堝箍锛岃€屼笖璐ㄩ噺閮藉緢涓嶉敊銆?
璧勬枡鑾峰彇鏂规硶
鎵弿涓嬫柟浜岀淮鐮?/span>
鍚庡彴鍥炲鍏抽敭璇嶏細Java鏍稿績鏁寸悊
鍘嗗彶鎺ㄨ崘
鐐逛釜鍦ㄧ湅鍚?/span>
以上是关于涓轰粈涔堥潰璇曞畼鍠滄闂?ZooKeeper 鍩烘湰鍘熺悊锛?/h1>
Posted 寮€鍙戣€呮妧鏈墠绾?/a>
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了涓轰粈涔堥潰璇曞畼鍠滄闂?ZooKeeper 鍩烘湰鍘熺悊锛?/h1>
鐐瑰嚮鈥?/span>寮€鍙戣€呮妧鏈墠绾?/span>鈥濓紝閫夋嫨鈥滄槦鏍囸煍濃€?/span>
璁╀竴閮ㄥ垎寮€鍙戣€呯湅鍒版湭鏉?/span>
鏉ユ簮锛歝nblogs.com/luxiaoxun/p/4887452.html
ZooKeeper 绠€浠?/span>
ZooKeeper鏄竴涓紑鏀炬簮鐮佺殑鍒嗗竷寮忓簲鐢ㄧ▼搴忓崗璋冩湇鍔★紝瀹冨寘鍚竴涓畝鍗曠殑鍘熻闆嗭紝鍒嗗竷寮忓簲鐢ㄧ▼搴忓彲浠ュ熀浜庡畠瀹炵幇鍚屾鏈嶅姟锛岄厤缃淮鎶ゅ拰鍛藉悕鏈嶅姟绛夈€?/span>
ZooKeeper 璁捐鐩殑
1. 鏈€缁堜竴鑷存€э細client涓嶈杩炴帴鍒板摢涓猄erver锛屽睍绀虹粰瀹冮兘鏄悓涓€涓鍥撅紝杩欐槸zookeeper鏈€閲嶈鐨勬€ц兘銆?/span>
2. 鍙潬鎬э細鍏锋湁绠€鍗曘€佸仴澹€佽壇濂界殑鎬ц兘锛屽鏋滄秷鎭痬琚埌涓€鍙版湇鍔″櫒鎺ュ彈锛岄偅涔堝畠灏嗚鎵€鏈夌殑鏈嶅姟鍣ㄦ帴鍙椼€?/span>
ZooKeeper鏁版嵁妯″瀷
Zookeeper杩欑鏁版嵁缁撴瀯鏈夊涓嬭繖浜涚壒鐐癸細
-
Persistent 鑺傜偣锛屼竴鏃﹁鍒涘缓锛屼究涓嶄細鎰忓涓㈠け锛屽嵆浣挎湇鍔″櫒鍏ㄩ儴閲嶅惎涔熶緷鐒跺瓨鍦ㄣ€傛瘡涓?Persist 鑺傜偣鍗冲彲鍖呭惈鏁版嵁锛屼篃鍙寘鍚瓙鑺傜偣銆? -
Ephemeral 鑺傜偣锛屽湪鍒涘缓瀹冪殑瀹㈡埛绔笌鏈嶅姟鍣ㄩ棿鐨?Session 缁撴潫鏃惰嚜鍔ㄨ鍒犻櫎銆傛湇鍔″櫒閲嶅惎浼氬鑷?Session 缁撴潫锛屽洜姝?Ephemeral 绫诲瀷鐨?znode 姝ゆ椂涔熶細鑷姩鍒犻櫎銆? -
Non-sequence 鑺傜偣锛屽涓鎴风鍚屾椂鍒涘缓鍚屼竴 Non-sequence 鑺傜偣鏃讹紝鍙湁涓€涓彲鍒涘缓鎴愬姛锛屽叾瀹冨寑澶辫触銆傚苟涓斿垱寤哄嚭鐨勮妭鐐瑰悕绉颁笌鍒涘缓鏃舵寚瀹氱殑鑺傜偣鍚嶅畬鍏ㄤ竴鏍枫€? -
Sequence 鑺傜偣锛屽垱寤哄嚭鐨勮妭鐐瑰悕鍦ㄦ寚瀹氱殑鍚嶇О涔嬪悗甯︽湁10浣?0杩涘埗鏁扮殑搴忓彿銆傚涓鎴风鍒涘缓鍚屼竴鍚嶇О鐨勮妭鐐规椂锛岄兘鑳藉垱寤烘垚鍔燂紝鍙槸搴忓彿涓嶅悓銆?
ZooKeeper Session
ZooKeeper Watch
瀹樻柟瀹氫箟濡備笅锛?/span>
a watch event is one-time trigger, sent to the client that set the watch, whichoccurs when the data for which the watch was set changes銆?/p>
Watch鐨勪笁涓叧閿偣锛?/span>
-
锛堜竴娆℃€цЕ鍙戯級One-time trigger
-
锛堝彂閫佽嚦瀹㈡埛绔級Sent to the client
-
锛堣璁剧疆 watch 鐨勬暟鎹級The data for which the watch was set
Consistency Guarantees
Zookeeper鏄竴涓珮鏁堢殑銆佸彲鎵╁睍鐨勬湇鍔★紝read鍜寃rite鎿嶄綔閮借璁捐涓哄揩閫熺殑锛宺ead姣攚rite鎿嶄綔鏇村揩銆?/span>
椤哄簭涓€鑷存€э紙Sequential Consistency锛夛細浠庝竴涓鎴风鏉ョ殑鏇存柊璇锋眰浼氳椤哄簭鎵ц銆?/span>
鍘熷瓙鎬э紙Atomicity锛夛細鏇存柊瑕佷箞鎴愬姛瑕佷箞澶辫触锛屾病鏈夐儴鍒嗘垚鍔熺殑鎯呭喌銆?/span>
鍞竴鐨勭郴缁熼暅鍍忥紙Single System Image锛夛細鏃犺瀹㈡埛绔繛鎺ュ埌鍝釜Server锛岀湅鍒扮郴缁熼暅鍍忔槸涓€鑷寸殑銆?/span>
鍙潬鎬э紙Reliability锛夛細鏇存柊涓€鏃︽湁鏁堬紝鎸佺画鏈夋晥锛岀洿鍒拌瑕嗙洊銆?/span>
鏃堕棿绾匡紙Timeliness锛夛細淇濊瘉鍦ㄤ竴瀹氱殑鏃堕棿鍐呭悇涓鎴风鐪嬪埌鐨勭郴缁熶俊鎭槸涓€鑷寸殑銆?/span>
ZooKeeper鐨勫伐浣滃師鐞?/span>
-
瑙掕壊锛?/strong>leader,follower,observer 鐘舵€侊細leading,following,observing,looking
Zookeeper鐨勬牳蹇冩槸鍘熷瓙骞挎挱锛岃繖涓満鍒朵繚璇佷簡鍚勪釜Server涔嬮棿鐨勫悓姝ャ€傚疄鐜拌繖涓満鍒剁殑鍗忚鍙仛Zab鍗忚锛圸ooKeeper Atomic Broadcast protocol锛夈€俍ab鍗忚鏈変袱绉嶆ā寮忥紝瀹冧滑鍒嗗埆鏄仮澶嶆ā寮忥紙Recovery閫変富锛夊拰骞挎挱妯″紡锛圔roadcast鍚屾锛夈€?/span>
褰撴湇鍔″惎鍔ㄦ垨鑰呭湪棰嗗鑰呭穿婧冨悗锛孼ab灏辫繘鍏ヤ簡鎭㈠妯″紡锛屽綋棰嗗鑰呰閫変妇鍑烘潵锛屼笖澶у鏁癝erver瀹屾垚浜嗗拰leader鐨勭姸鎬佸悓姝ヤ互鍚庯紝鎭㈠妯″紡灏辩粨鏉熶簡銆傜姸鎬佸悓姝ヤ繚璇佷簡leader鍜孲erver鍏锋湁鐩稿悓鐨勭郴缁熺姸鎬併€?/span>
涓轰簡淇濊瘉浜嬪姟鐨勯『搴忎竴鑷存€э紝zookeeper閲囩敤浜嗛€掑鐨勪簨鍔d鍙凤紙zxid锛夋潵鏍囪瘑浜嬪姟銆傛墍鏈夌殑鎻愯锛坧roposal锛夐兘鍦ㄨ鎻愬嚭鐨勬椂鍊欏姞涓婁簡zxid銆?/span>
瀹炵幇涓瓃xid鏄竴涓?4浣嶇殑鏁板瓧锛屽畠楂?2浣嶆槸epoch鐢ㄦ潵鏍囪瘑leader鍏崇郴鏄惁鏀瑰彉锛屾瘡娆′竴涓猯eader琚€夊嚭鏉ワ紝瀹冮兘浼氭湁涓€涓柊鐨別poch锛屾爣璇嗗綋鍓嶅睘浜庨偅涓猯eader鐨勭粺娌绘椂鏈熴€備綆32浣嶇敤浜庨€掑璁℃暟銆?/span>
Leader Election
褰搇eader宕╂簝鎴栬€卨eader澶卞幓澶у鏁扮殑follower锛岃繖鏃跺€檢k杩涘叆鎭㈠妯″紡锛屾仮澶嶆ā寮忛渶瑕侀噸鏂伴€変妇鍑轰竴涓柊鐨刲eader锛岃鎵€鏈夌殑Server閮芥仮澶嶅埌涓€涓纭殑鐘舵€併€?/span>
Zk鐨勯€変妇绠楁硶鏈変袱绉嶏細涓€绉嶆槸鍩轰簬basic paxos瀹炵幇鐨勶紝鍙﹀涓€绉嶆槸鍩轰簬fast paxos绠楁硶瀹炵幇鐨勩€?/span>
Leader宸ヤ綔娴佺▼
Leader涓昏鏈変笁涓姛鑳斤細
-
鎭㈠鏁版嵁锛? -
缁存寔涓巉ollower鐨勫績璺筹紝鎺ユ敹follower璇锋眰骞跺垽鏂璮ollower鐨勮姹傛秷鎭被鍨嬶紱 -
follower鐨勬秷鎭被鍨嬩富瑕佹湁PING娑堟伅銆丷EQUEST娑堟伅銆丄CK娑堟伅銆丷EVALIDATE娑堟伅锛屾牴鎹笉鍚岀殑娑堟伅绫诲瀷锛岃繘琛屼笉鍚岀殑澶勭悊銆?
PING娑堟伅鏄寚follower鐨勫績璺充俊鎭紱REQUEST娑堟伅鏄痜ollower鍙戦€佺殑鎻愯淇℃伅锛屽寘鎷啓璇锋眰鍙婂悓姝ヨ姹傦紱
ACK娑堟伅鏄痜ollower鐨勫鎻愯鐨勫洖澶嶏紝瓒呰繃鍗婃暟鐨刦ollower閫氳繃锛屽垯commit璇ユ彁璁紱
REVALIDATE娑堟伅鏄敤鏉ュ欢闀縎ESSION鏈夋晥鏃堕棿銆?/span>
Follower宸ヤ綔娴佺▼
-
鍚慙eader鍙戦€佽姹傦紙PING娑堟伅銆丷EQUEST娑堟伅銆丄CK娑堟伅銆丷EVALIDATE娑堟伅锛夛紱 -
鎺ユ敹Leader娑堟伅骞惰繘琛屽鐞嗭紱 -
鎺ユ敹Client鐨勮姹傦紝濡傛灉涓哄啓璇锋眰锛屽彂閫佺粰Leader杩涜鎶曠エ锛? -
杩斿洖Client缁撴灉銆?
-
PING娑堟伅锛氬績璺虫秷鎭? -
PROPOSAL娑堟伅锛歀eader鍙戣捣鐨勬彁妗堬紝瑕佹眰Follower鎶曠エ -
COMMIT娑堟伅锛氭湇鍔″櫒绔渶鏂颁竴娆℃彁妗堢殑淇℃伅 -
UPTODATE娑堟伅锛氳〃鏄庡悓姝ュ畬鎴? -
REVALIDATE娑堟伅锛氭牴鎹甃eader鐨凴EVALIDATE缁撴灉锛屽叧闂緟revalidate鐨剆ession杩樻槸鍏佽鍏舵帴鍙楁秷鎭? -
SYNC娑堟伅锛氳繑鍥濻YNC缁撴灉鍒板鎴风锛岃繖涓秷鎭渶鍒濈敱瀹㈡埛绔彂璧凤紝鐢ㄦ潵寮哄埗寰楀埌鏈€鏂扮殑鏇存柊銆?
Zab: Broadcasting State Updates
Zookeeper Server鎺ユ敹鍒颁竴娆equest锛屽鏋滄槸follower锛屼細杞彂缁檒eader锛孡eader鎵ц璇锋眰骞堕€氳繃Transaction鐨勫舰寮忓箍鎾繖娆℃墽琛屻€?/span>
Zookeeper闆嗙兢濡備綍鍐冲畾涓€涓猅ransaction鏄惁琚玞ommit鎵ц锛熼€氳繃鈥滀袱娈垫彁浜ゅ崗璁€濓紙a two-phase commit锛夛細
-
Leader缁欐墍鏈夌殑follower鍙戦€佷竴涓狿ROPOSAL娑堟伅銆? -
涓€涓猣ollower鎺ユ敹鍒拌繖娆ROPOSAL娑堟伅锛屽啓鍒扮鐩橈紝鍙戦€佺粰leader涓€涓狝CK娑堟伅锛屽憡鐭ュ凡缁忔敹鍒般€? -
褰揕eader鏀跺埌娉曞畾浜烘暟锛坬uorum锛夌殑follower鐨凙CK鏃跺€欙紝鍙戦€乧ommit娑堟伅鎵ц銆?
-
濡傛灉leader浠1鍜孴2鐨勯『搴忓箍鎾紝閭d箞鎵€鏈夌殑Server蹇呴』鍏堟墽琛孴1锛屽啀鎵цT2銆? -
濡傛灉浠绘剰涓€涓猄erver浠1銆乀2鐨勯『搴廲ommit鎵ц锛屽叾浠栨墍鏈夌殑Server涔熷繀椤讳互T1銆乀2鐨勯『搴忔墽琛屻€?
-
鍦ㄦ柊鐨刲eader骞挎挱Transaction涔嬪墠锛屽厛鍓峀eader commit鐨凾ransaction閮戒細鍏堟墽琛屻€? -
鍦ㄤ换鎰忔椂鍒伙紝閮戒笉浼氭湁2涓猄erver鍚屾椂鏈夋硶瀹氫汉鏁帮紙quorum锛夌殑鏀寔鑰呫€?
杩欓噷鐨剄uorum鏄竴鍗婁互涓婄殑Server鏁扮洰锛岀‘鍒囩殑璇存槸鏈夋姇绁ㄦ潈鍔涚殑Server锛堜笉鍖呮嫭Observer锛夈€?
鎬荤粨
鍦ㄨ繖閲岋紝鎴戜负澶у鍑嗗浜嗕竴浠?020骞存渶鏂版渶鍏ㄧ殑銆奐ava闈㈣瘯棰樺強绛旀V3.0銆嬶紝杩欏鐢靛瓙涔︽兜鐩栦簡璇稿鍚庣鎶€鏈爤鐨勯潰璇曢鍜岀瓟妗堬紝鐩镐俊鍙互甯姪澶у鍦ㄦ渶鐭殑鏃堕棿鍐呭涔燡ava鍚庣鐨勫ぇ澶氭暟闈㈣瘯棰橈紝浠庤€屾嬁鍒拌嚜宸卞績浠殑offer銆?
鎴簡寮犲浘锛屽ぇ瀹跺彲浠ヤ粩缁嗘煡鐪嬪乏杈圭殑鑿滃崟鏍忥紝瑕嗙洊鐨勭煡璇嗛潰鐪熺殑寰堝箍锛岃€屼笖璐ㄩ噺閮藉緢涓嶉敊銆?
璧勬枡鑾峰彇鏂规硶
鎵弿涓嬫柟浜岀淮鐮?/span>
鍚庡彴鍥炲鍏抽敭璇嶏細Java鏍稿績鏁寸悊
鍘嗗彶鎺ㄨ崘
鐐逛釜鍦ㄧ湅鍚?/span>
鎵弿涓嬫柟浜岀淮鐮?/span>
鍚庡彴鍥炲鍏抽敭璇嶏細Java鏍稿績鏁寸悊
以上是关于涓轰粈涔堥潰璇曞畼鍠滄闂?ZooKeeper 鍩烘湰鍘熺悊锛?/h1>