小表:count
shell > count 'tablename'
大表hbase row count:
hbase org.apache.hadoop.hbase.mapreduce.RowCounter 'tablename'
2)离线导出。
导出
hbase org.apache.hadoop.hbase.mapreduce.Export ID_CARD_IMG /export
需先创建表
create 'ID_CARD_IMG ','img'
导入
hbase org.apache.hadoop.hbase.mapreduce.Import ID_CARD_IMG /export
3)跨集群导出
1、Replication:这个是动态的备份(可以理解为实时备份)
步骤:(1)在old cluster将需要迁移的表属性进行修改: disable 'your_table' alter 'your_table', {NAME => 'family_name', REPLICATION_SCOPE => '1'} enable 'your_table' (2)打开new cluster集群的replication,修改hbase-site.xml <property> <name>hbase.replication</name> <value>true</value> </property> (3)添加peer,在new cluster的hbase shell中执行:add_peer '1','old cluster ip:2181:/hbase',启动replication,执行start_replication 说明:需要两个集群的hadoop版本一致,否则出现读写错误
2、CopyTable:可以在本集群中拷贝一张表,也可以将表拷贝到其他的集群中。
命令:./hbase org.apache.hadoop.hbase.mapreduce.CopyTable --peer.adr=new cluster ip:2181:/hbase zy_test 说明:(1)拷贝完成,不需要重启机器,在new cluster中就可以看到该表; (2)稳定性还需要考虑,测试过程中遇到一个问题,拷贝过程中始终都停留在这里Lookedup root region location, 查看日志没有什么错误和相关的信息。
3、Export and Import
步骤:(1)在old cluster上执行:./hbase org.apache.hadoop.hbase.mapreduce.Export test hdfs://new cluster ip:9000/zhuangyang/test (2)在new cluster上执行:./hbase org.apache.hadoop.hbase.mapreduce.Import test hdfs://new cluster ip:9000/zhuangyang/test 说明:(1)一定要写全路径,不能写相对路劲; (2)在import前,需要将表事先在new cluster中创建好.