1.zookeeper下载
下载博主自己用的比较多的zookeeper-3.4.8.tar.gz版本
小生在此,请点击下载,come on!
2.解压下载安装包。
tar -zxvf zookeeper-3.4.8.tar.gz
3.跳转zookeeper-3.4.8目录,新建data文件夹,用作数据存储路径。
[root@instance-n4r06itt zookeeper-3.4.8]# mkdir data
4.拷贝zoo_sample.cfg文件。
[root@instance-n4r06itt conf]# cp zoo_sample.cfg zoo.cfg
5.修改zoo.cfg,添加数据存放路径。
# The number of milliseconds of each tick
tickTime=2000
# The number of ticks that the initial
# synchronization phase can take
initLimit=10
# The number of ticks that can pass between
# sending a request and getting an acknowledgement
syncLimit=5
# the directory where the snapshot is stored.
# do not use /tmp for storage, /tmp here is just
# example sakes.
# 添加路径
dataDir=/opt/middleware/zookeeper-3.4.8/data
# the port at which the clients will connect
clientPort=2181
6.执行命令,启动、关闭、状态查询。
启动zk:
[root@instance-n4r06itt conf]# cd ../bin/
[root@instance-n4r06itt bin]# ll
total 36
-rwxr-xr-x 1 1000 1000 232 Feb 6 2016 README.txt
-rwxr-xr-x 1 1000 1000 1937 Feb 6 2016 zkCleanup.sh
-rwxr-xr-x 1 1000 1000 1056 Feb 6 2016 zkCli.cmd
-rwxr-xr-x 1 1000 1000 1534 Feb 6 2016 zkCli.sh
-rwxr-xr-x 1 1000 1000 1628 Feb 6 2016 zkEnv.cmd
-rwxr-xr-x 1 1000 1000 2696 Feb 6 2016 zkEnv.sh
-rwxr-xr-x 1 1000 1000 1089 Feb 6 2016 zkServer.cmd
-rwxr-xr-x 1 1000 1000 6773 Feb 6 2016 zkServer.sh
[root@instance-n4r06itt bin]# ./zkServer.sh start
ZooKeeper JMX enabled by default
Using config: /opt/middleware/zookeeper-3.4.8/bin/../conf/zoo.cfg
Starting zookeeper ... STARTED
关闭zk:
[root@instance-n4r06itt bin]# ./zkServer.sh stop
ZooKeeper JMX enabled by default
Using config: /opt/middleware/zookeeper-3.4.8/bin/../conf/zoo.cfg
Stopping zookeeper ... ./zkServer.sh: line 182: kill: (28909) - No such process
STOPPED
zk状态查询:
[root@instance-n4r06itt bin]# ./zkServer.sh status
ZooKeeper JMX enabled by default
Using config: /opt/middleware/zookeeper-3.4.8/bin/../conf/zoo.cfg
Error contacting service. It is probably not running.
由于博主用的是新虚拟机,环境是新的,出现问题,不过不要紧,有问题咋就解决,根据上述报错提示,博主得安装JDK,咋就装一个。
jdk系列之-linux系统安装
jdk安装完毕以后,再来尝试启动zookeeper。
[root@instance-n4r06itt bin]# ./zkServer.sh stop
ZooKeeper JMX enabled by default
Using config: /opt/middleware/zookeeper-3.4.8/bin/../conf/zoo.cfg
Stopping zookeeper ... ./zkServer.sh: line 182: kill: (28909) - No such process
STOPPED
[root@instance-n4r06itt bin]# ./zkServer.sh start
ZooKeeper JMX enabled by default
Using config: /opt/middleware/zookeeper-3.4.8/bin/../conf/zoo.cfg
Starting zookeeper ... STARTED
[root@instance-n4r06itt bin]# ./zkServer.sh status
ZooKeeper JMX enabled by default
Using config: /opt/middleware/zookeeper-3.4.8/bin/../conf/zoo.cfg
Mode: standalone
[root@instance-n4r06itt bin]# pwd
/opt/middleware/zookeeper-3.4.8/bin
[root@instance-n4r06itt bin]#
至此,zookeeper安装,启动成功。
来源:CSDN
作者:weinichendian
链接:https://blog.csdn.net/weinichendian/article/details/103681861