Hbase入门之-hbase rest接口
一:使用方式
./start-hbase.sh 启动后
通过多种方式可以启动对应的REST API可以包括:
1:普通方式
./hbase rest start
默认启动监听端口8080
./hbase rest start -p 8888
启动在端口8888监听
2:以daemon线程启动
./hbase-daemon.sh start rest -p <port>
启动daemon线程在某个端口
./hbase-daemon.sh stop rest
停止daemon线程
使用实例
http://192.168.0.138:9999/version
查看版本
rest 0.0.2 [JVM: Sun Microsystems Inc. 1.6.0_38-20.13-b02] [OS: Linux 2.6.32-279.el6.i686 i386] [Server: jetty/6.1.26] [Jersey: 1.8]
http://192.168.0.138:9999/user/regions
查看table的metadata
user,,1355613878998.390afb61ceb86ce50652c51894ab1401. [ id=1355613878998 startKey='' endKey='' location='localhost:38770']
查看表的某一个family的qualifier的值
get/table/row/column(:<qualifier>)?</timestamp>?
http://192.168.0.138:9999/user/1/info:name
查看table[user]的rowkey=1的family[info]的column[name]的值
<CellSet><Row key="MQ=="><Cell column="aW5mbzpuYW1l" timestamp="1355613941245">aHVhcmVhbA==</Cell></Row></CellSet>
http://192.168.0.138:9999/user/1/info
<CellSet><Row key="MQ==">
<Cell column="aW5mbzphZ2U=" timestamp="1355614294626">MzY=</Cell>
<Cell column="aW5mbzpuYW1l" timestamp="1355613941245">aHVhcmVhbA==</Cell>
<Cell column="aW5mbzpzZXg=" timestamp="1355614306590">bWFsZQ==</Cell></Row>
</CellSet>
String data = dmFsdWUy;
byte[] byteData = Base64.decode(data);
StringBuilder rawData = new StringBuilder("");
for (int i = 0; i < byteData.length; i++ ) {
char ch = (char) byteData[i];
rawData.append(ch);
}
System.out.println(rawData);