PageRenderTime 39ms CodeModel.GetById 15ms RepoModel.GetById 0ms app.codeStats 0ms

/tags/release-0.2.0-rc0/scripts/hcat_server_start.sh

#
Shell | 97 lines | 50 code | 20 blank | 27 comment | 9 complexity | 4688d82495538f556bbcba968c96c513 MD5 | raw file
Possible License(s): Apache-2.0, BSD-3-Clause, JSON, CPL-1.0
  1. #!/bin/sh
  2. # Licensed to the Apache Software Foundation (ASF) under one
  3. # or more contributor license agreements. See the NOTICE file
  4. # distributed with this work for additional information
  5. # regarding copyright ownership. The ASF licenses this file
  6. # to you under the Apache License, Version 2.0 (the
  7. # "License"); you may not use this file except in compliance
  8. # with the License. You may obtain a copy of the License at
  9. #
  10. # http://www.apache.org/licenses/LICENSE-2.0
  11. #
  12. # Unless required by applicable law or agreed to in writing, software
  13. # distributed under the License is distributed on an "AS IS" BASIS,
  14. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. # See the License for the specific language governing permissions and
  16. # limitations under the License.
  17. # Resolve our absolute path
  18. # resolve links - $0 may be a softlink
  19. this="${BASH_SOURCE-$0}"
  20. while [ -h "$this" ]; do
  21. ls=`ls -ld "$this"`
  22. link=`expr "$ls" : '.*-> \(.*\)$'`
  23. if expr "$link" : '.*/.*' > /dev/null; then
  24. this="$link"
  25. else
  26. this=`dirname "$this"`/"$link"
  27. fi
  28. done
  29. # convert relative path to absolute path
  30. bin=`dirname "$this"`
  31. script=`basename "$this"`
  32. bin=`unset CDPATH; cd "$bin"; pwd`
  33. this="$bin/$script"
  34. # the root of the HCatalog installation
  35. export HCAT_HOME=`dirname "$this"`/..
  36. # Read the env file created by the install script
  37. . $HCAT_HOME/conf/hcat-env.sh
  38. # back ground the metastore service and record the pid
  39. PID_FILE=${ROOT}/var/log/hcat.pid
  40. SLEEP_TIME_AFTER_START=15
  41. # check if service is already running, if so exit
  42. if [ -s "$PID_FILE" ]
  43. then
  44. echo "HCatalog server appears to be running. If you are SURE it is not" \
  45. " remove $PID_FILE and re-run this script."
  46. exit 1
  47. fi
  48. # add mysqldb jars
  49. for f in ${DBROOT}/mysql-connector-java-*-bin.jar; do
  50. AUX_CLASSPATH=${AUX_CLASSPATH}:$f
  51. done
  52. # add jars from lib dir
  53. for f in ${ROOT}/lib/*.jar ; do
  54. AUX_CLASSPATH=${AUX_CLASSPATH}:$f
  55. done
  56. # echo AUX_CLASSPATH = ${AUX_CLASSPATH}
  57. export AUX_CLASSPATH=${AUX_CLASSPATH}
  58. export HADOOP_HOME=$HADOOP_HOME
  59. #export HADOOP_OPTS="-Dlog4j.configuration=file://${ROOT}/conf/log4j.properties"
  60. export HADOOP_OPTS="${HADOOP_OPTS} -server -XX:+UseConcMarkSweepGC -XX:ErrorFile=${ROOT}/var/log/hcat_err_pid%p.log -Xloggc:${ROOT}/var/log/hcat_gc.log-`date +'%Y%m%d%H%M'` -verbose:gc -XX:+PrintGCDetails -XX:+PrintGCTimeStamps -XX:+PrintGCDateStamps"
  61. export HADOOP_HEAPSIZE=2048 # 8G is better if you have it
  62. nohup ${ROOT}/bin/hive --service metastore >${ROOT}/var/log/hcat.out 2>${ROOT}/var/log/hcat.err &
  63. PID=$!
  64. if [ "${PID}x" == "x" ] ; then # we failed right off
  65. echo "Metastore startup failed, see $ROOT/var/log/hcat.err"
  66. exit 1
  67. fi
  68. echo Started metastore server init, testing if initialized correctly...
  69. sleep $SLEEP_TIME_AFTER_START
  70. if ps -p $PID > /dev/null
  71. then
  72. echo $PID > $PID_FILE
  73. echo "Metastore initialized successfully."
  74. else
  75. echo "Metastore startup failed, see $ROOT/var/log/hcat.err"
  76. exit 1
  77. fi