From cf4fade514f8a5e8bf2d8fc4958ae643ccbf26dc Mon Sep 17 00:00:00 2001 From: Eric Yang Date: Tue, 4 Oct 2011 21:44:00 +0000 Subject: [PATCH] HADOOP-7708. Fixed hadoop-setup-conf.sh to handle config files consistently. (Eric Yang) git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1178965 13f79535-47bb-0310-9956-ffa450edef68 --- .../hadoop-common/CHANGES.txt | 3 + .../src/main/packages/hadoop-setup-conf.sh | 64 +++++-------------- 2 files changed, 18 insertions(+), 49 deletions(-) diff --git a/hadoop-common-project/hadoop-common/CHANGES.txt b/hadoop-common-project/hadoop-common/CHANGES.txt index d44f3aaa825..79145825957 100644 --- a/hadoop-common-project/hadoop-common/CHANGES.txt +++ b/hadoop-common-project/hadoop-common/CHANGES.txt @@ -664,6 +664,9 @@ Release 0.23.0 - Unreleased HADOOP-7681. Fixed security and hdfs audit log4j properties (Arpit Gupta via Eric Yang) + HADOOP-7708. Fixed hadoop-setup-conf.sh to handle config files + consistently. (Eric Yang) + Release 0.22.0 - Unreleased INCOMPATIBLE CHANGES diff --git a/hadoop-common-project/hadoop-common/src/main/packages/hadoop-setup-conf.sh b/hadoop-common-project/hadoop-common/src/main/packages/hadoop-setup-conf.sh index 9ec087f8ecd..d90747e0923 100644 --- a/hadoop-common-project/hadoop-common/src/main/packages/hadoop-setup-conf.sh +++ b/hadoop-common-project/hadoop-common/src/main/packages/hadoop-setup-conf.sh @@ -76,6 +76,9 @@ check_permission() { template_generator() { REGEX='(\$\{[a-zA-Z_][a-zA-Z_0-9]*\})' + if [ -e $2 ]; then + mv -f $2 "$2.bak" + fi cat $1 | while read line ; do while [[ "$line" =~ $REGEX ]] ; do @@ -391,46 +394,6 @@ if [ "${AUTOSETUP}" == "1" -o "${AUTOSETUP}" == "y" ]; then chmod 755 ${HADOOP_LOG_DIR}/${HADOOP_MR_USER} chown ${HADOOP_MR_USER}:${HADOOP_GROUP} ${HADOOP_LOG_DIR}/${HADOOP_MR_USER} - if [ -e ${HADOOP_CONF_DIR}/core-site.xml ]; then - mv -f ${HADOOP_CONF_DIR}/core-site.xml ${HADOOP_CONF_DIR}/core-site.xml.bak - fi - if [ -e ${HADOOP_CONF_DIR}/hdfs-site.xml ]; then - mv -f ${HADOOP_CONF_DIR}/hdfs-site.xml ${HADOOP_CONF_DIR}/hdfs-site.xml.bak - fi - if [ -e ${HADOOP_CONF_DIR}/mapred-site.xml ]; then - mv -f ${HADOOP_CONF_DIR}/mapred-site.xml ${HADOOP_CONF_DIR}/mapred-site.xml.bak - fi - if [ -e ${HADOOP_CONF_DIR}/hadoop-env.sh ]; then - mv -f ${HADOOP_CONF_DIR}/hadoop-env.sh ${HADOOP_CONF_DIR}/hadoop-env.sh.bak - fi - if [ -e ${HADOOP_CONF_DIR}/hadoop-policy.xml ]; then - mv -f ${HADOOP_CONF_DIR}/hadoop-policy.xml ${HADOOP_CONF_DIR}/hadoop-policy.xml.bak - fi - if [ -e ${HADOOP_CONF_DIR}/mapred-queue-acls.xml ]; then - mv -f ${HADOOP_CONF_DIR}/mapred-queue-acls.xml ${HADOOP_CONF_DIR}/mapred-queue-acls.xml.bak - fi - if [ -e ${HADOOP_CONF_DIR}/commons-logging.properties ]; then - mv -f ${HADOOP_CONF_DIR}/commons-logging.properties ${HADOOP_CONF_DIR}/commons-logging.properties.bak - fi - if [ -e ${HADOOP_CONF_DIR}/taskcontroller.cfg ]; then - mv -f ${HADOOP_CONF_DIR}/taskcontroller.cfg ${HADOOP_CONF_DIR}/taskcontroller.cfg.bak - fi - if [ -e ${HADOOP_CONF_DIR}/slaves ]; then - mv -f ${HADOOP_CONF_DIR}/slaves ${HADOOP_CONF_DIR}/slaves.bak - fi - if [ -e ${HADOOP_CONF_DIR}/dfs.include ]; then - mv -f ${HADOOP_CONF_DIR}/dfs.include ${HADOOP_CONF_DIR}/dfs.include.bak - fi - if [ -e ${HADOOP_CONF_DIR}/dfs.exclude ]; then - mv -f ${HADOOP_CONF_DIR}/dfs.exclude ${HADOOP_CONF_DIR}/dfs.exclude.bak - fi - if [ -e ${HADOOP_CONF_DIR}/mapred.include ]; then - mv -f ${HADOOP_CONF_DIR}/mapred.include ${HADOOP_CONF_DIR}/mapred.include.bak - fi - if [ -e ${HADOOP_CONF_DIR}/mapred.exclude ]; then - mv -f ${HADOOP_CONF_DIR}/mapred.exclude ${HADOOP_CONF_DIR}/mapred.exclude.bak - fi - template_generator ${HADOOP_PREFIX}/share/hadoop/common/templates/conf/core-site.xml ${HADOOP_CONF_DIR}/core-site.xml template_generator ${HADOOP_PREFIX}/share/hadoop/common/templates/conf/hdfs-site.xml ${HADOOP_CONF_DIR}/hdfs-site.xml template_generator ${HADOOP_PREFIX}/share/hadoop/common/templates/conf/mapred-site.xml ${HADOOP_CONF_DIR}/mapred-site.xml @@ -439,6 +402,9 @@ if [ "${AUTOSETUP}" == "1" -o "${AUTOSETUP}" == "y" ]; then template_generator ${HADOOP_PREFIX}/share/hadoop/common/templates/conf/commons-logging.properties ${HADOOP_CONF_DIR}/commons-logging.properties template_generator ${HADOOP_PREFIX}/share/hadoop/common/templates/conf/mapred-queue-acls.xml ${HADOOP_CONF_DIR}/mapred-queue-acls.xml template_generator ${HADOOP_PREFIX}/share/hadoop/common/templates/conf/taskcontroller.cfg ${HADOOP_CONF_DIR}/taskcontroller.cfg + template_generator ${HADOOP_PREFIX}/share/hadoop/templates/conf/capacity-scheduler.xml ${HADOOP_CONF_DIR}/capacity-scheduler.xml + template_generator ${HADOOP_PREFIX}/share/hadoop/templates/conf/log4j.properties ${HADOOP_CONF_DIR}/log4j.properties + template_generator ${HADOOP_PREFIX}/share/hadoop/templates/conf/hadoop-metrics2.properties ${HADOOP_CONF_DIR}/hadoop-metrics2.properties #set the owner of the hadoop dir to root chown root ${HADOOP_PREFIX} @@ -482,15 +448,9 @@ else template_generator ${HADOOP_PREFIX}/share/hadoop/common/templates/conf/mapred-queue-acls.xml ${HADOOP_CONF_DIR}/mapred-queue-acls.xml template_generator ${HADOOP_PREFIX}/share/hadoop/common/templates/conf/taskcontroller.cfg ${HADOOP_CONF_DIR}/taskcontroller.cfg template_generator ${HADOOP_PREFIX}/share/hadoop/common/templates/conf/hadoop-metrics2.properties ${HADOOP_CONF_DIR}/hadoop-metrics2.properties - if [ ! -e ${HADOOP_CONF_DIR}/capacity-scheduler.xml ]; then - template_generator ${HADOOP_PREFIX}/share/hadoop/common/templates/conf/capacity-scheduler.xml ${HADOOP_CONF_DIR}/capacity-scheduler.xml - fi - if [ ! -e ${HADOOP_CONF_DIR}/hadoop-metrics2.properties ]; then - cp ${HADOOP_PREFIX}/share/hadoop/common/templates/conf/hadoop-metrics2.properties ${HADOOP_CONF_DIR}/hadoop-metrics2.properties - fi - if [ ! -e ${HADOOP_CONF_DIR}/log4j.properties ]; then - cp ${HADOOP_PREFIX}/share/hadoop/common/templates/conf/log4j.properties ${HADOOP_CONF_DIR}/log4j.properties - fi + template_generator ${HADOOP_PREFIX}/share/hadoop/templates/conf/capacity-scheduler.xml ${HADOOP_CONF_DIR}/capacity-scheduler.xml + template_generator ${HADOOP_PREFIX}/share/hadoop/templates/conf/log4j.properties ${HADOOP_CONF_DIR}/log4j.properties + template_generator ${HADOOP_PREFIX}/share/hadoop/templates/conf/hadoop-metrics2.properties ${HADOOP_CONF_DIR}/hadoop-metrics2.properties chown root:${HADOOP_GROUP} ${HADOOP_CONF_DIR}/hadoop-env.sh chmod 755 ${HADOOP_CONF_DIR}/hadoop-env.sh @@ -523,6 +483,12 @@ else echo "${HADOOP_CONF_DIR}/hdfs-site.xml" echo "${HADOOP_CONF_DIR}/mapred-site.xml" echo "${HADOOP_CONF_DIR}/hadoop-env.sh" + echo "${HADOOP_CONF_DIR}/hadoop-policy.xml" + echo "${HADOOP_CONF_DIR}/commons-logging.properties" + echo "${HADOOP_CONF_DIR}/taskcontroller.cfg" + echo "${HADOOP_CONF_DIR}/capacity-scheduler.xml" + echo "${HADOOP_CONF_DIR}/log4j.properties" + echo "${HADOOP_CONF_DIR}/hadoop-metrics2.properties" echo echo " to ${HADOOP_CONF_DIR} on all nodes, and proceed to run hadoop-setup-hdfs.sh on namenode." fi