最近在学习kafka,但是了解到,在学习kafka之前,一定要懂得zookeeper。也就是说,在linux系统中,安装kafka之前一定要保证机子上安装有zookeeper才行。
接下来就简单介绍一下zookeeper的安装过程。
1.在linux中安装zookeeper一定要选择这个包:apache-zookeeper-3.5.8-bin.tar.gz,不要选择apache-zookeeper-3.6.2.tar.gz这个安装包。
至于为什么这样选择,请参考网址:https://blog.csdn.net/u010411264/article/details/104706506
2.将apache-zookeeper-3.5.8-bin.tar.gz上传到linux系统/usr/local/目录下,紧接着对安装包进行解压。tar -zxvf apache-zookeeper-3.5.8-bin.tar.gz
3.将解压之后的文件夹改成zookeeper-3.5.8,当然,你不改也是可以的。
4.进入到zookeeper-3.5.8文件夹中,创建data文件夹。mkdir data
5.进入到/usr/local/zookeeper-3.5.8/conf/ 文件夹下面,复制zoo_sample.cfg文件,命名为zoo.cfg。 mv zoo_sample.cfg zoo.cfg (注意:这个步骤必须要操作的)
6.修改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=/usr/local/zookeeper-3.5.8/data
# the port at which the clients will connect
clientPort=2181
admin.serverPort=8888
# the maximum number of client connections.
# increase this if you need to handle more clients
#maxClientCnxns=60
经过以上的操作步骤,zookeeper也就安装成功了。
我们可以进入到zookeeper的二进制可执行文件夹中,启动zookeeper,/usr/local/zookeeper-3.5.8/bin
启动:./zkServer.sh start
查看进程:ps -ef | grep zookeeper
关闭:./zkServer.sh stop