#!/bin/bash
source ~/.bash_profile
#日志目录
DACPDIR="/logs"
#DACPDIR=$(cd "$(dirname "$0")"; pwd)
#日志名称
LOGNAME="hbase_table"
#日志全路径名
full_log_name=${DACPDIR}/${LOGNAME}.log
#hbase名称
hbase_table=pro:info_d
CF=cf
echo `hbase shell <<EOF
exists '$hbase_table'
EOF` | grep 'does exist' >$full_log_name 2>&1
rtstatus=$?
if [ $rtstatus -ne 0 ]; then
echo `hbase shell << EOF
create '$hbase_table', {NAME => '$CF', COMPRESSION=>'lzo', BLOOMFILTER =>"ROW", TTL => '15552000', VERSIONS => '1'}
grant 'b','RW','$hbase_table'
grant 'bd','RW','$hbase_table'
grant 'pro','RW','$hbase_table'
EOF` >$full_log_name 2>&1
if [ "$?" -ne 0 ] ;then
echo "创建hbase表失败!"
else
echo "创建hbase表成功!"
fi
else
echo "hbase表已存在!"
fi
以上内容,仅作为自己学习使用