脚本内容如下
#!/bin/bash
v_date=`date -d '+1 day' +%Y%m%d`
delete_date=`date -d '-8 day' +%Y%m%d`
end_date=`date -d '+3 day' +%Y%m%d`
while [ $v_date != $end_date ]
do
echo "正在创建hbase表 namespace:table_name_${v_date}..................................."
hbase shell <<EOF
create 'namespace:table_name_${v_date}',{DURABILITY => 'SKIP_WAL'},{NAME=>'column_name', TTL=>691200, MIN_VERSIONS=>0, COMPRESSION=>'snappy',METADATA => {'SPLIT_POLICY' => 'org.apache.hadoop.hbase.regionserver.DisabledRegionSplitPolicy'} },SPLITS => ['0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f']
exit
EOF
echo "hbase表创建完成!"
v_date=`date -d "${v_date} +1 day" +%Y%m%d`
done
echo "正在删除8天前hbase表 namespace:table_name_${delete_date}............................"
hbase shell <<EOF
disable 'namespace:table_name_${delete_date}'
drop 'namespace:table_name_${delete_date}'
exit
EOF
echo "hbase表删除完成!"
标签:m%,建表,+%,Y%,自动化,date,hbase,day
From: https://www.cnblogs.com/whiteY/p/18053540