大数据集群环境启动总结

hadoop启动与停止

单个节点逐一启动

在主节点上使用以下命令启动 HDFS NameNode:

hadoop-daemon.sh start namenode

在每个从节点上使用以下命令启动 HDFS DataNode:

hadoop-daemon.sh start datanode

在主节点上使用以下命令启动 YARN ResourceManager:

yarn-daemon.sh start resourcemanager

在每个从节点上使用以下命令启动 YARN nodemanager:

yarn-daemon.sh start nodemanager

以上脚本位于$HADOOP_PREFIX/sbin/start stop

cd /kkb/install/hadoop-2.6.0-cdh5.14.2/

sbin/start-dfs.sh

sbin/start-yarn.sh

/kkb/install/hadoop-2.6.0-cdh5.14.2/sbin/mr-jobhistory-daemon.sh start historyserver

停止集群:

sbin/stop-dfs.sh

sbin/stop-yarn.sh

/kkb/install/hadoop-2.6.0-cdh5.14.2/sbin/mr-jobhistory-daemon.sh stop historyserver

HA启动

第一步:初始化zookeeper

在node01机器上进行zookeeper的初始化,其本质工作是创建对应的zookeeper节点

cd /kkb/install/hadoop-2.6.0-cdh5.14.2

bin/hdfs zkfc -formatZK

第二步:启动journalNode

三台机器执行以下命令启动journalNode,用于我们的元数据管理

cd /kkb/install/hadoop-2.6.0-cdh5.14.2

sbin/hadoop-daemon.sh start journalnode

第三步:初始化journalNode

node01机器上准备初始化journalNode

cd /kkb/install/hadoop-2.6.0-cdh5.14.2

bin/hdfs namenode -initializeSharedEdits -force

第四步:启动namenode

node01机器上启动namenode

cd /kkb/install/hadoop-2.6.0-cdh5.14.2

sbin/hadoop-daemon.sh start namenode

node02机器上启动namenode

cd /kkb/install/hadoop-2.6.0-cdh5.14.2

bin/hdfs namenode -bootstrapStandby

sbin/hadoop-daemon.sh start namenode

第五步:启动所有节点的datanode进程

在node01机器上启动所有节点的datanode进程

cd /kkb/install/hadoop-2.6.0-cdh5.14.2

sbin/hadoop-daemons.sh start datanode

第六步:启动zkfc

在node01机器上面启动zkfc进程

cd /kkb/install/hadoop-2.6.0-cdh5.14.2

sbin/hadoop-daemon.sh start zkfc

在node02机器上面启动zkfc进程

cd /kkb/install/hadoop-2.6.0-cdh5.14.2

sbin/hadoop-daemon.sh start zkfc

第七步:启动yarn进程

node03机器上启动yarn集群

cd /kkb/install/hadoop-2.6.0-cdh5.14.2

sbin/start-yarn.sh

node02机器上启动yarn集群

cd /kkb/install/hadoop-2.6.0-cdh5.14.2

sbin/start-yarn.sh

查看resourceManager的状态

node03上面执行

cd /kkb/install/hadoop-2.6.0-cdh5.14.2

bin/yarn rmadmin -getServiceState rm1

node02上面执行

cd /kkb/install/hadoop-2.6.0-cdh5.14.2

bin/yarn rmadmin -getServiceState rm2

第八步:启动jobhsitory

node03节点启动jobhistoryserver

cd /kkb/install/hadoop-2.6.0-cdh5.14.2

sbin/mr-jobhistory-daemon.sh start historyserver

第九步:浏览器界面访问

node01机器查看hdfs状态

http://192.168.52.100:50070/dfshealth.html#tab-overview

node02机器查看hdfs状态

http://192.168.52.110:50070/dfshealth.html#tab-overview

yarn集群访问查看

http://node03:8088/cluster

历史任务浏览界面

页面访问:

http://192.168.52.120:19888/jobhistory

zookeeper启动与停止

三台机器启动zookeeper服务

这个命令三台机器都要执行

/kkb/install/zookeeper-3.4.5-cdh5.14.2/bin/zkServer.sh start

查看启动状态

/kkb/install/zookeeper-3.4.5-cdh5.14.2/bin/zkServer.sh status

/kkb/install/zookeeper-3.4.5-cdh5.14.2/bin/zkServer.sh stop

Mysql启动与停止

首先启动MySQL服务

[root@node03 soft]# systemctl start mysqld.service

查看mysql启动状态

[root@node03 soft]# systemctl status mysqld.service

systemctl stop mysqld.service

HBase的启动与停止

  • 需要提前启动HDFS及ZooKeeper集群

  • 第一台机器node01(HBase主节点)执行以下命令,启动HBase集群

<pre class="md-fences md-end-block ty-contain-cm modeLoaded" lang="shell" style="box-sizing: border-box; overflow: visible; font-family: var(--monospace); font-size: 0.9em; display: block; break-inside: avoid; text-align: left; white-space: normal; background-image: inherit; background-position: inherit; background-size: inherit; background-repeat: inherit; background-attachment: inherit; background-origin: inherit; background-clip: inherit; background-color: rgb(248, 248, 248); position: relative !important; border: 1px solid rgb(231, 234, 237); border-radius: 3px; padding: 8px 4px 6px; margin-bottom: 15px; margin-top: 15px; width: inherit; color: rgb(51, 51, 51); font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial;" spellcheck="false" mdtype="fences" cid="n44">[hadoop@node01 ~]$ start-hbase.sh</pre>

  • 启动完后,jps查看HBase相关进程

    node01、node02上有进程HMaster、HRegionServer

    node03上有进程HRegionServer

  • 警告提示:HBase启动的时候会产生一个警告,这是因为jdk7与jdk8的问题导致的,如果linux服务器安装jdk8就会产生这样的一个警告

  • 可以注释掉所有机器的hbase-env.sh当中的

    “HBASE_MASTER_OPTS”和“HBASE_REGIONSERVER_OPTS”配置 来解决这个问题。

    不过警告不影响我们正常运行,可以不用解决

  • 我们也可以执行以下命令,单节点启动相关进程

<pre class="md-fences md-end-block ty-contain-cm modeLoaded" lang="shell" style="box-sizing: border-box; overflow: visible; font-family: var(--monospace); font-size: 0.9em; display: block; break-inside: avoid; text-align: left; white-space: normal; background-image: inherit; background-position: inherit; background-size: inherit; background-repeat: inherit; background-attachment: inherit; background-origin: inherit; background-clip: inherit; background-color: rgb(248, 248, 248); position: relative !important; border: 1px solid rgb(231, 234, 237); border-radius: 3px; padding: 8px 4px 6px; margin-bottom: 15px; margin-top: 15px; width: inherit; color: rgb(51, 51, 51); font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial;" spellcheck="false" mdtype="fences" cid="n58">#HMaster节点上启动HMaster命令
hbase-daemon.sh start master

启动HRegionServer命令

hbase-daemon.sh start regionserver</pre>

spark集群的启动和停止

启动

  • 1、先启动zk

  • 2、启动spark集群

    • 可以在任意一台服务器来执行(条件:需要任意2台机器之间实现ssh免密登录)

      • ==$SPARK_HOME/sbin/start-all.sh==

      • 在哪里启动这个脚本,就在当前该机器启动一个Master进程

      • 整个集群的worker进程的启动由slaves文件

    • 后期可以在其他机器单独在启动master

      • ==$SPARK_HOME/sbin/start-master.sh==

<pre class="md-fences md-end-block ty-contain-cm modeLoaded" lang="" style="box-sizing: border-box; overflow: visible; font-family: var(--monospace); font-size: 0.9em; display: block; break-inside: avoid; text-align: left; white-space: normal; background-image: inherit; background-position: inherit; background-size: inherit; background-repeat: inherit; background-attachment: inherit; background-origin: inherit; background-clip: inherit; background-color: rgb(248, 248, 248); position: relative !important; border: 1px solid rgb(231, 234, 237); border-radius: 3px; padding: 8px 4px 6px; margin-bottom: 15px; margin-top: 15px; width: inherit; color: rgb(51, 51, 51); font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial;" spellcheck="false" mdtype="fences" cid="n82">(1) 如何恢复到上一次活着master挂掉之前的状态?
在高可用模式下,整个spark集群就有很多个master,其中只有一个master被zk选举成活着的master,其他的多个master都处于standby,同时把整个spark集群的元数据信息通过zk中节点进行保存。

后期如果活着的master挂掉。首先zk会感知到活着的master挂掉,下面开始在多个处于standby中的master进行选举,再次产生一个活着的master,这个活着的master会读取保存在zk节点中的spark集群元数据信息,恢复到上一次master的状态。整个过程在恢复的时候经历过了很多个不同的阶段,每个阶段都需要一定时间,最终恢复到上个活着的master的转态,整个恢复过程一般需要1-2分钟。

(2) 在master的恢复阶段对任务的影响?

a)对已经运行的任务是没有任何影响
由于该任务正在运行,说明它已经拿到了计算资源,这个时候就不需要master。

b) 对即将要提交的任务是有影响
由于该任务需要有计算资源,这个时候会找活着的master去申请计算资源,由于没有一个活着的master,该任务是获取不到计算资源,也就是任务无法运行。</pre>

5.2 停止

  • 在处于active Master主节点执行

    • ==$SPARK_HOME/sbin/stop-all.sh==
  • 在处于standBy Master主节点执行

    • ==$SPARK_HOME/sbin/stop-master.sh==
  • 当启动好spark集群之后,可以访问这样一个地址

    • http://master主机名:8080

    • 可以通过这个web界面观察到很多信息

      • 整个spark集群的详细信息

      • 整个spark集群总的资源信息

      • 整个spark集群已经使用的资源信息

      • 整个spark集群还剩的资源信息

      • 整个spark集群正在运行的任务信息

      • 整个spark集群已经完成的任务信息

3. kafka集群启动和停止

3.1 启动

  • 先启动zk集群

  • 然后在所有节点执行脚本

    <pre class="md-fences md-end-block ty-contain-cm modeLoaded" lang="shell" style="box-sizing: border-box; overflow: visible; font-family: var(--monospace); font-size: 0.9em; display: block; break-inside: avoid; text-align: left; white-space: normal; background-image: inherit; background-position: inherit; background-size: inherit; background-repeat: inherit; background-attachment: inherit; background-origin: inherit; background-clip: inherit; background-color: rgb(248, 248, 248); position: relative !important; border: 1px solid rgb(231, 234, 237); border-radius: 3px; padding: 8px 4px 6px; margin-bottom: 15px; margin-top: 15px; width: inherit;" spellcheck="false" mdtype="fences" cid="n128">nohup kafka-server-start.sh /kkb/install/kafka/config/server.properties >/dev/null 2>&1 &</pre>

  • 一键启动kafka

    • start_kafka.sh

      <pre class="md-fences md-end-block ty-contain-cm modeLoaded" lang="shell" style="box-sizing: border-box; overflow: visible; font-family: var(--monospace); font-size: 0.9em; display: block; break-inside: avoid; text-align: left; white-space: normal; background-image: inherit; background-position: inherit; background-size: inherit; background-repeat: inherit; background-attachment: inherit; background-origin: inherit; background-clip: inherit; background-color: rgb(248, 248, 248); position: relative !important; border: 1px solid rgb(231, 234, 237); border-radius: 3px; padding: 8px 4px 6px; margin-bottom: 15px; margin-top: 15px; width: inherit;" spellcheck="false" mdtype="fences" cid="n134">#!/bin/sh
      for host in node01 node02 node03
      do
      ssh host "source /etc/profile;nohup kafka-server-start.sh /kkb/install/kafka/config/server.properties >/dev/null 2>&1 &" echo "host kafka is running"

      done</pre>

3.2 停止

  • 所有节点执行关闭kafka脚本

    <pre class="md-fences md-end-block ty-contain-cm modeLoaded" lang="" style="box-sizing: border-box; overflow: visible; font-family: var(--monospace); font-size: 0.9em; display: block; break-inside: avoid; text-align: left; white-space: normal; background-image: inherit; background-position: inherit; background-size: inherit; background-repeat: inherit; background-attachment: inherit; background-origin: inherit; background-clip: inherit; background-color: rgb(248, 248, 248); position: relative !important; border: 1px solid rgb(231, 234, 237); border-radius: 3px; padding: 8px 4px 6px; margin-bottom: 15px; margin-top: 15px; width: inherit;" spellcheck="false" mdtype="fences" cid="n140">kafka-server-stop.sh</pre>

  • 一键停止kafka

    • stop_kafka.sh

      <pre class="md-fences md-end-block ty-contain-cm modeLoaded" lang="shell" style="box-sizing: border-box; overflow: visible; font-family: var(--monospace); font-size: 0.9em; display: block; break-inside: avoid; text-align: left; white-space: normal; background-image: inherit; background-position: inherit; background-size: inherit; background-repeat: inherit; background-attachment: inherit; background-origin: inherit; background-clip: inherit; background-color: rgb(248, 248, 248); position: relative !important; border: 1px solid rgb(231, 234, 237); border-radius: 3px; padding: 8px 4px 6px; margin-bottom: 15px; margin-top: 15px; width: inherit;" spellcheck="false" mdtype="fences" cid="n146">#!/bin/sh
      for host in node01 node02 node03
      do
      ssh host "source /etc/profile;nohup /kkb/install/kafka/bin/kafka-server-stop.sh &" echo "host kafka is stopping"
      done</pre>

3.3 一键启动和停止脚本

  • kafkaCluster.sh

    <pre class="md-fences md-end-block ty-contain-cm modeLoaded" lang="shell" style="box-sizing: border-box; overflow: visible; font-family: var(--monospace); font-size: 0.9em; display: block; break-inside: avoid; text-align: left; white-space: normal; background-image: inherit; background-position: inherit; background-size: inherit; background-repeat: inherit; background-attachment: inherit; background-origin: inherit; background-clip: inherit; background-color: rgb(248, 248, 248); position: relative !important; border: 1px solid rgb(231, 234, 237); border-radius: 3px; padding: 8px 4px 6px; margin-bottom: 15px; margin-top: 15px; width: inherit;" spellcheck="false" mdtype="fences" cid="n152">#!/bin/sh
    case 1 in "start"){ for host in node01 node02 node03 do sshhost "source /etc/profile; nohup /kkb/install/kafka/bin/kafka-server-start.sh /kkb/install/kafka/config/
    server.properties > /dev/null 2>&1 &"
    echo "host kafka is running..." done };; ​ "stop"){ for host in node01 node02 node03 do sshhost "source /etc/profile; nohup /kkb/install/kafka/bin/kafka-server-stop.sh >/dev/null 2>&1 &"
    echo "$host kafka is stopping..."
    done
    };;
    esac</pre>

  • 启动

    <pre class="md-fences md-end-block ty-contain-cm modeLoaded" lang="shell" style="box-sizing: border-box; overflow: visible; font-family: var(--monospace); font-size: 0.9em; display: block; break-inside: avoid; text-align: left; white-space: normal; background-image: inherit; background-position: inherit; background-size: inherit; background-repeat: inherit; background-attachment: inherit; background-origin: inherit; background-clip: inherit; background-color: rgb(248, 248, 248); position: relative !important; border: 1px solid rgb(231, 234, 237); border-radius: 3px; padding: 8px 4px 6px; margin-bottom: 15px; margin-top: 15px; width: inherit;" spellcheck="false" mdtype="fences" cid="n155">sh kafkaCluster.sh start</pre>

  • 停止

    <pre class="md-fences md-end-block ty-contain-cm modeLoaded" lang="shell" style="box-sizing: border-box; overflow: visible; font-family: var(--monospace); font-size: 0.9em; display: block; break-inside: avoid; text-align: left; white-space: normal; background-image: inherit; background-position: inherit; background-size: inherit; background-repeat: inherit; background-attachment: inherit; background-origin: inherit; background-clip: inherit; background-color: rgb(248, 248, 248); position: relative !important; border: 1px solid rgb(231, 234, 237); border-radius: 3px; padding: 8px 4px 6px; margin-bottom: 15px; margin-top: 15px; width: inherit;" spellcheck="false" mdtype="fences" cid="n158">sh kafkaCluster.sh stop</pre>

Redis启动与停止

cd /kkb/install/redis-3.2.8/src

redis-server ../redis.conf

Filnk启动

cd /kkb/install/flink-1.9.2 bin/start-cluster.sh

停止flink bin/stop-cluster.sh

©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

  • 1、CDH软件版本重新进行编译1、编译hadoop的原因,需要对hadoop安装包中添加以下C程序库2、编译环境的...
    我还不够强阅读 3,283评论 0 0
  • --------"道路是曲折的,前途是光明的。"最近又涉及到了hadoop以及spark的安装,之前课题设计中有要...
    九七学姐阅读 8,329评论 3 5
  • 一、理论部分知识 1、HDFS :Hadoop DIstributed File System简写。 易于扩展的分...
    neimengguzn阅读 5,480评论 0 52
  • 感恩知义著新篇, 谢你尊他颂圣贤。 师德崇高扬国粹, 友情如海润心田。
    艾思阅读 6,729评论 26 42
  • 13日·随笔 好久没有踏实下来写点文字了,曾经觉得记录下来是用来怀念,也许,今天,值得怀念…… 我们的心是...
    Momoko_yay阅读 3,025评论 0 0

友情链接更多精彩内容