start-balancer.sh 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. #!/usr/bin/env bash
  2. # Licensed to the Apache Software Foundation (ASF) under one or more
  3. # contributor license agreements. See the NOTICE file distributed with
  4. # this work for additional information regarding copyright ownership.
  5. # The ASF licenses this file to You under the Apache License, Version 2.0
  6. # (the "License"); you may not use this file except in compliance with
  7. # the License. You may obtain a copy of the License at
  8. #
  9. # http://www.apache.org/licenses/LICENSE-2.0
  10. #
  11. # Unless required by applicable law or agreed to in writing, software
  12. # distributed under the License is distributed on an "AS IS" BASIS,
  13. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. # See the License for the specific language governing permissions and
  15. # limitations under the License.
  16. MYNAME="${BASH_SOURCE-$0}"
  17. function hadoop_usage
  18. {
  19. hadoop_add_option "--buildpaths" "attempt to add class files from build tree"
  20. hadoop_add_option "--loglevel level" "set the log4j level for this command"
  21. hadoop_add_option "-policy <policy>" "set the balancer's policy"
  22. hadoop_add_option "-threshold <threshold>" "set the threshold for balancing"
  23. hadoop_generate_usage "${MYNAME}" false
  24. }
  25. bin=$(cd -P -- "$(dirname -- "${MYNAME}")" >/dev/null && pwd -P)
  26. # let's locate libexec...
  27. if [[ -n "${HADOOP_HOME}" ]]; then
  28. HADOOP_DEFAULT_LIBEXEC_DIR="${HADOOP_HOME}/libexec"
  29. else
  30. HADOOP_DEFAULT_LIBEXEC_DIR="${bin}/../libexec"
  31. fi
  32. HADOOP_LIBEXEC_DIR="${HADOOP_LIBEXEC_DIR:-$HADOOP_DEFAULT_LIBEXEC_DIR}"
  33. # shellcheck disable=SC2034
  34. HADOOP_NEW_CONFIG=true
  35. if [[ -f "${HADOOP_LIBEXEC_DIR}/hdfs-config.sh" ]]; then
  36. . "${HADOOP_LIBEXEC_DIR}/hdfs-config.sh"
  37. else
  38. echo "ERROR: Cannot execute ${HADOOP_LIBEXEC_DIR}/hdfs-config.sh." 2>&1
  39. exit 1
  40. fi
  41. # Start balancer daemon.
  42. exec "${HADOOP_HDFS_HOME}/bin/hdfs" --config "${HADOOP_CONF_DIR}" --daemon start balancer "$@"