1、先进入/opt下载并解压最新稳定的zookeeper文件
cd /opt
tar -zxvf zookeeper-3.4.14.tar.gz 解压
新建data和logs文件
mkdir data
mkdir logs
/conf/cp zoo_sample.cfg zoo.cfg
修改zookeeper-3.4.14文件夹名称,改为zk
mv zookeeper-3.4.14 zk
修改配置文件
dataDir=/opt/zk/data
dataLogDir=/opt/zk/logs
配置环境变量
/etc/profile
export ZOOKEEPER_HOME=/opt/zk
export PATH=
P
A
T
H
:
PATH:
PATH:ZOOKEEPER_HOME/bin:$ZOOKEEPER_HOME/conf
ps:我这里把文件夹重命名未zk了,根据实际文件夹来改
最后就启动
进入bin目录下
./zkServer.sh start
./zkServer.sh stop
./zkServer.sh status
客户端连接
zkCli.sh -server 127.0.0.1:2181
连上了测试报错。。。
在这个过程中可能会出现问题
下面是我遇到的问题
找不到主类:原因是zookeeper版本下载错误
//错误信息
./zkServer.sh start-foreground
ZooKeeper JMX enabled by default
Using config: /usr/local/apache-zookeeper-3.5.5/bin/…/conf/zoo.cfg
Error: Could not find or load main class org.apache.zookeeper.server.quorum.QuorumPeerMain
// 错误信息
ZooKeeper JMX enabled by default
Using config: /usr/local/apache-zookeeper-3.5.5/bin/…/conf/zoo.cfg
Client port found: 2181. Client address: localhost.
Error contacting service. It is probably not running.