博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
hadoop集群之HDFS和YARN启动和停止命令
阅读量:6178 次
发布时间:2019-06-21

本文共 7112 字,大约阅读时间需要 23 分钟。

假如我们只有3台linux虚拟机,主机名分别为hadoop01、hadoop02和hadoop03,在这3台机器上,hadoop集群的部署情况如下:

hadoop01:1个namenode,1个datanode,1个journalnode,1个zkfc,1个resourcemanager,1个nodemanager;hadoop02:1个namenode,1个datanode,1个journalnode,1个zkfc,1个resourcemanager,1个nodemanager;hadoop03:1个datenode,1个journalnode,1个nodemanager;

 

下面我们来介绍启动hdfs和yarn的一些命令。

 

1.启动hdfs集群(使用hadoop的批量启动脚本)

/root/apps/hadoop/sbin/start-dfs.sh
[root@hadoop01 ~]# /root/apps/hadoop/sbin/start-dfs.sh Starting namenodes on [hadoop01 hadoop02]hadoop01: starting namenode, logging to /root/apps/hadoop/logs/hadoop-root-namenode-hadoop01.outhadoop02: starting namenode, logging to /root/apps/hadoop/logs/hadoop-root-namenode-hadoop02.outhadoop03: starting datanode, logging to /root/apps/hadoop/logs/hadoop-root-datanode-hadoop03.outhadoop02: starting datanode, logging to /root/apps/hadoop/logs/hadoop-root-datanode-hadoop02.outhadoop01: starting datanode, logging to /root/apps/hadoop/logs/hadoop-root-datanode-hadoop01.outStarting journal nodes [hadoop01 hadoop02 hadoop03]hadoop03: starting journalnode, logging to /root/apps/hadoop/logs/hadoop-root-journalnode-hadoop03.outhadoop02: starting journalnode, logging to /root/apps/hadoop/logs/hadoop-root-journalnode-hadoop02.outhadoop01: starting journalnode, logging to /root/apps/hadoop/logs/hadoop-root-journalnode-hadoop01.outStarting ZK Failover Controllers on NN hosts [hadoop01 hadoop02]hadoop01: starting zkfc, logging to /root/apps/hadoop/logs/hadoop-root-zkfc-hadoop01.outhadoop02: starting zkfc, logging to /root/apps/hadoop/logs/hadoop-root-zkfc-hadoop02.out[root@hadoop01 ~]#

从上面的启动日志可以看出,start-dfs.sh这个启动脚本是通过ssh对多个节点的namenode、datanode、journalnode以及zkfc进程进行批量启动的。

 

2.停止hdfs集群(使用hadoop的批量启动脚本)

/root/apps/hadoop/sbin/stop-dfs.sh
[root@hadoop01 ~]# /root/apps/hadoop/sbin/stop-dfs.sh Stopping namenodes on [hadoop01 hadoop02]hadoop02: stopping namenodehadoop01: stopping namenodehadoop02: stopping datanodehadoop03: stopping datanodehadoop01: stopping datanodeStopping journal nodes [hadoop01 hadoop02 hadoop03]hadoop03: stopping journalnodehadoop02: stopping journalnodehadoop01: stopping journalnodeStopping ZK Failover Controllers on NN hosts [hadoop01 hadoop02]hadoop01: stopping zkfchadoop02: stopping zkfc[root@hadoop01 ~]#

3.启动单个进程

[root@hadoop01 ~]# /root/apps/hadoop/sbin/hadoop-daemon.sh start namenodestarting namenode, logging to /root/apps/hadoop/logs/hadoop-root-namenode-hadoop01.out
[root@hadoop02 ~]# /root/apps/hadoop/sbin/hadoop-daemon.sh start namenodestarting namenode, logging to /root/apps/hadoop/logs/hadoop-root-namenode-hadoop02.out
[root@hadoop01 ~]# /root/apps/hadoop/sbin/hadoop-daemon.sh start datanodestarting datanode, logging to /root/apps/hadoop/logs/hadoop-root-datanode-hadoop01.out
[root@hadoop02 ~]# /root/apps/hadoop/sbin/hadoop-daemon.sh start datanodestarting datanode, logging to /root/apps/hadoop/logs/hadoop-root-datanode-hadoop02.out
[root@hadoop03 apps]# /root/apps/hadoop/sbin/hadoop-daemon.sh start datanodestarting datanode, logging to /root/apps/hadoop/logs/hadoop-root-datanode-hadoop03.out
[root@hadoop01 ~]# /root/apps/hadoop/sbin/hadoop-daemon.sh start journalnodestarting journalnode, logging to /root/apps/hadoop/logs/hadoop-root-journalnode-hadoop01.out
[root@hadoop02 ~]# /root/apps/hadoop/sbin/hadoop-daemon.sh start journalnodestarting journalnode, logging to /root/apps/hadoop/logs/hadoop-root-journalnode-hadoop02.out
[root@hadoop03 apps]# /root/apps/hadoop/sbin/hadoop-daemon.sh start journalnodestarting journalnode, logging to /root/apps/hadoop/logs/hadoop-root-journalnode-hadoop03.out
[root@hadoop01 ~]# /root/apps/hadoop/sbin/hadoop-daemon.sh start zkfcstarting zkfc, logging to /root/apps/hadoop/logs/hadoop-root-zkfc-hadoop01.out
[root@hadoop02 ~]# /root/apps/hadoop/sbin/hadoop-daemon.sh start zkfcstarting zkfc, logging to /root/apps/hadoop/logs/hadoop-root-zkfc-hadoop02.out

 分别查看启动后3台虚拟机上的进程情况:

[root@hadoop01 ~]# jps6695 DataNode2002 QuorumPeerMain6879 DFSZKFailoverController7035 Jps6800 JournalNode6580 NameNode[root@hadoop01 ~]#

 

[root@hadoop02 ~]# jps6360 JournalNode6436 DFSZKFailoverController2130 QuorumPeerMain6541 Jps6255 DataNode6155 NameNode[root@hadoop02 ~]#

 

[root@hadoop03 apps]# jps5331 Jps5103 DataNode5204 JournalNode2258 QuorumPeerMain[root@hadoop03 apps]#

 

3.停止单个进程

[root@hadoop01 ~]# jps6695 DataNode2002 QuorumPeerMain8486 Jps6879 DFSZKFailoverController6800 JournalNode6580 NameNode[root@hadoop01 ~]# [root@hadoop01 ~]# [root@hadoop01 ~]# [root@hadoop01 ~]# [root@hadoop01 ~]# /root/apps/hadoop/sbin/hadoop-daemon.sh stop zkfcstopping zkfc[root@hadoop01 ~]# /root/apps/hadoop/sbin/hadoop-daemon.sh stop journalnodestopping journalnode[root@hadoop01 ~]# /root/apps/hadoop/sbin/hadoop-daemon.sh stop datanodestopping datanode[root@hadoop01 ~]# /root/apps/hadoop/sbin/hadoop-daemon.sh stop namenodestopping namenode[root@hadoop01 ~]# jps2002 QuorumPeerMain8572 Jps[root@hadoop01 ~]#

 

[root@hadoop02 ~]# jps6360 JournalNode6436 DFSZKFailoverController2130 QuorumPeerMain7378 Jps6255 DataNode6155 NameNode[root@hadoop02 ~]# /root/apps/hadoop/sbin/hadoop-daemon.sh stop zkfcstopping zkfc[root@hadoop02 ~]# /root/apps/hadoop/sbin/hadoop-daemon.sh stop journalnodestopping journalnode[root@hadoop02 ~]# /root/apps/hadoop/sbin/hadoop-daemon.sh stop datanodestopping datanode[root@hadoop02 ~]# /root/apps/hadoop/sbin/hadoop-daemon.sh stop namenodestopping namenode[root@hadoop02 ~]# jps7455 Jps2130 QuorumPeerMain[root@hadoop02 ~]#

 

[root@hadoop03 apps]# jps5103 DataNode5204 JournalNode5774 Jps2258 QuorumPeerMain[root@hadoop03 apps]# /root/apps/hadoop/sbin/hadoop-daemon.sh stop journalnodestopping journalnode[root@hadoop03 apps]# /root/apps/hadoop/sbin/hadoop-daemon.sh stop datanodestopping datanode[root@hadoop03 apps]# jps5818 Jps2258 QuorumPeerMain[root@hadoop03 apps]#

 

 

3.启动yarn集群(使用hadoop的批量启动脚本)

/root/apps/hadoop/sbin/start-yarn.sh

 

[root@hadoop01 ~]# /root/apps/hadoop/sbin/start-yarn.sh starting yarn daemonsstarting resourcemanager, logging to /root/apps/hadoop/logs/yarn-root-resourcemanager-hadoop01.outhadoop03: starting nodemanager, logging to /root/apps/hadoop/logs/yarn-root-nodemanager-hadoop03.outhadoop02: starting nodemanager, logging to /root/apps/hadoop/logs/yarn-root-nodemanager-hadoop02.outhadoop01: starting nodemanager, logging to /root/apps/hadoop/logs/yarn-root-nodemanager-hadoop01.out[root@hadoop01 ~]#

 

从上面的启动日志可以看出,start-yarn.sh启动脚本只在本地启动一个ResourceManager进程,而3台机器上的nodemanager都是通过ssh的方式启动的。所以hadoop02机器上的ResourceManager需要我们手动去启动。

4.启动hadoop02上的ResourceManager进程

/root/apps/hadoop/sbin/yarn-daemon.sh start resourcemanager

 

 

 5.停止yarn

/root/apps/hadoop/sbin/stop-yarn.sh
[root@hadoop01 ~]# /root/apps/hadoop/sbin/stop-yarn.sh stopping yarn daemonsstopping resourcemanagerhadoop01: stopping nodemanagerhadoop03: stopping nodemanagerhadoop02: stopping nodemanagerno proxyserver to stop[root@hadoop01 ~]#

 

 通过上面的停止日志可以看出,stop-yarn.sh脚本只停止了本地的那个ResourceManager进程,所以hadoop02上的那个resourcemanager我们需要单独去停止。

 

6.停止hadoop02上的resourcemanager

/root/apps/hadoop/sbin/yarn-daemon.sh stop resourcemanager

 

 

注意:启动和停止单个hdfs相关的进程使用的是"hadoop-daemon.sh"脚本,而启动和停止yarn使用的是"yarn-daemon.sh"脚本。

 

如果觉得本文对您有帮助,不妨扫描下方微信二维码打赏点,您的鼓励是我前进最大的动力:

 

转载地址:http://cowda.baihongyu.com/

你可能感兴趣的文章
2019年一线大厂春招:Spring面试题和答案合集(上篇)
查看>>
尚未弄懂的JS系列(未完待续)
查看>>
浅析Java NIO
查看>>
企业级 SpringBoot 教程 (一)构建第一个SpringBoot工程
查看>>
学习云计算技术前景在哪里?云计算技术发展趋势
查看>>
干货|比特币如何产生与交易
查看>>
前端处理后端接口传递过来的图片文件
查看>>
react中的可控组件与非可控组件
查看>>
回调函数
查看>>
Android基础—四大组件之Activity
查看>>
Nginx 学习笔记
查看>>
你为什么选择程序员这个职业?
查看>>
[译] 用于 iOS 的 ML Kit 教程:识别图像中的文字
查看>>
InnoDB大数据插入的优化和FULLTEXT索引性能优化的调研
查看>>
chrome 73 以及之后的版本上安装crx插件出现「程序包无效 CRX_HEADER_INVALID」的报错解决办法...
查看>>
笔试记录集
查看>>
NoSQL Manager for MongoDB破解
查看>>
ViewPager+滑动条显示
查看>>
Load和initialize方法
查看>>
js自定义Android端手势事件
查看>>