- 下载
http://mirror.bit.edu.cn/apache/hbase/hbase-0.94.26/hbase-0.94.26.tar.gz
2. 解压
tar -zxvf hbase-0.94.26.tar.gz
3. 配置目录
HBASE_HOME/conf/hbase-site.xml
<configuration>
<property>
<name>hbase.rootdir</name>
<value>file:/usr/hbase/hbase-${user.name}</value>
</property>
</configuration>
4. 配置说明
默认只有<configuration></configuration>配置,没有property配置,需要自己加上
也可以不用配置,直接第四步启动(hbase默认目录:/tmp/hbase-${user.name},由于很多操作系统会在重启的时候清空/tmp目录,所以这里设置一下比较好)
5. 启动
[[email protected] bin]# ./start-hbase.sh
starting master, logging to /usr/local/hbase-0.94.26/bin/../logs/hbase-root-master-liuchao.out
6. 貌似成功了(试试)
[[email protected] bin]# ./hbase shell
HBase Shell; enter ‘help<RETURN>‘ for list of supported commands.
Type "exit<RETURN>" to leave the HBase Shell
Version 0.94.26, ra9114543cd48c7e230dabd31f45a086f7b7a5d6a, Wed Dec 17 20:37:01 UTC 2014hbase(main):001:0> status
1 servers, 0 dead, 2.0000 average loadhbase(main):002:0>
7. 看到这些,说明已经成功了,可以进行下一步测试了
创建一张表
hbase(main):001:0> create ‘testtable‘,‘colfam1‘
0 row(s) in 3.7160 seconds
1:>查看创建的表(写错了)
hbase(main):002:0> list ‘tae‘
TABLE
0 row(s) in 0.2010 secondshbase(main):003:0> list ‘testtable‘
TABLE
testtable
1 row(s) in 0.1050 seconds
插入几条数据
hbase(main):004:0> put ‘testtable‘,‘myrow-1‘,‘colfam1:q1‘,‘value-1‘
0 row(s) in 0.4080 secondshbase(main):005:0> put ‘testtable‘,‘myrow-2‘,‘colfam1:q2‘,‘value-2‘
0 row(s) in 0.1320 secondshbase(main):006:0> put ‘testtable‘,‘myrow-3‘,‘colfam1:q3‘,‘value-3‘
0 row(s) in 0.1090 seconds
查看表中的数据
hbase(main):007:0> scan ‘testtable‘
ROW COLUMN+CELL
myrow-1 column=colfam1:q1, timestamp=1424834391342, value=value-1
myrow-2 column=colfam1:q2, timestamp=1424834424591, value=value-2
myrow-3 column=colfam1:q3, timestamp=1424834464914, value=value-3
3 row(s) in 0.2360 seconds
获取某一行的数据
hbase(main):002:0> get ‘testtable‘,‘myrow-2‘
COLUMN CELL
colfam1:q2 timestamp=1424834424591, value=value-2
1 row(s) in 0.2090 seconds
删除一行数据
hbase(main):003:0> delete ‘testtable‘,‘myrow-2‘,‘colfam1:q2‘
0 row(s) in 0.1110 secondshbase(main):004:0> scan ‘testtable‘
ROW COLUMN+CELL
myrow-1 column=colfam1:q1, timestamp=1424834391342, value=value-1
myrow-3 column=colfam1:q3, timestamp=1424834464914, value=value-3
2 row(s) in 0.1780 seconds
禁用并删除表
hbase(main):004:0> disable ‘testtable‘
0 row(s) in 1.4690 seconds
这时再查看,表已经不能用了
hbase(main):005:0> scan ‘testtable‘
ROW COLUMN+CELLERROR: org.apache.hadoop.hbase.DoNotRetryIOException: testtable is disabled.
表启用
hbase(main):002:0> enable ‘testtable‘
0 row(s) in 1.5810 seconds
现在又可以用了
hbase(main):002:0> scan ‘testtable‘
ROW COLUMN+CELL
myrow-1 column=colfam1:q1, timestamp=1424834391342, value=value-1
myrow-3 column=colfam1:q3, timestamp=1424834464914, value=value-3
2 row(s) in 0.3160 seconds
删除表
hbase(main):003:0> drop ‘testtable‘
ERROR: Table testtable is enabled. Disable it first.‘
Here is some help for this command:
Drop the named table. Table must first be disabled: e.g. "hbase> drop ‘t1‘"
必须先禁用表,才能删除表
hbase(main):004:0> disable ‘testtable‘
0 row(s) in 1.4460 secondshbase(main):005:0> drop ‘testtable‘
0 row(s) in 1.3030 secondshbase(main):006:0> scan ‘testtable‘
ROW COLUMN+CELLERROR: Unknown table testtable!
退出
hbase(main):001:0> exit
关闭Hbase
[[email protected] bin]# ./stop-hbase.sh
stopping hbase.....................
8. 启动报错
[[email protected] bin]# ./start-hbase.sh
Exception in thread "main" java.lang.UnsupportedClassVersionError: org/apache/hadoop/hbase/util/HBaseConfTool : Unsupported major.minor version 51.0
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(ClassLoader.java:632)
at java.lang.ClassLoader.defineClass(ClassLoader.java:616)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:283)
at java.net.URLClassLoader.access$000(URLClassLoader.java:58)
at java.net.URLClassLoader$1.run(URLClassLoader.java:197)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
Could not find the main class: org.apache.hadoop.hbase.util.HBaseConfTool. Program will exit.
Exception in thread "main" java.lang.UnsupportedClassVersionError: org/apache/hadoop/hbase/zookeeper/ZKServerTool : Unsupported major.minor version 51.0
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(ClassLoader.java:632)
at java.lang.ClassLoader.defineClass(ClassLoader.java:616)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:283)
at java.net.URLClassLoader.access$000(URLClassLoader.java:58)
at java.net.URLClassLoader$1.run(URLClassLoader.java:197)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
Could not find the main class: org.apache.hadoop.hbase.zookeeper.ZKServerTool. Program will exit.
starting master, logging to /usr/local/hbase-1.0.0/bin/../logs/hbase-root-master-liuchao.out
Exception in thread "main" java.lang.UnsupportedClassVersionError: org/apache/hadoop/hbase/master/HMaster : Unsupported major.minor version 51.0
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(ClassLoader.java:632)
at java.lang.ClassLoader.defineClass(ClassLoader.java:616)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:283)
at java.net.URLClassLoader.access$000(URLClassLoader.java:58)
at java.net.URLClassLoader$1.run(URLClassLoader.java:197)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
starting regionserver, logging to /usr/local/hbase-1.0.0/bin/../logs/hbase-root-1-regionserver-liuchao.out
Exception in thread "main" java.lang.UnsupportedClassVersionError: org/apache/hadoop/hbase/regionserver/HRegionServer : Unsupported major.minor version 51.0
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(ClassLoader.java:632)
at java.lang.ClassLoader.defineClass(ClassLoader.java:616)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:283)
at java.net.URLClassLoader.access$000(URLClassLoader.java:58)
at java.net.URLClassLoader$1.run(URLClassLoader.java:197)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
9. 应该是版本不对
之前安装的是hbase-1.0.0-bin.tar.gz 可以版本高了
后来安装的是hbase-0.94.26.tar.gz 没有问题