用hadoop在hive表中加载数据

64jmpszr  于 2021-05-29  发布在  Hadoop
关注(0)|答案(2)|浏览(418)

我希望通过.sql脚本在配置单元表中加载数据,但遇到如下问题:

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

我的脚本看起来像:

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 ;

中的权限 /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

数据如下:

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

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

你知道为什么我可以用data.txt中的数据填充测试表吗?

lsmd5eda

lsmd5eda1#

我想你在haddop有权限问题。使用以下一个命令提供权限,并验证data.txt文件是否已损坏
hadoop fs-chmodg+w/用户/配置单元/仓库/测试/

bjp0bcyl

bjp0bcyl2#

要将文件写入的目录是

/user/hive/warehouse/test/

您通过浏览器检查的权限是

/tmp/hive/warehouse/test/

所以这里有一个明显的不匹配。

相关问题