我尝试使用 init.d 脚本启动 hive 服务器。如果我使用以下脚本:
/etc/init.d/hiveserver2 start
一切运作良好。
但是当我将它与以下对象一起使用时:
service hiveserver2 start
将会被立即停止。
启动后状态:
# systemctl status hiveserver2
● hiveserver2.service - LSB: Hive Server 2
Loaded: loaded (/etc/init.d/hiveserver2)
Active: active (exited) since Thu 2016-01-28 15:21:33 CET; 13s ago
Process: 3997 ExecStop=/etc/init.d/hiveserver2 stop (code=exited, status=0/SUCCESS)
Process: 4001 ExecStart=/etc/init.d/hiveserver2 start (code=exited, status=0/SUCCESS)
Jan 28 15:21:33 localhost hiveserver2[4001]: Start hiveserver2
Jan 28 15:21:33 localhost systemd[1]: Started LSB: Hive Server 2.
我使用的 init.d 脚本:
#!/bin/sh
### BEGIN INIT INFO
# Provides: hiveserver2
# Required-Start: $network $local_fs
# Required-Stop:
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Hive Server 2
# Description: Hive Server 2
#### END INIT INFO
NAME=hiveserver2
CMD="/root/apache-hive-1.2.1-bin/bin/hiveserver2"
########## Common
SSD=start-stop-daemon
PID=/var/run/${NAME}.pid
start () {
echo -n "Start $NAME"
$SSD --start --pidfile $PID --make-pidfile --retry 15 --background --exec $CMD
RETVAL=$?
echo
return $RETVAL
}
stop () {
echo -n "Stop $NAME"
$SSD --stop --oknodo --retry 15 --pidfile $PID
RETVAL=$?
echo
return $RETVAL
}
restart () {
stop
sleep 1
start
}
case "$1" in
start)
start
;;
stop)
stop
;;
status)
echo "not supported"
;;
restart)
restart
;;
*)
echo "Usage: $0 {start|stop|restart}"
exit 1
esac