简体   繁体   English

使用Hadoop在Hive表中加载数据

[英]Loading data in Hive table with Hadoop

I'm looking to load data in Hive table by a .sql script but I get an issue like this : 我正在寻找通过.sql脚本在Hive表中加载数据,但遇到这样的问题:

hduser@master:~$ hive -f script.sql 

Logging initialized using configuration in jar:file:/home/hduser/ecosystem/apache-hive-2.3.0-bin/lib/hive-common-2.3.0.jar!/hive-log4j2.properties Async: true
OK
Time taken: 5.798 seconds
Loading data to table default.test
Failed with exception Unable to move source file:/home/hduser/Data.txt to destination hdfs://master:9000/user/hive/warehouse/test/Data.txt
FAILED: Execution Error, return code 1 from org.apache.hadoop.hive.ql.exec.MoveTask. Unable to move source file:/home/hduser/Data.txt to destination hdfs://master:9000/user/hive/warehouse/test/Data.txt

My script looks like : 我的脚本看起来像:

CREATE TABLE IF NOT EXISTS Test (
id int, mdp string, id_employe int, category int)
ROW FORMAT DELIMITED
FIELDS TERMINATED BY ','
LINES TERMINATED BY '\n' ;

LOAD DATA LOCAL INPATH '/home/hduser/Data.txt' OVERWRITE INTO TABLE Test ;

Permissions in /home/hduser are : /home/hduser中的权限为:

hduser@master:~$ ls -l
total 5364168
-rwx-wx-wx 1 hduser hduser 5492885458 août  24 11:38 Data.txt
-rw-rw-r-- 1 hduser hduser        684 août  24 12:14 derby.log
drwxrwxr-x 3 hduser hduser       4096 juil. 26 11:46 ecosystem
drwxrwxr-x 5 hduser hduser       4096 août  24 12:14 metastore_db
-rwx-wx-wx 1 hduser hduser        233 août  24 12:10 script.sql

Data looks like : 数据如下:

1, jhkjhkjh, 18, 11
2, poilll, 87, 13
3, aoudliaoiud, 98, 76
...

In http://172.30.10.182:50070/explorer.html#/ I have : http://172.30.10.182:50070/explorer.html#/我有:

drwx-wx-wx  hduser  supergroup  0 B Aug 24 11:40    0   0 B tmp
then
drwx-wx-wx  hduser  supergroup  0 B Aug 24 11:40    0   0 B hive
then 
drwx-wx-wx  hduser  supergroup  0 B Aug 24 12:14    0   0 B hduser
then 
drwx-wx-wx  hduser  hduser  0 B Aug 24 12:12    0   0 B warehouse
then 
drwx-wx-wx  hduser  hduser  0 B Aug 24 12:12    0   0 B test

Do you have any idea why I can fill my test table with data from Data.txt ? 您知道为什么我可以用Data.txt中的数据填充测试表吗?

The directory that you are tying to write the file to is 您要写入文件的目录是

/user/hive/warehouse/test/

The rights that you check via the explorer are for 您通过资源管理器检查的权利适用于

/tmp/hive/warehouse/test/

So here is a clear mismatch. 因此,这显然是不匹配的。

I think you have permission issue in haddop. 我认为您在haddop中存在权限问题。 provide permission using below one command and also verify that data.txt file is not corrupt 使用以下命令提供许可,并验证data.txt文件未损坏

hadoop fs -chmod g+w /user/hive/warehouse/test/ hadoop fs -chmod g + w /用户/配置单元/仓库/测试/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM