最近频繁遇到一个问题,storm在提交运行jar程序时,子进程supervisor总是挂机,导致无法运行jar项目,之前以为是环境的问题或是ZK的版本问题,后来查看supervisor.log的日志信息才发现问题所在。先来看看错误
2017-10-11 09:50:06 b.s.event [ERROR] Error when processing event
java.lang.RuntimeException: java.io.EOFException
at backtype.storm.utils.Utils.deserialize(Utils.java:93) ~[storm-core-0.9.2-incubating.jar:0.9.2-incubating]
at backtype.storm.utils.LocalState.snapshot(LocalState.java:45) ~[storm-core-0.9.2-incubating.jar:0.9.2-incubating]
at backtype.storm.utils.LocalState.get(LocalState.java:56) ~[storm-core-0.9.2-incubating.jar:0.9.2-incubating]
at backtype.storm.daemon.supervisor$sync_processes.invoke(supervisor.clj:207) ~[storm-core-0.9.2-incubating.jar:0.9.2-incubating]
at clojure.lang.AFn.applyToHelper(AFn.java:161) [clojure-1.5.1.jar:na]
at clojure.lang.AFn.applyTo(AFn.java:151) [clojure-1.5.1.jar:na]
at clojure.core$apply.invoke(core.clj:619) ~[clojure-1.5.1.jar:na]
at clojure.core$partial$fn__4190.doInvoke(core.clj:2396) ~[clojure-1.5.1.jar:na]
at clojure.lang.RestFn.invoke(RestFn.java:397) ~[clojure-1.5.1.jar:na]
at backtype.storm.event$event_manager$fn__2378.invoke(event.clj:39) ~[storm-core-0.9.2-incubating.jar:0.9.2-incubating]
at clojure.lang.AFn.run(AFn.java:24) [clojure-1.5.1.jar:na]
at java.lang.Thread.run(Thread.java:745) [na:1.7.0_79]
Caused by: java.io.EOFException: null
at java.io.ObjectInputStream$PeekInputStream.readFully(ObjectInputStream.java:2325) ~[na:1.7.0_79]
at java.io.ObjectInputStream$BlockDataInputStream.readShort(ObjectInputStream.java:2794) ~[na:1.7.0_79]
at java.io.ObjectInputStream.readStreamHeader(ObjectInputStream.java:801) ~[na:1.7.0_79]
at java.io.ObjectInputStream.<init>(ObjectInputStream.java:299) ~[na:1.7.0_79]
at backtype.storm.utils.Utils.deserialize(Utils.java:88) ~[storm-core-0.9.2-incubating.jar:0.9.2-incubating]
... 11 common frames omitted
2017-10-11 09:50:06 b.s.util [INFO] Halting process: ("Error when processing an event")
问题原因
2017-10-11 09:50:06 b.s.event [ERROR] Error when processing event
这一句是说没有正常退出导致的storm错误
这里多说一点,那么我们应该怎样关闭storm才不会出现这种错误能,最简单的就是jps查看进程后杀死,先从在主。(kill -9 进程ID)
解决办法
1:先检测storm配置文件storm.yaml,是否配置属性storm.local.dir;
2:若配置了storm.local.dir属性,在配置的路径下删除supervisor和workers两个文件夹即可;
3:若没有配置storm.local.dir属性,则添加配置即可;
4:重新启动;
这里要说的是,storm的日志在storm的logs目录下,它分为ui.log、nimbus.log、supervisor.log等等,当那个进程出现问题就查看对应日志即可
以下是几个shell脚本供参考
(1)批量启动ZK脚本:zookeeperStart.sh
#!/bin/bash
#zk节点
zkhost='hadoop2004 hadoop2005 hadoop2006'
#启动zk节点
for zk in $zkhost
do
ssh -T $zk <<EOF
source /etc/profile
cd \$ZOOKEEPER_HOME
bin/zkServer.sh start
EOF
echo 节点 $zk 的QuorumPeerMain进程已启动...[ done ]
done
(2)批量关闭ZK脚本:zookeeperShutdown.sh
#!/bin/bash
#zk节点
zkhost='hadoop2004 hadoop2005 hadoop2006'
#停止zkji进程
for zk in $zkhost
do
echo zk节点 $zk 停止zookeeper...[ done ]
ssh -T $zk <<EOF
source /etc/profile
cd \$ZOOKEEPER_HOME
bin/zkServer.sh stop
EOF
done
(3)启动storm集群脚本:stormStart.sh
#!/bin/bash
#mbus节点
nimbusServers='hadoop2004'
#supervisor节点
supervisorServers='hadoop2005 hadoop2006'
#启动所有的nimbus
for nim in $nimbusServers
do
ssh -T $nim <<EOF
source /etc/profile
cd \$STORM_HOME
bin/storm nimbus >/dev/null 2>&1 &
EOF
echo 从节点 $nim 启动nimbus...[ done ]
sleep 1
done
#启动所有的ui
for u in $nimbusServers
do
ssh -T $u <<EOF
source /etc/profile
cd \$STORM_HOME
bin/storm ui >/dev/null 2>&1 &
EOF
echo 从节点 $u 启动ui...[ done ]
sleep 1
done
#启动所有的supervisor
for visor in $supervisorServers
do
ssh -T $visor <<EOF
source /etc/profile
cd \$STORM_HOME
bin/storm supervisor >/dev/null 2>&1 &
EOF
echo 从节点 $visor 启动supervisor...[ done ]
sleep 1
done
(4)关闭storm集群脚本:stormShutdown.sh
#!/bin/bash
#mbus节点
nimbusServers='hadoop2004'
#supervisor节点
supervisorServers='hadoop2005 hadoop2006'
#停止所有的nimbus和ui
for nim in $nimbusServers
do
echo 从节点 $nim 停止nimbus...[ done ]
ssh $nim "kill -9 `ssh $nim ps -ef | grep nimbus | awk '{print $2}'| head -n 1`" >/dev/null 2>&1
echo 从节点 $nim 停止ui...[ done ]
ssh $nim "kill -9 `ssh $nim ps -ef | grep core | awk '{print $2}'| head -n 1`" >/dev/null 2>&1
done
#停止所有的supervisor
for visor in $supervisorServers
do
echo 从节点 $visor 停止supervisor...[ done ]
ssh $visor "kill -9 `ssh $visor ps -ef | grep supervisor | awk '{print $2}'| head -n 1`" >/dev/null 2>&1
done