一 zookeeper的搭建

1.1 上传zkjar包

1.2 搭建配置

1.解压压缩包
[root@localhost export]# tar -zxvf zookeeper-3.7.0-bin.tar.gz

2.创建data文件夹

[root@localhost export]# cd apache-zookeeper-3.7.0-bin/
[root@localhost apache-zookeeper-3.7.0-bin]# ls
bin conf docs lib LICENSE.txt NOTICE.txt README.md README_packaging.md
[root@localhost apache-zookeeper-3.7.0-bin]# pwd
/root/export/apache-zookeeper-3.7.0-bin
[root@localhost apache-zookeeper-3.7.0-bin]# pwd
/root/export/apache-zookeeper-3.7.0-bin
[root@localhost apache-zookeeper-3.7.0-bin]# ls
bin conf docs lib LICENSE.txt NOTICE.txt README.md README_packaging.md
[root@localhost apache-zookeeper-3.7.0-bin]# mkdir -p data
[root@localhost apache-zookeeper-3.7.0-bin]# pwd
/root/export/apache-zookeeper-3.7.0-bin

3.修改配置

[root@localhost apache-zookeeper-3.7.0-bin]# ls
bin conf data docs lib LICENSE.txt NOTICE.txt README.md README_packaging.md
[root@localhost apache-zookeeper-3.7.0-bin]# cd conf
[root@localhost conf]# ls
configuration.xsl log4j.properties zoo_sample.cfg
[root@localhost conf]# mv zoo_sample.cfg zoo.cfg
[root@localhost conf]# ls
configuration.xsl log4j.properties zoo.cfg
[root@localhost conf]# pwd
/root/export/apache-zookeeper-3.7.0-bin/conf

4.通过vim修改配置文件夹,将dataDir 修改成刚才所建的data文件夹

5.启动服务

[root@localhost bin]# ./zkServer.sh start
ZooKeeper JMX enabled by default
Using config: /root/export/apache-zookeeper-3.7.0-bin/bin/../conf/zoo.cfg
Starting zookeeper … STARTED
[root@localhost bin]# ./zkServer.sh status
ZooKeeper JMX enabled by default
Using config: /root/export/apache-zookeeper-3.7.0-bin/bin/../conf/zoo.cfg
Client port found: 2181. Client address: localhost. Client SSL: false.
Mode: standalone
6.常用命令

./zkServer.sh start
./zkServer.sh status # 查看启动状态
./zkServer.sh stop # 停止
./zkServer.sh restart # 重启
./zkCli.sh # 查看zk客户端