GitHub地址:

https://github.com/apache/zookeeper

最新版本的 zookeeper 已经使用了 maven 进行管理了、不再需要安装 Ant

下载完成之后、使用 Idea 作为一个 maven 项目打开

拷贝配置文件

  • 拷贝zoo_sample.cfg文件至相同文件夹下,名为:zoo.cfg,配置全部使用默认;
  • 创建 /tmp/zookeeper 目录、用于存放 zk 数据.
  • 拷贝log4j.properties文件至:zookeeper-server/src/main/resources,文件名还是log4j.properties不变.
  • resource 标记为 Resources Root

增加启动项

找到类 org.apache.zookeeper.server.quorum.QuorumPeerMain

在参数中加上 conf/zoo.cfg

修改pom文件中scope

scope 注释掉

<dependency>
<groupId>io.dropwizard.metrics</groupId>
<artifactId>metrics-core</artifactId>
<version>3.1.0</version>
</dependency>
<dependency>
<groupId>org.xerial.snappy</groupId>
<artifactId>snappy-java</artifactId>
<version>1.1.7.3</version>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-server</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-servlet</artifactId>
</dependency>

执行server

执行 main 方法前建议执行命令 mvn clean install -DskipTests

2020-05-11 23:51:27,731 [myid:] - INFO  [main:NIOServerCnxnFactory@664] - binding to port 0.0.0.0/0.0.0.0:2181
2020-05-11 23:51:27,751 [myid:] - INFO [main:WatchManagerFactory@42] - Using org.apache.zookeeper.server.watch.WatchManager as watchmanager
2020-05-11 23:51:27,751 [myid:] - INFO [main:WatchManagerFactory@42] - Using org.apache.zookeeper.server.watch.WatchManager as watchmanager
2020-05-11 23:51:27,751 [myid:] - INFO [main:ZKDatabase@132] - zookeeper.snapshotSizeFactor = 0.33
2020-05-11 23:51:27,751 [myid:] - INFO [main:ZKDatabase@152] - zookeeper.commitLogCount=500
2020-05-11 23:51:27,757 [myid:] - INFO [main:SnapStream@61] - zookeeper.snapshot.compression.method = CHECKED
2020-05-11 23:51:27,759 [myid:] - INFO [main:FileSnap@85] - Reading snapshot /tmp/zookeeper/version-2/snapshot.3
2020-05-11 23:51:27,763 [myid:] - INFO [main:DataTree@1730] - The digest in the snapshot has digest version of 2, , with zxid as 0x3, and digest value as 1371985504
2020-05-11 23:51:27,774 [myid:] - INFO [main:FileTxnSnapLog@363] - 1 txns loaded in 5 ms
2020-05-11 23:51:27,774 [myid:] - INFO [main:ZKDatabase@289] - Snapshot loaded in 23 ms, highest zxid is 0x4, digest is 1371985504
2020-05-11 23:51:27,774 [myid:] - INFO [main:FileTxnSnapLog@470] - Snapshotting: 0x4 to /tmp/zookeeper/version-2/snapshot.4
2020-05-11 23:51:27,775 [myid:] - INFO [main:ZooKeeperServer@522] - Snapshot taken in 1 ms
2020-05-11 23:51:27,788 [myid:] - INFO [main:RequestThrottler@75] - zookeeper.request_throttler.shutdownTimeout = 10000
2020-05-11 23:51:27,802 [myid:] - INFO [main:ContainerManager@83] - Using checkIntervalMs=60000 maxPerMinute=10000 maxNeverUsedIntervalMs=0
2020-05-11 23:51:27,803 [myid:] - INFO [main:ZKAuditProvider@42] - ZooKeeper audit is disabled.
2020-05-11 23:51:58,403 [myid:] - INFO [SessionTracker:ZooKeeperServer@603] - Expiring session 0x100016819530000, timeout of 30000ms exceeded
2020-05-11 23:51:58,404 [myid:] - INFO [SessionTracker:ZooKeeperServer@603] - Expiring session 0x10001651fa70000, timeout of 30000ms exceeded
2020-05-11 23:51:58,407 [myid:] - INFO [SyncThread:0:FileTxnLog@284] - Creating new log file: log.5

启动成功

执行client

如 server 一般、配置入口类 org.apache.zookeeper.ZooKeeperMain

将下面的依赖的 scope 注释掉

<dependency>
<groupId>commons-cli</groupId>
<artifactId>commons-cli</artifactId>
</dependency>

启动

Welcome to ZooKeeper!JLine support is disabled
2020-05-11 23:54:50,732 [myid:localhost:2181] - INFO [main-SendThread(localhost:2181):ClientCnxn$SendThread@1169] - Opening socket connection to server localhost/127.0.0.1:2181.
2020-05-11 23:54:50,732 [myid:localhost:2181] - INFO [main-SendThread(localhost:2181):ClientCnxn$SendThread@1171] - SASL config status: Will not attempt to authenticate using SASL (unknown error)
2020-05-11 23:54:50,748 [myid:localhost:2181] - INFO [main-SendThread(localhost:2181):ClientCnxn$SendThread@1001] - Socket connection established, initiating session, client: /127.0.0.1:59060, server: localhost/127.0.0.1:2181
2020-05-11 23:54:50,769 [myid:localhost:2181] - INFO [main-SendThread(localhost:2181):ClientCnxn$SendThread@1436] - Session establishment complete on server localhost/127.0.0.1:2181, session id = 0x10001a019010000, negotiated timeout = 30000WATCHER::WatchedEvent state:SyncConnected type:None path:nullls /[zookeeper]ls /zookeeper[config, quota]

至此,已成功编译运行 zookeeper的源码

编译运行Zookeeper源码的更多相关文章

  1. 在win10上使用premake工具和vs2017编译运行Box2D源码和Testbed

    1.从github上下载Box2D源码的zip包 2.解压缩zip包 3.从premake网站下载premake5工具,解压后得到premake5.exe 4.将premake5.exe拷贝到Box2 ...

  2. 使用Shell脚本编译运行C++源码 输入输出重定向

    在写C++控制台程序的时,如果使用Xcode或者Visual Studio之类的IDE,需要创建许多工程,会造成很多不便.有时,采用Vim或者Sublime text等编辑器编写简单的控制台程序能节省 ...

  3. Zookeeper源码编译为Eclipse工程(转)

    原文地址:http://blog.csdn.net/jiyiqinlovexx/article/details/41179293 为了深入学习ZooKeeper源码,首先就想到将其导入到Eclispe ...

  4. Zookeeper源码编译为Eclipse工程(win7下Ant编译)

    前言 ZooKeeper是雅虎的.用Ant进行软件构建. 千里之行,始于足下.想看源码的第一步,是下载源码并导入某个IDE工具. Ant http://ant.apache.org/ Windows: ...

  5. 如何编译Zookeeper源码

    1. 安装Ant Ant下载地址:http://ant.apache.org/bindownload.cgi 解压即可. 2. 下载Zookeeper源码包 https://github.com/ap ...

  6. 使用ant编译zookeeper源码

    1. 安装Ant Ant下载地址:http://ant.apache.org/bindownload.cgi 解压即可. 注意如果不配置环境变量的话需要使用绝对路径,我配置了. 开始我ant跑错了 U ...

  7. Zookeeper源码用ant进行编译为eclipse工程--转载

    原文地址:http://www.it165.net/os/html/201411/10142.html Zookeeper GitHub的下载地址是:https://github.com/apache ...

  8. 【ZooKeeper系列】3.ZooKeeper源码环境搭建

    前文阅读: [ZooKeeper系列]1.ZooKeeper单机版.伪集群和集群环境搭建 [ZooKeeper系列]2.用Java实现ZooKeeper API的调用 在系列的前两篇文章中,介绍了Zo ...

  9. zookeeper源码分析之五服务端(集群leader)处理请求流程

    leader的实现类为LeaderZooKeeperServer,它间接继承自标准ZookeeperServer.它规定了请求到达leader时需要经历的路径: PrepRequestProcesso ...

随机推荐

  1. WALT(Window Assisted Load Tracking)学习

    QCOM平台使用WALT(Window Assisted Load Tracking)作为CPU load tracking的方法:相对地,ARM使用的是PELT(Per-Entity Load Tr ...

  2. golang内存逃逸

    golang程序变量会携带油一组校验数据,用来证明它的整个生命周期是否在运行时完全可知.如果变量通过了这些校验,它就可以在栈上分配.否则就说它逃逸了,必须在堆上分配     能引起变量逃逸到堆上的典型 ...

  3. (Java实现) 洛谷 P1091合唱队形

    题目描述 NN位同学站成一排,音乐老师要请其中的(N−K)位同学出列,使得剩下的KK位同学排成合唱队形. 合唱队形是指这样的一种队形:设K位同学从左到右依次编号为1,2,-,K1,2,-,K,他们的身 ...

  4. Java实现 LeetCode 628 三个数的最大乘积(暴力大法)

    628. 三个数的最大乘积 给定一个整型数组,在数组中找出由三个数组成的最大乘积,并输出这个乘积. 示例 1: 输入: [1,2,3] 输出: 6 示例 2: 输入: [1,2,3,4] 输出: 24 ...

  5. AWS 创建redis 集群模式遇到的问题

    问题描述 前几天在aws 平台创建了Redis 集群模式,但是链接集群的时候发现无法连接,返回信息超时. 通过参数组创建redis的时候提示报错:Replication group with spec ...

  6. MySQL 8.0权限认证(下)

    MySQL 8.0权限认证(下)   一.设置MySQL用户资源限制   通过设置全局变量max_user_connections可以限制所有用户在同一时间连接MySQL实例的数量,但此参数无法对每个 ...

  7. 实验三 Linux系统用户管理及VIM配置

    项目 内容 这个作业属于哪个课程 班级课程的主页链接 这个作业的要求在哪里 作业要求链接接地址 学号-姓名 17041428-朱槐健 作业学习目标  1.学习Linux系统用户管理 2.学习vim使用 ...

  8. cnblogs 博客爬取 + scrapy + 持久化 + 分布式

    目录 普通 scrapy 分布式爬取 cnblogs_spider.py 普通 scrapy # -*- coding: utf-8 -*- import scrapy from ..items im ...

  9. jQuery实现拖拽元素

    <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title> ...

  10. 2个线程A-B-A-B或者B-A-B-A循环输出

    代码: /** * 两个线程循环打印输出a-b-a-b */ public class AandBforTOthread { private static Object o = new Object( ...