starter.sh 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. #!/usr/bin/env bash
  2. ##
  3. # Licensed to the Apache Software Foundation (ASF) under one
  4. # or more contributor license agreements. See the NOTICE file
  5. # distributed with this work for additional information
  6. # regarding copyright ownership. The ASF licenses this file
  7. # to you under the Apache License, Version 2.0 (the
  8. # "License"); you may not use this file except in compliance
  9. # with the License. You may obtain a copy of the License at
  10. #
  11. # http://www.apache.org/licenses/LICENSE-2.0
  12. #
  13. # Unless required by applicable law or agreed to in writing, software
  14. # distributed under the License is distributed on an "AS IS" BASIS,
  15. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  16. # See the License for the specific language governing permissions and
  17. # limitations under the License.
  18. ##
  19. set -e
  20. #To avoid docker volume permission problems
  21. sudo chmod o+rwx /data
  22. DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
  23. $DIR/envtoconf.py --destination /opt/hadoop/etc/hadoop
  24. echo "Setting up environment!"
  25. if [ -n "$SLEEP_SECONDS" ]; then
  26. echo "Sleeping for $SLEEP_SECONDS seconds"
  27. sleep $SLEEP_SECONDS
  28. fi
  29. if [ -n "$KERBEROS_ENABLED" ]; then
  30. echo "Setting up kerberos!!"
  31. KERBEROS_SERVER=${KERBEROS_SERVER:-krb5}
  32. ISSUER_SERVER=${ISSUER_SERVER:-$KERBEROS_SERVER\:8081}
  33. echo "KDC ISSUER_SERVER => $ISSUER_SERVER"
  34. while true
  35. do
  36. STATUS=$(curl -s -o /dev/null -w '%{http_code}' http://$ISSUER_SERVER/keytab/test/test)
  37. if [ $STATUS -eq 200 ]; then
  38. echo "Got 200, KDC service ready!!"
  39. break
  40. else
  41. echo "Got $STATUS :( KDC service not ready yet..."
  42. fi
  43. sleep 5
  44. done
  45. export HOST_NAME=`hostname -f`
  46. for NAME in ${KERBEROS_KEYTABS}; do
  47. echo "Download $NAME/$HOSTNAME@EXAMPLE.COM keytab file to $CONF_DIR/$NAME.keytab"
  48. wget http://$ISSUER_SERVER/keytab/$HOST_NAME/$NAME -O $CONF_DIR/$NAME.keytab
  49. KERBEROS_ENABLED=true
  50. done
  51. cat $DIR/krb5.conf | sed "s/SERVER/$KERBEROS_SERVER/g" | sudo tee /etc/krb5.conf
  52. fi
  53. #To avoid docker volume permission problems
  54. sudo chmod o+rwx /data
  55. if [ -n "$ENSURE_NAMENODE_DIR" ]; then
  56. CLUSTERID_OPTS=""
  57. if [ -n "$ENSURE_NAMENODE_CLUSTERID" ]; then
  58. CLUSTERID_OPTS="-clusterid $ENSURE_NAMENODE_CLUSTERID"
  59. fi
  60. if [ ! -d "$ENSURE_NAMENODE_DIR" ]; then
  61. /opt/hadoop/bin/hdfs namenode -format -force $CLUSTERID_OPTS
  62. fi
  63. fi
  64. if [ -n "$ENSURE_STANDBY_NAMENODE_DIR" ]; then
  65. if [ ! -d "$ENSURE_STANDBY_NAMENODE_DIR" ]; then
  66. /opt/hadoop/bin/hdfs namenode -bootstrapStandby
  67. fi
  68. fi
  69. if [ -n "$ENSURE_SCM_INITIALIZED" ]; then
  70. if [ ! -f "$ENSURE_SCM_INITIALIZED" ]; then
  71. # Improve om and scm start up options
  72. /opt/hadoop/bin/ozone scm --init || /opt/hadoop/bin/ozone scm -init
  73. fi
  74. fi
  75. if [ -n "$ENSURE_OM_INITIALIZED" ]; then
  76. if [ ! -f "$ENSURE_OM_INITIALIZED" ]; then
  77. # To make sure SCM is running in dockerized environment we will sleep
  78. # Could be removed after HDFS-13203
  79. echo "Waiting 15 seconds for SCM startup"
  80. sleep 15
  81. # Improve om and scm start up options
  82. /opt/hadoop/bin/ozone om --init || /opt/hadoop/bin/ozone om -createObjectStore
  83. fi
  84. fi
  85. # The KSM initialization block will go away eventually once
  86. # we have completed renaming KSM to OzoneManager (OM).
  87. #
  88. if [ -n "$ENSURE_KSM_INITIALIZED" ]; then
  89. if [ ! -f "$ENSURE_KSM_INITIALIZED" ]; then
  90. # To make sure SCM is running in dockerized environment we will sleep
  91. # Could be removed after HDFS-13203
  92. echo "Waiting 15 seconds for SCM startup"
  93. sleep 15
  94. /opt/hadoop/bin/ozone ksm -createObjectStore
  95. fi
  96. fi
  97. # Supports byteman script to instrument hadoop process with byteman script
  98. #
  99. #
  100. if [ -n "$BYTEMAN_SCRIPT" ] || [ -n "$BYTEMAN_SCRIPT_URL" ]; then
  101. export PATH=$PATH:$BYTEMAN_DIR/bin
  102. if [ ! -z "$BYTEMAN_SCRIPT_URL" ]; then
  103. sudo wget $BYTEMAN_SCRIPT_URL -O /tmp/byteman.btm
  104. export BYTEMAN_SCRIPT=/tmp/byteman.btm
  105. fi
  106. if [ ! -f "$BYTEMAN_SCRIPT" ]; then
  107. echo "ERROR: The defined $BYTEMAN_SCRIPT does not exist!!!"
  108. exit -1
  109. fi
  110. AGENT_STRING="-javaagent:/opt/byteman.jar=script:$BYTEMAN_SCRIPT"
  111. export HADOOP_OPTS="$AGENT_STRING $HADOOP_OPTS"
  112. echo "Process is instrumented with adding $AGENT_STRING to HADOOP_OPTS"
  113. fi
  114. $@