免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 2432 | 回复: 0
打印 上一主题 下一主题

[Zookeeper] ZooKeeper 3.3.3 安装笔记 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2011-12-21 08:42 |只看该作者 |倒序浏览
<span class="Apple-style-span" style="color: rgb(51, 51, 51); font-family: Verdana, Simsun, sans-serif; font-size: 13px; line-height: 20px; ">ZooKeeper是Hadoop的正式子项目,它是一个针对大型分布式系统的可靠协调系统,提供的功能包括:配置维护、名字服务、分布式同步、组服务等。ZooKeeper的目标就是封装好复杂易出错的关键服务,将简单易用的接口和性能高效、功能稳定的系统提供给用户。</span><div><span class="Apple-style-span" style="color: rgb(51, 51, 51); font-family: Verdana, Simsun, sans-serif; font-size: 13px; line-height: 20px; ">Zookeeper是Google的Chubby一个开源的实现.是高有效和可靠的协同工作系统.Zookeeper能够用来leader选举,配置信息维护等.在一个分布式的环境中,我们需要一个Master实例或存储一些配置信息,确保文件写入的一致性等.</span></div><div><span class="Apple-style-span" style="color: rgb(51, 51, 51); font-family: Verdana, Simsun, sans-serif; font-size: 13px; line-height: 20px; ">ZooKeeper目前是安装HBase 0.90.2的必要前提,所以在安装HBase之前,先要确保ZooKeeper正常运行.</span></div><div><span class="Apple-style-span" style="color: rgb(51, 51, 51); font-family: Verdana, Simsun, sans-serif; font-size: 13px; line-height: 20px; "><br></span></div><div><span class="Apple-style-span" style="color: rgb(51, 51, 51); font-family: Verdana, Simsun, sans-serif; font-size: 13px; line-height: 20px; ">1.下载安装包</span></div><div><span class="Apple-style-span" style="color: rgb(51, 51, 51); font-family: Verdana, Simsun, sans-serif; font-size: 13px; line-height: 20px; ">2.将安装包解压到hadoop同一子目录,如/home/grid/zookeeper-3.3.3,编辑conf/zoo.cfg文件:</span></div><div><span class="Apple-style-span" style="color: rgb(51, 51, 51); font-family: Verdana, Simsun, sans-serif; font-size: 13px; line-height: 20px; "><div id="codeText" class="codeText"><ol style="margin:0 1px 0 0;padding:5px 0;" start="1" class="dp-css"><li>The number of milliseconds of each tick</li><li>
</li><li>
tickTime=2000</li><li>
</li><li>
# The number of ticks that the initial</li><li>
</li><li>
# synchronization phase can take</li><li>
</li><li>
initLimit=10</li><li>
</li><li>
# The number of ticks that can pass between</li><li>
</li><li>
# sending a request and getting an acknowledgement</li><li>
</li><li>
syncLimit=5</li><li>
</li><li>
# the directory where the snapshot is stored.</li><li>
</li><li>
dataDir=/home/grid/zookeeper</li><li>#dataLogDir=/hadoop/zookeeper/logs</li><li>
# the port at which the clients will connect</li><li>
</li><li>
clientPort=3355</li><li>
</li><li>
# 2888,3888 are election port</li><li>
</li><li>
server.1=hadoop1:2888:3888</li><li>
server.2=hadoop2:2888:3888</li><li>
server.3=hadoop3:2888:3888</li><li>
server.4=hadoop4:2888:3888</li></ol></div></span></div><div><span class="Apple-style-span" style="color: rgb(51, 51, 51); font-family: Verdana, Simsun, sans-serif; font-size: 13px; line-height: 20px; "><span class="Apple-tab-span" style="white-space:pre">        </span>其中tickTime表示节点间通信超时的单位时长,单位是毫秒,initLimit是指follower服务器初始化连接到leader服务器时可以忍受的超时时间,时长以initLimit*tickTime表示,syncLimit指leader与follower之间通信的超时时长,以</span><span class="Apple-style-span" style="color: rgb(92, 92, 92); font-family: Consolas, monospace; font-size: 12px; line-height: 15px; ">syncLimit*tickTime表示,这里是5*2000=10秒</span></div><div><font class="Apple-style-span" color="#333333" face="Verdana, Simsun, sans-serif" size="2"><span class="Apple-style-span" style="line-height: 20px;"><span class="Apple-tab-span" style="white-space:pre">        </span>"</span></font><span class="Apple-style-span" style="color: rgb(92, 92, 92); font-family: Consolas, monospace; font-size: 12px; line-height: 15px; ">server.1=hadoop1:2888:3888"这一句中的server.1表示节点编号,"hadoop1"表示这台服务器的主机名,也可以直接指定ip地址,"2888"是ZooKeeper服务间通信的端口,"3888"是ZooKeeper服务与其他服务通信的端口</span></div><div><font class="Apple-style-span" color="#5c5c5c" face="Consolas, monospace"><span class="Apple-style-span" style="font-size: 12px; line-height: 15px;"><span class="Apple-tab-span" style="white-space:pre">        </span>dataDir指定ZooKeeper的数据目录</span></font></div><div><span class="Apple-style-span" style="color: rgb(92, 92, 92); font-family: Consolas, monospace; font-size: 12px; line-height: 15px; "><br></span></div><div><span class="Apple-style-span" style="color: rgb(92, 92, 92); font-family: Consolas, monospace; font-size: 12px; line-height: 15px; ">2.建立</span><span class="Apple-style-span" style="color: rgb(92, 92, 92); font-family: Consolas, monospace; font-size: 12px; line-height: 15px; ">/home/grid/zookeeper目录</span></div><div><span class="Apple-style-span" style="color: rgb(92, 92, 92); font-family: Consolas, monospace; font-size: 12px; line-height: 15px; "><span class="Apple-tab-span" style="white-space:pre">        </span>在其中新建一个空白文件,名为myid</span></div><div><span class="Apple-style-span" style="color: rgb(92, 92, 92); font-family: Consolas, monospace; font-size: 12px; line-height: 15px; ">3.把/home/grid/zookeeper-3.3.3和/home/grid/zookeeper两个目录复制到所有服务器节点</span></div><div><span class="Apple-style-span" style="color: rgb(92, 92, 92); font-family: Consolas, monospace; font-size: 12px; line-height: 15px; ">4.修改</span><span class="Apple-style-span" style="color: rgb(92, 92, 92); font-family: Consolas, monospace; font-size: 12px; line-height: 15px; ">/home/grid/zookeeper/myid,比如:hadoop1上,修改myid内容为1,hadoop2上,修改为2</span></div><div><span class="Apple-style-span" style="color: rgb(92, 92, 92); font-family: Consolas, monospace; font-size: 12px; line-height: 15px; ">5.启动ZooKeeper</span></div><div><span class="Apple-style-span" style="color: rgb(92, 92, 92); font-family: Consolas, monospace; font-size: 12px; line-height: 15px; "><span class="Apple-tab-span" style="white-space:pre">        </span>在所有机器上分别启懂ZooKeeper:</span></div><div><span class="Apple-style-span" style="color: rgb(92, 92, 92); font-family: Consolas, monospace; font-size: 12px; line-height: 15px; "><span class="Apple-tab-span" style="white-space:pre">        </span>/home/grid/zookeeper-3.3.3/bin/zkServer.sh start</span></div><div><font class="Apple-style-span" color="#5c5c5c" face="Consolas, monospace"><span class="Apple-style-span" style="font-size: 12px; line-height: 15px;"><span class="Apple-tab-span" style="white-space:pre">        </span>在启动过程中,被选举为leader的服务器,会因为其他服务器连不上而报错,所有服务器都启动以后,报错就会消失</span></font></div><div><font class="Apple-style-span" color="#5c5c5c" face="Consolas, monospace"><span class="Apple-style-span" style="font-size: 12px; line-height: 15px;">6.查看服务器状态</span></font></div><div><font class="Apple-style-span" color="#5c5c5c" face="Consolas, monospace"><span class="Apple-style-span" style="font-size: 12px; line-height: 15px;"><span class="Apple-tab-span" style="white-space:pre">        </span></span></font><span class="Apple-style-span" style="color: rgb(92, 92, 92); font-family: Consolas, monospace; font-size: 12px; line-height: 15px; ">/home/grid/zookeeper-3.3.3/bin/zkServer.sh status</span></div><div><span class="Apple-style-span" style="color: rgb(92, 92, 92); font-family: Consolas, monospace; font-size: 12px; line-height: 15px; "><span class="Apple-tab-span" style="white-space:pre">        </span>输出最后一行会指出当前服务器所在集群的角色,不是follower就是leader,否则说明服务有问题</span></div><div><span class="Apple-style-span" style="color: rgb(92, 92, 92); font-family: Consolas, monospace; font-size: 12px; line-height: 15px; ">7.停止服务器</span></div><div><span class="Apple-style-span" style="color: rgb(92, 92, 92); font-family: Consolas, monospace; font-size: 12px; line-height: 15px; "><span class="Apple-tab-span" style="white-space:pre">        </span></span><span class="Apple-style-span" style="color: rgb(92, 92, 92); font-family: Consolas, monospace; font-size: 12px; line-height: 15px; ">/home/grid/zookeeper-3.3.3/bin/zkServer.sh stop</span></div><div><span class="Apple-style-span" style="color: rgb(92, 92, 92); font-family: Consolas, monospace; font-size: 12px; line-height: 15px; "><br></span></div><div><span class="Apple-style-span" style="color: rgb(92, 92, 92); font-family: Consolas, monospace; font-size: 12px; line-height: 15px; "><br></span></div><div><font class="Apple-style-span" color="#5c5c5c" face="Consolas, monospace"><span class="Apple-style-span" style="font-size: 12px; line-height: 15px;">ZooKeeper的选举算法使用的是Paxos,算法的详细过程见:</span></font></div><div><font class="Apple-style-span" color="#5c5c5c" face="Consolas, monospace"><span class="Apple-style-span" style="font-size: 12px; line-height: 15px;"><a href="http://hi.baidu.com/jrckkyy/blog/item/326a2c51d1ce182c43a75b0d.html" target="_blank" target="_blank">http://hi.baidu.com/jrckkyy/blog/item/326a2c51d1ce182c43a75b0d.html</a></span></font></div>
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP