hadoop主主机无法连接到localhost:连接被拒绝

tkqqtvp1  于 2021-05-29  发布在  Hadoop
关注(0)|答案(0)|浏览(415)

我在同一个网络中的不同主机上设置了两个节点的hdfs。我使用的是hdfs c++api。hdfs名称节点和数据节点正常启动,但当我尝试读取任何数据或打开文件时,会出现以下错误:

  1. Call From master/192.168.X.X to localhost:54310 failed on connection exception: connection refused

所以我猜这和ssh有关。
在master box上,以下命令起作用(/etc/hosts file包含master和slave):

  1. ssh master
  2. ssh slave
  3. ssh localhost
  4. ssh user@localhsot
  5. ssh localhost -p 22

但当我尝试 ssh localhost -p 54310 ,失败,出现“连接被拒绝”错误。但是ps-ef | grep:54310显示name节点监听该端口。
你知道怎么解决吗?
hdfs-site.xml文件

  1. <property>
  2. <name>dfs.replication</name>
  3. <value>2</value>
  4. <description>Default block replication.
  5. The actual number of replications can be specified when the file is created.
  6. The default is used if replication is not specified in create time.
  7. </description>
  8. </property>
  9. <property>
  10. <name>dfs.datanode.max.locked.memory</name>
  11. <value>0</value>
  12. <description>Default block replication.
  13. The actual number of replications can be specified when the file is created.
  14. The default is used if replication is not specified in create time.
  15. </description>
  16. </property>
  17. </configuration>

mapreg-site.xml文件

  1. <configuration>
  2. <property>
  3. <name>mapred.job.tracker</name>
  4. <value>master:54311</value>
  5. <description>The host and port that the MapReduce job tracker runs
  6. at. If "local", then jobs are run in-process as a single map
  7. and reduce task.
  8. </description>
  9. </property>
  10. </configuration>

core-site.xml文件

  1. <configuration>
  2. <property>
  3. <name>hadoop.tmp.dir</name>
  4. <value>/app/hadoop/tmp</value>
  5. <description>A base for other temporary directories.</description>
  6. </property>
  7. <property>
  8. <name>fs.default.name</name>
  9. <value>hdfs://master:54310</value>
  10. <description>The name of the default file system. A URI whose
  11. scheme and authority determine the FileSystem implementation. The
  12. uri's scheme determines the config property (fs.SCHEME.impl) naming
  13. the FileSystem implementation class. The uri's authority is used to
  14. determine the host, port, etc. for a filesystem.</description>
  15. </property>
  16. </configuration>

奴隶

  1. master
  2. slave

硕士

  1. master

编辑:来自netstat的结果-an

  1. tcp 0 0 127.0.0.1:54310 0.0.0.0:* LISTEN
  2. tcp 0 0 127.0.0.1:54310 127.0.0.1:45156 ESTABLISHED
  3. tcp 0 0 127.0.0.1:45156 127.0.0.1:54310 ESTABLISHED
  4. tcp 0 0 127.0.0.1:54310 127.0.0.1:45140 TIME_WAIT
  5. tcp 0 0 127.0.0.1:54310 127.0.0.1:45134 TIME_WAIT

我还将master替换为master host上的localhost,这解决了master上的问题。现在我得到的唯一错误是在slave中,它无法连接到master

  1. 2018-01-21 23:53:18,597 INFO org.apache.hadoop.ipc.Client: Retrying connect to server: master/ 192.168.0.237:54310. Already tried 8 time(s); retry policy is RetryUpToMaximumCountWithFixedSl eep(maxRetries=10, sleepTime=1000 MILLISECONDS)
  2. 2018-01-21 23:53:19,599 INFO org.apache.hadoop.ipc.Client: Retrying connect to server: master/ 192.168.0.237:54310. Already tried 9 time(s); retry policy is RetryUpToMaximumCountWithFixedSl eep(maxRetries=10, sleepTime=1000 MILLISECONDS)
  3. 2018-01-21 23:53:19,609 WARN org.apache.hadoop.hdfs.server.datanode.DataNode: Problem connecti ng to server: master/192.168.0.237:54310
  4. 2018-01-21 23:53:25,613 INFO org.apache.hadoop.ipc.Client: Retrying connect to server: master/ 192.168.0.237:54310. Already tried 0 time(s); retry policy is RetryUpToMaximumCountWithFixedSl eep(maxRetries=10, sleepTime=1000 MILLISECONDS)
  5. 2018-01-21 23:53:26,615 INFO org.apache.hadoop.ipc.Client: Retrying connect to server: master/ 192.168.0.237:54310. Already tried 1 time(s); retry policy is RetryUpToMaximumCountWithFixedSl eep(maxRetries=10, sleepTime=1000 MILLISECONDS)

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题