正在重试连接到服务器:已尝试9次;重试策略是RetryUpMaximumCountWithFixedSleep(maxretries=10,sleeptime=1000毫秒)

w3nuxt5m  于 2021-05-29  发布在  Hadoop
关注(0)|答案(1)|浏览(529)

我有三个物理节点。在每个节点中,我用这个命令输入docker。

docker run -v /home/user/.ssh:/root/.ssh --privileged 
   -p 5050:5050 -p 5051:5051 -p 5052:5052 -p 2181:2181 -p 8089:8081 
   -p 6123:6123 -p 8084:8080 -p 50090:50090 -p 50070:50070 
   -p 9000:9000 -p 2888:2888 -p 3888:3888 -p 4041:4040 -p 8020:8020 
   -p 8485:8485 -p 7078:7077 -p 52222:22 -e WEAVE_CIDR=10.32.0.3/12 
   -e MESOS_EXECUTOR_REGISTRATION_TIMEOUT=5mins 
   -e LIBPROCESS_IP=10.32.0.3 
   -e MESOS_RESOURCES=ports*:[11000-11999] 
   -ti hadoop_marathon_mesos_flink_2 /bin/bash

我将hadoop配置为:core-site.xml:

<configuration>
   <property>
     <name>fs.defaultFS</name>
     <value>hdfs://mycluster</value>
   </property>
   <property>
     <name>fs.default.name</name>
     <value>hdfs://mycluster</value>
   </property>
 </configuration>

hdfs-site.xml:

<configuration>
    <property>
      <name>dfs.namenode.shared.edits.dir</name>
      <value>
   qjournal://10.32.0.1:8485;10.32.0.2:8485;10.32.0.3:8485/mycluster
      </value>
    </property>

    <property>
      <name>dfs.journalnode.edits.dir</name>
      <value>/tmp/hadoop/dfs/jn</value>
    </property>

    <property>
      <name>dfs.nameservices</name>
      <value>mycluster</value>
      <description>Logical name for this new 
      nameservice</description>
    </property>

    <property>
      <name>dfs.ha.namenodes.mycluster</name>
      <value>nn1,nn2</value>
      <description>Unique identifiers for each NameNode in the 
      nameservice</description>
    </property>

     <property>
       <name>dfs.namenode.rpc-address.mycluster.nn1</name>
       <value>10.32.0.1:8020</value>
     </property>

     <property>
       <name>dfs.namenode.rpc-address.mycluster.nn2</name>
       <value>10.32.0.2:8020</value>
     </property>

     <property>
       <name>dfs.namenode.http-address.mycluster.nn1</name>
       <value>10.32.0.1:50070</value>
     </property>

     <property>
       <name>dfs.namenode.http-address.mycluster.nn2</name>
       <value>10.32.0.2:50070</value>
     </property>

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

     <property>
       <name>dfs.ha.fencing.methods</name>
       <value>shell(/bin/true)</value>
     </property>

     <property>
       <name>dfs.replication</name>
       <value>1</value>
     </property>

     <property>
       <name>dfs.namenode.name.dir</name>
       <value>file:///usr/local/hadoop_store/hdfs/namenode</value>
     </property>

     <property>
       <name>dfs.datanode.data.dir</name>
       <value>file:///usr/local/hadoop_store/hdfs/datanode</value>
     </property>

     <property>
       <name>dfs.namenode.datanode.registration.
       ip-hostname-check</name>
       <value>false</value>
     </property>

     <property>
       <name>dfs.ha.automatic-failover.enabled</name>
       <value>true</value>
     </property>

     <property>
       <name>ha.zookeeper.quorum</name>
       <value>10.32.0.1:2181,10.32.0.2:2181,10.32.0.3:2181</value>
     </property>
   </configuration>

问题在于格式化namenode时:

hadoop namenode -format

它不能格式化namenode。我收到这个错误:
2019-05-06 06:35:09969 info ipc.client:正在重试连接到服务器:10.32.0.2/10.32.0.2:8485。已尝试9次;重试策略是RetryUpMaximumCountWithFixedSleep(maxretries=10,sleeptime=1000毫秒)
2019-05-06 06:35:09969 info ipc.client:正在重试连接到服务器:10.32.0.3/10.32.0.3:8485。已尝试9次;重试策略是RetryUpMaximumCountWithFixedSleep(maxretries=10,sleeptime=1000毫秒)
2019-05-06 06:35:09987错误namenode.namenode:无法启动namenode。org.apache.hadoop.hdfs.qjournal.client.quorumexception:无法检查jns是否准备好格式化。1引发异常:
10.32.0.1:8485:从50c5244de4cd/10.32.0.1调用50c5244de4cd:8485连接失败异常:java.net.connectexception:连接被拒绝;有关详细信息,请参阅:http://wiki.apache.org/hadoop/connectionrefused
我已经发布了hadoop中需要的端口,但是我仍然收到了拒绝的连接。
有人能告诉我配置有什么问题吗?
先谢谢你。

agyaoht7

agyaoht71#

解决这个问题的原因是core-site.xml中的zookeeper配置。我将在以下内容中详细介绍高可用性hadoop配置:hdfs-site.xml:

<property>
     <name>dfs.nameservices</name>
     <value>mycluster</value>
     <description>Logical name for this new nameservice</description>
</property>
<property>
     <name>dfs.ha.namenodes.mycluster</name>
     <value>nn1,nn2</value>
     <description>Unique identifiers for each NameNode in 
      the nameservice</description>
</property>
<property>
     <name>dfs.namenode.rpc-address.mycluster.nn1</name>
     <value>10.32.0.1:8020</value>
</property>
<property>
     <name>dfs.namenode.rpc-address.mycluster.nn2</name>
     <value>10.32.0.2:8020</value>
</property>
<property>
     <name>dfs.namenode.http-address.mycluster.nn1</name>
     <value>10.32.0.1:50070</value>
</property>
<property>
     <name>dfs.namenode.http-address.mycluster.nn2</name>
     <value>10.32.0.2:50070</value>
</property>
<property>
     <name>dfs.client.failover.proxy.provider.mycluster</name>
     <value>org.apache.hadoop.hdfs.
     server.namenode.ha.ConfiguredFailoverProxyProvider</value>
</property>
<property>
     <name>dfs.namenode.shared.edits.dir</name>
     <value>
      qjournal://10.32.0.1:8485;10.32.0.2:8485;10.32.0.3:8485/mycluster
     </value>
</property>
<property>
     <name>dfs.permissions.enable</name>
     <value> false </value>
</property>
<property>
    <name>dfs.ha.fencing.methods</name>
    <value>sshfence</value>
</property>
<property>
    <name>dfs.ha.fencing.ssh.private-key-files</name>
    <value>/home/hdfs/.ssh/id_rsa</value>
</property>
<property>
    <name>dfs.ha.fencing.ssh.connect-timeout</name>
    <value>30000</value>
</property>
<property>
    <name>dfs.permissions.superusergroup</name>
    <value>hdfs</value>
</property>
<property>
    <name>dfs.replication</name>
    <value>1</value>
</property>
<property>
    <name>dfs.namenode.name.dir</name>
    <value>file:///usr/local/hadoop_store/hdfs/namenode</value>
</property>
<property>
    <name>dfs.datanode.data.dir</name>
    <value>file:///usr/local/hadoop_store/hdfs/datanode</value>
</property>
<property>
    <name>dfs.namenode.datanode.registration.ip-hostname-check</name>
    <value>false</value>
</property>
<property>
    <name>dfs.ha.automatic-failover.enabled</name>
    <value>true</value>
</property>

core-site.xml(例如在节点“10.32.0.1”中):

<property>
    <name>fs.defaultFS</name>
    <value>hdfs://mycluster</value>
 </property>
 <property>
    <name>dfs.journalnode.edits.dir</name>
    <value>/tmp/hadoop/dfs/journalnode</value>
 </property>
 <property>
    <name>fs.default.name</name>
    <value>hdfs://mycluster</value>
 </property>
 <property>
    <name>ha.zookeeper.quorum</name>
    <value>0.0.0.0:2181,10.32.0.2:2181,10.32.0.3:2181</value>
 </property>

zookeeper配置,例如“10.32.0.1”中的配置是:

server.1=0.0.0.0:2888:3888
  server.2=10.32.0.2:2888:3888
  server.3=10.32.0.3:2888:3888

另外,我在/var/lib/zookeeper/data中创建了myid文件,其中包含该节点的id。首先,删除以下所有文件夹:

rm -rf /tmp/hadoop/dfs/journalnode
  rm -rf /usr/local/hadoop_store/hdfs/namenode
  rm -rf /usr/local/hadoop_store/hdfs/datanode
  rm -rf /opt/hadoop/logs/*

然后,创建以下文件夹:

mkdir /usr/local/hadoop_store/hdfs/namenode
  mkdir /usr/local/hadoop_store/hdfs/datanode

然后,对这些文件夹授予正确的权限:

chmod 777 /usr/local/hadoop_store/hdfs/namenode
  chmod 777 /usr/local/hadoop_store/hdfs/datanode
  chown -R root /usr/local/hadoop_store/hdfs/namenode
  chown -R root /usr/local/hadoop_store/hdfs/datanode
  chmod 777 /tmp/hadoop/dfs/journalnode
  chown -R root /tmp/hadoop/dfs/journalnode

现在您可以按照此阶段格式化这些文件夹。最重要的是如何格式化这三个节点。你必须遵循以下几个阶段:1。停止hdfs服务2。只启动日志节点(因为它们需要知道格式)

/opt/hadoop/bin/hdfs --daemon start journalnode

在第一个namenode上(作为用户hdfs或root)
hadoop namenode-格式
在日志节点上:
hdfs namenode-initializesharededits-force
重新启动zookeeper:
/home/zookeeper-3.4.14/bin/zkserver.sh重新启动
格式zookeeper:

hdfs zkfc -formatZK -force (to force zookeeper to reinitialise)

重新启动第一个namenode:

/opt/hadoop/bin/hdfs --daemon start namenode

在第二个namenode上:

hdfs namenode -bootstrapStandby -force ​(force synch with first namenode)

在每个数据节点上清除数据目录:

hadoop datanode -format

重新启动hdfs服务:

/opt/hadoop/sbin/start-dfs.sh

顺便说一下,我有三个节点,两个namenodes和一个datanode。您可以在/opt/hadoop/logs/中检查hadoop日志。

相关问题