1.官网或 wget 下载 zookeeper-3.4.14.tar.gz 包
cd /home/tar
wget https://mirrors.tuna.tsinghua.edu.cn/apache/zookeeper/stable/zookeeper-3.4.14.tar.gz
2.解压 zookeeper-3.4.14.tar.gz 包
tar -zxvf zookeeper-3.4.14.tar.gz
mv ./zookeeper-3.4.14 /usr/local/
3.编辑 zoo.cfg 配置文件
cd /usr/local/zookeeper-3.4.14/conf
cp zoo_sample.cfg zoo.cfg
vi ./zoo.cfg
修改内容为如下:
# The number of milliseconds of each tick # zookeeper 定义的基准时间间隔,单位:毫秒 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=/tmp/zookeeper # 数据文件夹 dataDir=/usr/local/services/zookeeper/zookeeper-3.4.9/data # 日志文件夹 dataLogDir=/usr/local/services/zookeeper/zookeeper-3.4.9/logs # the port at which the clients will connect # 客户端访问 zookeeper 的端口号 clientPort=2181 # the maximum number of client connections. # increase this if you need to handle more clients #maxClientCnxns=60 # # Be sure to read the maintenance section of the # administrator guide before turning on autopurge. # # http://zookeeper.apache.org/doc/current/zookeeperAdmin.html#sc_maintenance # # The number of snapshots to retain in dataDir #autopurge.snapRetainCount=3 # Purge task interval in hours # Set to "0" to disable auto purge feature #autopurge.purgeInterval=1
保存并关闭 zoo.cfg 文件
4.配置环境变量
编辑 profile 文件
vi /etc/profile
追加如下内容
# set zookeeper env export ZOOKEEPER_HOME=/usr/local/zookeeper-3.4.14/ export PATH=$ZOOKEEPER_HOME/bin:$PATH export PATH
使其生效
source /etc/profile
5.启动服务
zkServer.sh start
若打印一下信息表示启动成功:
ZooKeeper JMX enabled by default
Using config: /usr/local/zookeeper-3.4.14/bin/../conf/zoo.cfg
Starting zookeeper ... STARTED
6.常用命令
zkServer.sh status 查看状态
zkServer.sh stop 停止服务
zkServer.sh restart 重启服务
7.集群配置
待续
8.设置开机自启
待续
参考文章:
https://www.cnblogs.com/huangjianping/p/8012580.html
https://blog.csdn.net/weixin_42231507/article/details/81154708
https://www.cnblogs.com/dayangcong/p/6368406.html