使用如下命令加载HIVE数据时,
load data local inpath '/usr/local/testdata/smalltable' into table testtab1;
一直报错,错误信息如下:
2021-03-27 08:47:59,819 INFO org.apache.hadoop.ipc.Server: IPC Server handler 4 on 9000, call org.apache.hadoop.hdfs.protocol.ClientProtocol.addBlock from 192.168.83.3:48061 Call#37 Retry#0
java.io.IOException: File /user/hive/warehouse/testtab1/smalltable could only be replicated to 0 nodes instead of minReplication (=1). There are 2 datanode(s) running and 2 node(s) are excluded in this operation.
解决方式个人认为有两个:
1、关闭防火墙
systemctl disable firewalld --关闭防火墙
systemctl status firewalld–查看防火墙状态 Active: inactive (dead) dead表示关掉
注意:关闭防火墙是要关闭所有节点的防火墙!我之前搭建hadoop时只关闭了主节点的防火墙,从节点的应该是忘记关了,导致一直报这个错误
2、core-site.xml hdfs-site.xml中的配置
core-site.xml文件中hadoop.tmp.dir与
hdfs-site.xml文件中的dfs.namenode.name.dir、dfs.datanode.data.dir的路径要一致(是在某一篇博客看到的,具体原因暂未知)
比如,我的路径是这样的
<name>hadoop.tmp.dir</name>
<value>file:/usr/local/software/hadoop-2.7.7/hdfs/tmp</value>
<name>dfs.namenode.name.dir</name>
<value>file:/usr/local/software/hadoop-2.7.7/hdfs/name</value>
<name>dfs.datanode.data.dir</name>
<value>file:/usr/local/software/hadoop-2.7.7/hdfs/data</value>
即tmp、name、data都是在file:/usr/local/software/hadoop-2.7.7/hdfs/这同一个路径下