hadoop hdfs-site.xml的配置

这篇博客详细介绍了如何配置Hadoop HDFS的高可用性,包括设置nameservices为shcluster,磁盘预留空间,两个NameNode的RPC和HTTP通信地址,JournalNode的设置,以及高可用自动切换和故障隔离机制的相关参数。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

<?xml version="1.0"encoding="UTF-8"?>

<?xml-stylesheet type="text/xsl"href="configuration.xsl"?>

<configuration>

              <!--指定hdfsnameservice为shcluster,需要和core-site.xml中的保持一致 -->

              <property>

                            <name>dfs.nameservices</name>

                            <value>shcluster</value>

              </property>

              <!—指定磁盘预留多少空间,防止磁盘被撑满用完,单位为bytes-->

              <property>

                            <name>dfs.datanode.du.reserved</name>

                            <value>107374182400</value>

              </property>

              <!--shcluster下面有两个NameNode,分别是namenode1namenode2 -->

              <property>

                            <name>dfs.ha.namenodes.shcluster</name>

                            <value>namenode1,namenode2</value>

              </property>

              <!--namenode1RPC通信地址,这里端口要和core-site.xmlfs.defaultFS保持一致 -->

              <property>

                            <name>dfs.namenode.rpc-address.shcluster.namenode1</name>

                            <value>app1:9000</value>

              </property>

              <!--namenode1http通信地址 -->

              <property>

                            <name>dfs.namenode.http-address.shcluster.namenode1</name>

                            <value>app1:50070</value>

              </property>

              <!--namenode2RPC通信地址,这里端口要和core-site.xmlfs.defaultFS保持一致 -->

              <property>

                            <name>dfs.namenode.rpc-address.shcluster.namenode2</name>

                            <value>app2:9000</value>

              </property>

              <!--namenode2http通信地址 -->

              <property>

                            <name>dfs.namenode.http-address.shcluster.namenode2</name>

                            <value>app2:50070</value>

              </property>

               <!--指定NameNode的元数据在JournalNode上的存放位置 -->

              <property>

                           <name>dfs.namenode.shared.edits.dir</name>                                               <value>qjournal://app1:8485;app2:8485;app3:8485:8485/shcluster</value>

              </property>

               <!--配置失败自动切换实现方式-->

              <property>

                            <name>dfs.client.failover.proxy.provider.shcluster</name>                          <value>org.apache.hadoop.hdfs.server.namenode.ha.ConfiguredFailoverProxyProvider</value>

              </property>

               <!--配置隔离机制,主要用户远程管理监听其他机器相关服务-->

              <property>

                            <name>dfs.ha.fencing.methods</name>

                            <value>sshfence</value>

              </property>

              <!--使用隔离机制时需要ssh免密码登陆 -->

              <property>

                            <name>dfs.ha.fencing.ssh.private-key-files</name>

                            <value>/home/hadoop/.ssh/id_rsa</value>

              </property>

               <!--指定NameNode的元数据在JournalNode上的存放位置 -->

              <property>

                            <name>dfs.journalnode.edits.dir</name>

                            <value>/home/hadoop/hadoop-2.7.4/journal </value>

              </property>

               <!--指定支持高可用自动切换机制-->

              <property>

                            <name>dfs.ha.automatic-failover.enabled</name>

                            <value>true</value>

              </property>

               <!--指定namenode名称空间的存储地址-->

              <property>

                            <name>dfs.namenode.name.dir</name>   

<value>file:/data1/hadoop/dfs/name,file:/data2/hadoop/dfs/name,file:/data3/hadoop/dfs/name,file:/data4/hadoop/dfs/name,file:/data5/hadoop/dfs/name,file:/data6/hadoop/dfs/name,file:/data7/hadoop/dfs/name,file:/data8/hadoop/dfs/name,file:/data9/hadoop/dfs/name,file:/data10/hadoop/dfs/name,file:/data11/hadoop/dfs/name,file:/data12/hadoop/dfs/name</value>>

              </property>

               <!--指定datanode数据存储地址-->

              <property>

                            <name>dfs.datanode.data.dir</name>

<value>file:/data1/hadoop/dfs/data,file:/data2/hadoop/dfs/data,file:/data3/hadoop/dfs/data,file:/data4/hadoop/dfs/data,file:/data5/hadoop/dfs/data,file:/data6/hadoop/dfs/data,file:/data7/hadoop/dfs/data,file:/data8/hadoop/dfs/data,file:/data9/hadoop/dfs/data,file:/data10/hadoop/dfs/data,file:/data11/hadoop/dfs/data,file:/data12/hadoop/dfs/data</value>              </property>

               <!--指定数据冗余份数-->

              <property>

                            <name>dfs.replication</name>

                            <value>3</value>

              </property>

               <!--指定可以通过web访问hdfs目录-->

              <property>

                            <name>dfs.webhdfs.enabled</name>

                            <value>false</value>

              </property>

               <property>

                            <name>ha.zookeeper.quorum</name>                                                         <value>app138:2181,app2:2181,app3:2181</value>

              </property>

               <property>

                            <name>dfs.namenode.handler.count</name>

                            <value>600</value>

                            <description>Thenumber of server threads for the namenode.</description>

              </property>

              <property>

                            <name>dfs.datanode.handler.count</name>

                            <value>600</value>

                            <description>Thenumber of server threads for the datanode.</description>

              </property>

              <property>

                            <name>dfs.client.socket-timeout</name>

                            <value>600000</value>

              </property>

              <property> 

                            <!--这里设置Hadoop允许打开最大文件数,默认4096,不设置的话会提示xcievers exceeded错误--> 

                            <name>dfs.datanode.max.transfer.threads</name> 

                            <value>409600</value> 

              </property> 

 <!--journal timeout setting-->

              <property>

               <name>dfs.qjournal.start-segment.timeout.ms</name>

               <value>600000</value>

       </property>

       <property>

               <name>dfs.qjournal.prepare-recovery.timeout.ms</name>

                <value>600000</value>

       </property>

       <property>

               <name>dfs.qjournal.accept-recovery.timeout.ms</name>

               <value>600000</value>

       </property>

       <property>

               <name>dfs.qjournal.finalize-segment.timeout.ms</name>

               <value>600000</value>

       </property>

       <property>

               <name>dfs.qjournal.select-input-streams.timeout.ms</name>

               <value>600000</value>

       </property>

       <property>

               <name>dfs.qjournal.get-journal-state.timeout.ms</name>

               <value>600000</value>

       </property>

       <property>

               <name>dfs.qjournal.new-epoch.timeout.ms</name>

               <value>600000</value>

       </property>

       <property>

               <name>dfs.qjournal.write-txns.timeout.ms</name>

               <value>600000</value>

       </property>

<!—start-balancer时,hdfs移动数据的速度,默认值为1M/S的速度。一般情况下设置为10M;设置的过大会影响当前job的运行-->

       <property>

               <name>dfs.datanode.balance.bandwidthPerSec</name>

               <value>10485760</value>

       </property>

 </configuration>

 </configuration>

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值