Mac 中 Zookeeper 安装与配置 一

  |   0 评论   |   829 浏览

下载与安装

http://mirror.bit.edu.cn/apache/zookeeper/

下载得到压缩包 zookeeper-3.4.12.tar.gz

解压:

tar zxvf zookeeper-3.4.12.tar.gz

解压缩后 Zookeeper 目录:

.
├── LICENSE.txt
├── NOTICE.txt
├── README.md
├── README_packaging.txt
├── bin
├── build.xml
├── conf
├── contrib
├── dist-maven
├── docs
├── ivy.xml
├── ivysettings.xml
├── lib
├── recipes
├── src
├── zookeeper-3.4.12.jar
├── zookeeper-3.4.12.jar.asc
├── zookeeper-3.4.12.jar.md5
└── zookeeper-3.4.12.jar.sha1

bin目录中存放有运行脚本;conf目录中存放有配置文件;lib目录中存放有运行所需要第三方库。

配置

集群模式

单机模式

修改配置文件
conf目录下重命名文件zoo_sample.cfg 为 zoo.cfg:

tickTime=2000
initLimit=10
syncLimit=5
dataDir=/tmp/zookeeper
clientPort=2181

运行ZooKeeper Server

$ ./bin/zkServer.sh start
ZooKeeper JMX enabled by default
Using config: /Users/chenlei/syssoft/soft/zookeeper-3.4.12/bin/../conf/zoo.cfg
Starting zookeeper ... STARTED

使用telnet连接验证ZooKeeper Server

$ telnet 127.0.0.1 2181
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.

停止ZooKeeper Server

$ ./bin/zkServer.sh stop
ZooKeeper JMX enabled by default
Using config: /Users/chenlei/syssoft/soft/zookeeper-3.4.12/bin/../conf/zoo.cfg
Stopping zookeeper ... STOPPED

非后台运行ZooKeeper Server

$ ./bin/zkServer.sh start-foreground
ZooKeeper JMX enabled by default
Using config: /Users/chenlei/syssoft/soft/zookeeper-3.4.12/bin/../conf/zoo.cfg
2018-06-26 16:52:16,532 [myid:] - INFO  [main:QuorumPeerConfig@136] - Reading configuration from: /Users/chenlei/syssoft/soft/zookeeper-3.4.12/bin/../conf/zoo.cfg
2018-06-26 16:52:16,538 [myid:] - INFO  [main:DatadirCleanupManager@78] - autopurge.snapRetainCount set to 3
2018-06-26 16:52:16,538 [myid:] - INFO  [main:DatadirCleanupManager@79] - autopurge.purgeInterval set to 0
2018-06-26 16:52:16,538 [myid:] - INFO  [main:DatadirCleanupManager@101] - Purge task is not scheduled.
2018-06-26 16:52:16,539 [myid:] - WARN  [main:QuorumPeerMain@116] - Either no config or no quorum defined in config, running  in standalone mode
2018-06-26 16:52:16,553 [myid:] - INFO  [main:QuorumPeerConfig@136] - Reading configuration from: /Users/chenlei/syssoft/soft/zookeeper-3.4.12/bin/../conf/zoo.cfg
2018-06-26 16:52:16,553 [myid:] - INFO  [main:ZooKeeperServerMain@98] - Starting server
2018-06-26 16:52:46,573 [myid:] - INFO  [main:Environment@100] - Server environment:zookeeper.version=3.4.12-e5259e437540f349646870ea94dc2658c4e44b3b, built on 03/27/2018 03:55 GMT
2018-06-26 16:52:46,573 [myid:] - INFO  [main:Environment@100] - Server environment:host.name=192.168.2.1
2018-06-26 16:52:46,573 [myid:] - INFO  [main:Environment@100] - Server environment:java.version=1.8.0_131
2018-06-26 16:52:46,573 [myid:] - INFO  [main:Environment@100] - Server environment:java.vendor=Oracle Corporation
2018-06-26 16:52:46,574 [myid:] - INFO  [main:Environment@100] - Server environment:java.home=/Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/jre
2018-06-26 16:52:46,574 [myid:] - INFO  [main:Environment@100] - Server environment:java.class.path=/Users/chenlei/syssoft/soft/zookeeper-3.4.12/bin/../build/classes:/Users/chenlei/syssoft/soft/zookeeper-3.4.12/bin/../build/lib/*.jar:/Users/chenlei/syssoft/soft/zookeeper-3.4.12/bin/../lib/slf4j-log4j12-1.7.25.jar:/Users/chenlei/syssoft/soft/zookeeper-3.4.12/bin/../lib/slf4j-api-1.7.25.jar:/Users/chenlei/syssoft/soft/zookeeper-3.4.12/bin/../lib/netty-3.10.6.Final.jar:/Users/chenlei/syssoft/soft/zookeeper-3.4.12/bin/../lib/log4j-1.2.17.jar:/Users/chenlei/syssoft/soft/zookeeper-3.4.12/bin/../lib/jline-0.9.94.jar:/Users/chenlei/syssoft/soft/zookeeper-3.4.12/bin/../lib/audience-annotations-0.5.0.jar:/Users/chenlei/syssoft/soft/zookeeper-3.4.12/bin/../zookeeper-3.4.12.jar:/Users/chenlei/syssoft/soft/zookeeper-3.4.12/bin/../src/java/lib/*.jar:/Users/chenlei/syssoft/soft/zookeeper-3.4.12/bin/../conf:
2018-06-26 16:52:46,574 [myid:] - INFO  [main:Environment@100] - Server environment:java.library.path=/Users/chenlei/Library/Java/Extensions:/Library/Java/Extensions:/Network/Library/Java/Extensions:/System/Library/Java/Extensions:/usr/lib/java:.
2018-06-26 16:52:46,575 [myid:] - INFO  [main:Environment@100] - Server environment:java.io.tmpdir=/var/folders/p6/c7x0g7sj603dt_1brhj2x1nr0000gn/T/
2018-06-26 16:52:46,575 [myid:] - INFO  [main:Environment@100] - Server environment:java.compiler=<NA>
2018-06-26 16:52:46,576 [myid:] - INFO  [main:Environment@100] - Server environment:os.name=Mac OS X
2018-06-26 16:52:46,576 [myid:] - INFO  [main:Environment@100] - Server environment:os.arch=x86_64
2018-06-26 16:52:46,577 [myid:] - INFO  [main:Environment@100] - Server environment:os.version=10.13.5
2018-06-26 16:52:46,577 [myid:] - INFO  [main:Environment@100] - Server environment:user.name=chenlei
2018-06-26 16:52:46,577 [myid:] - INFO  [main:Environment@100] - Server environment:user.home=/Users/chenlei
2018-06-26 16:52:46,577 [myid:] - INFO  [main:Environment@100] - Server environment:user.dir=/Users/chenlei/syssoft/soft/zookeeper-3.4.12
2018-06-26 16:52:46,593 [myid:] - INFO  [main:ZooKeeperServer@835] - tickTime set to 2000
2018-06-26 16:52:46,594 [myid:] - INFO  [main:ZooKeeperServer@844] - minSessionTimeout set to -1
2018-06-26 16:52:46,594 [myid:] - INFO  [main:ZooKeeperServer@853] - maxSessionTimeout set to -1
2018-06-26 16:52:46,609 [myid:] - INFO  [main:ServerCnxnFactory@117] - Using org.apache.zookeeper.server.NIOServerCnxnFactory as server connection factory
2018-06-26 16:52:46,622 [myid:] - INFO  [main:NIOServerCnxnFactory@89] - binding to port 0.0.0.0/0.0.0.0:2181

评论

发表评论