start-ozone.sh 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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. # Start hadoop hdfs and ozone daemons.
  17. # Run this on master node.
  18. function hadoop_usage
  19. {
  20. echo "Usage: start-ozone.sh"
  21. }
  22. this="${BASH_SOURCE-$0}"
  23. bin=$(cd -P -- "$(dirname -- "${this}")" >/dev/null && pwd -P)
  24. # let's locate libexec...
  25. if [[ -n "${HADOOP_HOME}" ]]; then
  26. HADOOP_DEFAULT_LIBEXEC_DIR="${HADOOP_HOME}/libexec"
  27. else
  28. HADOOP_DEFAULT_LIBEXEC_DIR="${bin}/../libexec"
  29. fi
  30. HADOOP_LIBEXEC_DIR="${HADOOP_LIBEXEC_DIR:-$HADOOP_DEFAULT_LIBEXEC_DIR}"
  31. # shellcheck disable=SC2034
  32. HADOOP_NEW_CONFIG=true
  33. if [[ -f "${HADOOP_LIBEXEC_DIR}/hdfs-config.sh" ]]; then
  34. # shellcheck disable=SC1090
  35. . "${HADOOP_LIBEXEC_DIR}/hdfs-config.sh"
  36. else
  37. echo "ERROR: Cannot execute ${HADOOP_LIBEXEC_DIR}/hdfs-config.sh." 2>&1
  38. exit 1
  39. fi
  40. #---------------------------------------------------------
  41. # Check if ozone is enabled
  42. OZONE_ENABLED=$("${HADOOP_HDFS_HOME}/bin/hdfs" getconf -confKey ozone.enabled | tr '[:upper:]' '[:lower:]' 2>&-)
  43. if [[ "${OZONE_ENABLED}" != "true" ]]; then
  44. echo "Operation is not supported because ozone is not enabled."
  45. exit -1
  46. fi
  47. #---------------------------------------------------------
  48. # Start hdfs before starting ozone daemons
  49. if [[ -f "${bin}/start-dfs.sh" ]]; then
  50. "${bin}/start-dfs.sh"
  51. else
  52. echo "ERROR: Cannot execute ${bin}/start-dfs.sh." 2>&1
  53. exit 1
  54. fi
  55. #---------------------------------------------------------
  56. # Ozone keyspacemanager nodes
  57. KSM_NODES=$("${HADOOP_HDFS_HOME}/bin/hdfs" getconf -keyspacemanagers 2>/dev/null)
  58. echo "Starting key space manager nodes [${KSM_NODES}]"
  59. if [[ "${KSM_NODES}" == "0.0.0.0" ]]; then
  60. KSM_NODES=$(hostname)
  61. fi
  62. hadoop_uservar_su hdfs ksm "${HADOOP_HDFS_HOME}/bin/hdfs" \
  63. --workers \
  64. --config "${HADOOP_CONF_DIR}" \
  65. --hostnames "${KSM_NODES}" \
  66. --daemon start \
  67. ksm
  68. HADOOP_JUMBO_RETCOUNTER=$?
  69. #---------------------------------------------------------
  70. # Ozone storagecontainermanager nodes
  71. SCM_NODES=$("${HADOOP_HDFS_HOME}/bin/hdfs" getconf -storagecontainermanagers 2>/dev/null)
  72. echo "Starting storage container manager nodes [${SCM_NODES}]"
  73. hadoop_uservar_su hdfs scm "${HADOOP_HDFS_HOME}/bin/hdfs" \
  74. --workers \
  75. --config "${HADOOP_CONF_DIR}" \
  76. --hostnames "${SCM_NODES}" \
  77. --daemon start \
  78. scm
  79. (( HADOOP_JUMBO_RETCOUNTER=HADOOP_JUMBO_RETCOUNTER + $? ))
  80. exit ${HADOOP_JUMBO_RETCOUNTER}