How to list the regions in an HBase table through the shell?

scan 'hbase:meta', {FILTER=>"PrefixFilter('tableName')", COLUMNS=>['info:regioninfo']}

To get the region info about the table, you need to scan hbase:meta table.

scan 'hbase:meta',{FILTER=>"PrefixFilter('table_name')"}

This command will give details of all the regions. Row key will have region name and there will be four column qualifiers. You may need following two column qualifiers:

info:regioninfo - This qualifier contains STARTKEY and ENDKEY.

info:server - This qualifier contains region server details


Here's a response from the HBase mailing list:

status 'detailed' would show you enough information e.g.

t1,30,1449175546660.da5f3853f6e59d1ada0a8554f12885ab." 
  numberOfStores=1, numberOfStorefiles=0, 
  storefileUncompressedSizeMB=0, lastMajorCompactionTimestamp=0, 
  storefileSizeMB=0, memstoreSizeMB=0, storefileIndexSizeMB=0, 
  readRequestsCount=0, writeRequestsCount=0, rootIndexSizeKB=0, 
  totalStaticIndexSizeKB=0, totalStaticBloomSizeKB=0, totalCompactingKVs=0, 
  currentCompactedKVs=0, compactionProgressPct=NaN, completeSequenceId=-1, 
  dataLocality=0.0 

However, this returns info from all the tables, and you need to parse the regions of the table you're interested in.


Use the "official" list_regions shell command to list out all the regions. Note that this tool is available only starting from HBase versions 1.4 and above.

Some examples are 
        Examples:
        hbase> list_regions 'table_name'
        hbase> list_regions 'table_name', 'server_name'
        hbase> list_regions 'table_name', {SERVER_NAME => 'server_name', LOCALITY_THRESHOLD => 0.8}
        hbase> list_regions 'table_name', {SERVER_NAME => 'server_name', LOCALITY_THRESHOLD => 0.8}, ['SERVER_NAME']
        hbase> list_regions 'table_name', {}, ['SERVER_NAME', 'start_key']
        hbase> list_regions 'table_name', '', ['SERVER_NAME', 'start_key']

Details on its implementation are at: https://issues.apache.org/jira/browse/HBASE-14925

Tags:

Hbase