hadoop-config.sh 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. # Licensed to the Apache Software Foundation (ASF) under one or more
  2. # contributor license agreements. See the NOTICE file distributed with
  3. # this work for additional information regarding copyright ownership.
  4. # The ASF licenses this file to You under the Apache License, Version 2.0
  5. # (the "License"); you may not use this file except in compliance with
  6. # the License. You may obtain a copy of the License at
  7. #
  8. # http://www.apache.org/licenses/LICENSE-2.0
  9. #
  10. # Unless required by applicable law or agreed to in writing, software
  11. # distributed under the License is distributed on an "AS IS" BASIS,
  12. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. # See the License for the specific language governing permissions and
  14. # limitations under the License.
  15. # included in all the hadoop scripts with source command
  16. # should not be executable directly
  17. # also should not be passed any arguments, since we need original $*
  18. # resolve links - $0 may be a softlink
  19. this="${BASH_SOURCE-$0}"
  20. common_bin=$(cd -P -- "$(dirname -- "$this")" && pwd -P)
  21. script="$(basename -- "$this")"
  22. this="$common_bin/$script"
  23. # convert relative path to absolute path
  24. config_bin=`dirname "$this"`
  25. script=`basename "$this"`
  26. config_bin=`cd "$config_bin"; pwd`
  27. this="$config_bin/$script"
  28. # the root of the Hadoop installation
  29. export HADOOP_PREFIX=`dirname "$this"`/..
  30. #check to see if the conf dir is given as an optional argument
  31. if [ $# -gt 1 ]
  32. then
  33. if [ "--config" = "$1" ]
  34. then
  35. shift
  36. confdir=$1
  37. shift
  38. HADOOP_CONF_DIR=$confdir
  39. fi
  40. fi
  41. # Allow alternate conf dir location.
  42. if [ -e "${HADOOP_PREFIX}/conf/hadoop-env.sh" ]; then
  43. DEFAULT_CONF_DIR="conf"
  44. else
  45. DEFAULT_CONF_DIR="etc/hadoop"
  46. fi
  47. HADOOP_CONF_DIR="${HADOOP_CONF_DIR:-$HADOOP_PREFIX/$DEFAULT_CONF_DIR}"
  48. if [ -f "${HADOOP_CONF_DIR}/hadoop-env.sh" ]; then
  49. . "${HADOOP_CONF_DIR}/hadoop-env.sh"
  50. fi
  51. #check to see it is specified whether to use the slaves or the
  52. # masters file
  53. if [ $# -gt 1 ]
  54. then
  55. if [ "--hosts" = "$1" ]
  56. then
  57. shift
  58. slavesfile=$1
  59. shift
  60. export HADOOP_SLAVES="${HADOOP_CONF_DIR}/$slavesfile"
  61. fi
  62. fi
  63. if [ "$HADOOP_HOME_WARN_SUPPRESS" = "" ] && [ "$HADOOP_HOME" != "" ]; then
  64. echo "Warning: \$HADOOP_HOME is deprecated." 1>&2
  65. echo 1>&2
  66. fi
  67. # Newer versions of glibc use an arena memory allocator that causes virtual
  68. # memory usage to explode. This interacts badly with the many threads that
  69. # we use in Hadoop. Tune the variable down to prevent vmem explosion.
  70. export MALLOC_ARENA_MAX=${MALLOC_ARENA_MAX:-4}
  71. export HADOOP_HOME=${HADOOP_PREFIX}
  72. export HADOOP_HOME_WARN_SUPPRESS=1