我有培训任务,可以用2个带有 HDFS 的Docker容器构建 HA群集。我从图像" sequenceiq/hadoop-docker "创建了2个Docker容器(它具有Hadoop版本2.7.0(。我尝试实现" 共享存储"体系结构(根据https://hadoop.apache.org/docs/stable/hadoop-project-project-project-dist/hadoop-hadoop-hadoop-hadoop-hadop-hadop-hadop-hadop-hadfs/hdfshighhighavaighavaighavelabilitywithabilitywithnfs.html(。代替NFS共享文件夹,我使用/音量文件夹,它是在运行命令期间,我的docker卷中的卷。两个容器都在/卷上写入/读取权限。我在core-site.xml和hdfs-site.xml中进行了配置。另外,我通过两个容器之间的SSH设置无密码访问。但是" $HADOOP_PREFIX/bin/hdfs namenode -format
"命令因这样的消息而失败:
19/07/31 11:50:14 INFO namenode.FSNamesystem: HA Enabled: false
19/07/31 11:50:14 WARN namenode.FSNamesystem: Configured NNs:
19/07/31 11:50:14 ERROR namenode.FSNamesystem: FSNamesystem initialization failed.
java.io.IOException: Invalid configuration: a shared edits dir must not be specified if HA is not enabled.
和运行" $HADOOP_PREFIX/sbin/hadoop-daemon.sh start namenode
"时的结果相同在 NN1 和 nn2 namenode别名配置中,似乎存在一个错误("配置nns:"(。但是我根据教程制作了配置!请帮助我在我的HDFS群集中启用HA!
这是core-site.xml:
<configuration>
<property>
<name>fs.defaultFS</name>
<value>hdfs://mycluster</value>
</property>
</configuration>
和hdfs-site.xml:
<configuration>
<property>
<name>dfs.replication</name>
<value>1</value>
</property>
<property>
<name>dfs.nameservice</name>
<value>mycluster</value>
</property>
<property>
<name>dfs.ha.namenodes.myclaster</name>
<value>nn1,nn2</value>
</property>
<property>
<name>dfs.namenode.name.dir</name>
<value>file:/home/hadoop/local_nn_dir</value>
</property>
<property>
<name>dfs.namenode.rpc-address.mycluster.nn1</name>
<value>nn1.mycluster.com:8020</value>
</property>
<property>
<name>dfs.namenode.rpc-address.mycluster.nn2</name>
<value>nn2.mycluster.com:8020</value>
</property>
<property>
<name>dfs.namenode.http-address.mycluster.nn1</name>
<value>nn1.mycluster.com:50070</value>
</property>
<property>
<name>dfs.namenode.http-address.mycluster.nn2</name>
<value>nn2.mycluster.com:50070</value>
</property>
<property>
<name>dfs.namenode.shared.edits.dir</name>
<value>file:///volume</value>
</property>
<property>
<name>dfs.datanode.data.dir</name>
<value>file:/home/hadoop/dn_dir</value>
</property>
<property>
<name>dfs.client.failover.proxy.provider.mycluster</name>
<value>org.apache.hadoop.hdfs.server.namenode.ha.ConfiguredFailoverProxyProvider</value>
</property>
</configuration>
两个Docker容器都有相同的配置XML文件,但是" nn1.mycluster.com "one_answers" nn2.mycluster.com "在/etc/hosts中配置了分别指向Localhost和另一个Docker容器。
我解决了一个问题。HDFS-Site.xml中有2个错别字:xml:" dfs.nameservice
"而不是" dfs.nameservices
"one_answers" dfs.ha.namenodes.myclaster
"而不是" dfs.ha.namenodes.mycluster
"。congulusion:配置精度是首先!