当前位置: 首页 > 工具软件 > hass_config > 使用案例 >

配置hadoop HA 初始化时报错 Configuration has multiple addresses that match local node's address.

慎俊雄
2023-12-01

出错详情

************************************************************/
20/03/11 10:49:09 INFO namenode.NameNode: registered UNIX signal handlers for [TERM, HUP, INT]
20/03/11 10:49:09 INFO namenode.NameNode: createNameNode [-format]
20/03/11 10:49:09 ERROR namenode.NameNode: Failed to start namenode.
org.apache.hadoop.HadoopIllegalArgumentException: Configuration has multiple addresses that match local node's address. Please configure the system with dfs.nameservice.id and dfs.ha.namenode.id
        at org.apache.hadoop.hdfs.DFSUtil.getSuffixIDs(DFSUtil.java:1453)
        at org.apache.hadoop.hdfs.HAUtil.getNameNodeId(HAUtil.java:113)
        at org.apache.hadoop.hdfs.server.namenode.NameNode.format(NameNode.java:1012)
        at org.apache.hadoop.hdfs.server.namenode.NameNode.createNameNode(NameNode.java:1488)
        at org.apache.hadoop.hdfs.server.namenode.NameNode.main(NameNode.java:1615)
20/03/11 10:49:09 INFO util.ExitUtil: Exiting with status 1
20/03/11 10:49:09 INFO namenode.NameNode: SHUTDOWN_MSG: 
/************************************************************
SHUTDOWN_MSG: Shutting down NameNode at hadoop01/192.168.100.100
************************************************************/

解决问题

一开始没有找到问题的所在,通过百度,百度上说是因为 3个节点hosts的问题,后来发现hosts并没有问题.最后通过谷歌去国外的网站找到了,是因为 hdfs-site.xml 配置出错了

出现问题的地方

出错的地方为
dfs.namenode.rpc-address.cluster1.nn2dfs.namenode.http-address.cluster1.nn2 的 value 配置为 nn1 的地址去了,导致地址重复了,因此初始化时就报错了

正确的配置文件如下:

<configuration>
	<!--指定hdfs的nameservice为cluster1,需要和core-site.xml中的保持一致 -->
	<property>
		<name>dfs.nameservices</name>
		<value>cluster1</value>
	</property>
	<!-- cluster1下面有两个NameNode,分别是nn1,nn2 -->
	<property>
		<name>dfs.ha.namenodes.cluster1</name>
		<value>nn1,nn2</value>
	</property>
	<!-- nn1的RPC通信地址 -->
	<property>
		<name>dfs.namenode.rpc-address.cluster1.nn1</name>
		<value>hadoop01:8020</value>
	</property>
	<!-- nn1的http通信地址 -->
	<property>
		<name>dfs.namenode.http-address.cluster1.nn1</name>
		<value>hadoop01:50070</value>
	</property>
	<!-- nn2的RPC通信地址 -->
	<property>
		<name>dfs.namenode.rpc-address.cluster1.nn2</name>
		<value>hadoop02:8020</value>
	</property>
	<!-- nn2的http通信地址 -->
	<property>
		<name>dfs.namenode.http-address.cluster1.nn2</name>
		<value>hadoop02:50070</value>
	</property>
	<!-- 指定NameNode的edits元数据在JournalNode上的存放位置 -->
	<property>
		<name>dfs.namenode.shared.edits.dir</name>
		<value>qjournal://hadoop01:8485;hadoop02:8485;hadoop03:8485/cluster1</value>
	</property>
	<!-- 指定JournalNode在本地磁盘存放数据的位置 -->
	<property>
		<name>dfs.journalnode.edits.dir</name>
		<value>/export/install/hadoop-2.6.0-cdh5.14.0/journaldata</value>
	</property>
	<!-- 开启NameNode失败自动切换 -->
	<property>
		<name>dfs.ha.automatic-failover.enabled</name>
		<value>true</value>
	</property>
	<!-- 指定该集群出故障时,哪个实现类负责执行故障切换 -->
	<property>
		<name>dfs.client.failover.proxy.provider.cluster1</name>
		<value>org.apache.hadoop.hdfs.server.namenode.ha.ConfiguredFailoverProxyProvider</value>
	</property>
	<!-- 配置隔离机制方法,多个机制用换行分割,即每个机制暂用一行-->
	<property>
		<name>dfs.ha.fencing.methods</name>
		<value>sshfence</value>
	</property>
	<!-- 使用sshfence隔离机制时需要ssh免登陆 -->
	<property>
		<name>dfs.ha.fencing.ssh.private-key-files</name>
		<value>/root/.ssh/id_rsa</value>
	</property>
	<!-- 配置sshfence隔离机制超时时间 -->
	<property>
		<name>dfs.ha.fencing.ssh.connect-timeout</name>
		<value>30000</value>
	</property>
</configuration>
 类似资料: