1. 程式人生 > >Linux鞏固記錄(6) Hbase環境準備-zookeeper安裝

Linux鞏固記錄(6) Hbase環境準備-zookeeper安裝

this 分析 時間同步 all zone direct .org def ech

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 

#狀態查看
[[email protected] 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
[[email protected] conf]# 


#如果啟動失敗,查看日誌
less zookeeper.out

#停止服務
[[email protected] 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
[[email protected] conf]# jps
3589 Jps
[[email protected] conf]# 

找到leader節點,並停掉,你會發現剛開始為follower的某個節點又變為leader了

至此zookeeper配置完成

Linux鞏固記錄(6) Hbase環境準備-zookeeper安裝