配置core-site.xml
在core-site.xml加入以下配置
master是整个服务的标识、以及配备了zookeeper的配置信息
配置hdfs-site.xml
<configuration> <property> <name>dfs.namenode.name.dir</name> <value>/home/hadoopData/dfs/name</value> </property> <property> <name>dfs.datanode.data.dir</name> <value>/home/hadoopData/dfs/data</value> </property> <property> <name>dfs.replication</name> <value>3</value> </property> <property> <name>dfs.webhdfs.enabled</name> <value>true</value> </property> <property> <name>dfs.permissions.superusergroup</name> <value>staff</value> </property> <property> <name>dfs.permissions.enabled</name> <value>false</value> </property> <!-- NanmeNode主备切换核心配置 --> <property> <name>dfs.nameservices</name> <value>master</value> </property> <property> <name>dfs.ha.namenodes.master</name> <value>nn1,nn2</value> </property> <property> <name>dfs.namenode.rpc-address.master.nn1</name> <value>master:9000</value> </property> <property> <name>dfs.namenode.http-address.master.nn1</name> <value>master:50070</value> </property> <property> <name>dfs.namenode.rpc-address.master.nn2</name> <value>standby-master:9000</value> </property> <property> <name>dfs.namenode.http-address.master.nn2</name> <value>standby-master:50070</value> </property> <!-- 指定NameNode的元数据在JournalNode上的存放位置 --> <property> <name>dfs.namenode.shared.edits.dir</name> <value>qjournal://slave1:8485;slave2:8485;slave3:8485/master</value> </property> <!-- 指定JournalNode在本地磁盘存放数据的位置 --> <property> <name>dfs.journalnode.edits.dir</name> <value>/home/hadoopData/journal</value> </property> <!-- 开启NameNode故障时自动切换 --> <property> <name>dfs.ha.automatic-failover.enabled</name> <value>true</value> </property> <property> <name>dfs.client.failover.proxy.provider.master</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>/root/.ssh/id_rsa</value> </property> <property> <name>dfs.replication</name> <value>2</value> </property> <property> <name>dfs.webhdfs.enabled</name> <value>true</value> </property> </configuration>