{"id":1786,"date":"2023-03-27T22:18:12","date_gmt":"2023-03-27T14:18:12","guid":{"rendered":"https:\/\/www.appblog.cn\/?p=1786"},"modified":"2023-04-23T21:15:42","modified_gmt":"2023-04-23T13:15:42","slug":"zookeeper-implements-distributed-locks","status":"publish","type":"post","link":"https:\/\/www.appblog.cn\/index.php\/2023\/03\/27\/zookeeper-implements-distributed-locks\/","title":{"rendered":"ZooKeeper\u5b9e\u73b0\u5206\u5e03\u5f0f\u9501"},"content":{"rendered":"<h2>\u4ec0\u4e48\u662f\u5206\u5e03\u5f0f\u9501<\/h2>\n<p>\u4ee5\u524d\u5728\u9879\u76ee\u8f83\u5c0f\u65f6\uff0c\u5355\u673a\u5373\u53ef\u5904\u7406\u5f88\u591a\u4e1a\u52a1\u3002\u4f46\u968f\u7740\u7528\u6237\u589e\u957f\uff0c\u5355\u673a\u5df2\u7ecf\u65e0\u6cd5\u6ee1\u8db3\u5f53\u4eca\u4e1a\u52a1\u3002\u89e3\u51b3\u65b9\u6848\u53ef\u80fd\u662f\u4e0a\u96c6\u7fa4\uff0c\u4f46\u662f\u5728\u591a\u4e2a JVM \u4e2d\u90fd\u6709\u540c\u4e00\u4e2a\u53d8\u91cf\u3002\u5047\u8bbe\u591a\u4e2a\u8bf7\u6c42\u5206\u5230\u4e0d\u540c\u7684 JVM \u4e2d\uff0c\u90fd\u5bf9\u53d8\u91cf\u8fdb\u884c\u4fee\u6539\uff0c\u8fd9\u5c31\u9020\u6210\u53d8\u91cf\u53ef\u80fd\u4f1a\u7684\u4e0d\u6b63\u786e\u3002<\/p>\n<p>\u4e3a\u4e86\u9632\u6b62\u5206\u5e03\u5f0f\u7cfb\u7edf\u4e2d\u7684\u591a\u4e2a\u8fdb\u7a0b\u4e4b\u95f4\u76f8\u4e92\u5e72\u6270\uff0c\u9700\u8981\u4e00\u4e2a\u5206\u5e03\u5f0f\u534f\u8c03\u6280\u672f\uff0c\u8fd9\u4e2a\u6280\u672f\u4fbf\u662f\u5206\u5e03\u5f0f\u9501\u3002<\/p>\n<p><!-- more --><\/p>\n<p>\u5206\u5e03\u5f0f\u9501\u548c\u6211\u4eec\u5e73\u5e38\u4f7f\u7528\u7684\u9501\u7c7b\u4f3c<\/p>\n<ul>\n<li>\u6392\u4ed6\uff0c\u53ea\u5141\u8bb8\u4e00\u4e2a\u7ebf\u7a0b\u5360\u7528<\/li>\n<li>\u53ef\u91cd\u5165\u6027\uff0c\u4e0d\u53ef\u91cd\u5165\u4f1a\u9020\u6210\u6b7b\u9501<\/li>\n<li>\u5177\u5907\u5931\u6548\u673a\u5236\uff0c\u4e07\u4e00\u6267\u884c\u8fc7\u7a0b\u5d29\u6e83\uff0c\u4e5f\u4f1a\u6709\u81ea\u52a8\u8fc7\u671f\u673a\u5236<\/li>\n<\/ul>\n<h2>ZooKeeper \u5206\u5e03\u5f0f\u9501\u539f\u7406<\/h2>\n<p><code>ZooKeeper<\/code>\u5b9e\u73b0\u5206\u5e03\u5f0f\u9501\u662f\u57fa\u4e8e<code>ZooKeeper<\/code>\u6570\u636e\u5b58\u50a8\u7ed3\u6784\uff0c<code>ZooKeeper<\/code>\u7684\u6570\u636e\u5b58\u50a8\u7ed3\u6784\u7c7b\u4f3c\u4e8e\u4e00\u68f5\u6811\u3002\u5176\u4e2d\u7684\u8282\u70b9\u53eb<code>Znode<\/code>\u3002<\/p>\n<p><code>Znode<\/code>\u6709\u56db\u79cd\u7c7b\u578b\uff0c\u5206\u522b\u4e3a<code>\u6301\u4e45\u8282\u70b9\uff08PERSISTENT\uff09<\/code>\u3001<code>\u6301\u4e45\u987a\u5e8f\u8282\u70b9\uff08PERSISTENT_SEQUENTIAL\uff09<\/code>\u3001<code>\u4e34\u65f6\u8282\u70b9\uff08EPHEMERAL\uff09<\/code>\u3001<code>\u4e34\u65f6\u987a\u5e8f\u8282\u70b9\uff08EPHEMERAL_SEQUENTIAL\uff09<\/code>\u3002<\/p>\n<p>\u800c<code>ZooKeeper<\/code>\u5b9e\u73b0\u5206\u5e03\u5f0f\u9501\u539f\u7406\u662f\u4f9d\u636e\u4e34\u65f6\u987a\u5e8f\u8282\u70b9<code>\uff08EPHEMERAL_SEQUENTIAL\uff09<\/code>\u6765\u5b9e\u73b0\u7684\u3002\u4e0b\u9762\u6211\u4eec\u6765\u5b66\u4e60\u4e00\u4e2a<code>ZooKeeper<\/code>\u662f\u5982\u4f55\u5229\u7528<strong>\u4e34\u65f6\u987a\u5e8f\u8282\u70b9<\/strong>\u5b9e\u73b0\u5206\u5e03\u5f0f\u9501\u7684\u3002<\/p>\n<p>\u9996\u5148\uff0c\u6211\u4eec\u521b\u5efa\u4e00\u4e2a\u6301\u4e45\u8282\u70b9<code>Lock<\/code>\uff0c\u5f53\u5ba2\u6237\u7aef\u60f3\u8981\u62ff\u5230\u9501\u65f6\uff0c\u9700\u8981\u521b\u5efa\u4e00\u4e2a\u4e34\u65f6\u8282\u70b9<code>lock1<\/code>\u3002<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/www.yezhou.me\/AppBlog\/images\/Java\/ZooKeeper\u5ba2\u6237\u7aef\u62ff\u9501.png\" alt=\"ZooKeeper\u5ba2\u6237\u7aef\u62ff\u9501\" \/><\/p>\n<p>\u8fd9\u6837\uff0c<code>client-1<\/code>\u521b\u5efa\u4e86\u4e34\u65f6\u8282\u70b9<code>lock1<\/code>\u5e76\u62ff\u5230\u4e86\u9501\u3002\u8fd9\u65f6\uff0c\u5047\u8bbe\u53c8\u6765\u4e86\u4e2a<code>client-2<\/code>\u60f3\u8981\u62ff\u9501\u3002<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/www.yezhou.me\/AppBlog\/images\/Java\/ZooKeeper\u9501\u88ab\u5360\u6709.png\" alt=\"ZooKeeper\u9501\u88ab\u5360\u6709\" \/><\/p>\n<p><code>client-2<\/code>\u4e5f\u5728<code>Lock<\/code>\u4e0b\u521b\u5efa\u4e86\u4e34\u65f6\u8282\u70b9<code>lock2<\/code>\uff0c\u904d\u5386<code>Lock<\/code>\u5224\u65ad\u81ea\u5df1\u7684<code>lock2<\/code>\u524d\u9762\u662f\u5426\u8fd8\u6709\u8282\u70b9\uff0c\u5982\u679c\u6ca1\u6709\uff0c\u8bf4\u660e\u81ea\u5df1\u662f\u7b2c\u4e00\u4e2a\uff0c\u5c31\u987a\u5229\u62ff\u9501\u3002\u5982\u679c\u6709\u5219\u8868\u660e\u9501\u88ab\u4eba\u62ff\u4e86\uff0c<code>client-2<\/code>\u5c06\u4f1a\u6ce8\u518c\u4e00\u4e2a<code>Watcher<\/code>\u53bb\u76d1\u542c<code>lock1<\/code>\u662f\u5426\u5b58\u5728\u3002<\/p>\n<p>\u8fd9\u65f6\uff0c\u53c8\u6765\u4e86\u4e00\u4e2a<code>client-3<\/code>\u60f3\u8981\u62ff\u9501\uff0c\u5728<code>Lock<\/code>\u4e0b\u521b\u5efa\u4e86\u4e00\u4e2a<code>lock3<\/code>\u8282\u70b9\uff0c\u7ed3\u679c\u4e5f\u53d1\u73b0\u81ea\u5df1\u4e0d\u662f\u6700\u524d\u9762\u7684\u4e00\u4e2a\u3002\u4fbf\u4f1a\u6ce8\u518c\u4e00\u4e2a<code>Watcher<\/code>\u53bb\u76d1\u542c\u4e0a\u4e00\u4e2a\u8282\u70b9\uff0c\u4e5f\u5c31\u662f<code>lock2<\/code>\u5224\u65ad\u5176\u662f\u5b58\u5728\u3002<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/www.yezhou.me\/AppBlog\/images\/Java\/ZooKeeper%20client-3\u62ff\u9501\u5931\u8d25.png\" alt=\"ZooKeeper client-3\u62ff\u9501\u5931\u8d25\" \/><\/p>\n<p><code>client-1<\/code>\u7684\u4e1a\u52a1\u6267\u884c\u5b8c\u6bd5\uff0c\u53ef\u4ee5\u91ca\u653e\u9501\u4e86\u3002\u6267\u884c\u5b8c\u6bd5\u540e\uff0c<code>client-1<\/code>\u8c03\u7528\u8282\u70b9\u5220\u9664\u7684\u6307\u4ee4\uff0c\u5c06\u4e34\u65f6\u8282\u70b9<code>lock1<\/code>\u5220\u9664\u3002<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/www.yezhou.me\/AppBlog\/images\/Java\/ZooKeeper%20client-1\u51c6\u5907\u91ca\u653e\u9501.png\" alt=\"ZooKeeper client-1\u51c6\u5907\u91ca\u653e\u9501\" \/><\/p>\n<p><img decoding=\"async\" src=\"http:\/\/www.yezhou.me\/AppBlog\/images\/Java\/ZooKeeper%20client-1\u91ca\u653e\u9501.png\" alt=\"ZooKeeper client-1\u91ca\u653e\u9501\" \/><\/p>\n<p>\u7531\u4e8e<code>client-2<\/code>\u4e00\u76f4\u5728\u76d1\u542c\u7740<code>lock1<\/code>\uff0c\u5f53<code>lock1<\/code>\u91ca\u653e\u9501\u5220\u9664\u8282\u70b9\u540e\uff0c\u987a\u7406\u6210\u7ae0\u7684\u62ff\u5230\u4e86\u9501\u3002\u800c<code>lock3<\/code>\u8fd8\u5728\u76d1\u542c\u7740<code>lock2<\/code>\uff0c\u7b49\u7740\u5b83\u91ca\u653e\u9501\u3002<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/www.yezhou.me\/AppBlog\/images\/Java\/ZooKeeper%20client-2\u62ff\u5230\u9501.png\" alt=\"ZooKeeper client-2\u62ff\u5230\u9501\" \/><\/p>\n<p>\u4e0a\u9762\u662f\u6b63\u5e38\u4e1a\u52a1\u6267\u884c\u5b8c\u6bd5\u7684\u60c5\u51b5\u4e0b\u91ca\u653e\u9501\u3002\u5047\u8bbe\uff0c\u6267\u884c\u5230\u4e2d\u9014\uff0c\u5ba2\u6237\u7aef\u5d29\u6e83\u4e86\uff0c\u4e0e<code>ZooKeeper<\/code>\u65ad\u5f00\u4e86\u8fde\u63a5\uff0c\u53c8\u4f1a\u5982\u4f55\u5462\uff1f<\/p>\n<p>\u4e34\u65f6\u8282\u70b9\u7684\u7279\u6027\uff1a<strong>\u4ec5\u5f53\u521b\u5efa\u8005\u4f1a\u8bdd\u6709\u6548\u65f6\u624d\u5f97\u4ee5\u4fdd\u5b58<\/strong>\uff0c\u5982\u679c\u5ba2\u6237\u7aef\u5d29\u6e83\u4e86\uff0c\u90a3\u521b\u5efa\u7684\u4f1a\u8bdd\u662f\u65e0\u6548\u7684\uff0c\u90a3\u6837\u4e0e\u5ba2\u6237\u7aef\u76f8\u5173\u8054\u7684\u8282\u70b9\u4e5f\u4f1a\u88ab\u5220\u9664\u3002<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/www.yezhou.me\/AppBlog\/images\/Java\/ZooKeeper%20client-2\u5d29\u6e83\u4e86.png\" alt=\"ZooKeeper client-2\u5d29\u6e83\u4e86\" \/><\/p>\n<p>\u76d1\u542c<code>lock2<\/code>\u7684\u5ba2\u6237\u7aef<code>client-3<\/code>\u53d1\u73b0\u8282\u70b9<code>lock2<\/code>\u88ab\u5220\u9664\uff0c\u90a3\u6837\u4ed6\u4e5f\u53ef\u4ee5\u62ff\u5230\u9501\u4e86\u3002<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/www.yezhou.me\/AppBlog\/images\/Java\/ZooKeeper%20client-3\u62ff\u5230\u9501.png\" alt=\"ZooKeeper client-3\u62ff\u5230\u9501\" \/><\/p>\n<p>\u6700\u540e\uff0c<code>client-3<\/code>\u4e5f\u91ca\u653e\u9501\uff0c\u6574\u4e2a\u5206\u5e03\u5f0f\u9501\u539f\u7406\u5c31\u8fd9\u6837\u7ed3\u675f\u4e86\u3002<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/www.yezhou.me\/AppBlog\/images\/Java\/ZooKeeper%20client-3\u91ca\u653e\u9501.png\" alt=\"ZooKeeper client-3\u91ca\u653e\u9501\" \/><\/p>\n<h2>\u4f7f\u7528 ZooKeeper \u5b9e\u73b0\u5206\u5e03\u5f0f\u9501<\/h2>\n<p>\u5b66\u4e60\u5b8c\u4e86<code>ZooKeeper<\/code>\u5206\u5e03\u5f0f\u9501\u539f\u7406\uff0c\u4e0b\u9762\u4eec\u6211\u4eec\u6765\u4f7f\u7528<code>ZooKeeper<\/code>\u5b9e\u73b0\u5b9e\u73b0\u5b9e\u73b0\u5206\u5e03\u5f0f\u9501\u3002\u4e3a\u4e86\u5feb\u901f\u793a\u4f8b\uff0c\u8fd9\u91cc\u4f7f\u7528<code>Spring Boot<\/code>\u6765\u8fdb\u884c\u7f16\u5199\u3002<\/p>\n<h3>\u4f9d\u8d56\u5305<\/h3>\n<pre><code class=\"language-xml\">&lt;dependency&gt;\n    &lt;groupId&gt;org.apache.curator&lt;\/groupId&gt;\n    &lt;artifactId&gt;curator-framework&lt;\/artifactId&gt;\n    &lt;version&gt;2.8.0&lt;\/version&gt;\n&lt;\/dependency&gt;\n &lt;dependency&gt;\n    &lt;groupId&gt;org.apache.curator&lt;\/groupId&gt;\n    &lt;artifactId&gt;curator-recipes&lt;\/artifactId&gt;\n    &lt;version&gt;2.8.0&lt;\/version&gt;\n&lt;\/dependency&gt;<\/code><\/pre>\n<h3>yml\u914d\u7f6e\u6587\u4ef6<\/h3>\n<pre><code>#zookeeper\u5730\u5740\nzookeeper.server=192.168.79.128:2181,192.168.79.128:2182,192.168.79.128:2183\n#\u9501\u6587\u4ef6\u8def\u5f84\nzookeeper.lockPath=\/springboot\/test\n#\u91cd\u8bd5\u95f4\u9694\u65f6\u95f4\nzookeeper.elapsedTimeMs=5000\n#session\u8d85\u65f6\u65f6\u95f4\nzookeeper.sessionTimeoutMs=60000\n#\u91cd\u8bd5\u6b21\u6570\nzookeeper.retryCount=5\n#\u8fde\u63a5\u8d85\u65f6\u65f6\u95f4\nzookeeper.connectionTimeoutMs=5000<\/code><\/pre>\n<h3>ZooKeeper\u914d\u7f6e<\/h3>\n<pre><code class=\"language-java\">@Component\n@ConfigurationProperties(prefix = &quot;zookeeper&quot;)\n@Data\npublic class ZookeeperProperties {\n    \/**\n     * zookeeper \u5730\u5740:ip\n     *\/\n    private String server;\n    \/**\n     * \u52a0\u9501\u8def\u5f84\n     *\/\n    private String lockPath;\n    \/**\n     * session\u8d85\u65f6\u65f6\u95f4\n     *\/\n    private Integer sessionTimeoutMs;\n    \/**\n     * \u8fde\u63a5\u8d85\u65f6\u65f6\u95f4\n     *\/\n    private Integer connectionTimeoutMs;\n    \/**\n     * \u91cd\u8bd5\u6b21\u6570\n     *\/\n    private Integer retryCount;\n    \/**\n     * \u91cd\u8bd5\u95f4\u9694\u65f6\u95f4\n     *\/\n    private  Integer elapsedTimeMs;\n}<\/code><\/pre>\n<pre><code class=\"language-java\">@Component\npublic class ZookeeperConfig {\n    @Autowired\n    ZookeeperProperties zookeeperProperties;\n\n    \/**\n     *  \u914d\u7f6e Zookeeper \u5ba2\u6237\u7aef\uff0c\u6784\u5efa\u8fde\u63a5\n     * @return CuratorFramework \u5bf9\u8c61\n     *\/\n    @Bean\n    public CuratorFramework curatorFramework() {\n        CuratorFramework curatorFramework = CuratorFrameworkFactory.newClient(\n                zookeeperProperties.getServer(),\n                zookeeperProperties.getSessionTimeoutMs(),\n                zookeeperProperties.getConnectionTimeoutMs(),\n                new RetryNTimes(zookeeperProperties.getRetryCount(), zookeeperProperties.getElapsedTimeMs()));\n        curatorFramework.start();\n        return curatorFramework;\n    }\n    \/**\n     * @param curatorFramework \u5206\u5e03\u5f0f\u9501\u5bf9\u8c61\n     * @return\n     *\/\n    @Bean\n    public InterProcessMutex interProcessMutex(CuratorFramework curatorFramework) {\n        return new InterProcessMutex(curatorFramework,zookeeperProperties.getLockPath());\n    }\n}<\/code><\/pre>\n<h3>\u4f7f\u7528\u6ce8\u89e3\u7684\u65b9\u5f0f\u8fdb\u884c\u89e3\u8026<\/h3>\n<pre><code class=\"language-java\">\/**\n * \u5206\u5e03\u5f0f\u505a\u6ce8\u89e3\n *\/\n@Target({ElementType.METHOD})\n@Retention(RetentionPolicy.RUNTIME)\n@Documented\npublic @interface LockAnnotation {\n    \/**\n     * @return \u9501\u7b49\u5f85\u65f6\u95f4\n     *\/\n    long time() default 20;\n    \/**\n     * \u65f6\u95f4\u7c7b\u578b \u53ef\u9009\u79d2\uff0c\u6beb\u79d2\uff0c\u65f6\u7b49\n     * @return\n     *\/\n    TimeUnit util() default TimeUnit.SECONDS;\n}<\/code><\/pre>\n<h3>AOP\u62e6\u622a\u5668<\/h3>\n<pre><code class=\"language-java\">\/**\n * \u5206\u5e03\u5f0f\u9501\u6ce8\u89e3\n *\/\n@Aspect\n@Order(5)\n@Component\npublic class LockIntercept {\n    @Autowired\n    private InterProcessMutex interProcessMutex;\n\n    @Around(&quot;@annotation(lockAnnotation)&quot;)\n    public void lockHandler(ProceedingJoinPoint joinPoint, LockAnnotation lockAnnotation ) {\n        \/\/\u5224\u65ad\u662f\u5426\u62ff\u5230\u9501\n        boolean acquire = false;\n        try {\n            \/\/\u81ea\u5b9a\u4e49\u65f6\u95f4\n            acquire = interProcessMutex.acquire(lockAnnotation.time(), lockAnnotation.util());\n            \/\/\u62ff\u9501\u6210\u529f\u5219\u8fdb\u884c\u4e1a\u52a1\n            if (acquire) {\n                Object proceed = joinPoint.proceed();\n            }\n        } catch (Throwable throwable) {\n            throwable.printStackTrace();\n        } finally {\n            \/\/\u62ff\u5230\u9501\u7684\u624d\u8fdb\u884c\u91ca\u653e\n            if (acquire) {\n                try {\n                    interProcessMutex.release();\n                } catch (Exception e) {\n                    e.printStackTrace();\n                }\n            }\n        }\n    }\n}<\/code><\/pre>\n<h3>\u4e1a\u52a1\u63a5\u53e3\u548c\u5b9e\u73b0\u7c7b<\/h3>\n<p>\u8fd9\u91cc\u7684\u4e1a\u52a1\u4ec5\u4ec5\u53ea\u505a\u4e00\u4e2a\u8ba1\u6570<\/p>\n<pre><code class=\"language-java\">public interface ZookeeperLockService {\n\n    \/**\n     * \u4e1a\u52a1\n     * @return\n     * @throws Exception\n     *\/\n    Boolean lockAcquireTimeOut() throws Exception;\n}<\/code><\/pre>\n<pre><code class=\"language-java\">@Service\npublic class ZookeeperLockServiceImpl implements ZookeeperLockService {\n\n    @Autowired\n    CuratorFramework curatorFramework;\n    \/**\n     * \u8ba1\u6570\n     *\/\n    int a =0;\n    \/**\n     * \u8ba1\u6570\u4e1a\u52a1\n     * @return false\n     *\/\n\n    @Override\n    \/\/\u5206\u5e03\u5f0f\u9501\u6ce8\u89e3\n    @LockAnnotation\n    public Boolean lockAcquireTimeOut() {\n        System.out.println(a++);\n        return false;\n    }\n}<\/code><\/pre>\n<h3>\u6d4b\u8bd5\u7c7b<\/h3>\n<pre><code class=\"language-java\">import org.junit.Test;\nimport org.junit.runner.RunWith;\nimport org.springframework.beans.factory.annotation.Autowired;\nimport org.springframework.boot.test.context.SpringBootTest;\nimport org.springframework.test.context.junit4.SpringRunner;\n\nimport java.util.concurrent.CountDownLatch;\nimport java.util.concurrent.ExecutorService;\nimport java.util.concurrent.Executors;\nimport java.util.concurrent.TimeUnit;\n\n@RunWith(SpringRunner.class)\n@SpringBootTest\npublic class GentleApplicationTests {\n\n    @Autowired\n    ZookeeperLockService zookeeperLockService;\n\n    \/**\n     * 200 \u4e2a\u7ebf\u7a0b\u6d4b\u8bd5\u5206\u5e03\u5f0f\u9501\n     * @throws InterruptedException\n     *\/\n    @Test\n    public void contextLoads() throws InterruptedException {\n        \/\/\u95ed\u9501\n        CountDownLatch countDownLatch = new CountDownLatch(200);\n        ExecutorService executorService = Executors.newCachedThreadPool();\n        \/\/200 \u4e2a\u7ebf\u7a0b\u8fdb\u884c\u6d4b\u8bd5\n        for (int i = 0; i &lt;200; i++) {\n            executorService.submit(() -&gt; {\n                try {\n                    \/\/\u8c03\u7528\u4e1a\u52a1\n                    zookeeperLockService.lockAcquireTimeOut();\n                } catch (Exception e) {\n                    e.printStackTrace();\n                }\n                countDownLatch.countDown();\n            });\n        }\n        \/\/\u7b49\u5f85\u5b8c\u6210\n        countDownLatch.await();\n    }\n}<\/code><\/pre>\n<p>\u6d4b\u8bd5\u7ed3\u679c\uff1a<\/p>\n<pre><code>191\n192\n193\n194\n195\n196\n197\n198\n199<\/code><\/pre>\n<h2>\u603b\u7ed3<\/h2>\n<p><code>ZooKeeper<\/code>\u5206\u5e03\u5f0f\u9501\u76f8\u5bf9\u6765\u8bf4\u8fd8\u662f\u6bd4\u8f83\u7b80\u5355\u7684\uff0c\u53ef\u80fd\u5728\u6027\u80fd\u65b9\u9762\u6bd4<code>Redis<\/code>\u5b9e\u73b0\u7684\u5206\u5e03\u5f0f\u9501\u8981\u5dee\u4e00\u4e9b\uff08\u9891\u7e41\u521b\u5efa\u548c\u5220\u9664\u8282\u70b9\uff09\uff0c\u4f46\u80dc\u5728<code>ZooKeeper<\/code>\u7684\u5b9e\u73b0\u6bd4\u8f83\u7b80\u5355\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4ec0\u4e48\u662f\u5206\u5e03\u5f0f\u9501 \u4ee5\u524d\u5728\u9879\u76ee\u8f83\u5c0f\u65f6\uff0c\u5355\u673a\u5373\u53ef\u5904\u7406\u5f88\u591a\u4e1a\u52a1\u3002\u4f46\u968f\u7740\u7528\u6237\u589e\u957f\uff0c\u5355\u673a\u5df2\u7ecf\u65e0\u6cd5\u6ee1\u8db3\u5f53\u4eca\u4e1a\u52a1\u3002\u89e3\u51b3\u65b9\u6848\u53ef\u80fd [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[189],"tags":[104],"class_list":["post-1786","post","type-post","status-publish","format-standard","hentry","category-zookeeper","tag-104"],"_links":{"self":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts\/1786","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/comments?post=1786"}],"version-history":[{"count":0,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts\/1786\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/media?parent=1786"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/categories?post=1786"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/tags?post=1786"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}