hbase模糊查询key删除指定创建时间的数据

1、转换创建时间

shell脚本

current="2018-10-28 19:00:00"
timeStamp=`date -d "$current" +%s`
currentTimeStamp=$((timeStamp*1000+`date "+%N"`/1000000))
echo $currentTimeStamp

2、将查询出的数据导入txt

echo "scan 'table_name',{FILTER=>org.apache.hadoop.hbase.filter.PrefixFilter.new(org.apache.hadoop.hbase.util.Bytes.toBytes('key前缀')), TIMERANGE => [1540713600162, 1540724400015]}" |  hbase shell > ./record.txt

3、准备删除脚本

cat record.txt|awk '{print "deleteall '\''table_name'\''", ",", "'\''"$1"'\''"}' > del.sh

在del.sh头尾分别加上:

#!/bin/sh 
exec hbase shell <<EOF 
和
EOF

4、执行del.sh

猜你喜欢

转载自www.cnblogs.com/water-sky/p/10221228.html