首页  »   开源软件

Hbase Rest API : Hbase治理

网友分享于:2015-07-22  浏览:0次
Hbase Rest API : Hbase管理

在上一篇关于Hbase Rest API的文章中介绍了如何查询数据,本章将介绍其Hbase Admin的功能。

 

  • 查询软件版本,包括操作系统,JVM,servlet容器等等。

语法:GET /version

 

范例:curl http://localhost:8000/version

 

输出结果:

{"@Stargate":"0.0.1","@OS":"Linux 2.6.18-128.1.6.el5.centos.plusxen amd64","@

JVM":"Sun Microsystems Inc. 1.6.0_13-11.3-b02","@Jetty":"6.1.14","@Jersey":"1

.1.0-ea"}

 

  • 查询hbase集群版本

语法:GET /version/cluster

 

范例:curl -H "Accept: application/json" http://localhost:8000/version/cluster

 

输出结果:"0.20.0"

 

相当于HBaseAdmin.getClusterStatus().getHBaseVersion()

 

  • 查询hbase集群状态

语法:GET /status/cluster

 

范例:curl -H "Accept: application/json" http://localhost:8000/status/cluster

 

相当于HBaseAdmin.getClusterStatus()

 

  • 列出所有hbase表

语法:GET /

 

范例:curl -H "Accept: application/json" http://localhost:8000/

 

输出结果:{"table":[{"name":"table1"},{"name":"table2"}]}

 

相当于HBaseAdmin.listTableNames()

 

  • 查询hbase表结构

语法:GET /<table>/schema

 

范例:curl -H "Accept: application/json" http://localhost:8000/table1/schema

 

输出结果:

{ NAME=> 'table1', IS_META => 'false', COLUMNS => [ { NAME => 'C', DATA_BLOCK_ENCODING => 'NONE', BLOOMFILTER => 'ROW', REPLICATION_SCOPE => '0', VERSIONS => '1', COMPRESSION => 'NONE', MIN_VERSIONS => '0', TTL => '2147483647', KEEP_DELETED_CELLS => 'FALSE', BLOCKSIZE => '65536', IN_MEMORY => 'false', BLOCKCACHE => 'true' }, { NAME => 'M', DATA_BLOCK_ENCODING => 'NONE', BLOOMFILTER => 'ROW', REPLICATION_SCOPE => '0', VERSIONS => '1', COMPRESSION => 'NONE', MIN_VERSIONS => '0', TTL => '2147483647', KEEP_DELETED_CELLS => 'FALSE', BLOCKSIZE => '65536', IN_MEMORY => 'false', BLOCKCACHE => 'true' } ] }

 

相当于HBaseAdmin.getTableDescriptor(TableName.valueOf("table1"))

 

  • 新建表或者更新表结构

语法:

PUT /<table>/schema

POST /<table>/schema

 

PUT完全替换表结构,POST只是更新或者新增column family(跟本次更新无关的cf仍然保留)

 

  • 查询region信息

语法:GET /<table>/regions

 

范例:curl -H "Accept: application/json" http://localhost:8000/table1/regions

 

输出结果:

pf_entity,,1436346991071.fce2165af7b49f1dd0995ddd535d3a6f. [

  id=1436346991071

  startKey=''

  endKey=''

  location='bd02:21003'

]

 

相当于HBaseAdmin.getTableRegions(TableName.valueOf("table1"))

 

 

 

相关解决方案

最新解决方案