hadoop 启动停止命令

时间:2021-09-06 12:30:12

1       批量启动与停止

1.1  Start-all.sh

# Start all hadoop daemons.  Run this on master node.

bin=`dirname "$0"`

bin=`cd "$bin"; pwd`

#变量配置命令

. "$bin"/hadoop-config.sh

#Dfs服务器启动

# start dfs daemons

"$bin"/start-dfs.sh --config $HADOOP_CONF_DIR

MR服务器启动

# start mapred daemons

"$bin"/start-mapred.sh --config $HADOOP_CONF_DIR

1.2  Stop-all.sh

"$bin"/stop-mapred.sh --config $HADOOP_CONF_DIR

"$bin"/stop-dfs.sh --config $HADOOP_CONF_DIR

2       hdfs的启动与停止

2.1  start-dfs.sh

# start dfs daemons

# start namenode after datanodes, to minimize time namenode is up w/o data

# note: datanodes will log connection errors until namenode starts

"$bin"/hadoop-daemon.sh --config $HADOOP_CONF_DIR start namenode $nameStartOpt

"$bin"/hadoop-daemons.sh --config $HADOOP_CONF_DIR start datanode $dataStartOpt

"$bin"/hadoop-daemons.sh --config $HADOOP_CONF_DIR --hosts masters start secondarynamenode

2.2  Stop-dfs.sh

"$bin"/hadoop-daemon.sh --config $HADOOP_CONF_DIR stop namenode

"$bin"/hadoop-daemons.sh --config $HADOOP_CONF_DIR stop datanode

"$bin"/hadoop-daemons.sh --config $HADOOP_CONF_DIR --hosts masters stop secondarynamenode

3       MapReduce的启动与停止

3.1  start-mapred.sh

# start mapred daemons

# start jobtracker first to minimize connection errors at startup

"$bin"/hadoop-daemon.sh --config $HADOOP_CONF_DIR start jobtracker

"$bin"/hadoop-daemons.sh --config $HADOOP_CONF_DIR start tasktracker

3.2  Stop-mapred.sh

"$bin"/hadoop-daemon.sh --config $HADOOP_CONF_DIR stop jobtracker

"$bin"/hadoop-daemons.sh --config $HADOOP_CONF_DIR stop tasktracker

4       Balancer的启动与停止

4.1  start-balancer.sh

"$bin"/hadoop-daemon.sh --config $HADOOP_CONF_DIR start balancer $@

4.2  Stop-balancer.sh

"$bin"/hadoop-daemon.sh --config $HADOOP_CONF_DIR stop balancer

5       hadoop-daemon.sh主机系统脚本

5.1  start

nohup nice -n $HADOOP_NICENESS "$HADOOP_HOME"/bin/hadoop --config $HADOOP_CONF_DIR $command "$@" > "$log" 2>&1 < /dev/null &

5.2  stop

echo stopping $command

kill `cat $pid`

6       hadoop-daemons.sh从机系统脚本

Run a Hadoop command on all slave hosts.

exec "$bin/slaves.sh" --config $HADOOP_CONF_DIR cd "$HADOOP_HOME" \; "$bin/hadoop-daemon.sh" --config $HADOOP_CONF_DIR "$@"

7       hadoop应用程序调用脚本

基于java调用相应的类