Hadoop之Linux修改虚拟本机地址

2022-07-03 11:26:53 浏览数 (1)

Hadoop是运行在Linux系统下的,但我们在Windows下Eclipse远程访问Hadoop HDFS时,如果两个机子地址不在同一网段便无法相互访问。

Windows测试是否可远程连接,只需Dos  执行ping即可。

为了统一网段,势必要对虚拟机设置网络地址:

1.root账户登录,修改interfaces

hadoop@HADOOP:~$ su root Password: root@HADOOP:/home/hadoop# vi /etc/network/interfaces

文件修改参考如下(按主机网段修改):

address 192.168.3.137 gateway 192.168.3.1 netmask 255.255.255.0

2.修改hosts

root@HADOOP:/home/hadoop# vi /etc/hosts

文件修改参考如下(按主机网段修改):

127.0.0.1      localhost 127.0.1.1      Ubuntu 192.168.3.137  HADOOP.MAIN 192.168.1.135  HADOOP.SLAVE 192.168.1.136  HADOOP.SLAVE2 # The following lines are desirable for IPv6 capable hosts ::1    ip6-localhost ip6-loopback fe00::0 ip6-localnet ff00::0 ip6-mcastprefix ff02::1 ip6-allnodes ff02::2 ip6-allrouters

注意两个地址要保持一致

3.ifconfig查看配置信息是否正确

hadoop@HADOOP:~$ ifconfig eth0      Link encap:Ethernet  HWaddr 00:0c:29:42:d4:51            inet addr:192.168.3.137  Bcast:192.168.3.255  Mask:255.255.255.0           inet6 addr: fe80::20c:29ff:fe42:d451/64 Scope:Link           UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1           RX packets:29 errors:0 dropped:0 overruns:0 frame:0           TX packets:73 errors:0 dropped:0 overruns:0 carrier:0           collisions:0 txqueuelen:1000           RX bytes:2531 (2.5 KB)  TX bytes:12238 (12.2 KB)           Interrupt:19 Base address:0x2024

lo        Link encap:Local Loopback            inet addr:127.0.0.1  Mask:255.0.0.0           inet6 addr: ::1/128 Scope:Host           UP LOOPBACK RUNNING  MTU:16436  Metric:1           RX packets:24 errors:0 dropped:0 overruns:0 frame:0           TX packets:24 errors:0 dropped:0 overruns:0 carrier:0           collisions:0 txqueuelen:0           RX bytes:1884 (1.8 KB)  TX bytes:1884 (1.8 KB)

4.在Windows Dos下执行 ping 地址  命令,查看是否连接成功

0 人点赞