hadoop hbase /etc/init.d style startup scripts
I scoured the InterTubes for example hadoop/hbase startup scripts and found absolutely none! I ended up creating a minimal one that is so far only suited for the Pseudo-Distributed Operation mode as it just calls the start-all / stop-all scripts./etc/init.d/hadoop
Create the place it will put its startup logs
mkdir /var/log/hadoopCreate /etc/init.d/hadoop with the following:
#!/bin/sh### BEGIN INIT INFO# Provides: hadoop services# Required-Start: $network# Required-Stop: $network# Default-Start: 2 3 4 5# Default-Stop: 0 1 6# Description: Hadoop services# Short-Description: Enable Hadoop services including hdfs### END INIT INFOPATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/binHADOOP_BIN=/usr/local/hadoop/binNAME=hadoopDESC=hadoopUSER=hadoopROTATE_SUFFIX=test -x $HADOOP_BIN || exit 0RETVAL=0set -ecd /start_hadoop () { set +e su $USER -s /bin/sh -c $HADOOP_BIN/start-all.sh > /var/log/hadoop/startup_log case "$?" in 0) echo SUCCESS RETVAL=0 ;; 1) echo TIMEOUT - check /var/log/hadoop/startup_log RETVAL=1 ;; *) echo FAILED - check /var/log/hadoop/startup_log RETVAL=1 ;; esac set -e}stop_hadoop () { set +e if [ $RETVAL = 0 ] ; then su $USER -s /bin/sh -c $HADOOP_BIN/stop-all.sh > /var/log/hadoop/shutdown_log RETVAL=$? if [ $RETVAL != 0 ] ; then echo FAILED - check /var/log/hadoop/shutdown_log fi else echo No nodes running RETVAL=0 fi set -e}restart_hadoop() { stop_hadoop start_hadoop}case "$1" in start) echo -n "Starting $DESC: " start_hadoop echo "$NAME." ;; stop) echo -n "Stopping $DESC: " stop_hadoop echo "$NAME." ;; force-reload|restart) echo -n "Restarting $DESC: " restart_hadoop echo "$NAME." ;; *) echo "Usage: $0 {start|stop|restart|force-reload}" >&2 RETVAL=1 ;;esacexit $RETVAL
/etc/init.d/hbase
Create the place it will put its startup logs
mkdir /var/log/hbaseCreate /etc/init.d/hbase with the following:
#!/bin/sh### BEGIN INIT INFO# Provides: hbase services# Required-Start: $network# Required-Stop: $network# Default-Start: 2 3 4 5# Default-Stop: 0 1 6# Description: Hbase services# Short-Description: Enable Hbase services including hdfs### END INIT INFOPATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/binHBASE_BIN=/usr/local/hbase/binNAME=hbaseDESC=hbaseUSER=hadoopROTATE_SUFFIX=test -x $HBASE_BIN || exit 0RETVAL=0set -ecd /start_hbase () { set +e su $USER -s /bin/sh -c $HBASE_BIN/start-hbase.sh > /var/log/hbase/startup_log case "$?" in 0) echo SUCCESS RETVAL=0 ;; 1) echo TIMEOUT - check /var/log/hbase/startup_log RETVAL=1 ;; *) echo FAILED - check /var/log/hbase/startup_log RETVAL=1 ;; esac set -e}stop_hbase () { set +e if [ $RETVAL = 0 ] ; then su $USER -s /bin/sh -c $HBASE_BIN/stop-hbase.sh > /var/log/hbase/shutdown_log RETVAL=$? if [ $RETVAL != 0 ] ; then echo FAILED - check /var/log/hbase/shutdown_log fi else echo No nodes running RETVAL=0 fi set -e}restart_hbase() { stop_hbase start_hbase}case "$1" in start) echo -n "Starting $DESC: " start_hbase echo "$NAME." ;; stop) echo -n "Stopping $DESC: " stop_hbase echo "$NAME." ;; force-reload|restart) echo -n "Restarting $DESC: " restart_hbase echo "$NAME." ;; *) echo "Usage: $0 {start|stop|restart|force-reload}" >&2 RETVAL=1 ;;esacexit $RETVAL
Set up the init system
This assumes you put the above init files in /etc/init.d
chmod +x /etc/init.d/{hbase,hadoop}
update-rc.d hadoop defaults
update-rc.d hbase defaults 25You can now start / stop hadoop by saying:
/etc/init.d/hadoop start/etc/init.d/hadoop stopAnd similarly with hbase
/etc/init.d/hbase start/etc/init.d/hbase stopMake sure you start hadoop before hbase and stop hbase before you stop hadoop
页:
[1]