PageRenderTime 30ms CodeModel.GetById 14ms app.highlight 11ms RepoModel.GetById 1ms 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
 1#!/bin/sh
 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
20# Resolve our absolute path
21# resolve links - $0 may be a softlink
22this="${BASH_SOURCE-$0}"
23while [ -h "$this" ]; do
24    ls=`ls -ld "$this"`
25    link=`expr "$ls" : '.*-> \(.*\)$'`
26    if expr "$link" : '.*/.*' > /dev/null; then
27        this="$link"
28    else
29        this=`dirname "$this"`/"$link"
30    fi
31done
32
33# convert relative path to absolute path
34bin=`dirname "$this"`
35script=`basename "$this"`
36bin=`unset CDPATH; cd "$bin"; pwd`
37this="$bin/$script"
38
39# the root of the HCatalog installation
40export HCAT_HOME=`dirname "$this"`/..
41
42# Read the env file created by the install script
43. $HCAT_HOME/conf/hcat-env.sh
44
45# back ground the metastore service and record the pid
46
47PID_FILE=${ROOT}/var/log/hcat.pid
48SLEEP_TIME_AFTER_START=15
49
50# check if service is already running, if so exit
51if [ -s "$PID_FILE" ]
52then
53	echo "HCatalog server appears to be running.  If you are SURE it is not" \
54		" remove $PID_FILE and re-run this script."
55    exit 1
56fi
57
58# add mysqldb jars
59for f in ${DBROOT}/mysql-connector-java-*-bin.jar; do
60  AUX_CLASSPATH=${AUX_CLASSPATH}:$f
61done
62
63# add jars from lib dir
64for f in ${ROOT}/lib/*.jar ; do
65  AUX_CLASSPATH=${AUX_CLASSPATH}:$f
66done
67
68# echo AUX_CLASSPATH = ${AUX_CLASSPATH}
69export AUX_CLASSPATH=${AUX_CLASSPATH}
70
71
72export HADOOP_HOME=$HADOOP_HOME
73#export HADOOP_OPTS="-Dlog4j.configuration=file://${ROOT}/conf/log4j.properties"
74export 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"
75export HADOOP_HEAPSIZE=2048 # 8G is better if you have it
76
77nohup ${ROOT}/bin/hive --service metastore >${ROOT}/var/log/hcat.out 2>${ROOT}/var/log/hcat.err &
78
79PID=$!
80
81if [ "${PID}x" == "x" ] ; then # we failed right off
82    echo "Metastore startup failed, see $ROOT/var/log/hcat.err"
83    exit 1
84fi
85
86echo Started metastore server init, testing if initialized correctly...
87sleep $SLEEP_TIME_AFTER_START
88
89if ps -p $PID > /dev/null 
90then
91    echo $PID > $PID_FILE
92    echo "Metastore initialized successfully."
93else
94    echo "Metastore startup failed, see $ROOT/var/log/hcat.err"
95    exit 1
96fi
97