周海汉/文 2013.4.2 可以将日期08/08/16 20:56:29从hbase log 转换成一个 timestamp, 操作如下: hbase(main):021:0 import java.text.simpledateformat hbase(main):022:0 import java.text.parseposition hbase(main):023:0 simpledateformat.new("yy/mm/dd
周海汉/文
2013.4.2
可以将日期’08/08/16 20:56:29′从hbase log 转换成一个 timestamp, 操作如下:
hbase(main):021:0> import java.text.simpledateformat
hbase(main):022:0> import java.text.parseposition
hbase(main):023:0> simpledateformat.new("yy/mm/dd hh:mm:ss").parse("08/08/16 20:56:29", parseposition.new(0)).gettime() => 1218920189000
也可以逆过来操作。
hbase(main):021:0> import java.util.date
hbase(main):022:0> date.new(1218920189000).tostring() => "sat aug 16 20:56:29 utc 2008"
$ bin/hbase org.apache.hadoop.hbase.mapreduce.copytable [--starttime=x] [--endtime=y] [--new.name=new] [--peer.adr=adr] tablename
hbase(main):001:0> import java.text.simpledateformat
=> java::javatext::simpledateformat
hbase(main):002:0> import java.text.parseposition
=> java::javatext::parseposition
hbase(main):004:0> simpledateformat.new(“yyyy/mm/dd hh:mm:ss”).parse(“2013/03/28 00:00:00″, parseposition.new(0)).gettime()
=> 1364400000000
hbase(main):005:0> simpledateformat.new(“yyyy/mm/dd hh:mm:ss”).parse(“2013/03/28 00:00:10″, parseposition.new(0)).gettime()
=> 1364400010000
[hbase@h46 sh]$ hbase org.apache.hadoop.hbase.mapreduce.copytable
usage: copytable [general options] [--starttime=x] [--endtime=y] [--new.name=new] [--peer.adr=adr]
导出部分数据到另一个表myolc,需先创建该表,也可以指定另一个集群:
--peer.adr=server1,server2,server3:2181:/hbase
[hbase@h46 hbase]$ hbase org.apache.hadoop.hbase.mapreduce.copytable –starttime=1364400000000 –endtime=1364400010000 –new.name=myolc online_count
导出实用工具可以将表的内容输出成hdfs的序列化文件,如下调用:
$ bin/hbase org.apache.hadoop.hbase.mapreduce.export [ [ []]]
导出2000秒数据
[hbase@h46 hbase]$ hbase org.apache.hadoop.hbase.mapreduce.export online_count onlinecount 1 1364400000000 1364402000000
[hbase@h46 hbase]$ hadoop fs -ls /user/hbase/onlinecount
found 3 items
-rw-r–r–?? 3 hbase supergroup????????? 0 2013-04-01 15:56 /user/hbase/onlinecount/_success
drwxr-xr-x?? – hbase supergroup????????? 0 2013-04-01 15:55 /user/hbase/onlinecount/_logs
-rw-r–r–?? 3 hbase supergroup??????? 451 2013-04-01 15:56 /user/hbase/onlinecount/part-m-00000
导入实用工具可以加载导出的数据回到hbase,如下调用:
$ bin/hbase org.apache.hadoop.hbase.mapreduce.import
[zhouhh@hadoop48 ~]$ hadoop fs -put olc onlinecount
[zhouhh@hadoop48 ~]$ hbase shell
hbase(main):001:0> create ‘online_count’,'info’
?[zhouhh@hadoop48 ~]$ hbase org.apache.hadoop.hbase.mapreduce.import online_count onlinecount
相关博文:
【说明】:本文章由站长整理发布,文章内容不代表本站观点,如文中有侵权行为,请与本站客服联系(QQ:)!