前面已经搭建好了一个伪分布式的hadoop环境,传送门:https://blog.csdn/qq1049545450/article/details/90019159

现在开始搭建hbase数据库:hbase数据库使用版本hbase-2.0.5-bin.tar.gz关于hbase和hadoop的版本选择在上一篇文章中已经说过了。

3.搭建hbase环境

搭建前先创建一个hadoop用户,用来分隔hadoop文件。

1.tar -zxvf hbase-2.0.5-bin.tar.gz解压hbase。

2. mv hbase-2.0.5 hbase    对hbase文件夹重命名。

3.vi ./hbase/hbase-env.sh配置hbase的JAVA_HOME

4.配置hbase-site.xml

<configuration>
  <property>
    <name>hbase.rootdir</name>
    <value>hdfs://hbasehost:9000/hbase</value>
  </property>
  <property>
    <name>hbase.zookeeper.property.dataDir</name>
    <value>/home/hadoop/zookeeper</value>
  </property>
  <property>
    <name>hbase.cluster.distributed</name>
    <value>true</value>
  </property>
</configuration>

配置好后,启动hbase:

./bin/start-hbase.sh

查看日志文件logs/hbase-root-regionserver-hbasehost-server.log:

看看下regionserver是不是绑定到服务器的ip上,而不是localhost上的,这个对后面java操作hbase很重要:

启动hbase shell:./bin/hbase shell

这个时候可能会报错::Found class jline.Terminal, but interface was expected

解决方案:将$HADOOP_HOME/share/hadoop/yarn/lib下的jline-0.9.94.jar  包删除即可

再次执行:./bin/hbase shell

hbase启动成功。

执行一个hbase shell命令看下:

至此hbase数据库搭建完成!!!!!

java api操作hbase数据库:https://blog.csdn/qq1049545450/article/details/90025401

更多推荐

java连接Hbase操作数据库的全过程---搭建hbase数据库