先决条件:
1)java环境,需要安装java1.6以上版本
2)hadoop环境,由于HBase架构是基于其他文件存储系统的,因此在分布式模式下安装Hadoop是必须的,但是,如果运行在单价模式下,此条件可以省略。Hadoop-1.2.1的安装方法参考 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
[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 ~]$
6、配置HBASE_HOME,打开.bashrc添加修改以下内容(可选)
export HBASE_HOME=/home/hadoop/hbase-0.94.16-security export PATH=$PATH:$JAVA_HOME/bin:$HADOOP_HOME/bin:$HBASE_HOME/bin
版权声明:本文为博主原创文章,转载请注明本文链接。
原文:http://blog.csdn.net/gnail_oug/article/details/46973429