hive (db_emp)> load data local inpath ‘/opt/datas/emp.txt’ into table emp_part partition(date
=‘2018120’);
When loading data to HDFS, an error is reported:
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.
problem solved:
1. Delete the hive meta database (metastore in mysql)
2. Manually create the metastore and execute the SQL statement: 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. Execute SQL statement: alter database metastore character set latin1;
mysql> alter database metastore character set latin1;
Query OK, 1 row affected (0.00 sec)
4. Go to the hive-site.xml under the hive configuration conf and modify the metadata database.
5.
Grant permissions to the data to be loaded. 6. Start 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. Open the browser and enter http://hadoop01.xningge.com:50070