Hadoop 连接在端口 9000 上被拒绝。VirtualBox 端口 9000 转发不适用于桥接适配器
Hadoop connection refused on port 9000. VirtualBox port 9000 forwarding not working with Bridged adapter
我在 VirtualBox Ubuntu 上安装了 Hadoop。所有端口都通过网桥适配器转发到 Windows。但是9000端口不可用。我已经禁用了 Windows Defender、Firewall 和 SmartScreen。
Ubuntu:
user@vrtualBox:~/hadoop/hadoop-2.10.0$ netstat -lntu
active internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 0.0.0.0:50010 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:50075 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:50020 0.0.0.0:* LISTEN
tcp 0 0 127.0.0.1:9000 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:50090 0.0.0.0:* LISTEN
tcp 0 0 127.0.0.1:33201 0.0.0.0:* LISTEN
tcp 0 0 127.0.0.53:53 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:50070 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN
tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN
tcp6 0 0 :::13562 :::* LISTEN
tcp6 0 0 :::8030 :::* LISTEN
tcp6 0 0 :::8031 :::* LISTEN
tcp6 0 0 :::8032 :::* LISTEN
tcp6 0 0 :::8033 :::* LISTEN
tcp6 0 0 :::8040 :::* LISTEN
tcp6 0 0 :::8042 :::* LISTEN
tcp6 0 0 :::42835 :::* LISTEN
tcp6 0 0 :::22 :::* LISTEN
tcp6 0 0 ::1:631 :::* LISTEN
tcp6 0 0 :::8088 :::* LISTEN
ser@vrtualBox:~/hadoop/hadoop-2.10.0$ sudo iptables -S
[sudo] password for user:
-P INPUT ACCEPT
-P FORWARD ACCEPT
-P OUTPUT ACCEPT
Windows:
PS C:\Windows\system32> Test-NetConnection -ComputerName 192.168.0.12 -Port 8088
ComputerName : 192.168.0.12
RemoteAddress : 192.168.0.12
RemotePort : 8088
InterfaceAlias : Ethernet
SourceAddress : 192.168.0.11
TcpTestSucceeded : True
PS C:\Windows\system32> Test-NetConnection -ComputerName 192.168.0.12 -Port 9000
WARNING: TCP connect to (192.168.0.12 : 9000) failed
ComputerName : 192.168.0.12
RemoteAddress : 192.168.0.12
RemotePort : 9000
InterfaceAlias : Ethernet
SourceAddress : 192.168.0.11
PingSucceeded : True
PingReplyDetails (RTT) : 0 ms
TcpTestSucceeded : False
问题解决:端口转发到localhost
sudo sysctl -w net.ipv4.conf.all.route_localnet=1
sudo iptables -t nat -A PREROUTING -p tcp -d 192.168.0.12/24 --dport 9000 -j DNAT --to-destination 127.0.0.1:9000
sudo iptables -t nat -A POSTROUTING -j MASQUERADE
我在 VirtualBox Ubuntu 上安装了 Hadoop。所有端口都通过网桥适配器转发到 Windows。但是9000端口不可用。我已经禁用了 Windows Defender、Firewall 和 SmartScreen。
Ubuntu:
user@vrtualBox:~/hadoop/hadoop-2.10.0$ netstat -lntu
active internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 0.0.0.0:50010 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:50075 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:50020 0.0.0.0:* LISTEN
tcp 0 0 127.0.0.1:9000 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:50090 0.0.0.0:* LISTEN
tcp 0 0 127.0.0.1:33201 0.0.0.0:* LISTEN
tcp 0 0 127.0.0.53:53 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:50070 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN
tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN
tcp6 0 0 :::13562 :::* LISTEN
tcp6 0 0 :::8030 :::* LISTEN
tcp6 0 0 :::8031 :::* LISTEN
tcp6 0 0 :::8032 :::* LISTEN
tcp6 0 0 :::8033 :::* LISTEN
tcp6 0 0 :::8040 :::* LISTEN
tcp6 0 0 :::8042 :::* LISTEN
tcp6 0 0 :::42835 :::* LISTEN
tcp6 0 0 :::22 :::* LISTEN
tcp6 0 0 ::1:631 :::* LISTEN
tcp6 0 0 :::8088 :::* LISTEN
ser@vrtualBox:~/hadoop/hadoop-2.10.0$ sudo iptables -S
[sudo] password for user:
-P INPUT ACCEPT
-P FORWARD ACCEPT
-P OUTPUT ACCEPT
Windows:
PS C:\Windows\system32> Test-NetConnection -ComputerName 192.168.0.12 -Port 8088
ComputerName : 192.168.0.12
RemoteAddress : 192.168.0.12
RemotePort : 8088
InterfaceAlias : Ethernet
SourceAddress : 192.168.0.11
TcpTestSucceeded : True
PS C:\Windows\system32> Test-NetConnection -ComputerName 192.168.0.12 -Port 9000
WARNING: TCP connect to (192.168.0.12 : 9000) failed
ComputerName : 192.168.0.12
RemoteAddress : 192.168.0.12
RemotePort : 9000
InterfaceAlias : Ethernet
SourceAddress : 192.168.0.11
PingSucceeded : True
PingReplyDetails (RTT) : 0 ms
TcpTestSucceeded : False
问题解决:端口转发到localhost
sudo sysctl -w net.ipv4.conf.all.route_localnet=1
sudo iptables -t nat -A PREROUTING -p tcp -d 192.168.0.12/24 --dport 9000 -j DNAT --to-destination 127.0.0.1:9000
sudo iptables -t nat -A POSTROUTING -j MASQUERADE