zookeeper 单机模式安装配置

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


source /etc/profile 改过文件后 让文件立即生效

6、启动zk

 ./zkServer.sh start

7、客户端连接测试

./zkCli.sh -server localhost:2181

[root@master bin]$ pwd
/opt/zk/zk/bin
[root@master bin]$ ./zkCli.sh -server localhost:2181
Connecting to localhost:2181
。。。
[zk: localhost:2181(CONNECTED) 0] ls /
[zookeeper]
[zk: localhost:2181(CONNECTED) 1] create /Test hellozk
Created /Test
[zk: localhost:2181(CONNECTED) 2] get /Test
hellozk
[zk: localhost:2181(CONNECTED) 3] set /Test hellozookeeper
[zk: localhost:2181(CONNECTED) 4] get /Test
hellozookeeper
[zk: localhost:2181(CONNECTED) 5] delete /Test
[zk: localhost:2181(CONNECTED) 6] get /Test
Node does not exist: /Test
[zk: localhost:2181(CONNECTED) 7] quit
2014-11-19 03:53:50,180 [myid:] - INFO  [main:ZooKeeper@968] - Session: 0x149c475d7db0000 closed
2014-11-19 03:53:50,182 [myid:] - INFO  [main-EventThread:ClientCnxn$EventThread@529] - EventThread shut down

 

单机安装配置 完成。

你可能感兴趣的:(linux,zookeeper)