标签:uid inf art imu html linux tin article 一个
Hbase是运行在hadoop之上,所以请参考第3篇文章搭建好一个master,两个slave的hadoop环境,我采用的版本为hadoop2.7.4
不了解Hbase的同学可以参考下这篇文章,分析得相当深刻,感谢作者 http://blog.csdn.net/u010270403/article/details/51648462
为啥在安装Hbase前需要安装zookeeper?
1,hbase regionserver 向zookeeper注册,提供hbase regionserver状态信息(是否在线)
2,hmaster启动时候会将hbase 系统表-ROOT- 加载到 zookeeper cluster,通过zookeeper cluster可以获取当前系统表.META.的存储所对应的regionserver信息。
注意:zookeeper集群节点最少3台,这样才能满足选举规则,少数服从多数
忘了讲一个问题
集群中,所有节点的时间同步非常重要,所以要将所有节点的时间设置为一样,
当然,手动设置时间肯定不行,需要用到ntp来自动同步
#设置时区为上海
cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
#安装ntp
yum -y install ntp
# 同步时间
ntpdate pool.ntp.org
#确认时间是否正确
date
现在master节点上配置,配置好后复制到两个slave节点就好了
wget http://mirror.bit.edu.cn/apache/zookeeper/current/zookeeper-3.4.10.tar.gz
tar -zxvf zookeeper-3.4.10.tar.gz
#进入conf目录
cp -p zoo_sample.cfg zoo.cfg
#编辑cfg文件
vi 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
server.1=master:2888:3888
server.2=slave1:2888:3888
server.3=slave2:2888:3888
#master
echo "1" > /tmp/zookeeper/myid
#slave1
echo "2" > /tmp/zookeeper/myid
#slave2
echo "3" > /tmp/zookeeper/myid
#启动
/home/zookeeper-3.4.10/bin/zkServer.sh start /home/zookeeper-3.4.10/conf/zoo.cfg
#状态查看
[root@master conf]# /home/zookeeper-3.4.10/bin/zkServer.sh status
ZooKeeper JMX enabled by default
Using config: /home/zookeeper-3.4.10/bin/../conf/zoo.cfg
Mode: follower
[root@master conf]#
#如果启动失败,查看日志
less zookeeper.out
#停止服务
[root@master conf]# /home/zookeeper-3.4.10/bin/zkServer.sh stop
ZooKeeper JMX enabled by default
Using config: /home/zookeeper-3.4.10/bin/../conf/zoo.cfg
Stopping zookeeper ... STOPPED
[root@master conf]# jps
3589 Jps
[root@master conf]#
找到leader节点,并停掉,你会发现刚开始为follower的某个节点又变为leader了
至此zookeeper配置完成
Linux巩固记录(6) Hbase环境准备-zookeeper安装
标签:uid inf art imu html linux tin article 一个
原文地址:http://www.cnblogs.com/xiaochangwei/p/7492184.html