友情提示:更多有关大数据、人工智能方面技术文章请关注博主个人微信公众号:高级大数据架构师!
hive (db_emp)> load data local inpath '/opt/datas/emp.txt' into table emp_part partition(`date`='2018120');
在加载数据到HDFS上时,报错:
Failed with exception MetaException(message:javax.jdo.JDODataStoreException: Error(s) were found while auto-creating/validating the datastore for classes. The errors are printed in the log, and are attached to this exception.
问题解决:
1.删除hive元数据库(mysql中metastore)
2.手动创建metastore,执行SQL语句:show create database metastore;
mysql> create database metastore;
Query OK, 1 row affected (0.00 sec)
mysql> show create database metastore;
+--------------+-------------------------------------------------------------------------+
| Database | Create Database |
+--------------+-------------------------------------------------------------------------+
| metastore | CREATE DATABASE `metastore` /*!40100 DEFAULT CHARACTER SET latin1 */ |
+--------------+-------------------------------------------------------------------------+
1 row in set (0.00 sec)
3.执行SQL语句:alter database metastore character set latin1;
mysql> alter database metastore character set latin1;
Query OK, 1 row affected (0.00 sec)
4.到hive配置conf下的hive-site.xml中修改元数据库
5.给要load data 的数据赋予权限
6.启动hive
[xningge@hadoop01 hive-0.13.1-cdh5.3.6]$ bin/hive
Logging initialized using configuration in file:/opt/modules/cdh/hive-0.13.1-cdh5.3.6/conf/hive-log4j.properties
hive (default)> show databases;
OK
database_name
default
Time taken: 0.182 seconds, Fetched: 1 row(s)
hive (default)> create database db_emp;
OK
Time taken: 0.222 seconds
hive (default)> create table emp_part(
> empno int ,
> ename string ,
> job string ,
> mgr int ,
> hiredate string,
> sal double ,
> comm double ,
> deptno int
> )PARTITIONED BY(`date` string)
> row format delimited fields terminated by '\t';
OK
Time taken: 0.348 seconds
hive (default)> load data local inpath '/opt/datas/emp.txt' into table emp_part partition(`date`='2018120');
Loading data to table default.emp_part partition (date=2018120)
Partition default.emp_part{date=2018120} stats: [numFiles=1, numRows=0, totalSize=657, rawDataSize=0]
OK
Time taken: 1.159 seconds
7.打开浏览器进入http://hadoop01.xningge.com:50070
问题解决,如果大家按我的步骤还是不成功,给我留言。