1、执行命令 下载zookeeper3.5.0 具体哪个目录下 自己定
wget http://mirror.bit.edu.cn/apache//zookeeper/zookeeper-3.5.0-alpha/zookeeper-3.5.0-alpha.tar.gz
2、解压文件
tar zxvf zookeeper-3.5.0-alpha.tar.gz
3、改名(这个可以随意)
mv zookeeper-3.5.0-alpha zk
4、配置文件zoo.cfg(默认是这个zoo_sample.cfg,可以复制一份,保存到其他地方,然后改名为zoo.cfg)
dataDir=/opt/zk/zk/data
dataLogDir=/opt/zk/zk/logs
5、配置环境变量
vim /etc/profile
export ZOOKEEPER_HOME=/opt/zk/zk (这里改成你自己的目录)
PATH=$ZOOKEEPER_HOME/bin:$PATH
export PATH
6、启动zk
./zkServer.sh start
7、客户端连接测试
./zkCli.sh -server localhost:2181
[[email protected] bin]$ pwd
/opt/zk/zk/bin
[[email protected] bin]$ ./zkCli.sh -server localhost:2181
Connecting to localhost:2181
。。。
[root: localhost:2181(CONNECTED) 0] ls /
[zookeeper]
[root: localhost:2181(CONNECTED) 1] create /Test hellozk
Created /Test
[root: localhost:2181(CONNECTED) 2] get /Test
hellozk
[root: localhost:2181(CONNECTED) 3] set /Test hellozookeeper
[root: localhost:2181(CONNECTED) 4] get /Test
hellozookeeper
[root: localhost:2181(CONNECTED) 5] delete /Test
[root: localhost:2181(CONNECTED) 6] get /Test
Node does not exist: /Test
[root: localhost:2181(CONNECTED) 7] quit
2014-11-19 03:53:50,180 [myid:] - INFO [main:[email protected]] - Session: 0x149c475d7db0000 closed
2014-11-19 03:53:50,182 [myid:] - INFO [main-EventThread:[email protected]] - EventThread shut down
单机安装配置 完成。
版权声明:本文为博主原创文章,未经博主允许不得转载。