1.把hadoop、starthadoop.sh stophadoop.sh 拷贝/opt/下面 (注starthadoop.sh stophadoop.sh 是开启、关闭hadoop 脚本,可以根据目录不同更改)
2.把hadoop拷贝/etc/rc.d/init.d/下面
3.chmod 755 /opt/starthadoop.sh stophadoop.sh /etc/rc.d/init.d/hadoop
4.chkconfig --add hadoop ← 将hadoop加入到chkconfig中
5.chkconfig hadoop on ← 将hadoop设置为自启动
6.chkconfig --list hadoop ← 确认hadoop服务状态 hadoop 0:off 1:off 2:on 3:on 4:on 5:on 6:off ← 确认2~5为on的状态就OK
7.以后可以用
service hadoop start
service hadoop stop
service hadoop restart
hadoop 文件
-
#!/bin/bash
-
#
-
# hadoop startup script for the Hadoop server
-
#
-
# chkconfig: 345 80 20
-
# description: start the hadooop deamon
-
#
-
# Source function library
-
-
prog=hadoopC
-
source /etc/profile
-
-
case "$1" in
-
start)
-
echo "Starting Hadoop..."
-
su hadoop -c "sh /opt/modules/starthadoop.sh"
-
;;
-
stop)
-
echo "Stoping Hadoop..."
-
su hadoop -c "sh /opt/modules/stophadoop.sh"
-
;;
-
restart)
-
echo "Restart Hadoop..."
-
su hadoop -c "sh /opt/modules/starthadoop.sh"
-
su hadoop -c "sh /opt/modules/stophadoop.sh"
-
;;
-
*)
-
echo "Usage: $prog {start|stop|restart}"
-
;;
-
esac
-
exit 0
#!/bin/bash
#
# hadoop startup script for the Hadoop server
#
# chkconfig: 345 80 20
# description: start the hadooop deamon
#
# Source function library
prog=hadoopC
source /etc/profile
case "$1" in
start)
echo "Starting Hadoop..."
su hadoop -c "sh /opt/modules/starthadoop.sh"
;;
stop)
echo "Stoping Hadoop..."
su hadoop -c "sh /opt/modules/stophadoop.sh"
;;
restart)
echo "Restart Hadoop..."
su hadoop -c "sh /opt/modules/starthadoop.sh"
su hadoop -c "sh /opt/modules/stophadoop.sh"
;;
*)
echo "Usage: $prog {start|stop|restart}"
;;
esac
exit 0
关机运行脚本
-
touch /var/lock/subsys/hadoop
-
ln -s /etc/rc.d/init.d/hadoop /etc/rc.d/rc0.d/K99hadoop
(责任编辑:IT) |