当前位置:   article > 正文

Hadoop HA高可用故障转移(hdfs+yarn)_org.apache.hadoop.hdfs.server.namenode.ha.configur

org.apache.hadoop.hdfs.server.namenode.ha.configuredfailoverproxyprovider

常用集群搭建脚本

  • xsync.sh      文件或文件夹同步
  • xcall.sh        在所有集群节点执行命令
  • xnode.sh     在非master节点执行命令
  • xenv.sh        配置环境变量辅助脚本

将脚本放在/usr/bin/或创建软连接 并授予执行权限

HDFS HA

配置文件

core-site.xml

  1. <configuration>
  2. <property>
  3. <name>fs.defaultFS</name>
  4. <value>hdfs://mycluster</value>
  5. <description>集群nameservice</description>
  6. </property>
  7. <property>
  8. <name>hadoop.tmp.dir</name>
  9. <value>/opt/module/tmp/ha/hadoop</value>
  10. <description>临时文件夹</description>
  11. </property>
  12. <property>
  13. <name>io.file.buffer.size</name>
  14. <value>131072</value>
  15. <final>4096</final>
  16. <description>流文件的缓冲区为4K</description>
  17. </property>
  18. <property>
  19. <name>hadoop.http.staticuser.user</name>
  20. <value>zakza</value>
  21. <description>用户</description>
  22. </property>
  23. <property>
  24. <name>ha.zookeeper.quorum</name>
  25. <value>master:2181,node1:2181,node2:2181</value>
  26. </property>
  27. </configuration>

hdfs-site.xml

  1. <configuration>
  2. <property>
  3. <name>dfs.nameservices</name>
  4. <value>mycluster</value>
  5. <description>名称服务</description>
  6. </property>
  7. <property>
  8. <name>dfs.ha.namenodes.mycluster</name>
  9. <value>nn1,nn2,nn3</value>
  10. <description>namenode 集群</description>
  11. </property>
  12. <!-- rpc服务 -->
  13. <property>
  14. <name>dfs.namenode.rpc-address.mycluster.nn1</name>
  15. <value>master:9820</value>
  16. </property>
  17. <property>
  18. <name>dfs.namenode.rpc-address.mycluster.nn2</name>
  19. <value>node1:9820</value>
  20. </property>
  21. <property>
  22. <name>dfs.namenode.rpc-address.mycluster.nn3</name>
  23. <value>node2:9820</value>
  24. </property>
  25. <!-- http服务 -->
  26. <property>
  27. <name>dfs.namenode.http-address.mycluster.nn1</name>
  28. <value>master:9870</value>
  29. </property>
  30. <property>
  31. <name>dfs.namenode.http-address.mycluster.nn2</name>
  32. <value>node1:9870</value>
  33. </property>
  34. <property>
  35. <name>dfs.namenode.http-address.mycluster.nn3</name>
  36. <value>node2:9870</value>
  37. </property>
  38. <!-- 共享edits目录 -->
  39. <property>
  40. <name>dfs.namenode.shared.edits.dir</name>
  41. <value>qjournal://master:8485;node1:8485;node2:8485/mycluster</value>
  42. </property>
  43. <!-- 判断活动namenode -->
  44. <property>
  45. <name>dfs.client.failover.proxy.provider.mycluster</name>
  46. <value>org.apache.hadoop.hdfs.server.namenode.ha.ConfiguredFailoverProxyProvider</value>
  47. </property>
  48. <property>
  49. <name>dfs.ha.fencing.methods</name>
  50. <value>sshfence</value>
  51. </property>
  52. <property>
  53. <name>dfs.ha.fencing.ssh.private-key-files</name>
  54. <value>~/.ssh/id_rsa</value>
  55. </property>
  56. <property>
  57. <name>dfs.journalnode.edits.dir</name>
  58. <value>${hadoop.tmp.dir}/journalnode/</value>
  59. </property>
  60. <property>
  61. <name>dfs.ha.automatic-failover.enabled</name>
  62. <value>true</value>
  63. </property>
  64. </configuration>

xsync 分发同步文件

初始化启动

启动QJM集群

hdfs --workers --daemon start

任一节点格式化namenode

hdfs namenode -format

hdfs --daemon start namenode

其他节点执行命令同步信息

xnode "hdfs namenode -bootstrapStandby"

xnode "hdfs --daemon start namenode"

xcall "hdfs –-daemon start datanode"

启动jobhistory(master)

mapred --daemon start historyserver

格式化zk

stop-dfs.sh

hdfs zkfc -formatZK

start-dfs.sh

Yarn高可用配置

yarn-site.xml

  1. <configuration>
  2. <property>
  3. <name>yarn.log-aggregation-enable</name>
  4. <value>true</value>
  5. <description>日志聚集功能</description>
  6. </property>
  7. <property>
  8. <name>yarn.log.server.url</name>
  9. <value>http://master:19888/jobhistory/logs</value>
  10. <description>日志web地址</description>
  11. </property>
  12. <!-- Site specific YARN configuration properties -->
  13. <!--指定MR走shuffle-->
  14. <property>
  15. <name>yarn.nodemanager.aux-services</name>
  16. <value>mapreduce_shuffle</value>
  17. </property>
  18. <!--环境变量继承-->
  19. <property>
  20. <name>yarn.nodemanager.env-whitelist</name>
  21. <value>JAVA_HOME,HADOOP_COMMON_HOME,HADOOP_HDFS_HOME,HADOOP_CONF_DIR,CLASSPATH_PREPEND_DISTCACHE,HADOOP_YARN_HOME,HADOOP_HOME,HADOOP_MAPRED_HOME</value>
  22. <description>环境变量继承</description>
  23. </property>
  24. <property>
  25. <name>yarn.log-aggregation.retain-seconds</name>
  26. <value>604800</value>
  27. <description>日志聚集功能</description>
  28. </property>
  29. <!--启用resourcemanager ha-->
  30. <property>
  31. <name>yarn.resourcemanager.ha.enabled</name>
  32. <value>true</value>
  33. </property>
  34. <!--声明两台resourcemanager的地址-->
  35. <property>
  36. <name>yarn.resourcemanager.cluster-id</name>
  37. <value>cluster-yarn1</value>
  38. </property>
  39. <property>
  40. <name>yarn.resourcemanager.ha.rm-ids</name>
  41. <value>rm1,rm2</value>
  42. </property>
  43. <property>
  44. <name>yarn.resourcemanager.hostname.rm1</name>
  45. <value>master</value>
  46. </property>
  47. <property>
  48. <name>yarn.resourcemanager.hostname.rm2</name>
  49. <value>node1</value>
  50. </property>
  51. <!--指定zookeeper集群的地址-->
  52. <property>
  53. <name>yarn.resourcemanager.zk-address</name>
  54. <value>master:2181,node1:2181,node2:2181</value>
  55. </property>
  56. <!--启用自动恢复-->
  57. <property>
  58. <name>yarn.resourcemanager.recovery.enabled</name>
  59. <value>true</value>
  60. </property>
  61. <!--指定resourcemanager的状态信息存储在zookeeper集群-->
  62. <property>
  63. <name>yarn.resourcemanager.store.class</name>
  64. <value>org.apache.hadoop.yarn.server.resourcemanager.recovery.ZKRMStateStore</value>
  65. </property>
  66. </configuration>

xsync分发同步配置文件

start-yarn.sh

查看所有启动服务

xcall jps 

参考

Apache Hadoop 3.3.1 – HDFS High Availability Using the Quorum Journal Manager

Apache Hadoop 3.3.1 – ResourceManager High Availability

配置文件查询参考

core-default.xmlhttps://hadoop.apache.org/docs/stable/hadoop-project-dist/hadoop-common/core-default.xml

hdfs-default.xmlhttps://hadoop.apache.org/docs/stable/hadoop-project-dist/hadoop-hdfs/hdfs-default.xmlmapred-default.xmlhttps://hadoop.apache.org/docs/stable/hadoop-mapreduce-client/hadoop-mapreduce-client-core/mapred-default.xmlyarn-default.xmlhttps://hadoop.apache.org/docs/stable/hadoop-yarn/hadoop-yarn-common/yarn-default.xml

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/菜鸟追梦旅行/article/detail/367624
推荐阅读
相关标签
  

闽ICP备14008679号