mac安装zookeeper客户端 记录
下载压缩包从此地址下载zookeeper-xxx.tar.gz注意:从目前的最新版本3.5.5开始,带有bin名称的包才是我们想要的下载可以直接使用的里面有编译后的二进制的包,而之前的普通的tar.gz的包里面是只是源码的包无法直接使用。,如果下载3.5.5以后的版本的Zookeeper安装包,需下载带有bin标识的。解压> tar -zxvf zo...
·
下载压缩包
从 此地址 下载zookeeper-xxx.tar.gz 注意:从目前的最新版本3.5.5开始,带有bin名称的包才是我们想要的下载可以直接使用的里面有编译后的二进制的包,而之前的普通的tar.gz的包里面是只是源码的包无法直接使用。,如果下载3.5.5以后的版本的Zookeeper安装包,需下载带有bin标识的。
解压
> tar -zxvf zookeeper-3.5.6.tar.gz //解压
> cd zookeeper-3.5.6/conf //切换到配置目录下
> mv zoo_sample.cfg zoo.cfg //更改默认配置文件名称
> vi zoo.cfg //编辑配置文件,自定义dataDir
启动Server
> cd zookeeper-3.4.10/bin //切换到 bin目录
> ./zkServer.sh start //启动
/usr/bin/java
ZooKeeper JMX enabled by default
Using config: /Users/admin/zookeeper/apache-zookeeper-3.5.6/bin/../conf/zoo.cfg
Starting zookeeper ... FAILED TO START
问题原因:
需要下载带有bin的文件
解决过程:
查看启动状态:
admindeMac-mini-2:bin admin$ ./zkServer.sh status
/usr/bin/java
ZooKeeper JMX enabled by default
Using config: /Users/admin/zookeeper/apache-zookeeper-3.5.6/bin/../conf/zoo.cfg
Client port found: 2181. Client address: localhost.
Error contacting service. It is probably not running.
查看报错日志
admindeMac-mini-2:bin admin$ ./zkServer.sh start-foreground
/usr/bin/java
ZooKeeper JMX enabled by default
Using config: /Users/admin/zookeeper/apache-zookeeper-3.5.6/bin/../conf/zoo.cfg
错误: 找不到或无法加载主类 org.apache.zookeeper.server.quorum.QuorumPeerMain
重新下载带有bin的文件后成功运行
客户端连接:
> cd zookeeper-3.4.10/bin //切换到 bin目录
> ./zkCli.sh -server 127.0.0.1:2181
[zk: 127.0.0.1:2181(CONNECTED) 0] help //输入help命令
ZooKeeper -server host:port cmd args
stat path [watch]
set path data [version]
ls path [watch]
delquota [-n|-b] path
ls2 path [watch]
setAcl path acl
setquota -n|-b val path
history
redo cmdno
printwatches on|off
delete path [version]
sync path
listquota path
rmr path
get path [watch]
create [-s] [-e] path data acl
addauth scheme auth
quit
getAcl path
close
connect host:port
/官方测试命令
[zk: 127.0.0.1:2181(CONNECTED) 2] ls /
[zookeeper]
[zk: 127.0.0.1:2181(CONNECTED) 3] create /zk_test my_data
Created /zk_test
[zk: 127.0.0.1:2181(CONNECTED) 4] ls /
[zookeeper, zk_test]
[zk: 127.0.0.1:2181(CONNECTED) 5] get /zk_test
my_data
cZxid = 0x2
ctime = Wed Feb 28 15:18:45 CST 2018
mZxid = 0x2
mtime = Wed Feb 28 15:18:45 CST 2018
pZxid = 0x2
cversion = 0
dataVersion = 0
aclVersion = 0
ephemeralOwner = 0x0
dataLength = 7
numChildren = 0
[zk: 127.0.0.1:2181(CONNECTED) 6] set /zk_test junk
cZxid = 0x2
ctime = Wed Feb 28 15:18:45 CST 2018
mZxid = 0x3
mtime = Wed Feb 28 15:20:23 CST 2018
pZxid = 0x2
cversion = 0
dataVersion = 1
aclVersion = 0
ephemeralOwner = 0x0
dataLength = 4
numChildren = 0
[zk: 127.0.0.1:2181(CONNECTED) 7] get /zk_test
junk
cZxid = 0x2
ctime = Wed Feb 28 15:18:45 CST 2018
mZxid = 0x3
mtime = Wed Feb 28 15:20:23 CST 2018
pZxid = 0x2
cversion = 0
dataVersion = 1
aclVersion = 0
ephemeralOwner = 0x0
dataLength = 4
numChildren = 0
[zk: 127.0.0.1:2181(CONNECTED) 8] delete /zk_test
[zk: 127.0.0.1:2181(CONNECTED) 9] ls
[zk: 127.0.0.1:2181(CONNECTED) 10] ls /
[zookeeper]
停止Server
> ./zkServer.sh stop //停止后,如果CLi没有关闭,将报错
ZooKeeper JMX enabled by default
Using config: zookeeper-3.4.10/bin/../conf/zoo.cfg
Stopping zookeeper ... STOPPED
参考:
https://blog.csdn.net/qq_23853743/article/details/88383536
更多推荐
已为社区贡献1条内容
所有评论(0)