Ubuntu下 zookeeper 的安装

文章目录

  • zookeeper的下载
  • 解压zookeeper安装包
  • 配置zookeeper
  • 启动zookeeper
    • 启动服务端
    • 启动客户端
  • 安装 zookeeper 的 C++ 开发环境
  • 参考文献

zookeeper的下载

如果大家是在虚拟机上安装可以在如下连接中下载zookeeper:微云链接
然后借助 vmtool 拖拽到虚拟机中。

如果是在云服务器可以用wget命令下载:

ubuntu@VM-0-2-ubuntu:~$ wget http://archive.apache.org/dist/zookeeper/zookeeper-3.4.10/zookeeper-3.4.10.atr.gz

解压zookeeper安装包

然后用zookeeper解压一下安装包

ubuntu@VM-0-2-ubuntu:~/zookeeper$ tar -xvf zookeeper-3.4.10.tar.gz 

配置zookeeper

进入刚刚的解压目录下

ubuntu@VM-0-2-ubuntu:~/zookeeper$ ls
zookeeper-3.4.10  zookeeper-3.4.10.tar.gz  zookeeper_data
ubuntu@VM-0-2-ubuntu:~/zookeeper$ cd zookeeper-3.4.10
ubuntu@VM-0-2-ubuntu:~/zookeeper/zookeeper-3.4.10$ ls
bin        contrib     ivysettings.xml  LICENSE.txt           README.txt  zookeeper-3.4.10.jar      zookeeper-3.4.10.jar.sha1
build.xml  dist-maven  ivy.xml          NOTICE.txt            recipes     zookeeper-3.4.10.jar.asc
conf       docs        lib              README_packaging.txt  src         zookeeper-3.4.10.jar.md5

可以看到有个conf目录,进入:

ubuntu@VM-0-2-ubuntu:~/zookeeper/zookeeper-3.4.10$ cd conf
ubuntu@VM-0-2-ubuntu:~/zookeeper/zookeeper-3.4.10/conf$ ls
configuration.xsl  log4j.properties  zoo_sample.cfg

然后将 zoo_sample.cfg 重命名为 zoo.cfg:

ubuntu@VM-0-2-ubuntu:~/zookeeper/zookeeper-3.4.10/conf$ mv zoo_sample.cfg zoo.cfg
ubuntu@VM-0-2-ubuntu:~/zookeeper/zookeeper-3.4.10/conf$ ls
configuration.xsl  log4j.properties  zoo.cfg

然后用 vim 打开 zoo.cfg,修改其中的一些配置:
Ubuntu下 zookeeper 的安装_第1张图片
找到其中 dataDir 这一项,修改其中的路径(推荐放到桌面)
博主这里是:/home/ubuntu/zookeeper

然后保存退出即可。

启动zookeeper

启动服务端

在刚刚安装的 bin 目录下,启动如下文件:
Ubuntu下 zookeeper 的安装_第2张图片

ubuntu@VM-0-2-ubuntu:/usr/share/zookeeper/bin$ sudo ./zkServer.sh start
ZooKeeper JMX enabled by default
Using config: /etc/zookeeper/conf/zoo.cfg
Starting zookeeper ... STARTED

启动客户端

同样还是在刚刚的目录 bin 下,启动客户端:

ubuntu@VM-0-2-ubuntu:/usr/share/zookeeper/bin$ sudo ./zkCli.sh 
Connecting to localhost:2181
Welcome to ZooKeeper!
JLine support is enabled

WATCHER::

WatchedEvent state:SyncConnected type:None path:null
[zk: localhost:2181(CONNECTED) 0] 

安装 zookeeper 的 C++ 开发环境

进入刚刚安装路径下的src目录:

ubuntu@VM-0-2-ubuntu:~/zookeeper/zookeeper-3.4.10$ cd src
ubuntu@VM-0-2-ubuntu:~/zookeeper/zookeeper-3.4.10/src$ ls
c  contrib  docs  java  lastRevision.bat  lastRevision.sh  LICENSE.txt  NOTICE.txt  packages  pom.template  recipes  zookeeper.jute

进入c目录

ubuntu@VM-0-2-ubuntu:~/zookeeper/zookeeper-3.4.10/src/c$ ls
acinclude.m4    Cli.vcproj     depcomp           libtool                     libzkmt_la-zookeeper.jute.lo  ltmain.sh    st_adaptor.lo      zookeeper.lo
aclocal.m4      compile        generated         libzkmt.la                  libzkmt_la-zookeeper.jute.o   Makefile     st_adaptor.o       zookeeper.o
aminclude.am    config.guess   hashtable_itr.lo  libzkmt_la-mt_adaptor.lo    libzkmt_la-zookeeper.lo       Makefile.am  stamp-h1           zookeeper.sln
autom4te.cache  config.h       hashtable_itr.o   libzkmt_la-mt_adaptor.o     libzkmt_la-zookeeper.o        Makefile.in  tests              zookeeper.vcproj
c-doc.Doxyfile  config.h.in    hashtable.lo      libzkmt_la-recordio.lo      libzkst.la                    missing      zk_hashtable.lo
ChangeLog       config.log     hashtable.o       libzkmt_la-recordio.o       libzookeeper_mt.la            NOTICE.txt   zk_hashtable.o
cli_mt          config.status  include           libzkmt_la-zk_hashtable.lo  libzookeeper_st.la            README       zk_log.lo
cli_mt-cli.o    config.sub     INSTALL           libzkmt_la-zk_hashtable.o   LICENSE                       recordio.lo  zk_log.o
cli.o           configure      install-sh        libzkmt_la-zk_log.lo        load_gen                      recordio.o   zookeeper.jute.lo
cli_st          configure.ac   libhashtable.la   libzkmt_la-zk_log.o         load_gen-load_gen.o           src          zookeeper.jute.o

然后依次执行以下命令:

ubuntu@VM-0-2-ubuntu:~/zookeeper/zookeeper-3.4.10/src/c$ sudo ./configure
ubuntu@VM-0-2-ubuntu:~/zookeeper/zookeeper-3.4.10/src/c$ sudo make
ubuntu@VM-0-2-ubuntu:~/zookeeper/zookeeper-3.4.10/src/c$ sudo make install

参考文献

[1] djqueue.CSDN.Zookeeper C API学习笔记(ubuntu)

你可能感兴趣的:(安装配置教程,linux,ubuntu,zookeeper)