首先需要安装jdk,参考之前的文章:Ubuntu 13.10-14.10 安装Oralce JDK
然后下载最新稳定版本到/opt目录
/opt$ wget http://mirrors.cnnic.cn/apache/zookeeper/stable/zookeeper-3.4.6.tar.gz
解压目录:
tar zxvf zookeeper-3.4.6.tar.gz
解压后的目录结构为:
/opt/zookeeper-3.4.6$ tree -L 1 . ├── bin ├── build.xml ├── CHANGES.txt ├── conf ├── contrib ├── dist-maven ├── docs ├── ivysettings.xml ├── ivy.xml ├── lib ├── LICENSE.txt ├── NOTICE.txt ├── README_packaging.txt ├── README.txt ├── recipes ├── src ├── zookeeper-3.4.6.jar ├── zookeeper-3.4.6.jar.asc ├── zookeeper-3.4.6.jar.md5 └── zookeeper-3.4.6.jar.sha1
进入conf目录,复制sample配置文件
cd conf/ $ cp zoo_sample.cfg zoo.cfg
编辑zoo.cfg文件,修改data目录路径,注释都解释了各个参数的作用:
# 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/zk_data # the port at which the clients will connect clientPort=2181
创建目录
mkdir /opt/zk_data
现在启动服务吧:
:/opt/zookeeper-3.4.6/conf$ cd .. :/opt/zookeeper-3.4.6$ bin/zkServer.sh start JMX enabled by default Using config: /opt/zookeeper-3.4.6/bin/../conf/zoo.cfg Starting zookeeper ... STARTED
时间: 2024-10-13 02:23:51