鍒嗗竷寮忎簨鍔$殑CAP鐞嗚

Posted SpringBoot

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了鍒嗗竷寮忎簨鍔$殑CAP鐞嗚相关的知识,希望对你有一定的参考价值。

鐩稿叧鍘嗗彶鏂囩珷锛?/strong>闃呰鏈枃涔嬪墠锛屾偍鍙兘闇€瑕佸厛鐪嬩笅涔嬪墠鐨勭郴鍒?/strong>馃憞锛?/strong>



鍓嶈█

       閫氳繃鍓嶉潰鐨勫涔狅紝鎴戜滑浜嗚В鍒颁簡鍒嗗竷寮忕殑鍩虹姒傚康锛屼笌鏈湴浜嬪姟涓嶅悓鐨勬槸锛屽垎甯冨紡绯荤粺涔嬫墍浠ュ彨鍒嗗竷寮忕郴缁燂紝鏄洜涓烘彁渚涙湇鍔$殑鑻ュ共涓妭鐐瑰垎甯冨湪涓嶅悓鏈哄櫒涓?/span>锛?/span>鐩镐簰涔嬮棿閫氳繃缃戠粶浜や簰锛屼笉鑳藉洜涓烘湁涓€鐐圭綉缁滈棶棰樺氨瀵艰嚧鏁翠釜绯荤粺鏃犳硶鎻愪緵鏈嶅姟锛岀綉缁滃洜绱犳垚涓轰簡鍒嗗竷寮忎簨鍔$殑鑰冮噺鏍囧噯涔嬩竴銆傚洜姝わ紝鍒嗗竷寮忎簨鍔¢渶瑕佽繘涓€姝ョ殑鐞嗚鍩虹锛屾帴涓嬫潵锛屾垜浠厛鏉ュ涔犱竴涓嬪垎甯冨紡浜嬪姟鐨?/span>CAP鐞嗚銆?/span>

       鍦ㄨ瑙e垎甯冨紡浜嬪姟浜嬪姟鎺у埗瑙e喅鏂规涔嬪墠闇€瑕佸厛瀛︿範涓€浜涘熀纭€鐞嗚锛岄€氳繃鐞嗚鐭ヨ瘑鎸囧鎴戜滑纭畾鍒嗗竷寮忎簨鍔℃帶鍒剁殑鐩爣锛屼粠鑰屽府鍔╂垜浠悊瑙f瘡涓В鍐虫柟妗堛€?/span>

 

涓€銆丆AP鐞嗚

       CAP鏄?/span>Consistency銆?/span>Avaliability銆?/span>Partitiontolerance涓変釜璇嶈鐨勭缉鍐欙紝鍒嗗埆琛ㄧず涓€鑷存€?/span>銆?/span>鍙敤鎬?/span>銆?/span>鍒嗗尯瀹瑰繊鎬?/span>銆?/span>

       涓轰簡鏂逛究瀵笴AP鐞嗚鐨勭悊瑙o紝鎴戜滑缁撳悎鐢靛晢绯荤粺涓殑涓€浜涗笟鍔″満鏅潵鐞嗚ВCAP锛屽涓嬪浘锛屾槸鍟嗗搧淇℃伅绠$悊鐨勬墽琛屾祦绋嬶細


鎵ц娴佺▼濡備笅锛?/span>

锛?锛夊晢鍝佽姹備富鏁版嵁搴撳啓鍏ュ晢鍝佷俊鎭紙娣诲姞鍟嗗搧銆佷慨鏀瑰晢鍝併€佸垹闄ゅ晢鍝侊級锛?/span>

锛?锛変富鏁版嵁搴撳悜鍟嗗搧鏈嶅姟鍝嶅簲鍐欏叆鎴愬姛锛?/span>

锛?锛夊晢鍝佹湇鍔¤姹備粠鏁版嵁搴撹鍙栧晢鍝佷俊鎭紱

 

1.1 C - 涓€鑷存€?/span>

       涓€鑷存€ф槸鍐欐搷浣滃悗鐨勮鎿嶄綔鍙互璇诲彇鍒?/span>鏈€鏂扮殑鏁版嵁鐘舵€?/span>锛屽綋鏁版嵁鍒嗗竷鍦ㄥ涓妭鐐规椂锛屼粠浠绘剰鑺傜偣璇诲彇鍒扮殑鏁版嵁閮芥槸鏈€鏂扮殑鐘舵€併€?/span>

       涓婂浘涓紝鍟嗗搧淇℃伅鐨勮鍐欒婊¤冻涓€鑷存€у氨鏄瀹炵幇濡備笅鐩爣锛?/span>

锛?锛夊晢鍝佹湇鍔″啓鍏ヤ富鏁版嵁搴撴垚鍔燂紝鍒欏悜浠庢暟鎹簱鏌ヨ鏂版暟鎹篃鎴愬姛銆?/span>

锛?锛夊晢鍝佹湇鍔″啓鍏ヤ富鏁版嵁搴撳け璐ワ紝鍒欏悜浠庢暟鎹簱鏌ヨ鏂版暟鎹篃澶辫触銆?/span>

       濡備綍瀹炵幇涓€鑷存€э紵

锛?锛夊啓鍏ヤ富鏁版嵁搴撳悗瑕佸皢鏁版嵁鍚屾鍒颁粠鏁版嵁搴撱€?/span>

锛?锛夊啓鍏ヤ富鏁版嵁搴撳悗锛屽湪鍚戜粠鏁版嵁搴撳悓姝ユ湡闂磋灏嗕粠鏁版嵁搴撻攣瀹氾紝寰呭悓姝ュ畬鎴愬悗鍐嶉噴鏀鹃攣锛屼互鍏嶅湪鏂版暟鎹簱鍐欏叆鎴愬姛鍚庯紝鍚戜粠鏁版嵁搴撴煡璇㈠埌鏃х殑鏁版嵁銆?/span>

       鍒嗗竷寮忎竴鑷存€х殑鐗圭偣锛?/span>

锛?锛夌敱浜庡瓨鍦ㄦ暟鎹悓姝ョ殑杩囩▼锛屽啓鎿嶄綔鐨勭浉搴斾細鏈変竴瀹氬欢杩熴€?/span>

锛?锛変负浜嗕繚璇佹暟鎹竴鑷存€т細瀵硅祫婧愭殏鏃堕攣瀹氾紝寰呮暟鎹悓姝ュ畬鎴愰噴鏀鹃攣瀹氳祫婧愩€?/span>

锛?锛夊鏋滆姹傛暟鎹悓姝ュけ璐ョ殑鑺傜偣鍒欎細杩斿洖閿欒淇℃伅锛屼竴瀹氫笉浼氳繑鍥炴棫淇℃伅銆?/span>

 

1.2 A 鈥?鍙敤鎬?/span>

       鍙敤鎬ф槸鎸?/span>浠讳綍浜嬪姟鎿嶄綔閮藉彲浠?/span>寰楀埌鐩稿簲缁撴灉锛屼笖涓嶄細鍑虹幇鍝嶅簲瓒呮椂鎴?/span>鍝嶅簲閿欒銆?/span>

       涓婂浘涓紝鍟嗗搧淇℃伅鐨勮鍙栬婊¤冻鍙敤鎬у氨鏄瀹炵幇濡備笅鐩爣锛?/span>

锛?锛変粠鏁版嵁搴撴帴鏀跺埌鏌ヨ鐨勮姹傚垯绔嬪嵆鑳藉鍝嶅簲鏁版嵁鏌ヨ缁撴灉銆?/span>

锛?锛変粠鏁版嵁搴撴煡璇笉鍏佽鍑虹幇鍝嶅簲瓒呮椂鎴栬€呭搷搴旈敊璇€?/span>

 

       濡備綍瀹炵幇鍙敤鎬э紵

锛?锛夊啓鍏ヤ富鏁版嵁搴撹灏嗘暟鎹悓姝ュ埌浠庢暟鎹簱銆?/span>

锛?锛夌敱浜庤淇濊瘉浠庢暟鎹簱鐨勫彲鐢ㄦ€э紝涓嶅彲灏嗕粠鏁版嵁搴撲腑鐨勮祫婧愰攣瀹氥€?/span>

锛?锛夊嵆鏃舵暟鎹繕娌℃湁鍚屾杩囨潵锛屼粠鏁版嵁搴撲篃瑕佽繑鍥炶鏌ヨ鐨勬暟鎹紝鍝€曟槸鏃ф暟鎹紝濡傛灉杩炴棫鏁版嵁涔熸病鏈夊垯鍙互鎸夌収绾﹀畾杩斿洖涓€涓粯璁や俊鎭紝浣嗕笉鑳借繑鍥為敊璇垨鐩稿簲瓒呮椂銆?/span>

       鍒嗗竷寮忕郴缁熷彲鐢ㄦ€х殑鐗圭偣锛?/span>

锛?锛夋墍鏈夎姹傞兘鏈夊搷搴旓紝涓斾笉浼氬嚭鐜板搷搴旇秴鏃舵垨鑰呭搷搴旈敊璇€?/span>

 

1.3 P 鈥?鍒嗗尯瀹瑰繊鎬?/span>

       閫氬父鍒嗗竷寮忕郴缁熺殑鍚勪釜鑺傜偣閮ㄧ讲鍦ㄤ笉鍚岀殑瀛愮綉锛岃繖灏辨槸缃戠粶鍒嗗尯锛屼笉鍙伩鍏嶇殑浼氬嚭鐜扮敱浜庣綉缁滈棶棰樿€屽鑷磋妭鐐逛箣闂撮€氫俊澶辫触锛屾鏃朵粛鍙澶栨彁渚涙湇鍔★紝杩欏彨鍒嗗尯瀹瑰繊鎬?/span>銆?/span>

       涓婂浘涓紝鍟嗗搧淇℃伅璇诲啓瑕佹弧瓒冲垎鍖哄蹇嶆€у氨鏄瀹炵幇濡備笅鐩爣锛?/span>

锛?锛変富鏁版嵁鍚戜粠鏁版嵁搴撳悓姝ユ暟鎹け璐ヤ笉褰卞搷璇诲啓鎿嶄綔銆?/span>

锛?锛変竴涓妭鐐规寕鎺変笉褰卞搷鍙︿竴涓妭鐐瑰澶栨彁渚涙湇鍔°€?/span>

       濡備綍瀹炵幇鍒嗗尯瀹瑰繊鎬э紵

锛?锛夊敖閲忎娇鐢ㄥ紓姝ュ彇浠e悓姝ユ搷浣滐紝渚嬪浣跨敤寮傛鏂瑰紡灏嗘暟鎹粠涓绘暟鎹簱鍚屾鍒颁粠鏁版嵁搴擄紝杩欐牱鑺傜偣涔嬮棿鏈夋晥鐨勫疄鐜版澗鑰﹀悎銆?/span>

锛?锛夋坊鍔犱粠鏁版嵁搴撹妭鐐癸紝鍏朵腑涓€涓妭鐐规寕鎺夊叾瀹冭妭鐐规彁渚涙湇鍔°€?/span>

       鍒嗗竷寮忓垎鍖哄蹇嶆€х殑鐗圭偣锛?/span>

锛?锛夊垎鍖哄蹇嶆€ф槸鍒嗗竷寮忕郴缁熷叿澶囩殑鍩烘湰鑳藉姏銆?/span>


浜屻€丆AP缁勫悎鏂瑰紡

       鍦ㄦ墍鏈夌殑鍒嗗竷寮忎簨鍔″満鏅腑涓嶄細鍚屾椂鍏峰CAP涓変釜鐗规€э紝鍥犱负鍦ㄥ叿澶囦簡P鐨勫墠鎻愪笅C鍜孉鏄笉鑳藉叡瀛樼殑銆?/span>

       涓嬪浘婊¤冻浜哖鍗宠〃绀哄疄鐜颁簡鍒嗗尯瀹瑰繊鎬э細

       鍒嗗尯瀹瑰繊鐨勫惈涔夛細

锛?锛変富鏁版嵁搴撻€氳繃缃戠粶鍚戜粠鏁版嵁搴撳悓姝ユ暟鎹紝鍙互璁や负涓讳粠鏁版嵁搴撻儴缃插湪涓嶅悓鐨勫垎鍖轰笂锛岄€氳繃缃戠粶杩涜浜や簰銆?/span>

锛?锛夊綋涓绘暟鎹簱鍜屼粠鏁版嵁搴撲箣闂寸殑缃戠粶鍑虹幇闂涓嶅奖鍝嶄富鏁版嵁搴撳拰浠庢暟鎹簱瀵瑰鎻愪緵鏈嶅姟銆?/span>

锛?锛夊叾涓€涓妭鐐规寕鎺変笉褰卞搷鍙︿竴涓妭鐐瑰澶栨彁渚涙湇鍔°€?/span>

       濡傛灉瑕?/span>瀹炵幇C鍒欏繀椤讳繚璇佹暟鎹竴鑷存€?/span>锛屽湪鏁版嵁鍚屾鐨勬椂鍊欎负闃叉鍚戜粠鏁版嵁搴撴煡璇㈢殑涓嶄竴鑷村垯闇€瑕佷粠鏁版嵁搴撻攣瀹氾紝寰呭畬鎴愬悓姝ヤ箣鍚庤В閿侊紝濡傛灉鍚屾澶辫触浠庢暟鎹簱瑕佽繑鍥?/span>閿欒淇℃伅鎴栬秴鏃朵俊鎭€?/span>

       濡傛灉瑕?/span>瀹炵幇A鍒欏繀椤讳繚璇佹暟鎹彲鐢ㄦ€?/span>锛屼笉绠′换浣曟椂鍊欓兘鍙互鍚戜粠鏁版嵁搴撹繘琛屾煡璇㈡暟鎹紝骞朵笖涓嶈兘澶熻繑鍥?/span>閿欒淇℃伅鎴栬€呰秴鏃朵俊鎭?/span>

       閫氳繃鍒嗘瀽鍦ㄦ弧瓒砅鐨勫墠鎻愪笅锛?/span>C鍜?/span>A瀛樺湪鐭涚浘銆?/span>

鎵€浠ュ湪鐢熶骇涓鍒嗗竷寮忎簨鍔″鐞嗘椂闇€瑕佹牴鎹渶姹傛潵纭畾婊¤冻CAP鐨?/span>鍝袱涓?/span>鏂归潰銆?/span>

 


1.1 CA缁勫悎

       CA缁勫悎灏辨槸淇濊瘉涓€鑷存€у拰鍙敤鎬?/span>锛?/span>鏀惧純鍒嗗尯瀹瑰繊鎬?/span>锛屽嵆涓嶈繘琛屽垎鍖猴紝涓嶈€冭檻鐢变簬缃戠粶涓嶉€氭垨鑺傜偣鎸傛帀鐨勯棶棰樸€傞偅涔堢郴缁熷皢涓嶆槸涓€涓爣鍑嗙殑鍒嗗竷寮忕郴缁燂紝鎴戜滑鏈€甯哥敤鐨勫叧绯诲瀷鏁版嵁搴?/span>灏辨弧瓒充簡CA銆?/span>

 

1.2 CP缁勫悎

       CP缁勫悎灏辨槸淇濊瘉涓€鑷存€у拰鍒嗗尯瀹瑰繊鎬?/span>锛?/span>鏀惧純鍙敤鎬?/span>銆?/span>Zookerper灏辨槸杩芥眰寮轰竴鑷存€э紝鏀惧純浜嗗彲鐢ㄦ€э紝杩樻湁璺ㄨ杞处锛屼竴娆¤浆璐﹁姹傝绛夊緟鍙屾柟閾惰绯荤粺閮藉畬鎴愭暣涓簨鍔℃墠鑳藉畬鎴愩€?/span>

1.3 AP缁勫悎

       AP缁勫悎灏辨槸淇濊瘉鍙敤鎬у拰鍒嗗尯瀹瑰繊鎬?/span>锛?/span>鏀惧純涓€鑷存€?/span>銆傝繖鏄垎甯冨紡绯荤粺璁捐鏃剁殑閫夋嫨銆?/span>

 

涓夈€佸皬缁?/span>

       閫氳繃涓婇潰鎴戜滑瀛︿範浜咰AP鐨勫熀纭€鐞嗚鐭ヨ瘑锛孋AP鏄竴涓凡缁忚瘉瀹炵殑鐞嗚锛氫竴涓垎甯冨紡绯荤粺鍋氬鍙兘婊¤冻CAP涓殑涓ら」锛屼负杈惧埌鑹ソ鐨勫搷搴旀€ц兘鏉ユ彁楂樼敤鎴蜂綋楠岋紝鍥犳涓€鑸細鍋氬嚭濡備笅閫夋嫨锛?/span>淇濊瘉A鍜孭锛岃垗寮僀寮轰竴鑷存€э紝淇濊瘉鏈€缁堜竴鑷存€?/span>銆?/span>


鍒嗗竷寮忎簨鍔¤В鍐虫柟妗?/span>銆屾墜鍐欎唬鐮併€嶏細http://t.cn/AieNUirK


鐐瑰嚮銆?/span>闃呰鍘熸枃銆?/span>锛屽揩浜轰竴姝ワ紝蹇€熷涔犲垎甯冨紡浜嬪姟锛?span class="mq-290"> 

以上是关于鍒嗗竷寮忎簨鍔$殑CAP鐞嗚的主要内容,如果未能解决你的问题,请参考以下文章

鍒嗗竷寮忎簨鍔?浜?

鍒嗗竷寮忎簨鍔′箣濡備綍鍩轰簬RocketMQ鐨勪簨鍔℃秷鎭壒鎬у疄鐜板垎甯冨紡绯荤粺鐨勬渶缁堜竴鑷存€э紵

鍒嗗竷寮忎腑鐨勪竴鑷存€х畻娉曚箣Raft绠楁硶

鍒嗗竷寮忕紦瀛樺涔犳€荤粨

redis setnx 鍒嗗竷寮忛攣

鍒嗗竷寮忓瓨鍌↖PFS鏁板瓧璧勪骇