hbase shell 根据rowKey范围批量删除

    技术2022-07-10  158

    hbase shell 根据rowKey范围批量删除

    #!/bin/bash tablename=$1 startrow=$2 endrow=$3 if [ $# -eq 0 ];then echo "请输入表名,startRow,endRow" exit 0 fi echo "scan '${tablename}',{STARTROW=>'${startrow}',ENDROW=>'${endrow}'}" |hbase shell|awk -F ' ' '{print $1'\t'}'> ./file.txt #删除前6行非表中数据 sed -i '1,6d' file.txt #删除最后一行(空行) sed -i '$d' file.txt #删除最后一行(总条数) sed -i '$d' file.txt cat ./file.txt|awk '{print $1}'|while read rowvalue do echo -e "deleteall '${tablename}','${rowvalue}'" >> ./deleteRowFile.txt done rm ./file.txt echo "exit" >> ./deleteRowFile.txt #为避免线上执行失误 ,先检查deleteRowFile.txt中要删除的rowkey是否正确,所以以下两行命令请手动执行 #hbase shell ./deleteRowFile.txt #rm ./deleteRowFile.txt
    Processed: 0.025, SQL: 9