码迷,mamicode.com
首页 > 其他好文 > 详细

Zookeeper安装,Zookeeper单机模式安装

时间:2016-11-17 07:51:35      阅读:233      评论:0      收藏:0      [点我收藏+]

标签:command   复制   kali   nbsp   状态   内容   获取   pac   不同   

http://zookeeper.apache.org/releases.html#download

下载解压到(我自己的)解压到 /usr/local 下

把名字改成 zookeeper

进入zookeeper目录下的conf目录,复制zoo_sample.cfg为zoo.cfg,并将内容修改如下(就是解压后的路径,其他的不用改了,这个路径一般与默认的不同,要改)

dataDir=/usr/local/zookeeper

 tickTime:Zookeeper 服务器之间或客户端与服务器之间心跳的时间间隔。
dataDir:Zookeeper 保存数据的目录,默认情况下,Zookeeper 将写数据的日志文件也保存在这个目录里。
clientPort:Zookeeper 服务器监听端口,用来接受客户端的访问请求。

然后,

进入Zookeeper/bin目录

启动服务与查看服务状态:

 

root@kali:/usr/local/zookeeper/bin# ./zkServer.sh start
ZooKeeper JMX enabled by default
Using config: /usr/local/zookeeper/bin/../conf/zoo.cfg
Starting zookeeper ... STARTED
root@kali:/usr/local/zookeeper/bin# ./zkServer.sh status
ZooKeeper JMX enabled by default
Using config: /usr/local/zookeeper/bin/../conf/zoo.cfg
Mode: standalone

 

打开客户端

 $ ./zkCli.sh 或 $ ./zkCli.sh -server 127.0.0.1:2181  

 

连接后可以

 1 [zk: localhost:2181(CONNECTED) 3] ls /         #查看节点
 2 [zookeeper]
 3 [zk: localhost:2181(CONNECTED) 4] create /mynode1 myvalue1  #建立节点
 4 Created /mynode1
 5 [zk: localhost:2181(CONNECTED) 5] create /mynode2 myvalue2
 6 Created /mynode2
 7 [zk: localhost:2181(CONNECTED) 6] ls /
 8 [mynode1, mynode2, zookeeper]
 9 [zk: localhost:2181(CONNECTED) 7] get /mynode1       #获取节点的值
10 myvalue1
11 cZxid = 0x2
12 ctime = Thu Nov 17 00:49:22 CST 2016
13 mZxid = 0x2
14 mtime = Thu Nov 17 00:49:22 CST 2016
15 pZxid = 0x2
16 cversion = 0
17 dataVersion = 0
18 aclVersion = 0
19 ephemeralOwner = 0x0
20 dataLength = 8
21 numChildren = 0
22 [zk: localhost:2181(CONNECTED) 8] set /mynode1 myvalue11
23 cZxid = 0x2
24 ctime = Thu Nov 17 00:49:22 CST 2016
25 mZxid = 0x4
26 mtime = Thu Nov 17 00:50:58 CST 2016
27 pZxid = 0x2
28 cversion = 0
29 dataVersion = 1
30 aclVersion = 0
31 ephemeralOwner = 0x0
32 dataLength = 9
33 numChildren = 0
34 [zk: localhost:2181(CONNECTED) 9] set /mynode2 myvalue22
35 cZxid = 0x3
36 ctime = Thu Nov 17 00:49:33 CST 2016
37 mZxid = 0x5
38 mtime = Thu Nov 17 00:51:15 CST 2016
39 pZxid = 0x3
40 cversion = 0
41 dataVersion = 1
42 aclVersion = 0
43 ephemeralOwner = 0x0
44 dataLength = 9
45 numChildren = 0
46 [zk: localhost:2181(CONNECTED) 10] ls /
47 [mynode1, mynode2, zookeeper]
48 [zk: localhost:2181(CONNECTED) 11] get /mynode1
49 myvalue11
50 cZxid = 0x2
51 ctime = Thu Nov 17 00:49:22 CST 2016
52 mZxid = 0x4
53 mtime = Thu Nov 17 00:50:58 CST 2016
54 pZxid = 0x2
55 cversion = 0
56 dataVersion = 1
57 aclVersion = 0
58 ephemeralOwner = 0x0
59 dataLength = 9
60 numChildren = 0
61 [zk: localhost:2181(CONNECTED) 12] set /mynode1
62 [zk: localhost:2181(CONNECTED) 13] set /mynode2
63 [zk: localhost:2181(CONNECTED) 14] ls /
64 [mynode1, mynode2, zookeeper]
65 [zk: localhost:2181(CONNECTED) 15] get mynode1
66 Command failed: java.lang.IllegalArgumentException: Path must start with / character
67 [zk: localhost:2181(CONNECTED) 16] get /mynode1
68 myvalue11
69 cZxid = 0x2
70 ctime = Thu Nov 17 00:49:22 CST 2016
71 mZxid = 0x4
72 mtime = Thu Nov 17 00:50:58 CST 2016
73 pZxid = 0x2
74 cversion = 0
75 dataVersion = 1
76 aclVersion = 0
77 ephemeralOwner = 0x0
78 dataLength = 9
79 numChildren = 0
80 [zk: localhost:2181(CONNECTED) 17]             

 

Zookeeper安装,Zookeeper单机模式安装

标签:command   复制   kali   nbsp   状态   内容   获取   pac   不同   

原文地址:http://www.cnblogs.com/tk55/p/6072250.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!