我在名为hadoop
.
该core-site.xml
文件的fs.defaultFS
(等效于fs.default.name
)设置为以下内容:
<property>
<name>fs.defaultFS</name>
<value>hdfs://hadoop:8020</value>
</property>
我有一个非常简单的表test_table
,该表当前存在于 HDFS 上的 Hive 服务器中。也就是说,它存储在/user/hive/warehouse/test_table
. 它是在 Hive 中使用一个非常简单的命令创建的:
CREATE TABLE new_table (record_id INT);
如果我尝试在本地(即使用LOAD DATA LOCAL
)将数据加载到表中,一切都会按预期进行。但是,如果数据存储在 HDFS 上并且我想从那里加载,则会出现问题。
我运行一个非常简单的查询来尝试这个加载:
hive> LOAD DATA INPATH '/user/haduser/test_table.csv' INTO TABLE test_table;
这样做会导致以下错误:
FAILED: SemanticException [Error 10028]: Line 1:17 Path is not legal ''/user/haduser/test_table.csv'':
Move from: hdfs://hadoop:8020/user/haduser/test_table.csv to: hdfs://localhost:8020/user/hive/warehouse/test_table is not valid.
Please check that values for params "default.fs.name" and "hive.metastore.warehouse.dir" do not conflict.
正如错误所述,它正试图从 移动hdfs://hadoop:8020/user/haduser/test_table.csv
到hdfs://localhost:8020/user/hive/warehouse/test_table
。第一条路径是正确的,因为它引用了hadoop:8020
; 第二条路径不正确,因为它引用了localhost:8020
.
该core-site.xml
文件明确规定使用hdfs://hadoop:8020
. 中的hive.metastore.warehouse
值hive-site.xml
正确指向/user/hive/warehouse
。因此,我怀疑此错误消息是否具有任何真实价值。
创建表时如何让 Hive 服务器使用正确的 NameNode 地址?