fs.default.name和fs.defaultFS

在hadoop的配置文件 core-site.xml中,需要设置 fs.default.name 或 fs.defaultFS ,具体应该使用哪一个,会造什么样的错误,需要在实际操作中去验证。官网有下面这段描述

We need to have only one of the two (fs.default.name or fs.defaultFS, and the former is deprecated). If both are present then NN HA will be enabled/disabled based on what is read first.

Following is description from NN HA in Apache docs:

fs.defaultFS - the default path prefix used by the Hadoop FS client when none is given.
Optionally, you may now configure the default path for Hadoop clients to use the new HA-enabled logical URI. If you used "mycluster" as the nameservice ID earlier, this will be the value of the authority portion of all of your HDFS paths. This may be configured like so, in your core-site.xml file:

<property>
    <name>fs.defaultFS</name>
    <value>hdfs://mycluster</value>
</property>

从文档中可以看出,使用 fs.default.name 还是 使用 fs.defaultFS ,要首先判断是否开启了 NN 的HA (namenode 的 highavaliable),如果开启了nn ha,那么就用fs.defaultFS,在单一namenode的情况下,就用 fs.default.name , 如果在单一namenode节点的情况使用 fs.defaultFS ,系统将报

 ERROR org.apache.hadoop.hdfs.server.namenode.NameNode: Failed to start namenode.
java.lang.IllegalArgumentException: Invalid URI for NameNode address (check fs.defaultFS): file:/// has no authority.
        at org.apache.hadoop.hdfs.server.namenode.NameNode.getAddress(NameNode.java:471)
        at org.apache.hadoop.hdfs.server.namenode.NameNode.getAddress(NameNode.java:461)
        at org.apache.hadoop.hdfs.server.namenode.NameNode.getRpcServerAddress(NameNode.java:512)
        at org.apache.hadoop.hdfs.server.namenode.NameNode.loginAsNameNodeUser(NameNode.java:612)
        at org.apache.hadoop.hdfs.server.namenode.NameNode.initialize(NameNode.java:632)
        at org.apache.hadoop.hdfs.server.namenode.NameNode.<init>(NameNode.java:811)
        at org.apache.hadoop.hdfs.server.namenode.NameNode.<init>(NameNode.java:795)
        at org.apache.hadoop.hdfs.server.namenode.NameNode.createNameNode(NameNode.java:1488)
        at org.apache.hadoop.hdfs.server.namenode.NameNode.main(NameNode.java:1554)
INFO org.apache.hadoop.util.ExitUtil: Exiting with status 1
INFO org.apache.hadoop.hdfs.server.namenode.NameNode: SHUTDOWN_MSG: 
————————————————
版权声明:本文为CSDN博主「lepton126」的原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/lepton126/article/details/88327205

posted @ 2020-03-04 16:38  IT实战家  阅读(6446)  评论(0编辑  收藏  举报