Zookeeper3.5.9源码编译和启动

news2024/11/18 19:59:41

目录

  • 参考链接
  • 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 脚本启动服务

参考链接

  1. Zookeeper GitHub 仓库
  2. Zookeeper3.5.9 官方参考手册
  3. Apache Ivy
  4. Apache Ivy 2.5.2 Reference
  5. Ant-Eclipse
  6. M2E-WTP
  7. 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 版本

更改项目jdk版本为1.8

3.3. 切换 Maven profiles 选项到 java-build

Zookeeper3.5.9 在 IDEA 的 Maven 界面有以下几个profiles选项:

  1. full-build,这个是包含了zookeeper-contrib模块的,该模块是指多个可选的附加组件,该zookeeper-contrib模块仅限在GNU/Linux系统支持开发和生产,而在windows系统是不支持,所以当我们在windows系统编译源码时不建议选择该profiles选项。
    <profile>
      <id>full-build</id>
      <modules>
        <module>zookeeper-contrib</module>
      </modules>
    </profile>
    
  2. java-build,这个是默认激活的选项,特意用注释提示我们排除了 contrib 模块
    <profile>
      <!-- Excluds contrib -->
      <id>java-build</id>
      <activation>
        <activeByDefault>true</activeByDefault>
      </activation>
    </profile>
    
  3. 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>
    
  4. 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>
    
  5. 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 任务之前会先执行其依赖的任务:

  1. ant-eclipse-download:下载 Ant-Eclipse,它是 Java 构建工具 Ant 生成 Eclipse 项目的任务,只需轻松导入和使用即可。Ant 构建脚本用作配置生成项目所基于的源代码和库的中心位置。
  2. init:初始化操作,包括创建新的目录和设置时间戳格式,创建的目录包括:
  • ${basedir}/build/classes
  • ${basedir}/build/lib
  • ${basedir}/build/package/lib
  • ${basedir}/build/test/lib
  1. ivy-download:下载 Apache Ivy™ ,它是一个流行的依赖管理器,专注于灵活性和简单性。
  2. ivy-taskdef:结合项目命名空间中的 antlib 定义,它将从 Ant 库或本地目录加载 Ivy 类。
  3. ivy-init:使用 ${basedir}/ivysettings.xml 文件配置 Ivy
  4. ivy-retrieve:该任务将已解析的依赖项复制到文件系统中所需的任何位置
  5. ivy-retrieve-javacc:初始化目录${basedir}/build/javacc/lib,并执行一次ivy:retrieve
  6. generate_jute_parser:生产 jute 解析器
    1. 初始化目录${basedir}/build/jute_compiler/org/apache/jute/compiler/generated
    2. 执行一次ivy:artifactproperty,根据之前解析过的依赖包的包名(解析包名根据 <ivy:retrieve> 标签的 pattern=${ivy.lib}/[artifact]-[revision].[ext] 属性),生成一批以 [artifact].revision 格式命名的属性,并将依赖包的 [revision] 赋值给对应包名的属性。例如slf4j-api.revision=1.7.25commons-lang.revision=2.6javacc.revision=5.0等等。
    3. 执行一次move同位移动来实现文件重命名,将带版本号的 ${basedir}/build/javacc/lib/javacc-${javacc.revision}.jar重命名为没有版本号的${basedir}/build/javacc/lib/javacc.jar
    4. 执行一次javacc编译${basedir}/zookeeper-jute/src/main/java/org/apache/jute/compiler/generated/rcc.jj为 java 类并输出到目录 ${basedir}/build/jute_compiler/org/apache/jute/compiler/generated/
  7. jute:用javac编译${basedir}/zookeeper-jute/src/main/java${basedir}/build/jute_compiler两处源文件为class文件并输出到目录${basedir}/build/classes
  8. compile_jute_uptodate:比较源文件与目标文件时间戳,如果目标文件比源文件更新,则设置属性juteBuild.notRequired=true,该属性用于任务compile_jute的执行条件,只有在它为 false 时才会执行compile_jute任务。
  9. compile_jute:生成一些java类
    1. 创建新目录:${basedir}/zookeeper-jute/target/main/java
    2. 创建新目录:${basedir}/zookeeper-client/zookeeper-client-c/generated
    3. 执行java代码:org.apache.jute.compiler.generated.Rcc,该代码的作用就是编译位于 ${basedir}/zookeeper-jute/src/main/resources/zookeeper.jute 文件内容中的java代码,生成相应的类。包含:
      1. org.apache.zookeeper.data.*
      2. org.apache.zookeeper.proto.*
      3. org.apache.zookeeper.server.quorum.*
      4. org.apache.zookeeper.server.persistence.*
      5. org.apache.zookeeper.txn.*
  10. ver-gen:执行 javac 编译目录为 ${basedir}/zookeeper-server/src/main/java 下的java类,并将产出class文件输出到 ${basedir}/build/classes 目录
  11. git-revision
    1. 创建新目录${basedir}/.revision
    2. 判断如果是 windows 操作系统,则设置属性:shell.name=cmdrevision.cmd.line=/c ${basedir}/zookeeper-server/src/main/resources\lastRevision.bat
    3. 执行命令:经过人工拼接最终执行的是 cmd /c ${basedir}/zookeeper-server/src/main/resources\lastRevision.bat ${basedir}/.revision/revision.properties (注意:${basedir}是项目根目录,请读者自行脑中替换),所以是执行了一个windows批命令脚本。该脚本会收集当前git仓库的最后一次提交的hash值,并输出到一个 revision.properties 文件中。
    4. 将上一个命令输出的 revision.properties 导入到属性集中,其中只有一个属性:lastRevision
  12. version-info
    1. 创建目录${basedir}/zookeeper-jute/target/main/java
    2. 执行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 文件,该文件记录了一下版本信息。
  13. process-template:将目录${basedir}/zookeeper-client/zookeeper-client-c中的configure.ac.ininclude/zookeeper_version.h.in文件复制到同目录并且重命名删除它们的.in后缀。
  14. build-generated:执行 javac 命令编译目录 ${basedir}/zookeeper-jute/target/main/java 下的所有java文件并将产出 class 文件输出到目录 ${basedir}/build/classes
  15. ivy-retrieve-test:测试执行 ivy:retrieve
  16. 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.ACLorg.apache.zookeeper.data.Stat以及更多

为了让zookeeper-server能接触的到这些类,需要将这些目录加到它的 classpath 里面。

具体操作方法如下:

依次点击菜单:File > Project structure... >

在这里插入图片描述
增加两个目录即可:

  1. ${basedir}/build/classes
  2. ${basedir}/conf

注意:目录 ${basedir}/conf 里面没有 class 文件,所以 idea 询问你选择的是该目录中的什么类型文件,选择 Classes 即可
在这里插入图片描述

配置完成之后,会发现,编辑器里也不会出现org.apache.zookeeper.data.ACLorg.apache.zookeeper.data.Stat等类红色警告,build project 的时候也不会提示找不到该类等错误了。

3.8. 启动 QuorumPeerMain

  1. ${basedir}/zookeeper-server 模块目录下找到 org.apache.zookeeper.server.quorum.QuorumPeerMain 类。
  2. 右键选择 Modify Run Configuration... 开启设置启动参数配置
  3. jdk选择和项目保持一致,idea会默认选择自带的jdk,建议手动更改为保持项目和ant同一个jdk。
  4. 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 明确包含有以下目录:

  1. ${basedir}\build\classes
  2. ${basedir}\build\lib\*
  3. ${basedir}\*
  4. ${basedir}\lib\*
  5. ${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 一样呢?

从两个方面来回答:

  1. 其实 Idea 也可以用不选择某个任务来执行从而让它执行默认的 ant jar ,但是对于 Idea 环境来说,前者已经足够,ant jar会生成更多的内容,比如会把 zookeeper-server 模块整个编译到 ${basedir}/build/classes里,那这样的话,和 mvn compile 编译到模块 target/classes 目录重复,而观察 InteliJ Idea 启动zookeeper的java命令内容 中的classpath,它是同时包含这两个目录的,一旦出现重复,而没有在更新代码之后及时保持两个目录下的编译结果一致,可能会出现不可预知的问题。
  2. 对于 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

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/1514817.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

微信小程序之vue按钮切换内容变化

效果图如下&#xff1b; 上代码 <template><view class"content"><view class"searchDiv"><view class"paytab"><view class"buttab" v-for"(t,index) in tabList" :key"index" clic…

叶子分享站PHP源码

叶子网盘分享站PHP网站源码&#xff0c;创建无限级文件夹&#xff0c;上传文件&#xff0c;可进行删除&#xff0c;下载等能很好的兼容服务器。方便管理者操作&#xff0c;查看更多的下载资源以及文章&#xff0c;新增分享功能&#xff0c;异步上传文件/资源等 PHP网盘源码优势…

Docker进阶:容器与镜像的导入和导出

Docker进阶&#xff1a;容器与镜像的导入和导出 1、容器&#xff08;Container&#xff09;和镜像&#xff08;Image&#xff09;的区别2、导出 Docker 容器3、导入 Docker 容器快照为镜像4、导出 Docker 镜像5、导入 Docker 镜像6、docker export 和 docker save区别7、docker…

优先级队列 priority_queue 的使用及示例代码

一、简介 priority_queue 即 优先级队列&#xff08;一种特殊的队列&#xff0c;其中的元素按照一定的优先级顺序排列&#xff0c;每次取出时都会取出具有最高优先级的元素&#xff0c;或者说可以获取队列中的最大/最小元素&#xff09;&#xff0c;它是C标准模板库&#xff0…

构建部署_Jenkins介绍与安装

构建部署_Jenkins介绍与安装 构建部署_Jenkins介绍与安装Jenkins介绍Jenkins安装 构建部署_Jenkins介绍与安装 Jenkins介绍 Jenkins是一个可扩展的持续集成引擎。 持续集成&#xff0c;就是通常所说的CI&#xff08;Continues Integration&#xff09;&#xff0c;可以说是现…

Android的UI渲染机制(二)

安卓系统中有 2 种 vsync 信号&#xff1a; &#xff08;1&#xff09;屏幕产生的硬件 vsync信号&#xff0c;主要用于通知应用程序开始在自己的窗口“画布”中执行一帧画面的绘制和渲染 &#xff08;2&#xff09;由SurfaceFlinger将其转成的软件 vsync 信号&#xff0c;经由…

十六、接口隔离原则、反射、依赖注入

接口隔离原则、反射、特性、依赖注入 接口隔离原则 客户端不应该依赖它不需要的接口&#xff1b;一个类对另一个类的依赖应该建立在最小的接口上。 五种原则当中的i 上一章中的接口&#xff0c;即契约。 契约就是在说两件事&#xff0c;甲方说自己不会多要&#xff0c;乙方会在…

(黑马出品_高级篇_03)SpringCloud+RabbitMQ+Docker+Redis+搜索+分布式

&#xff08;黑马出品_高级篇_03&#xff09;SpringCloudRabbitMQDockerRedis搜索分布式 微服务技术——多级缓存 今日目标1.什么是多级缓存2.JVM进程缓存2.1.导入案例2.1.1.安装MySQL2.1.1.1.准备目录2.1.1.2.运行命令2.1.1.3.修改配置 2.1.1.4.…

优雅的记录日志,拒绝打印模糊信息导致bug定位难

想必大家都有过这样的经历&#xff1a;在项目中遇到报错需要紧急修复时&#xff0c;却因为日志信息模糊不清&#xff0c;无法迅速准确地定位到错误源头&#xff0c;这确实让人感到十分苦恼和无奈。 在新入职一家公司并着手修改遗留bug时&#xff0c;经常发现之前的开发者并未记…

用云服务器构建gpt和stable-diffusion大模型

用云服务器构建gpt和stable-diffusion大模型 一、前置知识二、用云端属于自己的聊天chatGLM3step1、项目配置step2、环境配置1、前置知识2、环境配置流程 step3、创建镜像1、前置知识2、创建镜像流程 step4、通过 Gradio 创建ChatGLM交互界面1、前置知识2、创建ChatGLM交互界面…

利用HubSpot出海CRM和人工智能技术提升出海业务的效率和效果

在当今数字化时代&#xff0c;智能化营销已经成为企业获取客户和扩大市场份额的关键策略。特别是对于出海业务而言&#xff0c;利用智能化营销技术来应对不同文化、语言和市场的挑战&#xff0c;已经成为企业竞争的关键优势。今天运营坛将带领大家探讨如何利用HubSpot CRM和人工…

JVM 重要知识梳理

一、java内存区域 程序计数器&#xff1a;线程私有&#xff0c;唯一一个不会出现outOfMemoryError的内存区域虚拟机栈&#xff1a;线程私有&#xff0c;栈由一个个栈帧组成&#xff0c;而每个栈帧中都拥有&#xff1a;局部变量表、操作数栈、动态链接、方法返回地址。本地方法…

Prompt Learning:人工智能的新篇章

开篇&#xff1a;AI的进化之旅 想象一下&#xff0c;你正在和一位智能助手对话&#xff0c;它不仅理解你的问题&#xff0c;还能提出引导性的问题帮助你更深入地思考。这正是prompt learning的魔力所在——它让机器学习模型变得更加智能和互动。在这篇博客中&#xff0c;我们将…

【JavaScript】面试手撕柯里化函数

&#x1f308;个人主页: 鑫宝Code &#x1f525;热门专栏: 闲话杂谈&#xff5c; 炫酷HTML | JavaScript基础 ​&#x1f4ab;个人格言: "如无必要&#xff0c;勿增实体" 文章目录 引入柯里化定义实现快速使用柯里化的作用提高自由度bind函数 参考资料 引入 上周…

git区域与对象

大纲 工作区(workspace directory):本机的代码项目,是一种沙箱环境 暂存区(stage index):工作区在程序员写程序的过程中会发生无数次改动&#xff0c;git不可能记录每一次的改动&#xff0c;这些改动的过程在暂存区负责记录&#xff0c;暂存区会将最终的状态随着程序员的提交…

springboot与elasticsearch-7.16.2的基础CRUD使用——入门向

highlight: an-old-hope 基于elasticsearch-7.16.2 &#xff0c;使用的是旧版的高级客户端 restHighLevelClient springboot版本2.6.13 项目原代码地址 https://gitee.com/kenwm/es7demo.git 参考博客 1、SpringBoot集成ElasticSearch&#xff0c;实现模糊查询&#xff0c;批…

学python新手如何安装pycharm;python小白如何安装pycharm

首先找到官网&#xff1a; Download PyCharm: The Python IDE for data science and web development by JetBrains 打开后选择下载&#xff0c;下图标红部分 点击exe程序&#xff0c;点击下一步&#xff01; 选择安装路径&#xff0c;下一步 弹出界面全选 选择默认 然后直接…

Spring核心接口:BeanFactory接口

一图胜千言 BeanFactory 属性&方法解析 点击展开注意&#xff1a;以上代码仅供参考&#xff0c;可能存在不完整或不准确的情况。 public interface BeanFactory {// 根据Bean名称返回Bean实例。// 如果Bean不存在&#xff0c;则抛出NoSuchBeanDefinitionException异常。Obj…

华为机考:HJ43 迷宫问题

华为机考&#xff1a;HJ43 迷宫问题 描述 DFS 从迷宫入口开始进行dfs搜索&#xff0c;每次进入一个点&#xff0c;将其加入临时路径数组中&#xff0c;把该位改成0表示不能进入&#xff0c;然后依次搜索该位下、右、上、左四个方向的点&#xff0c;如果搜索的这个点可以进入则…

【机器学习智能硬件开发全解】(二)—— 政安晨:嵌入式系统基本素养【处理器原理】

嵌入式系统的基本素养包括以下几个方面&#xff1a; 硬件知识&#xff1a;嵌入式系统通常由硬件和软件组成&#xff0c;了解和熟悉硬件的基本知识&#xff0c;包括微处理器、存储器、外设等&#xff0c;并了解它们的工作原理和特性。 软件编程&#xff1a;熟悉至少一种编程语言…