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>
<!-- NameNode HA配置 -->
<property>
<name>dfs.nameservices</name>
<value>ns</value>
<description>指定hdfs的nameservice为ns,需要和core-site.xml中的保持一致</description>
</property>
<property>
<name>dfs.ha.namenodes.ns</name>
<value>nn1,nn2</value>
<description>ns命名空间下有两个NameNode,逻辑代号,随便起名字,分别是nn1,nn2</description>
</property>
<property>
<name>dfs.namenode.rpc-address.ns.nn1</name>
<value>node01:9000</value>
<description>nn1的RPC通信地址</description>
</property>
<property>
<name>dfs.namenode.http-address.ns.nn1</name>
<value>node01:50070</value>
<description>nn1的http通信地址</description>
</property>
<property>
<name>dfs.namenode.rpc-address.ns.nn2</name>
<value>node02:9000</value>
<description>nn2的RPC通信地址</description>
</property>
<property>
<name>dfs.namenode.http-address.ns.nn2</name>
<value>node02:50070</value>
<description>nn2的http通信地址</description>
</property>
<!--JournalNode配置 -->
<property>
<name>dfs.namenode.shared.edits.dir</name>
<value>qjournal://node03:8485;node04:8485;node05:8485/ns</value>
<description>指定NameNode的edits元数据在JournalNode上的存放位置</description>
</property>
<property>
<name>dfs.journalnode.edits.dir</name>
<value>/usr/local/hadoop/journaldata</value>
<description>指定JournalNode在本地磁盘存放数据的位置</description>
</property>
<!--namenode高可用主备切换配置 -->
<property>
<name>dfs.ha.automatic-failover.enabled</name>
<value>true</value>
<description>开启NameNode失败自动切换</description>
</property>
<property>
<name>dfs.client.failover.proxy.provider.ns</name>
<value>org.apache.hadoop.hdfs.server.namenode.ha.ConfiguredFailoverProxyProvider</value>
<description>配置失败自动切换实现方式,使用内置的zkfc</description>
</property>
<property>
<name>dfs.ha.fencing.methods</name>
<value>
sshfence
shell(/bin/true)
</value>
<description>配置隔离机制,多个机制用换行分割,先执行sshfence,执行失败后执行shell(/bin/true),/bin/true会直接返回0表示成功</description>
</property>
<property>
<name>dfs.ha.fencing.ssh.private-key-files</name>
<value>/home/hadoop/.ssh/id_rsa</value>
<description>使用sshfence隔离机制时需要ssh免登陆</description>
</property>
<property>
<name>dfs.ha.fencing.ssh.connect-timeout</name>
<value>30000</value>
<description>配置sshfence隔离机制超时时间</description>
</property>
<!--dfs文件属性设置-->
<property>
<name>dfs.replication</name>
<value>3</value>
<description>设置block副本数为3</description>
</property>

<property>
<name>dfs.block.size</name>
<value>134217728</value>
<description>设置block大小是128M</description>
</property>
</configuration>

原文地址:https://www.cnblogs.com/llphhl/p/8847879.html