{"id":178168,"date":"2020-05-10T09:49:02","date_gmt":"2020-05-10T01:49:02","guid":{"rendered":"https:\/\/lrxjmw.cn\/?p=178168"},"modified":"2020-04-26T09:49:36","modified_gmt":"2020-04-26T01:49:36","slug":"zookeeper-install-comfiguration","status":"publish","type":"post","link":"https:\/\/lrxjmw.cn\/zookeeper-install-comfiguration.html","title":{"rendered":"ZooKeeper \u5b89\u88c5\u914d\u7f6e\u5165\u95e8\u6559\u7a0b"},"content":{"rendered":"
\u5bfc\u8bfb<\/td>\n | ZooKeeper \u662f\u4e00\u4e2a\u5206\u5e03\u5f0f\u7684\uff0c\u5f00\u653e\u6e90\u7801\u7684\u5206\u5e03\u5f0f\u5e94\u7528\u7a0b\u5e8f\u534f\u540c\u670d\u52a1\u3002ZooKeeper \u7684\u8bbe\u8ba1\u76ee\u6807\u662f\u5c06\u90a3\u4e9b\u590d\u6742\u4e14\u5bb9\u6613\u51fa\u9519\u7684\u5206\u5e03\u5f0f\u4e00\u81f4\u6027\u670d\u52a1\u5c01\u88c5\u8d77\u6765\uff0c\u6784\u6210\u4e00\u4e2a\u9ad8\u6548\u53ef\u9760\u7684\u539f\u8bed\u96c6\uff0c\u5e76\u4ee5\u4e00\u7cfb\u5217\u7b80\u5355\u6613\u7528\u7684\u63a5\u53e3\u63d0\u4f9b\u7ed9\u7528\u6237\u4f7f\u7528\u3002<\/strong><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n ZooKeeper \u6700\u65e9\u8d77\u6e90\u4e8e\u96c5\u864e\u7814\u7a76\u9662\u7684\u4e00\u4e2a\u7814\u7a76\u5c0f\u7ec4\u3002\u5728\u5f53\u65f6\uff0c\u7814\u7a76\u4eba\u5458\u53d1\u73b0\uff0c\u5728\u96c5\u864e\u5185\u90e8\u5f88\u591a\u5927\u578b\u7cfb\u7edf\u57fa\u672c\u90fd\u9700\u8981\u4f9d\u8d56\u4e00\u4e2a\u7c7b\u4f3c\u7684\u7cfb\u7edf\u6765\u8fdb\u884c\u5206\u5e03\u5f0f\u534f\u540c\uff0c\u4f46\u662f\u8fd9\u4e9b\u7cfb\u7edf\u5f80\u5f80\u90fd\u5b58\u5728\u5206\u5e03\u5f0f\u5355\u70b9\u95ee\u9898\u3002<\/p>\n \u6240\u4ee5\uff0c\u96c5\u864e\u7684\u5f00\u53d1\u4eba\u5458\u5c31\u5f00\u53d1\u4e86\u4e00\u4e2a\u901a\u7528\u7684\u65e0\u5355\u70b9\u95ee\u9898\u7684\u5206\u5e03\u5f0f\u534f\u8c03\u6846\u67b6\uff0c\u8fd9\u5c31\u662f ZooKeeper\u3002ZooKeeper \u4e4b\u540e\u5728\u5f00\u6e90\u754c\u88ab\u5927\u91cf\u4f7f\u7528\uff0c\u4e0b\u9762\u5217\u51fa\u4e86 3 \u4e2a\u8457\u540d\u5f00\u6e90\u9879\u76ee\u662f\u5982\u4f55\u4f7f\u7528 ZooKeeper\uff1a<\/p>\n Hadoop\uff1a\u4f7f\u7528 ZooKeeper \u505a Namenode \u7684\u9ad8\u53ef\u7528\u3002 \u5f88\u591a\u5206\u5e03\u5f0f\u534f\u8c03\u670d\u52a1\u90fd\u53ef\u4ee5\u7528 ZooKeeper \u6765\u505a\uff0c\u5176\u4e2d\u5178\u578b\u5e94\u7528\u573a\u666f\u5982\u4e0b\uff1a<\/p>\n \u914d\u7f6e\u7ba1\u7406\uff08configuration management\uff09\uff1a\u5982\u679c\u6211\u4eec\u505a\u666e\u901a\u7684\u00a0Java\u00a0\u5e94\u7528\uff0c\u4e00\u822c\u914d\u7f6e\u9879\u5c31\u662f\u4e00\u4e2a\u672c\u5730\u7684\u914d\u7f6e\u6587\u4ef6\uff0c\u5982\u679c\u662f\u5fae\u670d\u52a1\u7cfb\u7edf\uff0c\u5404\u4e2a\u72ec\u7acb\u670d\u52a1\u90fd\u8981\u4f7f\u7528\u96c6\u4e2d\u5316\u7684\u914d\u7f6e\u7ba1\u7406\uff0c\u8fd9\u4e2a\u65f6\u5019\u5c31\u9700\u8981 ZooKeeper\u3002 ZooKeeper \u9002\u7528\u4e8e\u5b58\u50a8\u548c\u534f\u540c\u76f8\u5173\u7684\u5173\u952e\u6570\u636e\uff0c\u4e0d\u9002\u5408\u7528\u4e8e\u5927\u6570\u636e\u91cf\u5b58\u50a8\u3002\u5982\u679c\u8981\u5b58 KV \u6216\u8005\u5927\u91cf\u7684\u4e1a\u52a1\u6570\u636e\uff0c\u8fd8\u662f\u8981\u7528\u6570\u636e\u5e93\u6216\u8005\u5176\u4ed6 NoSql \u6765\u505a\u3002<\/p>\n \u4e3a\u4ec0\u4e48 ZooKeeper \u4e0d\u9002\u5408\u5927\u6570\u636e\u91cf\u5b58\u50a8\u5462\uff1f\u4e3b\u8981\u6709\u4ee5\u4e0b\u4e24\u4e2a\u539f\u56e0\uff1a<\/p>\n \u8bbe\u8ba1\u65b9\u9762\uff1aZooKeeper \u9700\u8981\u628a\u6240\u6709\u7684\u6570\u636e\uff08\u5b83\u7684 data tree\uff09\u52a0\u8f7d\u5230\u5185\u5b58\u4e2d\u3002\u8fd9\u5c31\u51b3\u5b9a\u4e86ZooKeeper \u5b58\u50a8\u7684\u6570\u636e\u91cf\u53d7\u5185\u5b58\u7684\u9650\u5236\u3002\u8fd9\u4e00\u70b9 ZooKeeper \u548c Redis \u6bd4\u8f83\u50cf\u3002\u4e00\u822c\u7684\u6570\u636e\u5e93\u7cfb\u7edf\u4f8b\u5982 MySQL\uff08\u4f7f\u7528 InnoDB \u5b58\u50a8\u5f15\u64ce\u7684\u8bdd\uff09\u53ef\u4ee5\u5b58\u50a8\u5927\u4e8e\u5185\u5b58\u7684\u6570\u636e\uff0c\u8fd9\u662f\u56e0\u4e3a InnoDB \u662f\u57fa\u4e8e B-Tree \u7684\u5b58\u50a8\u5f15\u64ce\u3002B-tree \u5b58\u50a8\u5f15\u64ce\u548c LSM \u5b58\u50a8\u5f15\u64ce\u90fd\u53ef\u4ee5\u5b58\u50a8\u5927\u4e8e\u5185\u5b58\u7684\u6570\u636e\u91cf\u3002 \u8981\u4f7f\u7528 ZooKeeper \u670d\u52a1\uff0c\u9996\u5148\u6211\u4eec\u7684\u5e94\u7528\u8981\u5f15\u5165 ZooKeeper \u7684\u5ba2\u6237\u7aef\u5e93\uff0c\u7136\u540e\u6211\u4eec\u5ba2\u6237\u7aef\u5e93\u548c ZooKeeper \u96c6\u7fa4\u6765\u8fdb\u884c\u7f51\u7edc\u901a\u4fe1\u6765\u4f7f\u7528 ZooKeeper \u7684\u670d\u52a1\uff0c\u672c\u8d28\u4e0a\u662f Client-Server \u7684\u67b6\u6784\uff0c\u6211\u4eec\u7684\u5e94\u7528\u4f5c\u4e3a\u4e00\u4e2a\u5ba2\u6237\u7aef\u6765\u8c03\u7528 ZooKeeper Server \u7aef\u7684\u670d\u52a1\u3002<\/p>\n <\/p>\n ZooKeeper\u670d\u52a1<\/strong><\/div>\n ZooKeeper\u5c42\u6b21\u6570\u636e\u6a21\u578b<\/p>\n <\/p>\n ZooKeeper \u7684\u6570\u636e\u6a21\u578b\u662f\u5c42\u6b21\u6a21\u578b\u3002\u5c42\u6b21\u6a21\u578b\u5e38\u89c1\u4e8e\u6587\u4ef6\u7cfb\u7edf\u3002\u5c42\u6b21\u6a21\u578b\u548c key-value \u6a21\u578b\u662f\u4e24\u79cd\u4e3b\u6d41\u7684\u6570\u636e\u6a21\u578b\u3002ZooKeeper \u4f7f\u7528\u6587\u4ef6\u7cfb\u7edf\u6a21\u578b\u4e3b\u8981\u57fa\u4e8e\u4ee5\u4e0b\u4e24\u70b9\u8003\u8651\uff1a<\/p>\n \u6587\u4ef6\u7cfb\u7edf\u7684\u6811\u5f62\u7ed3\u6784\u4fbf\u4e8e\u8868\u8fbe\u6570\u636e\u4e4b\u95f4\u7684\u5c42\u6b21\u5173\u7cfb\u3002 ZooKeeper \u7684\u5c42\u6b21\u6a21\u578b\u79f0\u4f5c data tree\u3002Data tree \u7684\u6bcf\u4e2a\u8282\u70b9\u53eb\u505a znode\u3002\u4e0d\u540c\u4e8e\u6587\u4ef6\u7cfb\u7edf\uff0c\u6bcf\u4e2a\u8282\u70b9\u90fd\u53ef\u4ee5\u4fdd\u5b58\u6570\u636e\u3002\u6bcf\u4e2a\u8282\u70b9\u90fd\u6709\u4e00\u4e2a\u7248\u672c(version)\uff0c\u7248\u672c\u4ece 0 \u5f00\u59cb\u8ba1\u6570\u3002<\/p>\n ZooKeeper\u5c42\u6b21\u6570\u636e\u6a21\u578b\u5b9e\u4f8b<\/p>\n <\/p>\n \u5982\u4e0a\u56fe\u6240\u793a\u7684 data tree \u4e2d\u6709\u4e24\u4e2a\u5b50\u6811\uff0c\u4e00\u4e2a\u7528\u4e8e\u5e94\u7528 1\uff08\/app1\uff09\u548c\u53e6\u4e00\u4e2a\u7528\u4e8e\u5e94\u7528 2\uff08\/app2\uff09\u3002<\/p>\n \u5e94\u7528 1 \u7684\u5b50\u6811\u5b9e\u73b0\u4e86\u4e00\u4e2a\u7b80\u5355\u7684\u7ec4\u6210\u5458\u534f\u8bae\uff1a\u6bcf\u4e2a\u5ba2\u6237\u7aef\u8fdb\u7a0b pi \u521b\u5efa\u4e00\u4e2a znode p_i \u5728 \/app1 \u4e0b\uff0c\u53ea\u8981 \/app1\/p_i \u5b58\u5728\u5c31\u4ee3\u8868\u8fdb\u7a0b pi \u5728\u6b63\u5e38\u8fd0\u884c\u3002<\/p>\n ZooKeeper \u5bf9\u5916\u63d0\u4f9b\u4e00\u4e2a\u7528\u6765\u8bbf\u95ee data tree\u7684\u7b80\u5316\u6587\u4ef6\u7cfb\u7edf API\uff1a<\/p>\n \u4f7f\u7528 UNIX \u98ce\u683c\u7684\u8def\u5f84\u540d\u6765\u5b9a\u4f4d znode,\u4f8b\u5982 \/A\/X \u8868\u793a znode A \u7684\u5b50\u8282\u70b9 X\u3002 \u4e00\u4e2a znode \u53ef\u4ee5\u662f\u6301\u4e45\u6027\u7684\uff0c\u4e5f\u53ef\u4ee5\u662f\u4e34\u65f6\u6027\u7684\uff0cznode \u8282\u70b9\u4e5f\u53ef\u4ee5\u662f\u987a\u5e8f\u6027\u7684\u3002\u6bcf\u4e00\u4e2a\u987a\u5e8f\u6027\u7684 znode \u5173\u8054\u4e00\u4e2a\u552f\u4e00\u7684\u5355\u8c03\u9012\u589e\u6574\u6570\uff0c\u56e0\u6b64 ZooKeeper \u4e3b\u8981\u6709\u4ee5\u4e0b 4 \u79cd znode\uff1a<\/p>\n |