hbase 安装和使用

下载hbase

配置conf中hbase-env.sh

#Java环境

export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_77.jdk/Contents/Home


#通过hadoop的配置文件找到hadoop集群

export HBASE_CLASSPATH=/Users/lihu/hadoop-2.7.2/hbase-1.2.4/conf

#使用HBASE自带的zookeeper管理集群

export HBASE_MANAGES_ZK=true

 配置conf中的hbase-site.xml

<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>

<configuration>
    <property>
        <name>hbase.rootdir</name>
        <value>hdfs://localhost:9000/hbase</value>
    </property>
    <property>
        <name>hbase.cluster.distributed</name>
        <value>true</value>
    </property>
    <property>
        <name>hbase.zookeeper.quorum</name>
        <value>localhost</value>
    </property>
</configuration>

 启动hbase

lihudeMacBook-Pro:~ SunAndLi$ ./start-hbase.sh

检查是否启动

lihudeMacBook-Pro:~ SunAndLi$ jps
18560 HMaster
19137 HRegionServer
450 
16484 DataNode
10054 QuorumPeerMain
16710 ResourceManager
16396 NameNode
10575 ConsoleConsumer
19216 Main
19536 Main
16594 SecondaryNameNode
10133 Kafka
16797 NodeManager
19742 Jps
lihudeMacBook-Pro:~ SunAndLi$ 

进入hbase shell

lihudeMacBook-Pro:~ SunAndLi$ hbase shell
2017-02-08 17:44:24,272 WARN  [main] util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/Users/lihu/hadoop-2.7.2/hbase-1.2.4/lib/slf4j-log4j12-1.7.5.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/Users/lihu/hadoop-2.7.2/share/hadoop/common/lib/slf4j-log4j12-1.7.10.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]
HBase Shell; enter 'help<RETURN>' for list of supported commands.
Type "exit<RETURN>" to leave the HBase Shell
Version 1.2.4, r67592f3d062743907f8c5ae00dbbe1ae4f69e5af, Tue Oct 25 18:10:20 CDT 2016

 创建表t1

 hbase(main):013:0> create 't1',{NAME => 'f1', VERSIONS => 2},{NAME => 'f2', VERSIONS => 2}

 查看有哪些表

hbase(main):001:0> list

 插入数据没有指定column

hbase(main):003:0> put 't1', 'r1', 'f1', 'v1'

 插入数据指定column

hbase(main):007:0> put 't1', 'r4', 'f1:c1', 'v1'

 插入多列数据

hbase(main):010:0> put 't1', 'r7', 'f1:c4', 'v9'
hbase(main):011:0> put 't1', 'r7', 'f2:c3', 'v9'

 启动错误

lihudeMacBook-Pro:bin SunAndLi$ ./start-hbase.sh 
localhost: starting zookeeper, logging to /Users/lihu/hadoop-2.7.2/hbase-1.2.4/bin/../logs/hbase-SunAndLi-zookeeper-lihudeMacBook-Pro.local.out
starting master, logging to /Users/lihu/hadoop-2.7.2/hbase-1.2.4/logs/hbase-SunAndLi-master-lihudeMacBook-Pro.local.out
Java HotSpot(TM) 64-Bit Server VM warning: ignoring option PermSize=128m; support was removed in 8.0
Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=128m; support was removed in 8.0
regionserver running as process 1385. Stop it first.

 将logs里面的文件删除和hdfs上面的/hbase删除就好了

原文地址:https://www.cnblogs.com/sunyaxue/p/6379401.html