hbase迁移数据到hive中
hive创建表关联hbase表时报错
CREATE EXTERNAL TABLE test01
(key string,
name string,
age string,
sex string)
STORED BY 'org.apache.hadoop.hive.hbase.HBaseStorageHandler'
WITH SERDEPROPERTIES ("hbase.columns.mapping" = ":key,info:name,info:age,info:sex")
TBLPROPERTIES ("hbase.table.name" = "test01", "hbase.mapred.output.outputtable" = "test01");
问题详情:
异常一:(没注意截图了)
FAILED: Execution Error, return code 1 from org.apache.hadoop.hive.ql.exec.DDLTask. org/apache/hadoop/hbase/mapreduce/TableInputFormatBase
异常二:
FAILED: Execution Error, return code 1 from MetaException(message:MetaException(message:java.io.IOException:java.lang.reflect.InvocationTargetException
(注:bin/hive -hiveconf hive.root.logger=DEBUG,console 进行debug)
解决方法:
1. 将hbase的以下jar导入到hive的lib目录
hbase-client-0.98.1-cdh5.1.0.jar
hbase-hadoop-compat-0.98.1-cdh5.1.0.jar
hbase-protocol-0.98.1-cdh5.1.0.jar
hbase-server-0.98.1-cdh5.1.0.jar
htrace-core-2.04.jar
2.修改hive-env.sh文件
3.修改hive仓库metastore的字符集为latin1【该操作可选】
alter database cdhmetastore character set latin1;
4.重启hbase和hive,并执行操作
5.表创建成功后,hbase表test01数据自动同步到hive test01表中
6.End......