hadoop启动namenode日志报这个错,首先说怎么看日志,
启动namenode会有这个,ubuntu: starting namenode, logging to /home/xiaoye/hadoop/logs/hadoop-xiaoye-namenode-ubuntu.out
这是hadoop启动时会自动帮助写日志,并告诉我们日志的目录,我直接tail -200 /home/xiaoye/hadoop/logs/hadoop-xiaoye-namenode-ubuntu.out 看日志后200行,可是出现的结果是:
xiaoye@ubuntu:~$ tail -200 hadoop/logs/hadoop-xiaoye-namenode-ubuntu.out
ulimit -a for user xiaoye
core file size (blocks, -c) 0
data seg size (kbytes, -d) unlimited
scheduling priority (-e) 0
file size (blocks, -f) unlimited
pending signals (-i) 3645
max locked memory (kbytes, -l) 64
max memory size (kbytes, -m) unlimited
open files (-n) 1024
pipe size (512 bytes, -p) 8
POSIX message queues (bytes, -q) 819200
real-time priority (-r) 0
stack size (kbytes, -s) 8192
cpu time (seconds, -t) unlimited
max user processes (-u) 3645
virtual memory (kbytes, -v) unlimited
file locks (-x) unlimited
应该不是这个日志啊,看着不对劲。
于是改成 tail -200 hadoop/logs/hadoop-xiaoye-namenode-ubuntu.log
这个命令,就可以看到出现这个错,NameNode has nsId 229502726 but storage has nsId 695608861
解决办法:原因分析:
是多次格式化namenode导致版本不一致,直接的办法是直接删掉hadoop/hadoop/目录下的data和name目录下的所有文件,然后重新格式化,重新启动。但是这样明显是不提倡的。
这里解决办法是改文件的内容,根据提示,把/hadoop/hadoop/name/current目录下的VERSION文件的namespaceID修改成报错信息中storage的id值。
xiaoye@ubuntu:~$ cd hadoop/hadoop/name/current
xiaoye@ubuntu:~/hadoop/hadoop/name/current$ ls
edits_0000000000000000001-0000000000000000001 fsimage_0000000000000000000.md5
edits_inprogress_0000000000000000002 seen_txid
fsimage_0000000000000000000 VERSION
xiaoye@ubuntu:~/hadoop/hadoop/name/current$ vim VERSION
xiaoye@ubuntu:~/hadoop/hadoop/name/current$
#Fri Mar 30 00:14:41 PDT 2018
namespaceID=695608861
clusterID=CID-657e9540-2de9-43a2-bf91-199a4334b05a
cTime=0
storageType=NAME_NODE
blockpoolID=BP-583631310-127.0.1.1-1522394081528
layoutVersion=-59
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
"VERSION" 7L, 200C
在重新启动namenode
./hadoop/sbin/hadoop-daemons.sh start namenode
这时namenode还是没有启动成功,与是重复上面步骤,日志出现新的错误。
home/xiaoye/hadoop/journal/ns: NameNode has clusterId 'CID-b824b399-e941-4982-a618-745373
9d3d55' but storage has clusterId 'CID-657e9540-2de9-43a2-bf91-199a4334b05a'
于是还是修改上面的VERSION文件,把clusterId的值改成 storage的值,即可。