Hadoop服务启动失败

Hadoop服务启动失败
今天启动Hadoop时,终端报了一个新的错误

```bash
Starting namenodes on [192.168.19.128]
192.168.19.128: ssh: connect to host 192.168.19.128 port 22: Network is unreachable
Starting datanodes
Starting secondary namenodes [zc-virtual-machine]

```
我使用**ifconfig**命令查看了虚拟机IP,惊奇地发现IP居然发生了变化,如下图:

```bash
hadoop@zc-virtual-machine:~$ ifconfig
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 1000 (本地环回)
RX packets 14229 bytes 1056774 (1.0 MB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 14229 bytes 1056774 (1.0 MB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

```
IP变为了127.0.0.1,难怪会报错,此时我的core-site.xml配置的还是之前的IP地址。

查询了下资料,找到了修改方法
使用**dhclient**命令([dhclient命令传送门](https://www.linuxcool.com/dhclient)),注意要使用sudo命令,以免权限不够。。如下图:

```bash
hadoop@zc-virtual-machine:~$ sudo dhclient -v
Internet Systems Consortium DHCP Client 4.4.1
Copyright 2004-2018 Internet Systems Consortium.
All rights reserved.
For info, please visit https://www.isc.org/software/dhcp/

Listening on LPF/ens33/00:0c:29:38:05:a8
Sending on LPF/ens33/00:0c:29:38:05:a8
Sending on Socket/fallback
DHCPDISCOVER on ens33 to 255.255.255.255 port 67 interval 3 (xid=0x13399c1d)
DHCPOFFER of 192.168.19.128 from 192.168.19.254
DHCPREQUEST for 192.168.19.128 on ens33 to 255.255.255.255 port 67 (xid=0x1d9c3913)
DHCPACK of 192.168.19.128 from 192.168.19.254 (xid=0x13399c1d)
bound to 192.168.19.128 -- renewal in 701 seconds.
```
再次查看虚拟机IP,

```bash
hadoop@zc-virtual-machine:~$ ifconfig
ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.19.128 netmask 255.255.255.0 broadcast 192.168.19.255
inet6 fe80::20c:29ff:fe38:5a8 prefixlen 64 scopeid 0x20<link>
ether 00:0c:29:38:05:a8 txqueuelen 1000 (以太网)
RX packets 13 bytes 1708 (1.7 KB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 41 bytes 6076 (6.0 KB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

```
操作成功

之后启动Hadoop,没有报错误,使用**jps**命令查看进程,如下图:

```bash
hadoop@zc-virtual-machine:~$ /usr/local/hadoop/hadoop-3.2.2/sbin/start-dfs.sh
Starting namenodes on [192.168.19.128]
Starting datanodes
Starting secondary namenodes [zc-virtual-machine]
hadoop@zc-virtual-machine:~$ jps
4897 DataNode
5218 Jps
5109 SecondaryNameNode
4766 NameNode
```
服务启动成功!

上一篇:机器之心年度奖项Synced Machine Intelligence Awards 2018正式发


下一篇:学习Python的书籍——入门到进阶