ViewFS的配置

为了解决Federation配置的问题(访问集群的时候我们要记住每个NameNode所在节点的名称)

ViewFS配置(在master节点配置):

  • 配置前先关闭集群
  • 1、配置core-site.xml:
将原本的文件:
<configuration >
        <property>
                <name>fs.defaultFS</name>
                <value>hdfs://master:9999</value>
                <description>表示HDFS的基本路径</description>
        </property>
</configuration>
改成:
<configuration xmlns:xi="http://www.w3.org/2001/XInclude">
        <xi:include href="mountTable.xml"/>
        <property>
                 <name>fs.default.name</name>
                <value>viewfs://my-cluster</value>
        </property>
</configuration>
其余的<property></property>内容保持不变(可以选择注释)
  • 2、增加mountTable.xml:
<configuration>
  <property>
    <name>fs.viewfs.mounttable.my-cluster.link./user</name>
    <value>hdfs://master:9999/user</value>
  </property>
  <property>
    <name>fs.viewfs.mounttable.my-cluster.link./tmp</name>
    <value>hdfs://master:9999/tmp</value>
  </property>
  <property>
    <name>fs.viewfs.mounttable.my-cluster.link./projects/foo</name>
    <value>hdfs://slave1:9999/projects/foo</value>
  </property>
  <property>
    <name>fs.viewfs.mounttable.my-cluster.link./projects/bar</name>
    <value>hdfs://slave1:9999/projects/bar</value>
  </property>
</configuration>
  • 3、将core-site.xml mountTable.xml同步到slave1、slave2上
    scp core-site.xml mountTable.xml hadoop-twq@slave1:~/bigdata/hadoop-2.7.5/etc/hadoop/
    scp core-site.xml mountTable.xml hadoop-twq@slave2:~/bigdata/hadoop-2.7.5/etc/hadoop/
  • 4、启动集群
  • 5、在master、slave1上执行hadoop fs -ls /发现看到的数据都一样,如此一来,无论是在master、slave1还是slave2上执行hadoop fs -ls viewfs://my-cluster/这个基本路径后看到数据都一样,这样用户就不用记住NameNode安装在那里,方便了用户
  • 6、通过执行hadoop fs -ls viewfs://my-cluster/我们看到的结果是一样的,这是呈现给用户的,而实际上,我们看到的结果在第二步mountTable.xml文件中配置得到的,通过这个配置我们可以知道,结果中呈现的viewfs://my-cluster/user这个目录由master的这个NameNode来管理的,viewfs://my-cluster/tmp这个目录也是由master的这个NameNode来管理的,而viewfs://my-cluster/projects这个目录是由slave1这个NameNode来管理的。

 

posted @ 2019-02-27 16:26  AntarcticPenguin  阅读(1600)  评论(0编辑  收藏  举报
//开启礼花特效的js