编辑
vi hadoop.server
内容如下:
#!/bin/bash
# chkconfig: 2345 88 33
# description: Starts and stops Hadoopserver
# Open files number
start()
{
# Start Hadoop
/home/myhadoop/hadoop/sbin/start-all.sh
}
stop()
{
# Stop Hadoop
/home/myhadoop/hadoop/sbin/stop-all.sh
}
case “$1” in
start)
start
exit $
;;
stop)
stop
exit $
;;
restart)
# Restart Hadoop
stop
sleep 5
start
exit $
;;
*)
echo “Usage hadoop.server start/stop/restart”
exit 1;;
esac
按Esc键
Shift+ZZ
添加可执行属性
chmod a+x hadoop.server
复制到系统启动目录
cp hadoop.server /etc/init.d/hadoop.server
设置为后台服务
# /sbin/chkconfig --del hadoop.server
# /sbin/chkconfig --add hadoop.server
# /sbin/chkconfig --list hadoop.server
测试启动
# service hadoop.server start
重启服务器试试
# reboot