hadoop使用init.d自动启动-启动后不启动

mw3dktmi  于 2021-05-31  发布在  Hadoop
关注(0)|答案(0)|浏览(193)

我有以下启动脚本/etc/init.d/hadoop


# !/bin/bash

# 

# 

# Starts a Hadoop Master

# 

# chkconfig: 2345 90 10

# description: Hadoop master

source /lib/lsb/init-functions
export HADOOP_HOME=/opt/hadoop-3.2.1
export HLOCK=/var/lock/subsys
source ${HADOOP_HOME}/etc/hadoop/hadoop-env.sh

RETVAL=0
PIDFILE=$HLOCK/hadoop-hdfs-master.pid
desc="Hadoop Master daemon"

start() {
  echo -n $"Starting $desc (hadoop): "
  daemon --user my_hadoop_user $HADOOP_HOME/sbin/start-all.sh $1
  RETVAL=$?
  echo
  [ $RETVAL -eq 0 ] && touch $HLOCK/hadoop-master
  return $RETVAL
}

stop() {
  echo -n $"Stopping $desc (hadoop): "
  daemon --user my_hadoop_user $HADOOP_HOME/sbin/stop-all.sh
  RETVAL=$?
  sleep 5
  echo
  [ $RETVAL -eq 0 ] && rm -f $HLOCK/hadoop-master $PIDFILE
}

checkstatus(){
  jps |grep NameNode
}

restart() {
  stop
  start
}

format() {
  sudo -u my_hadoop_user $HADOOP_HOME/bin/hdfs namenode -format -force
}

case "$1" in
  start)
    start
    ;;
  upgrade)
    upgrade
    ;;
  format)
    format
    ;;
  stop)
    stop
    ;;
  status)
    checkstatus
    ;;
  restart)
    restart
    ;;
  *)
    echo $"Usage: $0 {start|stop|status|restart|try-restart}"
    exit 1
esac

exit $RETVAL

适用于以下场景:
如果我手动启动 /etc/init.d/hadoop start 如果我直接执行 $HADOOP_HOME/sbin/start-all.sh 我还注意到 journalctl -u hadoop.service 日志显示如下,不知道为什么它是开始,然后停止?!!重新启动后拍摄:

-- Reboot --
May 15 19:27:40 zsingest01 systemd[1]: Starting SYSV: Hadoop master...
May 15 19:27:40 zsingest01 hadoop[2406]: Starting Hadoop Master daemon (hadoop):
May 15 19:27:40 zsingest01 systemd[1]: Started SYSV: Hadoop master.
May 15 19:36:14 zsingest01 systemd[1]: Stopping SYSV: Hadoop master...
May 15 19:36:20 zsingest01 hadoop[4385]: Stopping Hadoop Master daemon (hadoop):
May 15 19:36:20 zsingest01 systemd[1]: Stopped SYSV: Hadoop master.

为什么要停下来?!:(
以下是我添加/安装/注册服务的方式:

sudo mv hadoop /etc/init.d
sudo chmod +x /etc/init.d/hadoop
sudo update-rc.d hadoop defaults

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题