假设Hadoop已经成功安装。
实验环境如下:Ubuntu 12
hadoop-0.20.203.0
hbase-0.90.5
三台主机:
192.168.66.91 masternode
192.168.66.92 slavenode1
192.168.66.93 slavenode2
Ubuntu用户名grid
hadoop安装目录:/home/grid/hadoop
hbase计划安装目录:/home/grid/hbase
大致过程为:首先在masternode上安装hbase,配置好后再拷贝至slave机器。
(1)下载hbase-0.90.5.tar.gz,解压到/home/grid/hbase
(2)编辑/home/grid/hbase/conf/hbase-env.sh,编辑后如下所示,带颜色的部分为修改部分:
#
#
# Set environment variables here.
# The java implementation to use. Java 1.6 required. Java安装目录,最低1.6版本
export JAVA_HOME=/usr/lib/jvm/jdk1.7.0_07
# Extra Java CLASSPATH elements. Optional. 整合hadoop的配置文件
export HBASE_CLASSPATH=/home/grid/hadoop/conf
# The maximum amount of heap to use, in MB. Default is 1000.
# export HBASE_HEAPSIZE=1000
# Extra Java runtime options.
# Below are what we set by default. May only work with SUN JVM.
# For more on why as well as other possible settings,
# see http://wiki.apache.org/hadoop/PerformanceTuning
export HBASE_OPTS="-ea -XX:+UseConcMarkSweepGC -XX:+CMSIncrementalMode"
# Uncomment below to enable java garbage collection logging in the .out file.
# export HBASE_OPTS="$HBASE_OPTS -verbose:gc -XX:+PrintGCDetails -XX:+PrintGCDateStamps"
# Uncomment and adjust to enable JMX exporting
# See jmxremote.password and jmxremote.access in $JRE_HOME/lib/management to configure remote password access.
# More details at: http://java.sun.com/javase/6/doc ... nagement/agent.html
#
# export HBASE_JMX_BASE="-Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false"
# export HBASE_MASTER_OPTS="$HBASE_JMX_BASE -Dcom.sun.management.jmxremote.port=10101"
# export HBASE_REGIONSERVER_OPTS="$HBASE_JMX_BASE -Dcom.sun.management.jmxremote.port=10102"
# export HBASE_THRIFT_OPTS="$HBASE_JMX_BASE -Dcom.sun.management.jmxremote.port=10103"
# export HBASE_ZOOKEEPER_OPTS="$HBASE_JMX_BASE -Dcom.sun.management.jmxremote.port=10104"
# File naming hosts on which HRegionServers will run. $HBASE_HOME/conf/regionservers by default.
# export HBASE_REGIONSERVERS=${HBASE_HOME}/conf/regionservers
# Extra ssh options. Empty by default.
# export HBASE_SSH_OPTS="-o ConnectTimeout=1 -o SendEnv=HBASE_CONF_DIR"
# Where log files are stored. $HBASE_HOME/logs by default. hbase日志目录,注意logs目录需创建
export HBASE_LOG_DIR=/home/grid/hbase/logs
# A string representing this instance of hbase. $USER by default.
# export HBASE_IDENT_STRING=$USER
# The scheduling priority for daemon processes. See 'man nice'.
# export HBASE_NICENESS=10
# The directory where pid files are stored. /tmp by default.
# export HBASE_PID_DIR=/var/hadoop/pids
# Seconds to sleep between slave commands. Unset by default. This
# can be useful in large clusters, where, e.g., slave rsyncs can
# otherwise arrive faster than the master can service them.
# export HBASE_SLAVE_SLEEP=0.1
# Tell HBase whether it should manage it's own instance of Zookeeper or not.开启zookeeper
export HBASE_MANAGES_ZK=true
(3)编辑/home/grid/hbase/conf/hbase-site.xml,默认内无属性,均需自行添加:
hbase.rootdir
hdfs://masternode:9000/hbase
hbase.cluster.distributed
true
hbase.master
hdfs://masternode:6000
hbase.zookeeper.quorum
slavenode1
hbase.zookeeper.property.dataDir
/home/grid/hbase/zookeeper
(4)编辑/home/grid/hbase/conf/regionservers,将所有的slavenode添加到这个文件,类似与hadoop中slaves文件,该文件原本为空,如下是我添加的内容,两台slavenode机器的域名(hosts文件中已做解析):
slavenode1
slavenode2
(5)解决版本、jar包冲突:
1)删除hbase/lib/hadoop-core-0.20-append-r1056497.jar(我是拷贝到其它路径,以备万一);
2)拷贝hadoop/hadoop-core-0.20.203.0.jar(注意是hadoop根目录下),hadoop/lib/commons-collections-3.2.1.jar,hadoop/lib/commons-configuration-1.6.jar到hbase/lib下。
(6)将master节点上已经配置好的hbase文件夹拷贝到slave节点,执行:
scp -r /home/grid/hbase grid@slavenode1:/home/grid/hbase
scp -r /home/grid/hbase grid@slavenode2:/home/grid/hbase
(7)启动
1)启动hadoop:/home/grid/hadoop/bin/start-all.sh
执行命令后用jps命令验证,显示:
3549 Jps
2438 NameNode
2758 JobTracker
2690 SecondaryNameNode
说明hadoop启动成功。
2)启动hbase:/home/grid/hbase/bin/start-hbase.sh
执行命令后用jps命令验证,显示:
3750 Jps
3652 HMaster
2438 NameNode
2758 JobTracker
2690 SecondaryNameNode
说明hbase启动成功,然后分别到两台slave机器上执行jps,slavenode1上执行jps,显示:
2676 TaskTracker
2504 DataNode
3800 Jps
3501 HQuorumPeer
3669 HRegionServer
注意:其中HQuorumPeer是zookeeper进程,在hbase-site.xml中的hbase.zookeeper.quorum属性中为slavenode1配置了zookeeper;
slavenode2上执行jps,显示:
2663 TaskTracker
2482 DataNode
3607 Jps
3530 HRegionServer
(8)进入hbase
在master机器执行hbase/bin/hbase shell即可进入hbase的shell
grid@masternode:~$ hbase/bin/hbase shell
HBase Shell; enter 'help' for list of supported commands.
Type "exit" to leave the HBase Shell
Version 0.90.5, r1212209, Fri Dec 9 05:40:36 UTC 2011
hbase(main):001:0>