Start and close hadoop

Source: Internet
Author: User

tag: OS ar Java SP art C on code r

启动hadoop
1.start-all.sh
  可以看到这个脚本包含两个部分,start-dfs.sh和start-mapred.sh
2.start-dfs.sh包含
    "$HADOOP_COMMON_HOME"/bin/hadoop-daemon.sh  --config $HADOOP_CONF_DIR --script "$bin"/hdfs start namenode $nameStartOpt
    "$HADOOP_COMMON_HOME"/bin/hadoop-daemons.sh --config $HADOOP_CONF_DIR --script "$bin"/hdfs start datanode $dataStartOpt
    "$HADOOP_COMMON_HOME"/bin/hadoop-daemons.sh --config $HADOOP_CONF_DIR --hosts masters --script "$bin"/hdfs start secondarynamenode

   start-mapred.sh包含
    "$HADOOP_COMMON_HOME"/bin/hadoop-daemon.sh --config $HADOOP_CONF_DIR --script "$bin"/mapred start jobtracker
    "$HADOOP_COMMON_HOME"/bin/hadoop-daemons.sh --config $HADOOP_CONF_DIR --script "$bin"/mapred start tasktracker 

   可见namenode 和 jobtracker通过hadoop-daemon.sh启动,datanode,secondarynamenode,tasktracker 通过hadoop-daemons.sh启动.
3.hadoop-daemons.sh 
  由这个脚本可以看到其中启动slaves.sh和hadoop-daemon.sh
4.hdfs.sh和mapred.sh
  最后一行代码都是 
  exec "$JAVA" $JAVA_HEAP_MAX $HADOOP_OPTS $CLASS "[email protected]"  
  这个就是真正的启动命令了。就是常见的java程序启动了,入口方法为java中的main 函数.
  这里启动了NameNode,DataNode,SecondaryNameNode,JobTracker,TaskTracker.


停止hadoop
1.stop-all.sh
  可以看到这个脚本也包含两个部分,stop-dfs.sh和stop-mapred.sh
  
2.stop-dfs.sh包含
  "$HADOOP_COMMON_HOME"/bin/hadoop-daemon.sh --config $HADOOP_CONF_DIR --script "$bin"/hdfs stop namenode
  "$HADOOP_COMMON_HOME"/bin/hadoop-daemons.sh --config $HADOOP_CONF_DIR --script "$bin"/hdfs stop datanode
  "$HADOOP_COMMON_HOME"/bin/hadoop-daemons.sh --config $HADOOP_CONF_DIR --hosts masters --script "$bin"/hdfs stop secondarynamenode

  stop-mapred.sh包含
  "$HADOOP_COMMON_HOME"/bin/hadoop-daemon.sh --config $HADOOP_CONF_DIR --script "$bin"/mapred stop jobtracker
  "$HADOOP_COMMON_HOME"/bin/hadoop-daemons.sh --config $HADOOP_CONF_DIR --script "$bin"/mapred stop tasktracker
3.分析hadoop-daemon.sh,其中包含   kill `cat $pid` ,程序通过kill命令来杀死进程号,达到停止hadoop的目的.

启动与关闭hadoop

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.