zookeeper偽分布安裝配置
1、下載路徑為:http://mirrors.cnnic.cn/apache/zookeeper/stable/
2、安裝:
第一步 解壓zookeeper壓縮包:
進入 zookeeper安裝目錄
第二步 創建一個data目錄:
第三步 修改 conf/zoo.cfg文件:
先將zoo_sample.cfg copy 為 zoo.cfg
然後 編輯zoo.cfg文件:
修改後:
第三步 將ZOOKEEPER_HOME加入到.bash_profile環境變量中並使用source使環境變量生效
第三步 啟動zookeeper的server:
我們啟動zookeeper後,通過jps,可以查看到QuorunPeerMain進程
如果我們想配置集群zookeeper,請查看這個文檔:http://zookeeper.apache.org/doc/trunk/zookeeperStarted.html#sc_RunningReplicatedZooKeeper
3、使用:
客戶端連接zookeeper server:
help命令:
ls命令:
[zk: 127.0.0.1:2181(CONNECTED) 2] ls /
[zookeeper]
create命令:
[zk: 127.0.0.1:2181(CONNECTED) 5] create /zk_test my_data
Created /zk_test
[zk: 127.0.0.1:2181(CONNECTED) 8] ls /
[zookeeper, zk_test]
get命令:
[zk: 127.0.0.1:2181(CONNECTED) 0] get /zk_test
my_data
cZxid = 0x2
ctime = Fri Feb 06 01:45:04 PST 2015
mZxid = 0x2
mtime = Fri Feb 06 01:45:04 PST 2015
pZxid = 0x2
cversion = 0
dataVersion = 0
aclVersion = 0
ephemeralOwner = 0x0
dataLength = 7
numChildren = 0
[zk: 127.0.0.1:2181(CONNECTED) 1]
修改下zk_test節點數據:
[zk: 127.0.0.1:2181(CONNECTED) 15] set /zk_test summer
cZxid = 0x2
ctime = Fri Feb 06 01:45:04 PST 2015
mZxid = 0x5
mtime = Fri Feb 06 01:49:19 PST 2015
pZxid = 0x2
cversion = 0
dataVersion = 1
aclVersion = 0
ephemeralOwner = 0x0
dataLength = 6
numChildren = 0
[zk: 127.0.0.1:2181(CONNECTED) 16]
再查下:
[zk: 127.0.0.1:2181(CONNECTED) 29] get /zk_test
summer
cZxid = 0x2
ctime = Fri Feb 06 01:45:04 PST 2015
mZxid = 0x5
mtime = Fri Feb 06 01:49:19 PST 2015
pZxid = 0x2
cversion = 0
dataVersion = 1
aclVersion = 0
ephemeralOwner = 0x0
dataLength = 6
numChildren = 0
[zk: 127.0.0.1:2181(CONNECTED) 30]
delete命令:
[zk: 127.0.0.1:2181(CONNECTED) 44] delete /zk_test
再使用get查下該節點:
[zk: 127.0.0.1:2181(CONNECTED) 45] get /zk_test
Node does not exist: /zk_test
[zk: 127.0.0.1:2181(CONNECTED) 46]
更多關於使用操作,請看這篇文檔:http://zookeeper.apache.org/doc/trunk/zookeeperProgrammers.html
參考文檔1:http://zookeeper.apache.org/doc/trunk/zookeeperStarted.html
參考文檔2:http://zookeeper.apache.org/doc/trunk/zookeeperAdmin.html
本文轉載自 http://blog.csdn.net/stark_summer/article/details/43566531
zookeeper偽分布安裝配置