惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

雷峰网
雷峰网
小众软件
小众软件
有赞技术团队
有赞技术团队
P
Proofpoint News Feed
V
V2EX
aimingoo的专栏
aimingoo的专栏
WordPress大学
WordPress大学
Forbes - Security
Forbes - Security
Project Zero
Project Zero
Microsoft Security Blog
Microsoft Security Blog
Cyberwarzone
Cyberwarzone
Security Latest
Security Latest
S
Securelist
NISL@THU
NISL@THU
B
Blog RSS Feed
爱范儿
爱范儿
H
Hackread – Cybersecurity News, Data Breaches, AI and More
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
D
Darknet – Hacking Tools, Hacker News & Cyber Security
L
LINUX DO - 最新话题
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
H
Hacker News: Front Page
F
Full Disclosure
J
Java Code Geeks
Recent Commits to openclaw:main
Recent Commits to openclaw:main
The Hacker News
The Hacker News
L
LangChain Blog
Google DeepMind News
Google DeepMind News
I
InfoQ
Last Week in AI
Last Week in AI
S
Security @ Cisco Blogs
PCI Perspectives
PCI Perspectives
IT之家
IT之家
P
Proofpoint News Feed
AI
AI
Hacker News - Newest:
Hacker News - Newest: "LLM"
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
www.infosecurity-magazine.com
www.infosecurity-magazine.com
W
WeLiveSecurity
Application and Cybersecurity Blog
Application and Cybersecurity Blog
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
Martin Fowler
Martin Fowler
L
LINUX DO - 热门话题
T
Tenable Blog
M
MIT News - Artificial intelligence
N
News | PayPal Newsroom
Blog — PlanetScale
Blog — PlanetScale
Recorded Future
Recorded Future
罗磊的独立博客
大猫的无限游戏
大猫的无限游戏

博客园 - LixingTie

Git添加排除文件规则 [RabbitMQ+Python入门经典] 兔子和兔子窝 Win7强制删除文件 vim配置 Ubuntu部署HBase Ubuntu 12.04 Hadoop自动安装脚本 Ubuntu 12.04下安装Extmail 白话MongoDB(三) 白话MongoDB(二) 白话MongoDB(一) 关于HBase的一些零碎事 Paxos在大型系统中常见的应用场景 某分布式应用实践一致性哈希的一些问题 多IDC的数据分布设计(二) 多IDC的数据分布设计(一) Redis新的存储模式diskstore Redis容量及使用规划 Redis几个认识误区 一致性哈希(Consistent Hashing)
Ubuntu部署Zookeeper
LixingTie · 2012-06-28 · via 博客园 - LixingTie

安装JDK

sudo apt-get install default-jdk

安装Zookeeper

cd /home/hadoop/zookeeper
sudo wget http://mirror.bjtu.edu.cn/apache/zookeeper/stable/zookeeper-3.3.5.tar.gz #下载zookeeper
tar xvzf zookeeper-3.3.5.tar.gz #解压
ln -s zookeeper-3.3.5 zookeeper #建立软链接

编辑/etc/profile 设置环境变量

# zookeeper配置
export ZOOKEEPER_INSTALL=/home/hadoop/zookeeper-3.3.5
export PATH=$PATH:$ZOOKEEPER_INSTALL/bin

配置zookeeper

cd /home/hadoop/zookeeper/zookeeper/conf/
cp zoo_sample.cfg zoo.cfg
vim zoo.cfg

修改zoo.cfg文件内容为

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 # 日志保存路径

启动zookeeper server

cd /home/hadoop/zookeeper/zookeeper/
bin/zkServer.sh start
bin/zkCli.sh -server localhost:2181

初次启动zookeeper server会看到报错信息:

FAILED TO WRITE PID

查看进程发现zookeeper进程存在, 并可以正常使用.

这是zkServer.sh脚本的一个BUG,dataDir是zookeeper进程内部建立的,并且有一定延迟, 因此将zookeeper进程id写入到dataDir下的pidfile时,dataDir还没有建立好, 因此就出现了上述情况。

解决办法修改脚本,等待dataDir目录创建完毕再将pid写入即可

...
    if [ $? -eq 0 ] 
    then
      while [ ! -d `dirname $ZOOPIDFILE` ]
      do  
        sleep 1;
      done
      if /bin/echo -n $zkpid > "$ZOOPIDFILE"
      then
        sleep 1
        echo STARTED
      else
        echo FAILED TO WRITE PID
        exit 1
      fi