Hbase的安裝以及配置

前置條件
jdk1.8
Hadoop 2.6
Zookeeper 3.4.5

一、安裝Zookeeper

單節點zookeeper可以參考
Kafka概述以及安裝配置中zookeeper的安裝配置
以下介紹多節點的配置
1)下載zookeeper
我們使用的是cdh套件
http://archive.cloudera.com/cdh5/cdh/5/zookeeper-3.4.5-cdh5.15.0.tar.gz
2)解壓
我們這裏統一解壓到同一個目錄下
tar -xzvf zookeeper-3.4.5-cdh5.15.0.tar.gz -C /app/cdh
3)配置環境變量
vim /etc/profile
export ZOOKEEPER_HOME=/app/cdh/zookeeper-3.4.5-cdh5.15.0
export PATH=$ZOOKEEPER_HOME/bin:PATH
4) 修改配置文件

# 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=/app/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=dev2:2888:3888
server.2=dev3:2888:3888
server.3=dev4:2888:3888

這裏的

server.1=dev2:2888:3888
server.2=dev3:2888:3888
server.3=dev4:2888:3888

是集羣間互相通信的
然後我們將/app/cdh/zookeeper-3.4.5-cdh5.15.0的zookeeper目錄完整scp到其他節點配置好環境變量
另外我們需要在所有節點上創建一下目錄:

dataDir=/app/tmp/zookeeper

最後我們還需要做一件事,我們需要在dataDir目錄下創建一個myid文件
vim myid
#myid的內容和我們之前的配置是相對應的
#當前機器爲dev2,我們之前設置的server.1=dev2:2888:3888 那麼myid的內容就是1
#當前機器爲dev3,我們之前設置的server.2=dev3:2888:3888 那麼myid的內容就是2
#當前機器爲dev4,我們之前設置的server.3=dev4:2888:3888 那麼myid的內容就是4
5)啓動各個節點的zookeeper
由於之前我們配置過環境變量,所以我們直接使用
zkServer.sh start
#$ZOOKEEPER_HOME/bin/zkServer.sh start

如果出現啓動不了的情況,記得關閉防火牆,因爲防火牆沒有關閉。
關閉防火牆:
#查看防火牆狀態
sudo service iptables status
#關閉防火牆
sudo service iptables stop
#查看防火牆開機啓動狀態
sudo chkconfig iptables --list
#關閉防火牆開機啓動
sudo chkconfig iptables off

二、Hbase安裝

1)Hbase下載
https://archive.cloudera.com/cdh5/cdh/5/hbase-1.2.0-cdh5.15.0.tar.gz
2)解壓
tar -xzvf hbase-1.2.0-cdh5.15.0.tar.gz -C /app/cdh
3) 配置環境變量
vim /etc/profile

export HBASE_HOME=/app/cdh/hbase-1.2.0-cdh5.15.0
export PATH=$HBASE_HOME/bin:PATH

source /etc/profile
4) 修改配置文件

vim $HBASE_HOME/conf/hbase-env.sh

export JAVA_HOME=/usr/java/jdk1.8.0_71
#不使用Hbase管理zookeeper,使用集羣安裝的zookeeper來管理 
export HBASE_MANAGES_ZK=false

vim $HBASE_HOME/conf/hbase-site.xml

<property>    
	<name>hbase.rootdir</name>    
	<value>hdfs://dev2:8020/hbase</value>    
	<description>
	The directory shared by RegionServers.    
	</description>  
</property>
<property>    
	<name>hbase.cluster.distributed</name>    
	<value>true</value>    
	<description>
	The mode the cluster will be in. Possible values are      
	false: standalone and pseudo-distributed setups with managed Zookeeper      
	true: fully-distributed with unmanaged Zookeeper Quorum (see hbase-env.sh)    
	</description>  
</property>

<property>    
	<name>hbase.zookeeper.quorum</name>    
	<value>dev2:2181,dev3:2181,dev4:2181</value>    
	<description>
	The directory shared by RegionServers.    
	</description>  
</property>

hbase.rootdir爲hbase的存儲根目錄,設爲hadoopHDFS根目錄下的hbase
hbase.cluster.distributed集羣分佈式模式
hbase.zookeeper.quorum設置zookeeper地址

vim $HBASE_HOME/conf/regionservers

dev2
dev3
dev4

regionservers類似於slaves的配置

  1. 啓動
    將/app/cdh/hbase-1.2.0-cdh5.15.0完全scp到其他節點
    配置環境變量後啓動hbase
    $HBASE_HOME/bin/start-hbase.sh

  2. 使用測試

hbase shell

> create 'member','name','gender'
> list #查看所有表

在http://dev2:60010中可以查看到對應的hbase信息
在這裏插入圖片描述

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章