1. 下载稳定版源码 http://www.apache.org/dyn/closer.cgi/hbase/

    注意在生产环境,要选择合适的hadoop 版本。从下篇文档 4.1 节可以查看 hadoop 和 hbase 的兼容表

    http://hbase.apache.org/book.html#basic.prerequisites

  2. 使用以下命令进行编译, 具体参照 Hadoop3.0.0 编译

    mvn clean package -Pnative -DskipTests -Dtar assembly:single

  3. 编译好的文件在hbase-assembly/target里

  4. 遇到bug

    Failed to execute goal org.apache.maven.plugins:maven-antrun-plugin:1.6:run (generate) on project hbase-server: An Ant BuildException has occured: java.lang.NullPointerException
    

    解决办法:

    这是hbase的一个bug,具体可见 https://issues.apache.org/jira/browse/HBASE-19188

    修改三个pom文件 hbase-rest/pom.xml hbase-server/pom.xml hbase-thrift/pom.xml

    将这三个pom的 jasper-runtime 添加 <scope>compile</scope>

  5. 解压到目录之后添加环境变量

    export HBASE_HOME=<dir>
    
    export PATH=$PATH:$HBASE_HOME/bin
    
  6. 设置conf/hbase-env.sh中的JAVA_HOME地址, 修改 HBASE_MANAGES_ZK=false. 不使用hbase自带的zookeeper

  7. 修改hbase的存储目录为hdfs, hbase的web 界面默认不会开启,需要手动配置. 修改文件 conf/hbase-site.xml

    <configuration>
    	<property>
    		<name>hbase.cluster.distributed</name>
    		<value>true</value>
    	</property>
    	<property>
    		<name>hbase.rootdir</name>
    		<value>hdfs://localhost/hbase</value>
    	</property>
    	<property>
    		<name>hbase.master.info.port</name>
    		<value>60010</value>
    	</property>
    </configuration>
    
  8. 启动hbase. start-hbase.sh

其他问题

hbase启动之后没有在hdfs中建立相应的目录

检查一下日志,有可能是因为hdfs 在安全模式下引起的

启动hbase shell 时出现如下提示

SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/opt/hbase-manager/hbase-1.2.6/lib/slf4j-log4j12-1.7.5.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/opt/hadoop-manager/hadoop-3.0.0/share/hadoop/common/lib/slf4j-log4j12-1.7.25.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See <http://www.slf4j.org/codes.html#multiple_bindings> for an explanation.
SLF4J: Actual binding is of type [org.slf4j.impl.Log4jLoggerFactory]

是包冲突导致,删除其中一个jar包就好

rm -rf /opt/hbase-manager/hbase-1.2.6/lib/slf4j-log4j12-1.7.5.jar