欢迎访问 生活随笔!

生活随笔

当前位置: 首页 >

macos brew zookeeper,安装后zookeeper启动失败?

发布时间:2023/12/10 37 豆豆
生活随笔 收集整理的这篇文章主要介绍了 macos brew zookeeper,安装后zookeeper启动失败? 小编觉得挺不错的,现在分享给大家,帮大家做个参考.

一、Zookeeper安装流程

执行如下安装命令:

brew install zookeeper

执行截图如下:

安装后查看 zookeeper 安装信息(默认拉取最新版本)

brew info zookeeper

执行截图如下:

二、Zookeeper启动、状态查询、及关闭

启动执行命令:

zkServer start

执行截图如下:

状态查询执行命令:

zkServer status

执行截图如下(启动失败,翻车现场截图):

红线部分说明未启动成功,后面细谈

关闭执行命令:

zkServer stop

执行截图如下:

三、Zookeeper 启动失败

在上方我们在启动 zookeeper 时,看到好多博客要么没有截图,要么直接把启动失败截图当启动成功附上了…

当然有的小伙伴也不一定遇到这个问题哈,我们先给出错误提示:

Error contacting service. It is probably not running

如果没有出现该错误的小伙伴,可以关闭这篇文章了,下面内容主要是出错解决:

启动失败的场景:

  • 端口被占用:ps -ef | grep 2181
  • zoo.cfg 配置错误
  • 防火墙
  • zookeeper 版本问题

经过一系列排除,最终解决方法:卸载…

是的,你没有听错,由于 brew 无法选择下载的 zookeeper 版本,默认下载最新版本,而出现这种情况,大概率是版本问题,跟本地 jdk 不兼容…

don’t say so much …

执行卸载命令:

brew uninstall zookeeper

执行截图:

四、手动安装Zookeeper

1、下载zookeeper

官网下载路径:https://zookeeper.apache.org/releases.html#download

推荐下载版本:3.4.14

我提供的链接:https://niceyoo.lanzoui.com/iCG1Sgm00oh

下载后解压至:/usr/local/etc

2、配置环境变量

打开环境变量文件:

open ~/.bash_profile

添加如下:

export ZOOKEEPER_HOME=/usr/local/etc/zookeeper-3.4.14 export PATH=$PATH:$ZOOKEEPER_HOME/bin:

修改保存文件后执行:

source ~/.bash_profile

3、修改zookeeper -> conf文件

打开 zookeeper 文件下的 conf 文件夹,然后找到 zoo_sample.cfg 文件,

  • 将 zoo_sample.cfg 重命名为 zoo.cfg
  • 修改 dataDir 文件路径,在 zookeeper/ 根节点下新建 data 目录
  • 将 dataDir 路径修改为:/usr/local/etc/zookeeper-3.4.14/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=/usr/local/var/run/zookeeper/data # the port at which the clients will connect 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

    4、启动zookeeper

    终端下执行 zkServer.sh start

    zkServer.sh start

    执行效果截图:

    五、Zookeeper常用命令

    启动:zkServer.sh start

    关闭:zkServer.sh stop

    状态:zkServer.sh status

    重启:zkServer.sh restart

    博客园持续更新,关注订阅,未来,我们一起成长。

    本文首发于博客园:https://www.cnblogs.com/niceyoo/p/13666003.html

    总结

    以上是生活随笔为你收集整理的macos brew zookeeper,安装后zookeeper启动失败?的全部内容,希望文章能够帮你解决所遇到的问题。

    如果觉得生活随笔网站内容还不错,欢迎将生活随笔推荐给好友。