目录
- 参考链接
- 1. 下载源码
- 2. 准备更高版本的JDK和Maven环境
- Java 8
- Maven 3.6.3
- 3. 用IDEA打开项目进行编译和启动
- 3.1. 设置maven版本
- 3.2. 设置JDK版本为1.8
- 3.3. 切换 Maven profiles 选项到 java-build
- 3.4. 执行 Ant build 生成和编译Java文件
- 3.4.1. 执行`ant build-generated`而非`ant eclipse`
- 3.4.2. 对比构建前后项目多了什么
- 3.5. maven compile
- 3.6. 准备一个zoo.cfg配置文件
- 3.7. 配置classpath
- 3.8. 启动 QuorumPeerMain
- 4. 在命令行 cmd 中编译和启动
- 4.1. 安装 Ant
- 4.2. 使用 Ant 编译
- 4.3. 准备一个zoo.cfg配置文件
- 4.4. 执行 zkServer.cmd 脚本启动服务
参考链接
- Zookeeper GitHub 仓库
- Zookeeper3.5.9 官方参考手册
- Apache Ivy
- Apache Ivy 2.5.2 Reference
- Ant-Eclipse
- M2E-WTP
- OpenJdk 的发行版 Azul JDKs
1. 下载源码
用git克隆到本地
git clone https://github.com/apache/zookeeper.git
查找对应某个版本的标签,假设是 3.5.9 版本,则基于该版本创建一个本地分支
# 查找对应某个版本的标签
git tag | grep 3.5.9
## release-3.5.9
## release-3.5.9-rc0
## release-3.5.9-rc1
## release-3.5.9-rc2
# 基于标签创建本地分支
git branch myloc-release-3.5.9 release-3.5.9
# 切换到该分支
git checkout myloc-release-3.5.9
## Switched to branch 'myloc-release-3.5.9'
2. 准备更高版本的JDK和Maven环境
Java 8
打开 Zookeeper 仓库根目录下的 README.md 文件,查看其中内容,可能会明确地告知用户需要什么版本的 JDK,例如:
## Java 8 u211 或以上版本
If you are going to compile with Java 1.8, you should use a
recent release at u211 or above.
windows 系统用户可以考虑用 OpenJdk 的发行版 Azul JDKs代替 Oracle JDKs
Maven 3.6.3
Maven 3.6.3 这是我测试过程中稳定的版本,而当时用 InteliJ Idea 本身的 Maven 3 还是有些小问题,故在此特意提及。
3. 用IDEA打开项目进行编译和启动
3.1. 设置maven版本
File
> Setting...
> Build,Execution,Deployment
> Build Tools
> Maven
在此设置 Maven home path
自定义选择外部安装的新版本 maven 3.6.3
3.2. 设置JDK版本为1.8
第一件事,设置项目jdk版本:File
> Project Structure...
> Project Settings
> Project
SDK 在选项中选择 1.8 版本
3.3. 切换 Maven profiles 选项到 java-build
Zookeeper3.5.9 在 IDEA 的 Maven 界面有以下几个profiles选项:
full-build
,这个是包含了zookeeper-contrib
模块的,该模块是指多个可选的附加组件,该zookeeper-contrib
模块仅限在GNU/Linux系统支持开发和生产,而在windows系统是不支持,所以当我们在windows系统编译源码时不建议选择该profiles选项。<profile> <id>full-build</id> <modules> <module>zookeeper-contrib</module> </modules> </profile>
java-build
,这个是默认激活的选项,特意用注释提示我们排除了 contrib 模块<profile> <!-- Excluds contrib --> <id>java-build</id> <activation> <activeByDefault>true</activeByDefault> </activation> </profile>
m2e
,这个是指 “Maven Integration for Eclipse” (又名m2e)的环境所准备的,而我们并非使用 Eclipse,而是用的 InteliJ IDEA,所以这个选项也不建议选择。从<activation>
标签可以看到是通过设置m2e.version
属性来激活的,所以用IDEA默认情况下是不用担心激活该选项的<profile> <id>m2e</id> <activation> <property> <name>m2e.version</name> </property> </activation> <properties> <maven.compiler.release>8</maven.compiler.release> </properties> </profile>
jdk-release-flag
,这个是指当JDK版本为9及以上时应该激活的选项<profile> <id>jdk-release-flag</id> <activation> <jdk>[9,)</jdk> </activation> <properties> <maven.compiler.release>8</maven.compiler.release> </properties> </profile>
apache-release
:这个是指最终发布的选项,在执行mvn release:perform
时启用<releaseProfiles>
profiles<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-release-plugin</artifactId> <version>2.5.3</version> <configuration> <releaseProfiles>apache-release</releaseProfiles> <arguments>-Dmaven.test.skip.exec ${arguments}</arguments> </configuration> </plugin>
虽然我们在刚打开项目的时候就更改了项目jdk版本,但是maven并不会实时更新激活的profiles选项,所以为谨慎起见,需要手动设置 Maven profiles 选项为 java-build
:
3.4. 执行 Ant build 生成和编译Java文件
安装 IDEA 的 Ant
插件:File
> Settings...
> Plugins
调出 IDEA 的 ant build 界面,如果没有,请依次点击菜单:View
> Tool Windows
> Ant
然后找到项目根目录下的 build.xml
文件,并右键点击它唤出菜单,选择 Add as Ant Build File
。
打开 Ant 界面的 Properties 属性设置,确认设置正确的 jdk:Run under JDK:
,保持与之前项目jdk一致(JDK 1.8)。同时也可以将 IDEA 默认的Ant自定义指定为其他已经安装的Ant。
3.4.1. 执行ant build-generated
而非ant eclipse
网上很多文章都要求执行 ant eclipse
任务,但实际上其本质只是生成一些 .eclipse
、.project
之类的文件和目录罢了,关键的其实是其依赖的其他任务。
这样的话,我们是用 InteliJ Idea 打开的项目,eclipse的项目文件就没有作用了,再执行这个任务生成一些没有用的文件就显得有不优雅了,既然关键的不是 eclipse
任务本身,而是其依赖,那我们就可以仅执行我们需要的依赖任务即可,恰好,根据对 eclipse
任务的依赖关系梳理,找到了一个完美的依赖任务,其几乎也依赖所有除 eclipse
之外的需要的任务,那不就巧了,它就是:
ant build-generated
笔记:
ant eclipse
任务的依赖关系梳理过程如下在正式执行
eclipse
任务之前会先执行其依赖的任务:
ant-eclipse-download
:下载 Ant-Eclipse,它是 Java 构建工具 Ant 生成 Eclipse 项目的任务,只需轻松导入和使用即可。Ant 构建脚本用作配置生成项目所基于的源代码和库的中心位置。init
:初始化操作,包括创建新的目录和设置时间戳格式,创建的目录包括:
${basedir}/build/classes
${basedir}/build/lib
${basedir}/build/package/lib
${basedir}/build/test/lib
ivy-download
:下载 Apache Ivy™ ,它是一个流行的依赖管理器,专注于灵活性和简单性。ivy-taskdef
:结合项目命名空间中的 antlib 定义,它将从 Ant 库或本地目录加载 Ivy 类。ivy-init
:使用${basedir}/ivysettings.xml
文件配置 Ivyivy-retrieve
:该任务将已解析的依赖项复制到文件系统中所需的任何位置ivy-retrieve-javacc
:初始化目录${basedir}/build/javacc/lib
,并执行一次ivy:retrieve
generate_jute_parser
:生产 jute 解析器
- 初始化目录
${basedir}/build/jute_compiler/org/apache/jute/compiler/generated
;- 执行一次
ivy:artifactproperty
,根据之前解析过的依赖包的包名(解析包名根据<ivy:retrieve>
标签的pattern=${ivy.lib}/[artifact]-[revision].[ext]
属性),生成一批以[artifact].revision
格式命名的属性,并将依赖包的[revision]
赋值给对应包名的属性。例如slf4j-api.revision=1.7.25
、commons-lang.revision=2.6
和javacc.revision=5.0
等等。- 执行一次
move
同位移动来实现文件重命名,将带版本号的${basedir}/build/javacc/lib/javacc-${javacc.revision}.jar
重命名为没有版本号的${basedir}/build/javacc/lib/javacc.jar
- 执行一次
javacc
编译${basedir}/zookeeper-jute/src/main/java/org/apache/jute/compiler/generated/rcc.jj
为 java 类并输出到目录${basedir}/build/jute_compiler/org/apache/jute/compiler/generated/
jute
:用javac编译${basedir}/zookeeper-jute/src/main/java
和${basedir}/build/jute_compiler
两处源文件为class文件并输出到目录${basedir}/build/classes
compile_jute_uptodate
:比较源文件与目标文件时间戳,如果目标文件比源文件更新,则设置属性juteBuild.notRequired=true
,该属性用于任务compile_jute
的执行条件,只有在它为false
时才会执行compile_jute
任务。compile_jute
:生成一些java类
- 创建新目录:
${basedir}/zookeeper-jute/target/main/java
- 创建新目录:
${basedir}/zookeeper-client/zookeeper-client-c/generated
- 执行java代码:
org.apache.jute.compiler.generated.Rcc
,该代码的作用就是编译位于${basedir}/zookeeper-jute/src/main/resources/zookeeper.jute
文件内容中的java代码,生成相应的类。包含:
org.apache.zookeeper.data.*
org.apache.zookeeper.proto.*
org.apache.zookeeper.server.quorum.*
org.apache.zookeeper.server.persistence.*
org.apache.zookeeper.txn.*
ver-gen
:执行javac
编译目录为${basedir}/zookeeper-server/src/main/java
下的java类,并将产出class文件输出到${basedir}/build/classes
目录git-revision
:
- 创建新目录
${basedir}/.revision
- 判断如果是 windows 操作系统,则设置属性:
shell.name=cmd
、revision.cmd.line=/c ${basedir}/zookeeper-server/src/main/resources\lastRevision.bat
- 执行命令:经过人工拼接最终执行的是
cmd /c ${basedir}/zookeeper-server/src/main/resources\lastRevision.bat ${basedir}/.revision/revision.properties
(注意:${basedir}
是项目根目录,请读者自行脑中替换),所以是执行了一个windows批命令脚本。该脚本会收集当前git仓库的最后一次提交的hash值,并输出到一个revision.properties
文件中。- 将上一个命令输出的
revision.properties
导入到属性集中,其中只有一个属性:lastRevision
version-info
:
- 创建目录
${basedir}/zookeeper-jute/target/main/java
- 执行java代码
org.apache.zookeeper.version.util.VerGen
,其main()
函数参数有三个分别为{3.5.9-SNAPSHOT,83df9301aa5c2a5d284a9940177808c01bc35cef,03/10/2024 00:00:00}
,创建一个org.apache.zookeeper.version.Info.java
文件,该文件记录了一下版本信息。process-template
:将目录${basedir}/zookeeper-client/zookeeper-client-c
中的configure.ac.in
和include/zookeeper_version.h.in
文件复制到同目录并且重命名删除它们的.in
后缀。build-generated
:执行javac
命令编译目录${basedir}/zookeeper-jute/target/main/java
下的所有java文件并将产出 class 文件输出到目录${basedir}/build/classes
ivy-retrieve-test
:测试执行ivy:retrieve
eclipse
:在执行完上面所有 ant 任务之后,才执行最后的这个 eclipse 任务
3.4.2. 对比构建前后项目多了什么
3.5. maven compile
在 Idea maven 界面执行 compile 目标,如下图所示。
如果严格按照以上步骤的话,没有意外的会编译成功:
main:
[INFO] Executed tasks
[INFO]
[INFO] --- maven-remote-resources-plugin:1.5:process (process-resource-bundles) @ zookeeper-assembly ---
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary for Apache ZooKeeper 3.5.9:
[INFO]
[INFO] Apache ZooKeeper ................................... SUCCESS [ 2.642 s]
[INFO] Apache ZooKeeper - Documentation ................... SUCCESS [ 1.811 s]
[INFO] Apache ZooKeeper - Jute ............................ SUCCESS [ 3.659 s]
[INFO] Apache ZooKeeper - Server .......................... SUCCESS [ 4.100 s]
[INFO] Apache ZooKeeper - Client .......................... SUCCESS [ 0.108 s]
[INFO] Apache ZooKeeper - Recipes ......................... SUCCESS [ 0.310 s]
[INFO] Apache ZooKeeper - Recipes - Election .............. SUCCESS [ 0.628 s]
[INFO] Apache ZooKeeper - Recipes - Lock .................. SUCCESS [ 0.489 s]
[INFO] Apache ZooKeeper - Recipes - Queue ................. SUCCESS [ 0.411 s]
[INFO] Apache ZooKeeper - Assembly ........................ SUCCESS [ 0.470 s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 14.832 s
[INFO] Finished at: 2024-03-11T02:08:15+08:00
[INFO] ------------------------------------------------------------------------
3.6. 准备一个zoo.cfg配置文件
进入目录 ${basedir}/conf/
,在同目录复制一个 zoo_sample.cfg
文件并重命名为 zoo.cfg
。
打开并且编辑,增加两个属性:
# windows系统下的绝对路径,该目录用于存储zookeeper数据
dataDir=F:\\privateBox\\kafkaCodeReadProject\\zookeeper\\tmp\\zookeeper
# 修改服务端口,避开常用的8080
admin.serverPort=8083
这个配置文件是执行 java 命令时需要作为参数用的,例如:
java org.apache.zookeeper.server.quorum.QuorumPeerMain F:\privateBox\kafkaCodeReadProject\zookeeper\conf\zoo.cfg
3.7. 配置classpath
由于 ant build 生成和编译的文件,大部分都放在了 ${basedir}/build/
目录下,所以单独构建 zookeeper-server 模块时会找不到一些由 zookeeper-jute 模块生成的一些类。例如:org.apache.zookeeper.data.ACL
、org.apache.zookeeper.data.Stat
以及更多
为了让zookeeper-server能接触的到这些类,需要将这些目录加到它的 classpath 里面。
具体操作方法如下:
依次点击菜单:File
> Project structure...
>
增加两个目录即可:
${basedir}/build/classes
${basedir}/conf
注意:目录
${basedir}/conf
里面没有 class 文件,所以 idea 询问你选择的是该目录中的什么类型文件,选择Classes
即可
配置完成之后,会发现,编辑器里也不会出现org.apache.zookeeper.data.ACL
、org.apache.zookeeper.data.Stat
等类红色警告,build project 的时候也不会提示找不到该类等错误了。
3.8. 启动 QuorumPeerMain
- 在
${basedir}/zookeeper-server
模块目录下找到org.apache.zookeeper.server.quorum.QuorumPeerMain
类。 - 右键选择
Modify Run Configuration...
开启设置启动参数配置 - jdk选择和项目保持一致,idea会默认选择自带的jdk,建议手动更改为保持项目和ant同一个jdk。
Program arguments
增加内容:${basedir}\conf\zoo.cfg
(请自行替换${basedir}
以确保输入一个绝对路径)
然后启动就可以了
查看 InteliJ Idea 启动时的控制台输出的 java
命令内容是什么:
"C:\Program Files\Java\zulu8.76.0.17-ca-jdk8.0.402-win_x64\bin\java.exe" -agentlib:jdwp=transport=dt_socket,address=127.0.0.1:54029,suspend=y,server=n -javaagent:C:\Users\Kitman\AppData\Local\JetBrains\IdeaIC2022.1\captureAgent\debugger-agent.jar -Dfile.encoding=UTF-8 -classpath "C:\Program Files\Java\zulu8.76.0.17-ca-jdk8.0.402-win_x64\jre\lib\cat.jar;C:\Program Files\Java\zulu8.76.0.17-ca-jdk8.0.402-win_x64\jre\lib\charsets.jar;C:\Program Files\Java\zulu8.76.0.17-ca-jdk8.0.402-win_x64\jre\lib\ext\access-bridge-64.jar;C:\Program Files\Java\zulu8.76.0.17-ca-jdk8.0.402-win_x64\jre\lib\ext\cldrdata.jar;C:\Program Files\Java\zulu8.76.0.17-ca-jdk8.0.402-win_x64\jre\lib\ext\crs-agent.jar;C:\Program Files\Java\zulu8.76.0.17-ca-jdk8.0.402-win_x64\jre\lib\ext\dnsns.jar;C:\Program Files\Java\zulu8.76.0.17-ca-jdk8.0.402-win_x64\jre\lib\ext\jaccess.jar;C:\Program Files\Java\zulu8.76.0.17-ca-jdk8.0.402-win_x64\jre\lib\ext\localedata.jar;C:\Program Files\Java\zulu8.76.0.17-ca-jdk8.0.402-win_x64\jre\lib\ext\nashorn.jar;C:\Program Files\Java\zulu8.76.0.17-ca-jdk8.0.402-win_x64\jre\lib\ext\sunec.jar;C:\Program Files\Java\zulu8.76.0.17-ca-jdk8.0.402-win_x64\jre\lib\ext\sunjce_provider.jar;C:\Program Files\Java\zulu8.76.0.17-ca-jdk8.0.402-win_x64\jre\lib\ext\sunmscapi.jar;C:\Program Files\Java\zulu8.76.0.17-ca-jdk8.0.402-win_x64\jre\lib\ext\sunpkcs11.jar;C:\Program Files\Java\zulu8.76.0.17-ca-jdk8.0.402-win_x64\jre\lib\ext\zipfs.jar;C:\Program Files\Java\zulu8.76.0.17-ca-jdk8.0.402-win_x64\jre\lib\jce.jar;C:\Program Files\Java\zulu8.76.0.17-ca-jdk8.0.402-win_x64\jre\lib\jfr.jar;C:\Program Files\Java\zulu8.76.0.17-ca-jdk8.0.402-win_x64\jre\lib\jsse.jar;C:\Program Files\Java\zulu8.76.0.17-ca-jdk8.0.402-win_x64\jre\lib\management-agent.jar;C:\Program Files\Java\zulu8.76.0.17-ca-jdk8.0.402-win_x64\jre\lib\resources.jar;C:\Program Files\Java\zulu8.76.0.17-ca-jdk8.0.402-win_x64\jre\lib\rt.jar;F:\privateBox\kafkaCodeReadProject\zookeeper\zookeeper-server\target\classes;F:\privateBox\kafkaCodeReadProject\zookeeper\zookeeper-jute\target\classes;F:\software\apache-maven-3.6.3\repo\org\apache\yetus\audience-annotations\0.5.0\audience-annotations-0.5.0.jar;F:\software\apache-maven-3.6.3\repo\io\netty\netty-handler\4.1.50.Final\netty-handler-4.1.50.Final.jar;F:\software\apache-maven-3.6.3\repo\io\netty\netty-common\4.1.50.Final\netty-common-4.1.50.Final.jar;F:\software\apache-maven-3.6.3\repo\io\netty\netty-resolver\4.1.50.Final\netty-resolver-4.1.50.Final.jar;F:\software\apache-maven-3.6.3\repo\io\netty\netty-buffer\4.1.50.Final\netty-buffer-4.1.50.Final.jar;F:\software\apache-maven-3.6.3\repo\io\netty\netty-transport\4.1.50.Final\netty-transport-4.1.50.Final.jar;F:\software\apache-maven-3.6.3\repo\io\netty\netty-codec\4.1.50.Final\netty-codec-4.1.50.Final.jar;F:\software\apache-maven-3.6.3\repo\io\netty\netty-transport-native-epoll\4.1.50.Final\netty-transport-native-epoll-4.1.50.Final.jar;F:\software\apache-maven-3.6.3\repo\io\netty\netty-transport-native-unix-common\4.1.50.Final\netty-transport-native-unix-common-4.1.50.Final.jar;F:\software\apache-maven-3.6.3\repo\org\slf4j\slf4j-api\1.7.25\slf4j-api-1.7.25.jar;F:\software\apache-maven-3.6.3\repo\org\slf4j\slf4j-log4j12\1.7.25\slf4j-log4j12-1.7.25.jar;F:\software\apache-maven-3.6.3\repo\log4j\log4j\1.2.17\log4j-1.2.17.jar;F:\privateBox\kafkaCodeReadProject\zookeeper\build\classes;F:\privateBox\kafkaCodeReadProject\zookeeper\conf;D:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2021.3.2\lib\idea_rt.jar" org.apache.zookeeper.server.quorum.QuorumPeerMain F:\privateBox\kafkaCodeReadProject\zookeeper\conf\zoo.cfg
其中命令的 classpath 部分整理为列表如下所示:
C:\Program Files\Java\zulu8.76.0.17-ca-jdk8.0.402-win_x64\jre\lib\cat.jar
C:\Program Files\Java\zulu8.76.0.17-ca-jdk8.0.402-win_x64\jre\lib\charsets.jar
C:\Program Files\Java\zulu8.76.0.17-ca-jdk8.0.402-win_x64\jre\lib\ext\access-bridge-64.jar
C:\Program Files\Java\zulu8.76.0.17-ca-jdk8.0.402-win_x64\jre\lib\ext\cldrdata.jar
C:\Program Files\Java\zulu8.76.0.17-ca-jdk8.0.402-win_x64\jre\lib\ext\crs-agent.jar
C:\Program Files\Java\zulu8.76.0.17-ca-jdk8.0.402-win_x64\jre\lib\ext\dnsns.jar
C:\Program Files\Java\zulu8.76.0.17-ca-jdk8.0.402-win_x64\jre\lib\ext\jaccess.jar
C:\Program Files\Java\zulu8.76.0.17-ca-jdk8.0.402-win_x64\jre\lib\ext\localedata.jar
C:\Program Files\Java\zulu8.76.0.17-ca-jdk8.0.402-win_x64\jre\lib\ext\nashorn.jar
C:\Program Files\Java\zulu8.76.0.17-ca-jdk8.0.402-win_x64\jre\lib\ext\sunec.jar
C:\Program Files\Java\zulu8.76.0.17-ca-jdk8.0.402-win_x64\jre\lib\ext\sunjce_provider.jar
C:\Program Files\Java\zulu8.76.0.17-ca-jdk8.0.402-win_x64\jre\lib\ext\sunmscapi.jar
C:\Program Files\Java\zulu8.76.0.17-ca-jdk8.0.402-win_x64\jre\lib\ext\sunpkcs11.jar
C:\Program Files\Java\zulu8.76.0.17-ca-jdk8.0.402-win_x64\jre\lib\ext\zipfs.jar
C:\Program Files\Java\zulu8.76.0.17-ca-jdk8.0.402-win_x64\jre\lib\jce.jar
C:\Program Files\Java\zulu8.76.0.17-ca-jdk8.0.402-win_x64\jre\lib\jfr.jar
C:\Program Files\Java\zulu8.76.0.17-ca-jdk8.0.402-win_x64\jre\lib\jsse.jar
C:\Program Files\Java\zulu8.76.0.17-ca-jdk8.0.402-win_x64\jre\lib\management-agent.jar
C:\Program Files\Java\zulu8.76.0.17-ca-jdk8.0.402-win_x64\jre\lib\resources.jar
C:\Program Files\Java\zulu8.76.0.17-ca-jdk8.0.402-win_x64\jre\lib\rt.jar
F:\privateBox\kafkaCodeReadProject\zookeeper\zookeeper-server\target\classes
F:\privateBox\kafkaCodeReadProject\zookeeper\zookeeper-jute\target\classes
F:\software\apache-maven-3.6.3\repo\org\apache\yetus\audience-annotations\0.5.0\audience-annotations-0.5.0.jar
F:\software\apache-maven-3.6.3\repo\io\netty\netty-handler\4.1.50.Final\netty-handler-4.1.50.Final.jar
F:\software\apache-maven-3.6.3\repo\io\netty\netty-common\4.1.50.Final\netty-common-4.1.50.Final.jar
F:\software\apache-maven-3.6.3\repo\io\netty\netty-resolver\4.1.50.Final\netty-resolver-4.1.50.Final.jar
F:\software\apache-maven-3.6.3\repo\io\netty\netty-buffer\4.1.50.Final\netty-buffer-4.1.50.Final.jar
F:\software\apache-maven-3.6.3\repo\io\netty\netty-transport\4.1.50.Final\netty-transport-4.1.50.Final.jar
F:\software\apache-maven-3.6.3\repo\io\netty\netty-codec\4.1.50.Final\netty-codec-4.1.50.Final.jar
F:\software\apache-maven-3.6.3\repo\io\netty\netty-transport-native-epoll\4.1.50.Final\netty-transport-native-epoll-4.1.50.Final.jar
F:\software\apache-maven-3.6.3\repo\io\netty\netty-transport-native-unix-common\4.1.50.Final\netty-transport-native-unix-common-4.1.50.Final.jar
F:\software\apache-maven-3.6.3\repo\org\slf4j\slf4j-api\1.7.25\slf4j-api-1.7.25.jar
F:\software\apache-maven-3.6.3\repo\org\slf4j\slf4j-log4j12\1.7.25\slf4j-log4j12-1.7.25.jar
F:\software\apache-maven-3.6.3\repo\log4j\log4j\1.2.17\log4j-1.2.17.jar
F:\privateBox\kafkaCodeReadProject\zookeeper\build\classes
F:\privateBox\kafkaCodeReadProject\zookeeper\conf
D:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2021.3.2\lib\idea_rt.jar
4. 在命令行 cmd 中编译和启动
在完成 准备一个zoo.cfg配置文件 步骤后,尝试在项目根目录打开 cmd 直接执行 cmd /k bin\zkServer.cmd
脚本启动服务,会直接报错,日志如下所示:
F:\privateBox\kafkaCodeReadProject\zookeeper>cmd /k bin\zkServer.cmd
F:\privateBox\kafkaCodeReadProject\zookeeper>call "C:\Program Files\Java\zulu8.76.0.17-ca-jdk8.0.402-win_x64"\bin\java "-Dzookeeper.log.dir=F:\privateBox\kafkaCodeReadProject\zookeeper\bin\..\logs" "-Dzookeeper.log.file=zookeeper-Kitman-server-DESKTOP-S0UTLJU.log" "-XX:+HeapDumpOnOutOfMemoryError" "-XX:OnOutOfMemoryError=cmd /c taskkill /pid %%p /t /f" -cp "F:\privateBox\kafkaCodeReadProject\zookeeper\bin\..\build\classes;F:\privateBox\kafkaCodeReadProject\zookeeper\bin\..\build\lib\*;F:\privateBox\kafkaCodeReadProject\zookeeper\bin\..\*;F:\privateBox\kafkaCodeReadProject\zookeeper\bin\..\lib\*;F:\privateBox\kafkaCodeReadProject\zookeeper\bin\..\conf" org.apache.zookeeper.server.quorum.QuorumPeerMain "F:\privateBox\kafkaCodeReadProject\zookeeper\bin\..\conf\zoo.cfg"
错误: 找不到或无法加载主类 org.apache.zookeeper.server.quorum.QuorumPeerMain
F:\privateBox\kafkaCodeReadProject\zookeeper>endlocal
无法加载某某类肯定是 classpath 中没有包含该类导致的,说明源码还没有编译完成,至少没有编译这个类到 classpath 包含的目录中,所以在找不到。
通过观察命令当中的 -cp
参数研究其 classpath
明确包含有以下目录:
${basedir}\build\classes
${basedir}\build\lib\*
${basedir}\*
${basedir}\lib\*
${basedir}\conf
也就是说,以上这些目录中,没有编译过的 org.apache.zookeeper.server.quorum.QuorumPeerMain
主类,说明我们还没有完成编译工作。
4.1. 安装 Ant
根据 zookeeper 项目根目录下的 README_packaging.txt
文件中的内容提示,ant 版本建议在 1.9.4
以上。
我们直接到官网下载一个最新的:
在 官方下载页面 下载一个当前最新版本的二进制包 apache-ant-1.10.14-bin.zip
。
注意!Ant 官方提供二进制包下载以及源码包下载,如果下载了源码包还要再次进行编译构建才能真正应用,所以建议直接下载二进制包方便直接配置应用。
解压缩二进制包,将解压缩后 bin
的父目录,添加到环境配置中,命名为ANT_HOME
,并添加 %ANT_HOME%/bin/
到 Path
中。
在新打开的 cmd 中执行 ant -version
验证安装成功。
4.2. 使用 Ant 编译
注意,我们这里不需要制定执行的 ant 任务,就直接执行一个:
ant
查看 build.xml
,发现其中是给项目配置了默认ant任务为 jar
的:
<project name="ZooKeeper" default="jar"
xmlns:ivy="antlib:org.apache.ivy.ant"
xmlns:artifact="antlib:org.apache.maven.artifact.ant"
xmlns:maven="antlib:org.apache.maven.artifact.ant"
xmlns:cs="antlib:com.puppycrawl.tools.checkstyle.ant">
有的读者可能会问:
为什么不是跟 Idea 打开项目时执行的 ant build-generated
一样呢?
从两个方面来回答:
- 其实 Idea 也可以用不选择某个任务来执行从而让它执行默认的
ant jar
,但是对于 Idea 环境来说,前者已经足够,ant jar
会生成更多的内容,比如会把zookeeper-server
模块整个编译到${basedir}/build/classes
里,那这样的话,和mvn compile
编译到模块target/classes
目录重复,而观察 InteliJ Idea 启动zookeeper的java命令内容 中的classpath,它是同时包含这两个目录的,一旦出现重复,而没有在更新代码之后及时保持两个目录下的编译结果一致,可能会出现不可预知的问题。 - 对于
zkServer.cmd
脚本只包含${basedir}/build/classes
而不包含模块target/classes
的 classpath 来说,ant build-generated
是不够用的,因为它不会编译zookeeper-server
模块,会导致脚本找不到主类。
以下记录执行 ant
命令(等效 ant jar
)的日志:
F:\privateBox\kafkaCodeReadProject\zookeeper>ant
Buildfile: F:\privateBox\kafkaCodeReadProject\zookeeper\build.xml
init:
[mkdir] Created dir: F:\privateBox\kafkaCodeReadProject\zookeeper\build\classes
[mkdir] Created dir: F:\privateBox\kafkaCodeReadProject\zookeeper\build\lib
[mkdir] Created dir: F:\privateBox\kafkaCodeReadProject\zookeeper\build\package\lib
[mkdir] Created dir: F:\privateBox\kafkaCodeReadProject\zookeeper\build\test\lib
ivy-download:
[get] Getting: https://repo1.maven.org/maven2/org/apache/ivy/ivy/2.5.0-rc1/ivy-2.5.0-rc1.jar
[get] To: F:\privateBox\kafkaCodeReadProject\zookeeper\zookeeper-server\src\main\resources\lib\ivy-2.5.0-rc1.jar
ivy-taskdef:
ivy-init:
ivy-retrieve:
[ivy:retrieve] :: Apache Ivy 2.5.0-rc1 - 20180412005306 :: http://ant.apache.org/ivy/ ::
[ivy:retrieve] :: loading settings :: file = F:\privateBox\kafkaCodeReadProject\zookeeper\ivysettings.xml
[ivy:retrieve] :: resolving dependencies :: org.apache.zookeeper#zookeeper;3.5.9-SNAPSHOT
[ivy:retrieve] confs: [default]
[ivy:retrieve] found jline#jline;2.11 in maven2
[ivy:retrieve] found org.eclipse.jetty#jetty-server;9.4.35.v20201120 in maven2
[ivy:retrieve] found javax.servlet#javax.servlet-api;3.1.0 in maven2
[ivy:retrieve] found org.eclipse.jetty#jetty-http;9.4.35.v20201120 in maven2
[ivy:retrieve] found org.eclipse.jetty#jetty-util;9.4.35.v20201120 in maven2
[ivy:retrieve] found org.eclipse.jetty#jetty-io;9.4.35.v20201120 in maven2
[ivy:retrieve] found org.eclipse.jetty#jetty-servlet;9.4.35.v20201120 in maven2
[ivy:retrieve] found org.eclipse.jetty#jetty-security;9.4.35.v20201120 in maven2
[ivy:retrieve] found org.eclipse.jetty#jetty-util-ajax;9.4.35.v20201120 in maven2
[ivy:retrieve] found com.fasterxml.jackson.core#jackson-databind;2.10.3 in maven2
[ivy:retrieve] found com.fasterxml.jackson.core#jackson-annotations;2.10.3 in maven2
[ivy:retrieve] found com.fasterxml.jackson.core#jackson-core;2.10.3 in maven2
[ivy:retrieve] found org.slf4j#slf4j-api;1.7.25 in maven2
[ivy:retrieve] found org.slf4j#slf4j-log4j12;1.7.25 in maven2
[ivy:retrieve] found commons-cli#commons-cli;1.2 in maven2
[ivy:retrieve] found com.github.spotbugs#spotbugs-annotations;3.1.9 in maven2
[ivy:retrieve] found com.google.code.findbugs#jsr305;3.0.2 in maven2
[ivy:retrieve] found log4j#log4j;1.2.17 in maven2
[ivy:retrieve] found org.apache.yetus#audience-annotations;0.5.0 in maven2
[ivy:retrieve] found io.netty#netty-handler;4.1.50.Final in maven2
[ivy:retrieve] found io.netty#netty-common;4.1.50.Final in maven2
[ivy:retrieve] found io.netty#netty-resolver;4.1.50.Final in maven2
[ivy:retrieve] found io.netty#netty-buffer;4.1.50.Final in maven2
[ivy:retrieve] found io.netty#netty-transport;4.1.50.Final in maven2
[ivy:retrieve] found io.netty#netty-codec;4.1.50.Final in maven2
[ivy:retrieve] found io.netty#netty-transport-native-epoll;4.1.50.Final in maven2
[ivy:retrieve] found io.netty#netty-transport-native-unix-common;4.1.50.Final in maven2
[ivy:retrieve] :: resolution report :: resolve 569ms :: artifacts dl 44ms
---------------------------------------------------------------------
| | modules || artifacts |
| conf | number| search|dwnlded|evicted|| number|dwnlded|
---------------------------------------------------------------------
| default | 27 | 0 | 0 | 0 || 27 | 0 |
---------------------------------------------------------------------
[ivy:retrieve] :: retrieving :: org.apache.zookeeper#zookeeper
[ivy:retrieve] confs: [default]
[ivy:retrieve] 27 artifacts copied, 0 already retrieved (6939kB/40ms)
ivy-retrieve-clover:
clover.check:
clover.setup:
clover:
ivy-retrieve-javacc:
[mkdir] Created dir: F:\privateBox\kafkaCodeReadProject\zookeeper\build\javacc\lib
[ivy:retrieve] :: resolving dependencies :: org.apache.zookeeper#zookeeper;3.5.9-SNAPSHOT
[ivy:retrieve] confs: [javacc]
[ivy:retrieve] found net.java.dev.javacc#javacc;5.0 in maven2
[ivy:retrieve] :: resolution report :: resolve 20ms :: artifacts dl 0ms
---------------------------------------------------------------------
| | modules || artifacts |
| conf | number| search|dwnlded|evicted|| number|dwnlded|
---------------------------------------------------------------------
| javacc | 1 | 0 | 0 | 0 || 1 | 0 |
---------------------------------------------------------------------
[ivy:retrieve] :: retrieving :: org.apache.zookeeper#zookeeper
[ivy:retrieve] confs: [javacc]
[ivy:retrieve] 1 artifacts copied, 0 already retrieved (291kB/4ms)
generate_jute_parser:
[mkdir] Created dir: F:\privateBox\kafkaCodeReadProject\zookeeper\build\jute_compiler\org\apache\jute\compiler\generated
[ivy:artifactproperty] DEPRECATED: 'ivy.conf.file' is deprecated, use 'ivy.settings.file' instead
[ivy:artifactproperty] :: loading settings :: file = F:\privateBox\kafkaCodeReadProject\zookeeper\ivysettings.xml
[move] Moving 1 file to F:\privateBox\kafkaCodeReadProject\zookeeper\build\javacc\lib
[javacc] Java Compiler Compiler Version 5.0 (Parser Generator)
[javacc] (type "javacc" with no arguments for help)
[javacc] Reading from file F:\privateBox\kafkaCodeReadProject\zookeeper\zookeeper-jute\src\main\java\org\apache\jute\compiler\generated\rcc.jj . . .
[javacc] File "TokenMgrError.java" does not exist. Will create one.
[javacc] File "ParseException.java" does not exist. Will create one.
[javacc] File "Token.java" does not exist. Will create one.
[javacc] File "SimpleCharStream.java" does not exist. Will create one.
[javacc] Parser generated successfully.
jute:
[javac] Compiling 39 source files to F:\privateBox\kafkaCodeReadProject\zookeeper\build\classes
compile_jute_uptodate:
compile_jute:
[mkdir] Created dir: F:\privateBox\kafkaCodeReadProject\zookeeper\zookeeper-jute\target\main\java
[mkdir] Created dir: F:\privateBox\kafkaCodeReadProject\zookeeper\zookeeper-client\zookeeper-client-c\generated
[java] ../../../src/main/resources/zookeeper.jute Parsed Successfully
[java] ../../../zookeeper-jute/src/main/resources/zookeeper.jute Parsed Successfully
[touch] Creating F:\privateBox\kafkaCodeReadProject\zookeeper\zookeeper-jute\target\main\java\.generated
ver-gen:
[javac] Compiling 1 source file to F:\privateBox\kafkaCodeReadProject\zookeeper\build\classes
git-revision:
[mkdir] Created dir: F:\privateBox\kafkaCodeReadProject\zookeeper\.revision
[exec]
[exec] F:\privateBox\kafkaCodeReadProject\zookeeper>echo off
version-info:
process-template:
build-generated:
[javac] Compiling 63 source files to F:\privateBox\kafkaCodeReadProject\zookeeper\build\classes
compile:
[javac] Compiling 276 source files to F:\privateBox\kafkaCodeReadProject\zookeeper\build\classes
jar:
[jar] Building jar: F:\privateBox\kafkaCodeReadProject\zookeeper\build\zookeeper-3.5.9-SNAPSHOT.jar
BUILD SUCCESSFUL
Total time: 11 seconds
4.3. 准备一个zoo.cfg配置文件
进入目录 ${basedir}/conf/
,在同目录复制一个 zoo_sample.cfg
文件并重命名为 zoo.cfg
。
打开并且编辑,增加两个属性:
# windows系统下的绝对路径,该目录用于存储zookeeper数据
dataDir=F:\\privateBox\\kafkaCodeReadProject\\zookeeper\\tmp\\zookeeper
# 修改服务端口,避开常用的8080
admin.serverPort=8083
这个配置文件是执行 java 命令时需要作为参数用的,例如:
java org.apache.zookeeper.server.quorum.QuorumPeerMain F:\privateBox\kafkaCodeReadProject\zookeeper\conf\zoo.cfg
4.4. 执行 zkServer.cmd 脚本启动服务
F:\privateBox\kafkaCodeReadProject\zookeeper>cmd /k bin\zkServer.cmd
F:\privateBox\kafkaCodeReadProject\zookeeper>call "C:\Program Files\Java\zulu8.76.0.17-ca-jdk8.0.402-win_x64"\bin\java "-Dzookeeper.log.dir=F:\privateBox\kafkaCodeReadProject\zookeeper\bin\..\logs" "-Dzookeeper.root.logger=INFO,CONSOLE" "-Dzookeeper.log.file=zookeeper-Kitman-server-DESKTOP-S0UTLJU.log" "-XX:+HeapDumpOnOutOfMemoryError" "-XX:OnOutOfMemoryError=cmd /c taskkill /pid %%p /t /f" -cp "F:\privateBox\kafkaCodeReadProject\zookeeper\bin\..\build\classes;F:\privateBox\kafkaCodeReadProject\zookeeper\bin\..\build\lib\*;F:\privateBox\kafkaCodeReadProject\zookeeper\bin\..\*;F:\privateBox\kafkaCodeReadProject\zookeeper\bin\..\lib\*;F:\privateBox\kafkaCodeReadProject\zookeeper\bin\..\conf" org.apache.zookeeper.server.quorum.QuorumPeerMain "F:\privateBox\kafkaCodeReadProject\zookeeper\bin\..\conf\zoo.cfg"
2024-03-12 05:03:37,127 [myid:] - INFO [main:QuorumPeerConfig@136] - Reading configuration from: F:\privateBox\kafkaCodeReadProject\zookeeper\bin\..\conf\zoo.cfg
2024-03-12 05:03:37,262 [myid:] - INFO [main:QuorumPeerConfig@388] - clientPortAddress is 0.0.0.0:2181
2024-03-12 05:03:37,262 [myid:] - INFO [main:QuorumPeerConfig@392] - secureClientPort is not set
2024-03-12 05:03:37,270 [myid:] - INFO [main:DatadirCleanupManager@78] - autopurge.snapRetainCount set to 3
2024-03-12 05:03:37,270 [myid:] - INFO [main:DatadirCleanupManager@79] - autopurge.purgeInterval set to 0
2024-03-12 05:03:37,270 [myid:] - INFO [main:DatadirCleanupManager@101] - Purge task is not scheduled.
2024-03-12 05:03:37,270 [myid:] - WARN [main:QuorumPeerMain@125] - Either no config or no quorum defined in config, running in standalone mode
2024-03-12 05:03:37,278 [myid:] - INFO [main:ManagedUtil@45] - Log4j 1.2 jmx support found and enabled.
2024-03-12 05:03:37,346 [myid:] - INFO [main:QuorumPeerConfig@136] - Reading configuration from: F:\privateBox\kafkaCodeReadProject\zookeeper\bin\..\conf\zoo.cfg
2024-03-12 05:03:37,346 [myid:] - INFO [main:QuorumPeerConfig@388] - clientPortAddress is 0.0.0.0:2181
2024-03-12 05:03:37,346 [myid:] - INFO [main:QuorumPeerConfig@392] - secureClientPort is not set
2024-03-12 05:03:37,346 [myid:] - INFO [main:ZooKeeperServerMain@118] - Starting server
2024-03-12 05:03:37,350 [myid:] - INFO [main:FileTxnSnapLog@115] - zookeeper.snapshot.trust.empty : false
2024-03-12 05:03:52,946 [myid:] - INFO [main:Environment@109] - Server environment:zookeeper.version=3.5.9-SNAPSHOT-83df9301aa5c2a5d284a9940177808c01bc35cef, built on 03/11/2024 21:02 GMT
2024-03-12 05:03:52,946 [myid:] - INFO [main:Environment@109] - Server environment:host.name=DESKTOP-S0UTLJU
2024-03-12 05:03:52,947 [myid:] - INFO [main:Environment@109] - Server environment:java.version=1.8.0_402
2024-03-12 05:03:52,949 [myid:] - INFO [main:Environment@109] - Server environment:java.vendor=Azul Systems, Inc.
2024-03-12 05:03:52,949 [myid:] - INFO [main:Environment@109] - Server environment:java.home=C:\Program Files\Java\zulu8.76.0.17-ca-jdk8.0.402-win_x64\jre
2024-03-12 05:03:52,950 [myid:] - INFO [main:Environment@109] - Server environment:java.class.path=F:\privateBox\kafkaCodeReadProject\zookeeper\bin\..\build\classes;F:\privateBox\kafkaCodeReadProject\zookeeper\bin\..\build\lib\audience-annotations-0.5.0.jar;F:\privateBox\kafkaCodeReadProject\zookeeper\bin\..\build\lib\commons-cli-1.2.jar;F:\privateBox\kafkaCodeReadProject\zookeeper\bin\..\build\lib\jackson-annotations-2.10.3.jar;F:\privateBox\kafkaCodeReadProject\zookeeper\bin\..\build\lib\jackson-core-2.10.3.jar;F:\privateBox\kafkaCodeReadProject\zookeeper\bin\..\build\lib\jackson-databind-2.10.3.jar;F:\privateBox\kafkaCodeReadProject\zookeeper\bin\..\build\lib\javax.servlet-api-3.1.0.jar;F:\privateBox\kafkaCodeReadProject\zookeeper\bin\..\build\lib\jetty-http-9.4.35.v20201120.jar;F:\privateBox\kafkaCodeReadProject\zookeeper\bin\..\build\lib\jetty-io-9.4.35.v20201120.jar;F:\privateBox\kafkaCodeReadProject\zookeeper\bin\..\build\lib\jetty-security-9.4.35.v20201120.jar;F:\privateBox\kafkaCodeReadProject\zookeeper\bin\..\build\lib\jetty-server-9.4.35.v20201120.jar;F:\privateBox\kafkaCodeReadProject\zookeeper\bin\..\build\lib\jetty-servlet-9.4.35.v20201120.jar;F:\privateBox\kafkaCodeReadProject\zookeeper\bin\..\build\lib\jetty-util-9.4.35.v20201120.jar;F:\privateBox\kafkaCodeReadProject\zookeeper\bin\..\build\lib\jetty-util-ajax-9.4.35.v20201120.jar;F:\privateBox\kafkaCodeReadProject\zookeeper\bin\..\build\lib\jline-2.11.jar;F:\privateBox\kafkaCodeReadProject\zookeeper\bin\..\build\lib\jsr305-3.0.2.jar;F:\privateBox\kafkaCodeReadProject\zookeeper\bin\..\build\lib\log4j-1.2.17.jar;F:\privateBox\kafkaCodeReadProject\zookeeper\bin\..\build\lib\netty-buffer-4.1.50.Final.jar;F:\privateBox\kafkaCodeReadProject\zookeeper\bin\..\build\lib\netty-codec-4.1.50.Final.jar;F:\privateBox\kafkaCodeReadProject\zookeeper\bin\..\build\lib\netty-common-4.1.50.Final.jar;F:\privateBox\kafkaCodeReadProject\zookeeper\bin\..\build\lib\netty-handler-4.1.50.Final.jar;F:\privateBox\kafkaCodeReadProject\zookeeper\bin\..\build\lib\netty-resolver-4.1.50.Final.jar;F:\privateBox\kafkaCodeReadProject\zookeeper\bin\..\build\lib\netty-transport-4.1.50.Final.jar;F:\privateBox\kafkaCodeReadProject\zookeeper\bin\..\build\lib\netty-transport-native-epoll-4.1.50.Final.jar;F:\privateBox\kafkaCodeReadProject\zookeeper\bin\..\build\lib\netty-transport-native-unix-common-4.1.50.Final.jar;F:\privateBox\kafkaCodeReadProject\zookeeper\bin\..\build\lib\slf4j-api-1.7.25.jar;F:\privateBox\kafkaCodeReadProject\zookeeper\bin\..\build\lib\slf4j-log4j12-1.7.25.jar;F:\privateBox\kafkaCodeReadProject\zookeeper\bin\..\build\lib\spotbugs-annotations-3.1.9.jar;F:\privateBox\kafkaCodeReadProject\zookeeper\bin\..\*;F:\privateBox\kafkaCodeReadProject\zookeeper\bin\..\lib\*;F:\privateBox\kafkaCodeReadProject\zookeeper\bin\..\conf
2024-03-12 05:03:52,951 [myid:] - INFO [main:Environment@109] - Server environment:java.library.path=C:\Program Files\Java\zulu8.76.0.17-ca-jdk8.0.402-win_x64\bin;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\Program Files\Java\zulu8.76.0.17-ca-jdk8.0.402-win_x64\bin\;C:\Program Files\Java\zulu8.76.0.17-ca-jdk8.0.402-win_x64\jre\bin\;F:\software\apache-maven-3.6.3\bin\;F:\software\gradle-8.6-bin\gradle-8.6\bin;C:\Program Files (x86)\VMware\VMware Workstation\bin\;C:\Program Files\Python310\Scripts\;C:\Program Files\Python310\;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Program Files\Git\cmd;D:\Program Files (x86)\NetSarang\Xftp 7\;D:\Program Files (x86)\NetSarang\Xshell 7\;C:\Android;C:\Windows\System32;C:\Program Files\dotnet\;C:\Program Files (x86)\scala\bin;F:\software\apache-ant-1.10.14-bin\apache-ant-1.10.14\bin\;C:\Users\Kitman\AppData\Local\Microsoft\WindowsApps;;C:\Users\Kitman\AppData\Local\Programs\Microsoft VS Code\bin;.
2024-03-12 05:03:52,951 [myid:] - INFO [main:Environment@109] - Server environment:java.io.tmpdir=C:\Users\Kitman\AppData\Local\Temp\
2024-03-12 05:03:52,952 [myid:] - INFO [main:Environment@109] - Server environment:java.compiler=<NA>
2024-03-12 05:03:52,952 [myid:] - INFO [main:Environment@109] - Server environment:os.name=Windows 10
2024-03-12 05:03:52,952 [myid:] - INFO [main:Environment@109] - Server environment:os.arch=amd64
2024-03-12 05:03:52,952 [myid:] - INFO [main:Environment@109] - Server environment:os.version=10.0
2024-03-12 05:03:52,953 [myid:] - INFO [main:Environment@109] - Server environment:user.name=Kitman
2024-03-12 05:03:52,953 [myid:] - INFO [main:Environment@109] - Server environment:user.home=C:\Users\Kitman
2024-03-12 05:03:52,953 [myid:] - INFO [main:Environment@109] - Server environment:user.dir=F:\privateBox\kafkaCodeReadProject\zookeeper
2024-03-12 05:03:52,955 [myid:] - INFO [main:Environment@109] - Server environment:os.memory.free=236MB
2024-03-12 05:03:52,955 [myid:] - INFO [main:Environment@109] - Server environment:os.memory.max=3614MB
2024-03-12 05:03:52,955 [myid:] - INFO [main:Environment@109] - Server environment:os.memory.total=245MB
2024-03-12 05:03:52,960 [myid:] - INFO [main:ZooKeeperServer@953] - minSessionTimeout set to 4000
2024-03-12 05:03:52,960 [myid:] - INFO [main:ZooKeeperServer@962] - maxSessionTimeout set to 40000
2024-03-12 05:03:52,960 [myid:] - INFO [main:ZooKeeperServer@181] - Created server with tickTime 2000 minSessionTimeout 4000 maxSessionTimeout 40000 datadir F:\privateBox\kafkaCodeReadProject\zookeeper\tmp\zookeeper\version-2 snapdir F:\privateBox\kafkaCodeReadProject\zookeeper\tmp\zookeeper\version-2
2024-03-12 05:03:53,023 [myid:] - INFO [main:Log@169] - Logging initialized @16096ms to org.eclipse.jetty.util.log.Slf4jLog
2024-03-12 05:03:53,166 [myid:] - WARN [main:ContextHandler@1660] - o.e.j.s.ServletContextHandler@2a2d45ba{/,null,STOPPED} contextPath ends with /*
2024-03-12 05:03:53,166 [myid:] - WARN [main:ContextHandler@1671] - Empty contextPath
2024-03-12 05:03:53,189 [myid:] - INFO [main:Server@375] - jetty-9.4.35.v20201120; built: 2020-11-20T21:17:03.964Z; git: bdc54f03a5e0a7e280fab27f55c3c75ee8da89fb; jvm 1.8.0_402-b06
2024-03-12 05:03:53,237 [myid:] - INFO [main:DefaultSessionIdManager@334] - DefaultSessionIdManager workerName=node0
2024-03-12 05:03:53,237 [myid:] - INFO [main:DefaultSessionIdManager@339] - No SessionScavenger set, using defaults
2024-03-12 05:03:53,240 [myid:] - INFO [main:HouseKeeper@132] - node0 Scavenging every 660000ms
2024-03-12 05:03:53,244 [myid:] - WARN [main:ConstraintSecurityHandler@758] - ServletContext@o.e.j.s.ServletContextHandler@2a2d45ba{/,null,STARTING} has uncovered http methods for path: /*
2024-03-12 05:03:53,262 [myid:] - INFO [main:ContextHandler@916] - Started o.e.j.s.ServletContextHandler@2a2d45ba{/,null,AVAILABLE}
2024-03-12 05:03:53,594 [myid:] - INFO [main:AbstractConnector@331] - Started ServerConnector@dfd3711{HTTP/1.1, (http/1.1)}{0.0.0.0:8083}
2024-03-12 05:03:53,594 [myid:] - INFO [main:Server@415] - Started @16670ms
2024-03-12 05:03:53,598 [myid:] - INFO [main:JettyAdminServer@116] - Started AdminServer on address 0.0.0.0, port 8083 and command URL /commands
2024-03-12 05:03:53,607 [myid:] - INFO [main:ServerCnxnFactory@135] - Using org.apache.zookeeper.server.NIOServerCnxnFactory as server connection factory
2024-03-12 05:03:53,611 [myid:] - INFO [main:NIOServerCnxnFactory@673] - Configuring NIO connection handler with 10s sessionless connection timeout, 2 selector thread(s), 16 worker threads, and 64 kB direct buffers.
2024-03-12 05:03:53,615 [myid:] - INFO [main:NIOServerCnxnFactory@686] - binding to port 0.0.0.0/0.0.0.0:2181
2024-03-12 05:03:53,637 [myid:] - INFO [main:ZKDatabase@117] - zookeeper.snapshotSizeFactor = 0.33
2024-03-12 05:03:53,639 [myid:] - INFO [main:FileSnap@83] - Reading snapshot F:\privateBox\kafkaCodeReadProject\zookeeper\tmp\zookeeper\version-2\snapshot.0
2024-03-12 05:03:53,647 [myid:] - INFO [main:FileTxnSnapLog@404] - Snapshotting: 0x0 to F:\privateBox\kafkaCodeReadProject\zookeeper\tmp\zookeeper\version-2\snapshot.0
2024-03-12 05:03:53,671 [myid:] - INFO [ProcessThread(sid:0 cport:2181)::PrepRequestProcessor@132] - PrepRequestProcessor (sid:0) started, reconfigEnabled=false
2024-03-12 05:03:53,677 [myid:] - INFO [main:ContainerManager@64] - Using checkIntervalMs=60000 maxPerMinute=10000