HBASE 查看表记录数

命令:hbase   org.apache.hadoop.hbase.mapreduce.RowCounter  '表名'

 

输出:

INFO  [main] mapreduce.Job:  map 100% reduce 0%
INFO  [main] mapreduce.Job: Job job_1488875331552_130163 completed successfully
INFO  [main] mapreduce.Job: Counters: 31
        File System Counters
                FILE: Number of bytes read=0
                FILE: Number of bytes written=167892
                FILE: Number of read operations=0
                FILE: Number of large read operations=0
                FILE: Number of write operations=0
                HDFS: Number of bytes read=95
                HDFS: Number of bytes written=0
                HDFS: Number of read operations=1
                HDFS: Number of large read operations=0
                HDFS: Number of write operations=0
        Job Counters 
                Launched map tasks=1
                Other local map tasks=1
                Total time spent by all maps in occupied slots (ms)=322947
                Total time spent by all reduces in occupied slots (ms)=0
                Total time spent by all map tasks (ms)=322947
                Total vcore-seconds taken by all map tasks=322947
                Total megabyte-seconds taken by all map tasks=661395456
        Map-Reduce Framework
                Map input records=31959661
                Map output records=0
                Input split bytes=95
                Spilled Records=0
                Failed Shuffles=0
                Merged Map outputs=0
                GC time elapsed (ms)=1351
                CPU time spent (ms)=62460
                Physical memory (bytes) snapshot=250777600
                Virtual memory (bytes) snapshot=3830263808
                Total committed heap usage (bytes)=215482368
        org.apache.hadoop.hbase.mapreduce.RowCounter$RowCounterMapper$Counters
                ROWS=31959661 //总记录数
        File Input Format Counters 
                Bytes Read=0
        File Output Format Counters 
                Bytes Written=0

 

### 查看HBase的分区信息 在HBase中,通常所说的“分区”实际上是指Region的信息。要查看某个特定的Region分布情况以及相关信息,可以利用HBase Shell命令或者通过Java客户端API来实现。 #### 使用HBase Shell查看Partition Information 可以通过`describe 'tablename'`命令获取关于指定格结构的一些基本信息,包括其Regions数量等概览数据[^1]。然而更详细的Region位置详情,则需借助于如下指令: ```shell hbase> describe_regions 'your_table_name' ``` 此命令会返回一系列有关该各个Region边界、服务器地址等内容的数据集合[^2]。 另外一种方式是直接查询`.META.`系统,它存储着集群内所有用户空间里Tables与Regions之间的映射关系记录。具体操作如下所示: ```shell hbase> scan '.META.', {FILTER => "PrefixFilter('your_table_name')" } ``` 上述方法能够帮助管理员了解当前环境中某张具体的物理切分状态及其所在节点的位置信息[^3]。 #### 利用Java API 获取 Partition Details 对于程序化需求而言,也可以采用官方提供的Client Library来进行编程式的访问控制。下面给出了一段简单的代码片段用于展示如何连接至目标实例并读取相应元数据: ```java Configuration config = HBaseConfiguration.create(); Connection connection = ConnectionFactory.createConnection(config); Admin admin = connection.getAdmin(); TableName tableName = TableName.valueOf("your_table_name"); HTableDescriptor tableDescriptor = admin.getTableDescriptor(tableName); // Get region locations List<HRegionLocation> regions = admin.getRegions(tableName).stream() .map(region -> new HRegionLocation(region, null)) .collect(Collectors.toList()); regions.forEach(region -> { System.out.println("Start Key: " + Bytes.toStringBinary(region.getStartKey())); System.out.println("End Key: " + Bytes.toStringBinary(region.getEndKey())); System.out.println("Region Server Address: " + region.getServerName()); }); admin.close(); connection.close(); ``` 这段代码展示了怎样通过Java API获得给定的所有region的相关细节,比如起始键、结束键还有所在的RegionServer地址等重要参数[^4]。
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值