HBase常用工具

Background

hbase集群是基于CDH搭建的,版本2.1.0+cdh6.2.0

1、HBCK

hbck是HBase最基本运维工具。
作用:检查集群上region的一致性。根据检查结果使用相应的命令进行修复。
注意:部分命令在HBase version 2.0+已经不支持了。

在这里插入图片描述
使用示例

# 查看表cloudansys:gps的region状态
hbase hbck 'cloudansys:gps'

2、HFile

作用:检查当前某个具体的HFile的内容/元数据。当业务上发现某个region无法读取,在regionserver上由于文件问题无法打开region或者读取某个文件出现异常时,可用此工具单独来检查HFile是否有问题。

usage: HFile [-a] [-b] [-e] [-f <arg> | -r <arg>] [-h] [-i] [-k] [-m] [-p]
       [-s] [-v] [-w <arg>]
 -a,--checkfamily         Enable family check
 -b,--printblocks         Print block index meta data
 -e,--printkey            Print keys
 -f,--file <arg>          File to scan. Pass full-path; e.g.
                          hdfs://a:9000/hbase/hbase:meta/12/34
 -h,--printblockheaders   Print block headers for each block.
 -i,--checkMobIntegrity   Print all cells whose mob files are missing
 -k,--checkrow            Enable row order check; looks for out-of-order
                          keys
 -m,--printmeta           Print meta data of file
 -p,--printkv             Print key/value pairs
 -r,--region <arg>        Region to scan. Pass region name; e.g.
                          'hbase:meta,,1'
 -s,--stats               Print statistics
 -v,--verbose             Verbose output; emits file and meta data
                          delimiters
 -w,--seekToRow <arg>     Seek to this row and print all the kvs for this
                          row only

使用示例

# 查看namespace下表gps的其中一个HFile的详情,打印KV
hbase org.apache.hadoop.hbase.io.hfile.HFile -v -m -p -f /hbase/data/cloudansys/gps/3c382ab68883d6b345eb879b7d4df918/info/4c24ff2c8c584b49980f6b99c7d3c6a8

3、RowCounter和CellCounter

作用:HBase表行数统计工具,其中CellCounter也可以收集和表相关的更细节的统计数据,包括:表的行数、列族数、qualifier数以及对应出现的次数等。两个工具都可以指定row的起止位置和timestamp来进行范围查询。比hbase shell中count效率高。

使用示例

# 统计表cloudansys:gps有多少行
hbase(main):031:0> count 'cloudansys:gps', INTERVAL => 2000, CACHE => 500
# 统计表cloudansys:gps有多少行
hbase org.apache.hadoop.hbase.mapreduce.RowCounter 'cloudansys:gps'
# 统计表cloudansys:gps有多少行,并将结果写入HDFS的/tmp/gps.cell目录
hbase org.apache.hadoop.hbase.mapreduce.CellCounter 'cloudansys:gps' /tmp/gps.cell

4、OfflineMetaRepair

作用:离线修复HBase的元数据。
hbck工具是HBase的在线修复工具,如果HBase没有启动是无法使用的。OfflineMetaRepair是在离线状态修复HBase元数据。

Usage: OfflineMetaRepair [opts]
 where [opts] are:
   -details               Display full report of all regions.
   -base <hdfs://>        Base Hbase Data directory.
   -sidelineDir <hdfs://> HDFS path to backup existing meta and root.
   -fix                   Auto fix as many problems as possible.
   -fixHoles              Auto fix as region holes.

使用示例

# 重新建立hbase的元数据
hbase org.apache.hadoop.hbase.util.hbck.OfflineMetaRepair

5、Export

作用:用来将表中的内容转储到HDFS上面的序列文件,可指定时间戳。

Usage: Export [-D <property=value>]* <tablename> <outputdir> [<versions> [<starttime> [<endtime>]] [^[regex pattern] or [Prefix] to filter]]

  Note: -D properties will be applied to the conf used.
  For example:
   -D mapreduce.output.fileoutputformat.compress=true
   -D mapreduce.output.fileoutputformat.compress.codec=org.apache.hadoop.io.compress.GzipCodec
   -D mapreduce.output.fileoutputformat.compress.type=BLOCK
  Additionally, the following SCAN properties can be specified
  to control/limit what is exported..
   -D hbase.mapreduce.scan.column.family=<family1>,<family2>, ...
   -D hbase.mapreduce.include.deleted.rows=true
   -D hbase.mapreduce.scan.row.start=<ROWSTART>
   -D hbase.mapreduce.scan.row.stop=<ROWSTOP>
   -D hbase.client.scanner.caching=100
   -D hbase.export.visibility.labels=<labels>
For tables with very wide rows consider setting the batch size as below:
   -D hbase.export.scanner.batch=10
   -D hbase.export.scanner.caching=100
   -D mapreduce.job.name=jobName - use the specified mapreduce job name for the export
For MR performance consider the following properties:
   -D mapreduce.map.speculative=false
   -D mapreduce.reduce.speculative=false

使用示例

# 把表cloudansys:gps的部分数据导出到HDFS上/tmp/hbase/export/cloudansys/gps目录下
hbase org.apache.hadoop.hbase.mapreduce.Export 'cloudansys:gps' /tmp/hbase/export/cloudansys/gps 1 1598849899000 1598947200000

6、Import

作用:用来将之前被 Export 的数据载入HBase中。

Usage: Import [options] <tablename> <inputdir>
By default Import will load data directly into HBase. To instead generate
HFiles of data to prepare for a bulk data load, pass the option:
  -Dimport.bulk.output=/path/for/output
If there is a large result that includes too much Cell whitch can occur OOME caused by the memery sort in reducer, pass the option:
  -Dimport.bulk.hasLargeResult=true
 To apply a generic org.apache.hadoop.hbase.filter.Filter to the input, use
  -Dimport.filter.class=<name of filter class>
  -Dimport.filter.args=<comma separated list of args for filter
 NOTE: The filter will be applied BEFORE doing key renames via the HBASE_IMPORTER_RENAME_CFS property. Futher, filters will only use the Filter#filterRowKey(byte[] buffer, int offset, int length) method to identify  whether the current row needs to be ignored completely for processing and  Filter#filterCell(Cell) method to determine if the Cell should be added; Filter.ReturnCode#INCLUDE and #INCLUDE_AND_NEXT_COL will be considered as including the Cell.
To import data exported from HBase 0.94, use
  -Dhbase.import.version=0.94
  -D mapreduce.job.name=jobName - use the specified mapreduce job name for the import
For performance consider the following options:
  -Dmapreduce.map.speculative=false
  -Dmapreduce.reduce.speculative=false
  -Dimport.wal.durability=<Used while writing data to hbase. Allowed values are the supported durability values like SKIP_WAL/ASYNC_WAL/SYNC_WAL/...>

使用示例

# 把HDFS上/tmp/hbase/export/cloudansys/gps目录下的数据导入到表cloudansys:gpsimport中
hbase org.apache.hadoop.hbase.mapreduce.Import 'cloudansys:gpsimport' /tmp/hbase/export/cloudansys/gps
  • 2
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 2
    评论
### 回答1: hide and seek 隐写是一种在信息技术领域中的隐写术,它通过隐藏消息在其他数据中以防止被发现。 在Linux C编程中,我们可以使用该技术实现隐藏消息的功能。 首先,我们需要选定一个载体文件,可以是图片、音频或者视频文件。接下来,我们需要将希望隐藏的消息编码到这个载体文件中。 在Linux C编程中,可以使用文件操作函数来读取和操作文件。我们可以使用标准的C库函数(如fread和fwrite)来读取和写入文件。 在隐藏消息的过程中,我们需要遵循以下步骤: 1. 打开载体文件和消息文件。 2. 读取载体文件的每一个字节,同时读取消息文件的每一个字节。 3. 将消息字节的位逐一插入到载体字节的低位中,使得载体字节的内容并不明显发生改变。 4. 写入修改后的载体字节到一个新的文件中,即隐藏了消息的文件。 5. 关闭载体文件和消息文件。 顺利完成上述步骤后,可以生成一个新的文件,其中隐藏了消息的载体文件被创建出来了。 在接收方想要提取隐藏的消息时,需要使用相同的方法来读取隐藏信息文件,同时将每一个字节的低位提取出来得到隐藏的消息。 ### 回答2: 在Linux的C编程中隐藏和寻找( hide and seek)可以有多种含义。 首先,隐藏可能指的是在代码中隐藏某些敏感信息或秘密参数,以防止其他用户或攻击者获取。这可以通过使用密码学技术,如加密和解密函数,确保只有授权用户才能访问这些隐藏信息。另外,隐藏也可以指在代码中隐藏某些功能或逻辑,以使其更难以被发现和利用。这可以在软件开发中用作一种安全措施,以减轻潜在的漏洞利用和攻击。 而寻找可以指的是Linux环境中查找隐藏的文件或目录。在Linux中,隐藏的文件或目录通常以句点 "." 开头。通过使用命令行工具如ls或find等,可以寻找指定目录下的所有隐藏文件和目录,以便对其进行进一步的操作或分析。这在系统管理和安全审计中非常有用,因为有时隐藏文件和目录可能包含一些重要的配置或日志信息。 总结起来,在Linux的C编程中,隐藏和寻找可以是指隐藏一些敏感信息或代码逻辑,以及在系统中寻找隐藏的文件和目录。这些都是为了确保代码和系统的安全性和可靠性,以防止潜在的风险和攻击。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

WaiSaa

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值