|NO.Z.00012|——————————|^^ 部署 ^^|——|Hadoop&Hadoop核心框架.V12|——|Hadoop.v12|集群启动|单节点启动|群启动|
一、[Hadoop完全分布式集群搭建之集群启动]
### --- 启动集群注意事项
~~~ # 注意:如果集群是第一次启动,需要在Namenode所在节点格式化NameNode,
~~~ # 非第一次不用执行格式化Namenode操作!!
二、单节点启动
### --- 所有节点执行
~~~ 输出这句内容说明格式化成功
[root@linux121 ~]# cd /opt/yanqi/servers/hadoop-2.9.2/
[root@linux121 hadoop-2.9.2]# hadoop namenode -format
/************************************************************
SHUTDOWN_MSG: Shutting down NameNode at linux121/192.168.80.121
************************************************************/
二、格式化命令执行效果:
### --- 格式化命令执行效果:
~~~ 格式化后创建的文件:/opt/yanqi/servers/hadoop-2.9.2/data/tmp/dfs/name/current
[root@linux121 hadoop-2.9.2]# ll /opt/yanqi/servers/hadoop-2.9.2/data/tmp/dfs/name/current
-rw-r--r-- 1 root root 323 Aug 8 18:36 fsimage_0000000000000000000
### --- 在linux121上启动NameNode
[root@linux121 sbin]# pwd
/opt/yanqi/servers/hadoop-2.9.2/sbin
[root@linux121 sbin]# hadoop-daemon.sh start namenode
starting namenode, logging to /opt/yanqi/servers/hadoop-2.9.2/logs/hadoop-root-namenode-linux121.out
[root@linux121 sbin]# jps
18417 NameNode
### --- 在linux121、linux122以及linux123上分别启动DataNode
[root@linux121 ~]# hadoop-daemon.sh start datanode
[root@linux121 sbin]# jps
18417 NameNode
18514 DataNode
[root@linux122 ~]# hadoop-daemon.sh start datanode
[root@linux122 ~]# jps
18656 DataNode
[root@linux123 ~]# hadoop-daemon.sh start datanode
[root@linux123 ~]# jps
18717 DataNode
三、web端查看Hdfs界面
### --- web端查看Hdfs界面
http://linux121:50070/dfshealth.html#tab-overview
四、查看HDFS集群正常节点:
五、Yarn集群单节点启动
### --- 思考:Hadoop集群每次需要一个一个节点的启动,如果节点数增加到成千上万个怎么办?
~~~ # 启动yarn集群的主节点
[root@linux123 sbin]# yarn-daemon.sh start resourcemanager
[root@linux123 sbin]# jps
18852 ResourceManager
18717 DataNode
~~~ # 启动yarn集群的从节点1
[root@linux122 sbin]# yarn-daemon.sh start nodemanager
[root@linux122 sbin]# jps
18656 DataNode
18786 NodeManager
~~~ # 启动yarn集群的从节点2
[root@linux121 sbin]# yarn-daemon.sh start nodemanager
[root@linux121 sbin]# jps
18417 NameNode
18514 DataNode
18649 NodeManager
~~~ # 启动yarn集群的从节点3
[root@linux123 sbin]# yarn-daemon.sh start nodemanager
[root@linux123 sbin]# jps
18852 ResourceManager
18717 DataNode
19119 NodeManager
六、停止集群服务
### --- 停止linux121上的服务
[root@linux121 sbin]# jps
18417 NameNode
18514 DataNode
18649 NodeManager
[root@linux121 sbin]# hadoop-daemon.sh stop namenode
[root@linux121 sbin]# hadoop-daemon.sh stop datanode
[root@linux121 sbin]# yarn-daemon.sh stop nodemanager
### --- 停止linux122上的服务
[root@linux122 sbin]# jps
18656 DataNode
18786 NodeManager
[root@linux122 sbin]# hadoop-daemon.sh stop datanode
[root@linux122 sbin]# yarn-daemon.sh stop nodemanager
### --- 停止linux123上的服务
[root@linux123 sbin]# jps
18852 ResourceManager
18717 DataNode
19119 NodeManager
[root@linux123 sbin]# hadoop-daemon.sh stop datanode
[root@linux123 sbin]# yarn-daemon.sh stop nodemanager
[root@linux123 sbin]# yarn-daemon.sh stop resourcemanager
七、集群群起
### --- 如果已经单节点方式启动了Hadoop,
~~~ 可以先停止之前的启动的Namenode与Datanode进程,如果之前Namenode没有执行格式化,
~~~ 这里需要执行格式化!!!!
~~~ # 不用执行
[root@linux121 sbin]# hadoop namenode -format
### --- 启动HDFS
~~~ # 启动脚本
[root@linux121 sbin]# pwd
/opt/yanqi/servers/hadoop-2.9.2/sbin
[root@linux121 sbin]# start-dfs.sh
Starting namenodes on [linux121]
linux121: starting namenode, logging to /opt/yanqi/servers/hadoop-2.9.2/logs/hadoop-root-namenode-linux121.out
linux123: starting datanode, logging to /opt/yanqi/servers/hadoop-2.9.2/logs/hadoop-root-datanode-linux123.out
linux121: starting datanode, logging to /opt/yanqi/servers/hadoop-2.9.2/logs/hadoop-root-datanode-linux121.out
linux122: starting datanode, logging to /opt/yanqi/servers/hadoop-2.9.2/logs/hadoop-root-datanode-linux122.out
Starting secondary namenodes [linux123]
linux123: starting secondarynamenode, logging to /opt/yanqi/servers/hadoop-2.9.2/logs/hadoop-root-secondarynamenode-linux123.out
~~~ # 查看启动的服务
[root@linux121 sbin]# jps
19029 NameNode
19157 DataNode
[root@linux122 sbin]# jps
19121 DataNode
[root@linux123 sbin]# jps
19570 SecondaryNameNode
19470 DataNode
### --- 启动YARN
~~~ 注意:NameNode和ResourceManger不是在同一台机器,
~~~ 不能在NameNode上启动 YARN,应该在ResouceManager所在的机器上启动YARN。
~~~ # 启动yarn服务
[root@linux123 sbin]# start-yarn.sh
starting yarn daemons
starting resourcemanager, logging to /opt/yanqi/servers/hadoop-2.9.2/logs/yarn-root-resourcemanager-linux123.out
linux122: starting nodemanager, logging to /opt/yanqi/servers/hadoop-2.9.2/logs/yarn-root-nodemanager-linux122.out
linux121: starting nodemanager, logging to /opt/yanqi/servers/hadoop-2.9.2/logs/yarn-root-nodemanager-linux121.out
linux123: starting nodemanager, logging to /opt/yanqi/servers/hadoop-2.9.2/logs/yarn-root-nodemanager-linux123.out
~~~ # 查看服务状态
[root@linux123 sbin]# jps
20272 ResourceManager
19570 SecondaryNameNode
20373 NodeManager
19470 DataNode
[root@linux122 sbin]# jps
19121 DataNode
19544 NodeManager
[root@linux121 sbin]# jps
19029 NameNode
19157 DataNode
19662 NodeManager
八、Hadoop集群启动停止命令汇总
### --- 各个服务组件逐一启动/停止
~~~ 分别启动/停止HDFS组件
[root@linux121 sbin]# hadoop-daemon.sh start / stop namenode / datanode / secondarynamenode
~~~ # 启动/停止YARN
[root@linux123 sbin]# yarn-daemon.sh start / stop resourcemanager / nodemanager
### --- 各个模块分开启动/停止(配置ssh是前提)常用
~~~ 整体启动/停止HDFS
[root@linux123 sbin]# start-dfs.sh / stop-dfs.sh
~~~ 整体启动/停止YARN
[root@linux123 sbin]# start-yarn.sh / stop-yarn.sh
Walter Savage Landor:strove with none,for none was worth my strife.Nature I loved and, next to Nature, Art:I warm’d both hands before the fire of life.It sinks, and I am ready to depart
——W.S.Landor
版权声明:本文为yanqi_vip原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。