mysql数据导⼊到hbase
思路:读取到⼀个数据库⾥所有的表名,然后通过sqoop循环导⼊到hbase
实现过程中发现不会写shell是个硬伤
最后只能分两步进⾏操作
1.sel_tabs.sh
/usr/bin/mysql -hIp地址 -u⽤户名 -p密码 -D数据库名<<EOF
use
select table_name from information_schema.tables where table_schema='数据库名' and table_type='base table';
EOF
运⾏ bash sel_tabs.sh>tbsnam.dat
将结果写⼊tbsname.dat
#!/bin/sh
cat tbsnam.dat |while read LINE
do
echo $LINE
if [ "$LINE" = "table_name" ]; then
echo "table_name test"
else
echo $LINE
str="/opt/dtma/sqoop/bin/sqoop import --connect jdbc:mysql://Ip地址:端⼝号/数据库名称 --username '⽤户名' --password '密码' --table AA --hbase-table AA --column-family f1 --hbase-row-key  id --hbase-create-table -              strend=${str//"AA"/$LINE}
echo $strend
$strend
fi
done
str是sqoop 增量导⼊单个表的语句
上⾯sql语句查询结果第⼀⾏出现 table_name,所以把table_name 剔除掉
hbase属于什么类型数据库最后运⾏
bash readdat.sh