栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 前沿技术 > 大数据 > 大数据系统

vertx zookeeper集群

vertx zookeeper集群

一、zk安装参考

zookeeper之二:手把手教你安装zookeeper3.7.0(绝对实用) - 北漂程序员 - 博客园前面分享了zookeeper的基本知识,下面分享有关zookeeper安装的知识。 1、下载 zookeeper的官网是:https://zookeeper.apache.org/ 在官网上找到下载链https://www.cnblogs.com/teach/p/14852801.html二、vertx zookeeper集群

1、添加vertx-zookeeper依赖


 io.vertx
 vertx-zookeeper
 4.2.4

Vert.x 集群管理器包含以下几个功能:

发现并管理集群中的节点

管理集群端的主题订阅清单(这样就可以轻松得知集群中的那些节点订阅了那些 EventBus 地址)

分布式 Map 支持

分布式锁

分布式计数器

Vert.x 集群器并不处理节点之间的通信,在 Vert.x 中节点中的通信是直接由 TCP 链接处理的。

2、使用ZookeeperClusterManager

zk配置方式:

         a、 通过编程方式指定(代码实例如下)

         b、在 classpath 中添加一个 zookeeper.json 文件

        c、启动参数增加

-Dvertx.zookeeper.config=./config/my-zookeeper-conf.json
 
JsonObject zkConfig = new JsonObject();
zkConfig.put("zookeeperHosts", "x.x.x.x");//zk地址
zkConfig.put("rootPath", "io.vertx");
zkConfig.put("retry", new JsonObject()
        .put("initialSleepTime", 3000)
        .put("maxTimes", 3));

ClusterManager mgr = new ZookeeperClusterManager(zkConfig);
VertxOptions options = new VertxOptions().setClusterManager(mgr);
Vertx.clusteredVertx(options, res -> {
    if (res.succeeded()) {
        Vertx vertx = res.result();
        EventBus eventBus = vertx.eventBus();
        System.out.println("We now have a clustered event bus: " + eventBus);
    } else {
        System.out.println("Failed: " + res.cause());
    }
});
参考vertx中文网站

https://vertx-china.github.io/docs/vertx-zookeeper/java/

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/741874.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号