Hadoop3.1.0 HA(hdfs+yarn) 集群模式-下

Posted 大数据技术与实战

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Hadoop3.1.0 HA(hdfs+yarn) 集群模式-下相关的知识,希望对你有一定的参考价值。


4. 启动hdfs服务 (hadoop 用户)

(1)Start JournalNode

[10.16.18.224:/home/hadoop]# su - hadoop
[10.16.18.224:/home/hadoop]$ hadoop-daemon.sh  start journalnode
WARNING: Use of this script to start HDFS daemons is deprecated.
WARNING: Attempting to execute replacement "hdfs --daemon start" instead.
[10.16.18.224:hadoop@bj-jd-backup-hdp-prod-0001:/home/hadoop]$ jps
2514 JournalNode
2873 Jps
8671 QuorumPeerMain


[10.16.18.224:/tmp]$  ssh -n 10.16.18.225 "/usr/local/apache/hadoop/latest/sbin/hadoop-daemon.sh start journalnode"


WARNING: Use of this script to start HDFS daemons is deprecated.
WARNING: Attempting to execute replacement "hdfs --daemon start" instead.
[10.16.18.224:/tmp]$ ssh -n 10.16.18.226 "/usr/local/apache/hadoop/latest/sbin/hadoop-daemon.sh start journalnode"
WARNING: Use of this script to start HDFS daemons is deprecated.
WARNING: Attempting to execute replacement "hdfs --daemon start" instead.
[10.16.18.224:/tmp]$ ssh -n 10.16.18.225 "/usr/local/apache/hadoop/latest/sbin/hadoop-daemon.sh start journalnode^C
[10.16.18.224:/home/hadoop]$ which java
/usr/java/default/bin/java
[10.16.18.224:/home/hadoop]$ ssh -n 10.16.18.225 "/usr/java/default/bin/jps"                                              
1874 QuorumPeerMain
28216 Jps
28139 JournalNode
[10.16.18.224:/home/hadoop]$ ssh -n 10.16.18.226 "/usr/java/default/bin/jps"
1744 QuorumPeerMain
27794 Jps
27725 JournalNode

使用jps 命令查看   java 进程 发现 存在  JournalNode 进程,说明  JournalNode服务已经运行了。

详细的服务信息可以去$HADOOP_HOME/logs/hadoop-hadoop-journalnode-*.log  查看


日志显示服务正常

(2)Start NameNode

# 登录一台namenode 节点 hadoop hdfs format
[10.16.18.224:/home/hadoop]$ hdfs namenode -format

Hadoop3.1.0 HA(hdfs+yarn) 集群模式-下

[10.16.18.224:/home/hadoop]$ ll /data/nn/
total 0
drwxrwxr-x 2 hadoop hadoop 112 Jun 16 18:06 current
# namenode 初始化完毕

[10.16.18.224:/home/hadoop]$ hadoop-daemon.sh start namenode
WARNING: Use of this script to start HDFS daemons is deprecated.
WARNING: Attempting to execute replacement "hdfs --daemon start" instead.
[10.16.18.224:/home/hadoop]$ jps
2514 JournalNode
4170 Jps
3582 NameNode
8671 QuorumPeerMain


(3)Start ZKFC

# zkfc format
[10.16.18.224:/home/hadoop]$ hdfs zkfc -formatZK -force

Hadoop3.1.0 HA(hdfs+yarn) 集群模式-下

[10.16.18.224:/home/hadoop]$ hadoop-daemon.sh start zkfc
WARNING: Use of this script to start HDFS daemons is deprecated.
WARNING: Attempting to execute replacement "hdfs --daemon start" instead.
[10.16.18.224:/home/hadoop]$ jps
2514 JournalNode
4418 DFSZKFailoverController
4482 Jps
3582 NameNode
8671 QuorumPeerMain


登录第二、第三台 namenode 节点

# 使用hadoop 用户 同步集群元数据
[10.16.18.225:/home/hadoop]$ hdfs namenode -bootstrapStandby

Hadoop3.1.0 HA(hdfs+yarn) 集群模式-下

[10.16.18.225:/home/hadoop]$ hadoop-daemon.sh start namenode
WARNING: Use of this script to start HDFS daemons is deprecated.
WARNING: Attempting to execute replacement "hdfs --daemon start" instead.
[10.16.18.225:/home/hadoop]$ hadoop-daemon.sh start zkfc
WARNING: Use of this script to start HDFS daemons is deprecated.
WARNING: Attempting to execute replacement "hdfs --daemon start" instead.
[10.16.18.225:/home/hadoop]$ jps
1874 QuorumPeerMain
29832 DFSZKFailoverController
28139 JournalNode
29196 NameNode
29871 Jps

(4)Start DataNode

[10.16.18.224:/home/hadoop]$ hadoop-daemon.sh  start datanode
WARNING: Use of this script to start HDFS daemons is deprecated.
WARNING: Attempting to execute replacement "hdfs --daemon start" instead.
# 远程启动 datanode 服务
[10.16.18.224:/tmp]$ ssh -n 10.16.18.226 "/usr/local/apache/hadoop/latest/sbin/hadoop-daemon.sh start datanode"
WARNING: Use of this script to start HDFS daemons is deprecated.
WARNING: Attempting to execute replacement "hdfs --daemon start" instead.
[10.16.18.224:/tmp]$ ssh -n 10.16.18.225 "/usr/local/apache/hadoop/latest/sbin/hadoop-daemon.sh start datanode"
WARNING: Use of this script to start HDFS daemons is deprecated.
WARNING: Attempting to execute replacement "hdfs --daemon start" instead.
[10.16.18.224:/home/hadoop]$ jps
2514 JournalNode
4418 DFSZKFailoverController
4948 DataNode
5604 Jps
3582 NameNode
8671 QuorumPeerMain


查看hdfs 状态


[10.16.18.224:/home/hadoop]$ hdfs haadmin -getAllServiceState
bj-jd-backup-hdp-prod-0001.tendcloud.com:9820     active    
bj-jd-backup-hdp-prod-0002.tendcloud.com:9820     standby  
bj-jd-backup-hdp-prod-0003.tendcloud.com:9820     standby  

[10.16.18.224:/home/hadoop]$ hdfs dfsadmin -report | more
Configured Capacity: 128814351360 (119.97 GB)
Present Capacity: 114688327680 (106.81 GB)
DFS Remaining: 114688315392 (106.81 GB)
DFS Used: 12288 (12 KB)
DFS Used%: 0.00%
Replicated Blocks:
      Under replicated blocks: 0
      Blocks with corrupt replicas: 0
      Missing blocks: 0
      Missing blocks (with replication factor 1): 0
      Pending deletion blocks: 0
Erasure Coded Block Groups:
      Low redundancy block groups: 0
      Block groups with corrupt internal blocks: 0
      Missing block groups: 0
      Pending deletion blocks: 0

-------------------------------------------------
Live datanodes (3):


URL :

http://10.16.18.224:9870/dfshealth.html#tab-overview

http://10.16.18.225:9870/dfshealth.html#tab-overview

http://10.16.18.226:9870/dfshealth.html#tab-overview


Hadoop3.1.0 HA(hdfs+yarn) 集群模式-下

5. 启动yarn服务

(1)启动 resourcemanager 服务

# 登录 10.16.18.226 节点 切换到 hadoop 用户
[10.16.18.226:/home/hadoop]$ yarn-daemon.sh  start resourcemanager
WARNING: Use of this script to start YARN daemons is deprecated.
WARNING: Attempting to execute replacement "yarn --daemon start" instead.
[10.16.18.226:/home/hadoop]$ mr-jobhistory-daemon.sh start historyserver
WARNING: Use of this script to start the MR JobHistory daemon is deprecated.
WARNING: Attempting to execute replacement "mapred --daemon start" instead.
[10.16.18.226:/home/hadoop]$ jps
1744 QuorumPeerMain
29416 DFSZKFailoverController
30744 ResourceManager
31241 Jps
27725 JournalNode
31182 JobHistoryServer
28783 NameNode
29647 DataNode

# 登录 10.16.18.225 节点 切换到 hadoop 用户
[10.16.18.225:/home/hadoop]$ yarn-daemon.sh  start resourcemanager
WARNING: Use of this script to start YARN daemons is deprecated.
WARNING: Attempting to execute replacement "yarn --daemon start" instead.
[10.16.18.225:/home/hadoop]$ jps
1874 QuorumPeerMain
31410 Jps
29832 DFSZKFailoverController
31354 ResourceManager
28139 JournalNode
30187 DataNode
29196 NameNode

Hadoop3.1.0 HA(hdfs+yarn) 集群模式-下

(2)启动nodemanager 服务

[10.16.18.224:/home/hadoop]$ yarn-daemon.sh  start nodemanager
WARNING: Use of this script to start YARN daemons is deprecated.
WARNING: Attempting to execute replacement "yarn --daemon start" instead.

[10.16.18.224:/tmp]$ ssh -n 10.16.18.226 "/usr/local/apache/hadoop/latest/sbin/yarn-daemon.sh start nodemanager"
WARNING: Use of this script to start YARN daemons is deprecated.
WARNING: Attempting to execute replacement "yarn --daemon start" instead.

[10.16.18.224:/tmp]$ ssh -n 10.16.18.225 "/usr/local/apache/hadoop/latest/sbin/yarn-daemon.sh start nodemanager"
WARNING: Use of this script to start YARN daemons is deprecated.
WARNING: Attempting to execute replacement "yarn --daemon start" instead.

[10.16.18.224:/home/hadoop]$ jps
2514 JournalNode
4418 DFSZKFailoverController
4948 DataNode
7000 NodeManager
7180 Jps
3582 NameNode
8671 QuorumPeerMain

URL :

http://10.16.18.226:8088/cluster/scheduler

http://10.16.18.225:8088/cluster/scheduler

Hadoop3.1.0 HA(hdfs+yarn) 集群模式-下

6. 验证服务可用性

(1)hdfs 基本测试

[10.16.18.226:/home/hadoop]$ hdfs dfs -mkdir -p /{user,tmp}
[10.16.18.226:/home/hadoop]$ hdfs dfs -put core-site.xml /tmp/
[10.16.18.226:/home/hadoop]$ hdfs dfs -ls /tmp/
Found 2 items
-rw-r--r--   3 hadoop supergroup       2023 2020-06-16 18:35 /tmp/core-site.xml
drwxrwx---   - hadoop supergroup          0 2020-06-16 18:22 /tmp/jobhistory
[10.16.18.226:/home/hadoop]$ hdfs dfs -rm -r /tmp/core-site.xml
2020-06-16 18:35:49,946 INFO fs.TrashPolicyDefault: Moved: 'hdfs://hdp310/tmp/core-site.xml' to trash at: hdfs://hdp310/user/hadoop/.Trash/Current/tmp/core-site.xml


(2)yarn 任务测试

[10.16.18.226:/tmp]$ hadoop jar /usr/local/apache/hadoop/latest/share/hadoop/mapreduce/hadoop-mapreduce-examples-3.1.0.jar pi 10 10


Hadoop3.1.0 HA(hdfs+yarn) 集群模式-下

Hadoop3.1.0 HA(hdfs+yarn) 集群模式-下

Hadoop3.1.0 HA(hdfs+yarn) 集群模式-下

Hadoop3.1.0 HA(hdfs+yarn) 集群模式-下


7. Hdfs 压力测试
[10.16.18.226:/home/hadoop]$ vim  Basic_Hdfs.sh
#!/bin/bash

Hadoop_Home='/usr/local/apache/hadoop/latest'
Cmd_Hadoop="$Hadoop_Home/bin/hadoop"
MapReduce_jar=`ls $Hadoop_Home/share/hadoop/mapreduce/hadoop-mapreduce-client-jobclient-*-tests.jar`

echo -e "Hadoop Home : $Hadoop_Home Cmd_Hadoop : $Cmd_Hadoop MapReduce_jar : $MapReduce_jar "

hdfs dfs -rm -r /benchmarks/*
hdfs ec -getPolicy -path /benchmarks
#hdfs ec -setPolicy -path /benchmarks
#hdfs ec -getPolicy -path /benchmarks
######## Hdfs io Test ###########
echo -e " 33[31mHDFS Read/Write Test (files:10 ,size : 200MB)33[0m "
$Cmd_Hadoop jar $MapReduce_jar TestDFSIO -write  -nrFiles 10 -size 200MB
echo -e " +++++++++++++++++++++ "
$Cmd_Hadoop jar $MapReduce_jar TestDFSIO -read  -nrFiles 10 -size 200MB
echo -e " +++++++++++++++++++++ "
$Cmd_Hadoop jar $MapReduce_jar TestDFSIO -clean

echo -e " +++++++++++++++++++++ "
cat TestDFSIO_results.log


[10.16.18.226:hadoop@bj-jd-backup-hdp-prod-0003:/home/hadoop]$ sh Basic_Hdfs.sh
Hadoop Home : /usr/local/apache/hadoop/latest
Cmd_Hadoop : /usr/local/apache/hadoop/latest/bin/hadoop
MapReduce_jar : /usr/local/apache/hadoop/latest/share/hadoop/mapreduce/hadoop-mapreduce-client-jobclient-3.1.0-tests.jar

rm: `/benchmarks/*': No such file or directory
FileNotFoundException: Path not found: /benchmarks

      HDFS Read/Write Test (files:10 ,size : 200MB)


由于是虚机部署,结果只做参考,但部署与验证流程大概是这样



以上是关于Hadoop3.1.0 HA(hdfs+yarn) 集群模式-下的主要内容,如果未能解决你的问题,请参考以下文章

HDFS 和 YARN 的 HA 故障切换

HadoopHDFS HA高可用

搭建hadoop2.6.0 HDFS HA及YARN HA

HDFS HA之手动高可用故障转移配置自动高可用故障转移配置配置YARN-HA集群

Hadoop hdfs yarn HA

Hadoop 2.5.2 HDFS HA+YARN HA 应用配置