#!/usr/bin/env bash set -ueo pipefail HDFS_CONFIG_TEMPLATE="/tmp/hadoop/etc/hadoop/hdfs-site.xml.j2" HDFS_CONFIG_TEMPLATE_CORE="/tmp/hadoop/etc/hadoop/core-site.xml.j2" HDFS_CONFIG_TEMPLATE_MAPRED="/tmp/hadoop/etc/hadoop/mapred-site.xml.j2" SCRIPT_PATH=$(dirname "$0") source setup.sh create_hdfs_core_config_template() { #printf "Writing HDFS core-site.xml config\n" read -r -d '' CONFIG < fs.defaultFS hdfs://{{ hdfs_cluster_id }} dfs.journalnode.edits.dir /.tmp/hadoop EOF echo "$CONFIG" } create_hdfs_mapred_config_template() { #printf "Writing HDFS mapred-site.xml config\n" read -r -d '' CONFIG < fs.defaultFS hdfs://{{ cluster_ha_id }} EOF echo "$CONFIG" } create_hdfs_config_template() { #printf "Writing HDFS hdfs-site.xml config\n" read -r -d '' CONFIG < dfs.nameservices {{ hdfs_cluster_id }} dfs.ha.namenodes.{{ hdfs_cluster_id }} nn1,nn2 fs.defaultFS hdfs://{{ hdfs_cluster_id }} dfs.namenode.rpc-address.{{ hdfs_cluster_id }}.nn1 {{ namenode_1 }}:8020 dfs.namenode.rpc-address.{{ hdfs_cluster_id }}.nn2 {{ namenode_2 }}:8020 dfs.namenode.http-address.{{ hdfs_cluster_id }}.nn1 {{ namenode_1 }}:50070 dfs.namenode.http-address.{{ hdfs_cluster_id }}.nn2 {{ namenode_2}}:50070 dfs.namenode.http-address.{{ hdfs_cluster_id }}.nn1 {{ namenode_1 }}:9870 dfs.namenode.http-address.{{ hdfs_cluster_id }}.nn2 {{ namenode_2 }}:9870 dfs.namenode.name.dir /tmp/hdfs/namenode dfs.datanode.data.dir /tmp/hdfs/datanode dfs.namenode.shared.edits.dir file:///tmp/hadoop ha.zookeeper.quorum 127.0.0.1:2181 EOF echo "$CONFIG" } HDFS_CONFIG=$(create_hdfs_config_template) HDFS_CONFIG_CORE=$(create_hdfs_core_config_template) HDFS_CONFIG_MAPRED=$(create_hdfs_mapred_config_template) write_file ${HDFS_CONFIG_TEMPLATE} "${HDFS_CONFIG}" write_file ${HDFS_CONFIG_TEMPLATE_CORE} "${HDFS_CONFIG_CORE}" write_file ${HDFS_CONFIG_TEMPLATE_MAPRED} "${HDFS_CONFIG_MAPRED}"