zookeeper版本是: apache-zookeeper-3.7.0
IntelliJ 版本是: IntelliJ IDEA 2021.1 (Community Edition)
1.使用IntelliJ 打开zookeeper源码目录:
2. 将conf文件夹下的zoo_sample.cfg复制为zoo.cfg
3. 创建数据存储目
右击apache-zookeeper-3.7.0[parent], New->Directory,输入tmp/zookeeper
4. 编译zookeeper包,点击右侧边栏的Maven,打开Maven窗口
这是为解决 程序包org.apache.zookeeper.data不存在 的错误;
点击Apache Zookeeper -> compile
5. QuorumPeerMain运行设置
定位到zookeeper-server-> src-> main -> java ->org ->apache ->zookeeper ->server ->quorum -> QuorumPeerMain
右击QuorumPeerMain -> Modify Run Configuration…
然后点击Modify options -> Add VM option
输入如下参数: 都是在源码conf目录下
6. 定位到zookeeper-server -> pom.xml
将所有的provided注释掉
这是为了解决 Exception in thread “main” java.lang.NoClassDefFoundError: com/codahale/metrics/Reservoir的错误;
7. 运行
右击QuorumPeerMain -> Run “QuorumPeerMain.main()”