You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@dubbo.apache.org by "kezhenxu94 (GitHub)" <gi...@apache.org> on 2019/03/22 11:22:18 UTC

[GitHub] [incubator-dubbo-admin] kezhenxu94 commented on issue #342: 如何配置dubbo.configcenter

@skyjilygao 就是在 ZK 上创建一个节点 `/dubbo/config/dubbo/dubbo.properties `, 并设置其内容为:

```
dubbo.registry.address=zookeeper://127.0.0.1:2181
dubbo.metadata-report.address=zookeeper://127.0.0.1:2181
```

项目第一次启动调试的时候, 如果 ZK 没有这个配置, 会看不到元数据, 可以在 `org.apache.dubbo.admin.config.ConfigCenter` 中添加以下代码来创建这个节点(也可以通过其他方式):

```java


    @PostConstruct
    public void init() throws Exception {
        CuratorFramework zkClient = CuratorFrameworkFactory.builder().
                connectString("127.0.0.1:2181").
                retryPolicy(new ExponentialBackoffRetry(1000, 3)).build();
        zkClient.start();

        if (zkClient.checkExists().forPath("/dubbo/config/dubbo/dubbo.properties") == null) {
            zkClient.create().creatingParentsIfNeeded().forPath("/dubbo/config/dubbo/dubbo.properties");
        }
        zkClient.setData().forPath("/dubbo/config/dubbo/dubbo.properties", ("dubbo.registry.address=zookeeper://127.0.0.1:2181\n" +
                "dubbo.metadata-report.address=zookeeper://127.0.0.1:2181").getBytes());
    }
```

类似这样:
![image](https://user-images.githubusercontent.com/15965696/54819704-b0d5ec00-4cd7-11e9-82d0-eb2d591be71a.png)

> 如果要提交 PR, 记得不要提交这段代码  :)

[ Full content available at: https://github.com/apache/incubator-dubbo-admin/issues/342 ]
This message was relayed via gitbox.apache.org for notifications@dubbo.apache.org