Ubuntu 安装zookeeper
下载zookeeper Zookeeper下载
下载以后将文件迁移到/home/Hadoop/文件夹下面
hongdada@ubuntu:~/Downloads$ sudo mv zookeeper-3.4.9.tar.gz /home/Hadoop
tar -zxvf解压
hongdada@ubuntu:/home/Hadoop$ sudo tar -zxvf zookeeper-3.4.9.tar.gz
将文件夹zookeeper-3.4.9改成zookeeper
hongdada@ubuntu:/home/Hadoop$ sudo mv zookeeper-3.4.9 zookeeper
解压以后conf文件夹中创建zoo_sample.cfg的副本zoo.cfg
hongdada@ubuntu:/home/Hadoop$ cd zookeeper hongdada@ubuntu:/home/Hadoop/zookeeper$ cd conf hongdada@ubuntu:/home/Hadoop/zookeeper/conf$ mp zoo_sample.cfg zoo_cfg mp:未找到命令 hongdada@ubuntu:/home/Hadoop/zookeeper/conf$ cp zoo_sample.cfg zoo.cfg cp: 无法创建普通文件'zoo.cfg': 权限不够 hongdada@ubuntu:/home/Hadoop/zookeeper/conf$ sudo cp zoo_sample.cfg zoo.cfg hongdada@ubuntu:/home/Hadoop/zookeeper/conf$ sudo gedit zoo.cfg
原始的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=/tmp/zookeeper # 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
修改为:
# 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=/home/Hadoop/zookeeper/data # 数据持久化路径 dataLogDir=/home/Hadoop/zookeeper/log #日志保存路径 server.1=192.168.1.203:2888:3888 # 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
说明:
syncLimit=5 # Leader与Follower之间的最大响应时间单位,响应超过syncLimit*tickTime,Leader认为Follwer死掉,从服务器列表中删除Follwer。 initLimit=10 # 投票选举新leader的初始化时间。 tickTime=2000 # Zookeeper服务器心跳时间,单位毫秒 clientPort=2181 # 连接端口 dataDir=/home/Hadoop/zookeeper/data # 数据持久化路径 dataLogDir=/home/Hadoop/zookeeper/log # 日志保存路径 server.1=10.10.100.10:2888:3888
设置环境变量:
hongdada@ubuntu:/home/Hadoop/zookeeper/conf$ export ZOOKEEPER_HOME=/home/Hadoop/zookeeper
hongdada@ubuntu:/home/Hadoop/zookeeper/conf$ export PATH=$PATH:$ZOOKEEPER_HOME/bin
启动zookeeper:
hongdada@ubuntu:/home/Hadoop/zookeeper/conf$ cd . hongdada@ubuntu:/home/Hadoop/zookeeper/conf$ cd ../ hongdada@ubuntu:/home/Hadoop/zookeeper$ cd bin hongdada@ubuntu:/home/Hadoop/zookeeper/bin$ zkServer.sh start ZooKeeper JMX enabled by default Using config: /home/Hadoop/zookeeper/bin/../conf/zoo.cfg mkdir: 无法创建目录"/home/Hadoop/zookeeper/data # 数据持久化路径": 权限不够 Starting zookeeper ... /home/Hadoop/zookeeper/bin/zkServer.sh: 行 140: ./zookeeper.out: 权限不够 /home/Hadoop/zookeeper/bin/zkServer.sh: 行 149: /home/Hadoop/zookeeper/data # 数据持久化路径/zookeeper_server.pid: 没有那个文件或目录 FAILED TO WRITE PID hongdada@ubuntu:/home/Hadoop/zookeeper/bin$ sudo zkServer.sh start [sudo] hongdada 的密码: sudo: zkServer.sh:找不到命令 hongdada@ubuntu:/home/Hadoop/zookeeper/bin$ sudo ./zkServer.sh start ZooKeeper JMX enabled by default Using config: /home/Hadoop/zookeeper/bin/../conf/zoo.cfg Starting zookeeper ... STARTED
启动是./zkServer.sh start
http://jingyan.baidu.com/article/456c463b60bd380a5931446f.html
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本
· C#/.NET/.NET Core优秀项目和框架2025年2月简报
· Manus爆火,是硬核还是营销?
· 终于写完轮子一部分:tcp代理 了,记录一下
· 【杭电多校比赛记录】2025“钉耙编程”中国大学生算法设计春季联赛(1)