Hadoop BUG和采坑集锦—阿里云ECS配置Hadoop, datanode一直显示localhost, 下载文件失败

问题描述

 我个人的阿里云主机,在上面搭建Hadoop,主要配置如下:

/etc/hosts文件内容:
host文件
~etc/hadoop/hdfs-site.xml文件内容
在这里插入图片描述
为了方便大家复制粘贴下面是源码

<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<!--
  Licensed under the Apache License, Version 2.0 (the "License");
  you may not use this file except in compliance with the License.
  You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License. See accompanying LICENSE file.
-->

<!-- Put site-specific property overrides in this file. -->
<configuration>
    <property>
        <name>dfs.replication</name>
        <value>1</value>
    </property>
    <property>
        <name>dfs.datanode.http.address</name>
        <value>aliyun:50075</value>
    </property>
    <property>
        <name>dfs.datanode.address</name>
        <value>aliyun:50010</value>
    </property>
</configuration>

~etc/hadoop/core-site.xml文件内容:
在这里插入图片描述

为了方便大家复制粘贴下面是源码

<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<!--
  Licensed under the Apache License, Version 2.0 (the "License");
  you may not use this file except in compliance with the License.
  You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License. See accompanying LICENSE file.
-->

<!-- Put site-specific property overrides in this file. -->
<configuration>
        <property>
                <name>fs.defaultFS</name>
                <value>hdfs://aliyun:9001</value>
        </property>
        <property>
                <name>hadoop.tmp.dir</name>
                <value>/opt/hadoop/hadoop-2.10.1/tmp/</value>
        </property>
</configuration>

启动 datanodenamenode之后,然后访问结果:
在这里插入图片描述
还有下面浏览文件的时候准备 download的时候:
在这里插入图片描述

百思不得其解:因为在上面的hdfs-site.xml设置dfs.datanode.http.addressaliyun:50075寻思着为什么还是localhost不是aliyun呢?

然后就开始外网上冲浪,外海也去冲浪了,都说要配置hosts文件,我配置了,而且也生效(可以ping自己的域名)了,

然后问一个大佬,他告诉我,你修改一下主机名试试竟然是这个
然后他就让我改一下hostname试试改成aliyun,试试呗,
在这里插入图片描述
然后重启 datanodenamenode,其他的都没改动,你猜怎么着?
在这里插入图片描述
在这里插入图片描述
TMD,全体起立,成了。

然后我就寻思这不科学啊,这尼玛一定要将dfs.datanode.http.address设置成hostname这就离谱,约束性也太强了,而且我配置的时候是根据官方配置文件理解配置的,
在这里插入图片描述
这明明写的是Server address 不是hostname(个人认为这个是文档的bug)。然后我寻思着他们好像还有个配置在这里插入图片描述
这里可以指定hostname,后面解释写的是默认是主机当前的hostname,但是也不对啊,我上面查看hostname的时候返回的是iZ2ze5ru3jzfp5m5bmaganZ, 但是Hadoop显示的却是localhost(个人认为是bug),
为了举一反三,我就寻思着既然和hostname有关,刚好dfs.datanode.hostname可以指订hostname,并且将hostname先设置回iZ2ze5ru3jzfp5m5bmaganZ,再在hdfs-site.xml添加dfs.datanode.hostname设置看看会不会生效,操作步骤如下:

  1. 还原hostname
    在这里插入图片描述
  2. 在hdfs-site.xml添加配置后如下:
    在这里插入图片描述

为了方便大家复制粘贴下面是源码

<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<!--
  Licensed under the Apache License, Version 2.0 (the "License");
  you may not use this file except in compliance with the License.
  You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License. See accompanying LICENSE file.
-->

<!-- Put site-specific property overrides in this file. -->
<configuration>
    <property>
        <name>dfs.replication</name>
        <value>1</value>
    </property>
    <property>
        <name>dfs.datanode.hostname</name>
        <value>aliyun</value>
    </property>
    <property>
        <name>dfs.datanode.http.address</name>
        <value>aliyun:50075</value>
    </property>
    <property>
        <name>dfs.datanode.address</name>
        <value>aliyun:50010</value>
    </property>
</configuration>

然后重启datanodenamenode你猜怎么着,
卧槽 绝了,

在这里插入图片描述
在这里插入图片描述
举一反三成功。

点击文件下载失败

在这里插入图片描述
因为在阿里云上部署的,只能部署内网ip,我上面的hosts的文件配置映射aliyun也是映射的内网,不然根本启动不起来,所以这里你点击download的时候,就会失败,出现下面的画面
在这里插入图片描述
因为aliyun上面只能配置内网,所以这里自动跳转的时候的域名也是hadoop上面配置的aliyun:50075,但是你本地没办法解析这个域名,所以要想成功就需要你自己在自己本地的电脑上的hosts文件上面添加
在这里插入图片描述
这样就成了,或者你直接
在这里插入图片描述
在这里插入图片描述
这样就妥了。

  • 4
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 3
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值