在虛擬機部署 Hadoop(CentOS 7)後,常遇到宿主機或局域網其他電腦無法訪問 NameNode (9870)、ResourceManager (8088) 等 Web UI 的問題。經排查,核心原因通常是防火牆攔截或端口未放行。
curl localhost:9870 可訪問,說明 Hadoop 進程無誤。systemctl status firewalld → 若運行中,需放行端口或關閉。firewall-cmd --permanent --add-port=9870/tcpfirewall-cmd --permanent --add-port=8088/tcpfirewall-cmd --permanent --add-port=50070/tcp (舊版 NameNode)firewall-cmd --reloadsystemctl stop firewalld && systemctl disable firewalldhttps://<VM_IP>:9870。hdfs-site.xml / yarn-site.xml 中 dfs.namenode.http-address 等設置為 0.0.0.0:port 而非 127.0.0.1。nc -zv <VM_IP> 9870 # 顯示 succeeded 即通