先决条件:
1)java环境,须要安装java1.6以上版本号
2)hadoop环境。因为HBase架构是基于其它文件存储系统的,因此在分布式模式下安装Hadoop是必须的,可是,假设执行在单位价格模式下,此条件能够省略。Hadoop-1.2.1的安装方法參考
注意:安装时要注意Hadoop和HBase之间的版本号关系,假设不匹配。非常可能会影响HBase系统的稳定性。
本帖教程採用的hadoop是hadoop-1.2.1,hbase採用的是hbase-0.94
hbase有三种安装模式:
单机模式
伪分布模式
全然分布模式
单机模式安装步骤:
1、上传并解压hbase-0.94.16-security.tar.gz
[hadoop@mdw temp]$ cp /mnt/cdrom/hbase-0.94.16-security.tar.gz .
[hadoop@mdw temp]$ tar xzf hbase-0.94.16-security.tar.gz
2、改动hbase-env.sh配置文件
打开/home/hadoop/hbase-0.94.16-security/conf/hbase-env.sh文件。加入或改动JAVA_HOME环境变量
export JAVA_HOME=/usr/java/jdk1.6.0_45
改动HBASE_HEAPSIZE配置,默认是1000(假设内存比較大能够不设置。依据自己的内存设定)
export HBASE_HEAPSIZE=50
3、改动hbase-site.xml文件,配置hbase.rootdir
<property>
<name>hbase.rootdir</name>
<value>file:///home/hadoop/hbase/data</value>
</property>
路径能够是随意有权限读写的路径。要创建好并将owner改为hadoop用户。这里放在了hadoop用户文件夹下的 hbase/data文件夹下
4、启动并验证Hbase
启动hbase
[hadoop@mdw ~]$ hbase-0.94.16-security/bin/start-hbase.sh
starting master, logging to /home/hadoop/hbase-0.94.16-security/bin/../logs/hbase-hadoop-master-mdw.out
启动之后,通过jps能够看到多了一个HMaster进程
[hadoop@mdw ~]$ jps
2541 NameNode
4236 HMaster
4430 Jps
2687 SecondaryNameNode
2773 JobTracker
訪问hbase
[hadoop@mdw ~]$ hbase-0.94.16-security/bin/hbase shell
HBase Shell; enter 'help<RETURN>' for list of supported commands.
Type "exit<RETURN>" to leave the HBase Shell
Version 0.94.16, r1557241, Fri Jan 10 20:10:24 UTC 2014
hbase(main):001:0> quit
[hadoop@mdw ~]$
到此hbase的单机模式已经成功安装
伪分布模式安装:
伪分布模式是在单机模式的基础上改动对应配置
1、先停止单机模式已安装的hbase
[hadoop@mdw ~]$ hbase-0.94.16-security/bin/stop-hbase.sh
stopping hbase..............
2、改动hbase-env.sh配置文件
打开/home/hadoop/hbase-0.94.16-security/conf/hbase-env.sh文件。加入或改动HBASE_CLASSPATH环境变量,以便hbase找到hadoop
export HBASE_CLASSPATH=/home/hadoop/hadoop-1.2.1/conf
设置由hbase自己管理zookeeper,不须要单独的zookeeper
export HBASE_MANAGES_ZK=true
3、改动hbase-site.xml配置文件,改动hbase.rootdir參数。加入hbase.cluster.distributed參数打开分布模式
<property>
<name>hbase.rootdir</name>
<value>hdfs://master:9000/hbase</value>
</property>
<property>
<name>hbase.cluster.distributed</name>
<value>true</value>
</property>
4、替换hadoop的jar文件,主要目的是防止由于hbase和hadoop版本号不同出现兼容问题,造成hmaster启动异常
[hadoop@mdw lib]$ pwd
/home/hadoop/hbase-0.94.16-security/lib
备份hbase自带的hadoop-core文件,并将hadoop安装文件夹下的hadoop-core拷贝到hbase的lib下
[hadoop@mdw lib]$ mv hadoop-core-1.0.4.jar hadoop-core-1.0.4.bak
[hadoop@mdw lib]$ cp ~/hadoop-1.2.1/hadoop-core-1.2.1.jar .
[hadoop@mdw lib]$ ll hadoop-core*
-rw-r--r-- 1 hadoop hadoop 3929148 Jan 10 2014 hadoop-core-1.0.4.bak
-rw-rw-r-- 1 hadoop hadoop 4203147 Jun 1 02:01 hadoop-core-1.2.1.jar
5、启动并验证hbase
启动hbase
[hadoop@mdw ~]$ hbase-0.94.16-security/bin/start-hbase.sh
localhost: starting zookeeper, logging to /home/hadoop/hbase-0.94.16-security/bin/../logs/hbase-hadoop-zookeeper-mdw.out
starting master, logging to /home/hadoop/hbase-0.94.16-security/bin/../logs/hbase-hadoop-master-mdw.out
localhost: starting regionserver, logging to /home/hadoop/hbase-0.94.16-security/bin/../logs/hbase-hadoop-regionserver-mdw.out
通过jps命令能够看出。比单机模式多了HRegionServer进程和HQuorumPeer进程
[hadoop@mdw ~]$ jps
2541 NameNode
5552 HRegionServer
5404 HMaster
2687 SecondaryNameNode
2773 JobTracker
5293 HQuorumPeer
5681 Jps
訪问hbase并查看状态
[hadoop@mdw ~]$ hbase-0.94.16-security/bin/hbase shell
HBase Shell; enter 'help<RETURN>' for list of supported commands.
Type "exit<RETURN>" to leave the HBase Shell
Version 0.94.16, r1557241, Fri Jan 10 20:10:24 UTC 2014
hbase(main):001:0> status
1 servers, 0 dead, 2.0000 average load
hbase(main):002:0> exit
[hadoop@mdw ~]$
通过hadoop dfs命令查看hadoop文件系统,会发现hadoop文件系统的根文件夹多了一个hbase文件夹
[hadoop@mdw ~]$ hadoop dfs -ls /
Found 3 items
drwxr-xr-x - hadoop supergroup 0 2015-06-01 02:06 /hbase
drwxr-xr-x - hadoop supergroup 0 2015-05-27 02:14 /home
drwxr-xr-x - hadoop supergroup 0 2015-05-29 01:31 /user
[hadoop@mdw ~]$ hadoop dfs -ls /hbase
Found 7 items
drwxr-xr-x - hadoop supergroup 0 2015-06-01 02:06 /hbase/-ROOT-
drwxr-xr-x - hadoop supergroup 0 2015-06-01 02:06 /hbase/.META.
drwxr-xr-x - hadoop supergroup 0 2015-06-01 02:06 /hbase/.logs
drwxr-xr-x - hadoop supergroup 0 2015-06-01 02:06 /hbase/.oldlogs
drwxr-xr-x - hadoop supergroup 0 2015-06-01 02:06 /hbase/.tmp
-rw-r--r-- 2 hadoop supergroup 38 2015-06-01 02:06 /hbase/hbase.id
-rw-r--r-- 2 hadoop supergroup 3 2015-06-01 02:06 /hbase/hbase.version
到眼下为止,为分布模式的hbase已经成功安装
全然分布模式安装:
全然分布模式是在伪分布模式的基础上改动对应配置
1、停止hbase
[hadoop@mdw ~]$ hbase-0.94.16-security/bin/stop-hbase.sh
stopping hbase...........
localhost: stopping zookeeper.
2、清除hdfs文件系统中/hbase文件文件夹
[hadoop@mdw ~]$ hadoop dfs -rmr /hbase
Deleted hdfs://master:9000/hbase
3、改动 hbase-site.xml 配置文件,加入zookeeper相关配置
<property>
<name>hbase.zookeeper.quorum</name>
<value>sdw1,sdw2</value>
</property>
<property>
<name>hbase.zookeeper.property.dataDir</name>
<value>/home/hadoop/tmp/zookeeper</value>
</property>
4、改动regionservers文件,加入全部Region服务器的主机名或IP地址。
[hadoop@mdw conf]$ cat regionservers
sdw1
sdw2
5、将配置好的hbase安装程序拷贝到sdw1和sdw2节点
[hadoop@mdw ~]$ scp -r hbase-0.94.16-security/ sdw1:~
[hadoop@mdw ~]$ scp -r hbase-0.94.16-security/ sdw2:~
6、启动并验证hbase
[hadoop@mdw ~]$ hbase-0.94.16-security/bin/start-hbase.sh
sdw2: starting zookeeper, logging to /home/hadoop/hbase-0.94.16-security/bin/../logs/hbase-hadoop-zookeeper-sdw2.out
sdw1: starting zookeeper, logging to /home/hadoop/hbase-0.94.16-security/bin/../logs/hbase-hadoop-zookeeper-sdw1.out
starting master, logging to /home/hadoop/hbase-0.94.16-security/logs/hbase-hadoop-master-mdw.out
sdw1: starting regionserver, logging to /home/hadoop/hbase-0.94.16-security/bin/../logs/hbase-hadoop-regionserver-sdw1.out
sdw2: starting regionserver, logging to /home/hadoop/hbase-0.94.16-security/bin/../logs/hbase-hadoop-regionserver-sdw2.out
[hadoop@mdw ~]$ jps
6890 HMaster
2541 NameNode
7031 Jps
2687 SecondaryNameNode
2773 JobTracker
sdw1和sdw2上进程:
[hadoop@sdw1 ~]$ jps
2407 TaskTracker
2340 DataNode
4012 HQuorumPeer
4229 Jps
4079 HRegionServer
訪问hbase并查看状态
[hadoop@mdw ~]$ hbase-0.94.16-security/bin/hbase shell
HBase Shell; enter 'help<RETURN>' for list of supported commands.
Type "exit<RETURN>" to leave the HBase Shell
Version 0.94.16, r1557241, Fri Jan 10 20:10:24 UTC 2014
hbase(main):001:0> status
2 servers, 0 dead, 1.0000 average load
hbase(main):002:0> exit
[hadoop@mdw ~]$
7、配置HBASE_HOME。打开.bashrc加入改动下面内容(可选)
export HBASE_HOME=/home/hadoop/hbase-0.94.16-securityexport PATH=$PATH:$JAVA_HOME/bin:$HADOOP_HOME/bin:$HBASE_HOME/bin至此hbase的全然分布模式已经成功安装