Author: jdcryans Date: Tue Jan 27 18:20:09 2009 New Revision: 738184 URL: http://svn.apache.org/viewvc?rev=738184&view=rev Log: HBASE-1147 Modify the scripts to use Zookeeper
Added: hadoop/hbase/trunk/bin/hbase-zookeeper.sh (with props) hadoop/hbase/trunk/bin/zookeeper.sh (with props) hadoop/hbase/trunk/conf/zoo.cfg Modified: hadoop/hbase/trunk/CHANGES.txt hadoop/hbase/trunk/bin/hbase hadoop/hbase/trunk/bin/start-hbase.sh hadoop/hbase/trunk/bin/stop-hbase.sh hadoop/hbase/trunk/conf/hbase-env.sh Modified: hadoop/hbase/trunk/CHANGES.txt URL: http://svn.apache.org/viewvc/hadoop/hbase/trunk/CHANGES.txt?rev=738184&r1=738183&r2=738184&view=diff ============================================================================== --- hadoop/hbase/trunk/CHANGES.txt (original) +++ hadoop/hbase/trunk/CHANGES.txt Tue Jan 27 18:20:09 2009 @@ -1,6 +1,7 @@ HBase Change Log Release 0.20.0 - Unreleased INCOMPATIBLE CHANGES + HBASE-1147 Modify the scripts to use Zookeeper BUG FIXES HBASE-1140 "ant clean test" fails (Nitay Joffe via Stack) Modified: hadoop/hbase/trunk/bin/hbase URL: http://svn.apache.org/viewvc/hadoop/hbase/trunk/bin/hbase?rev=738184&r1=738183&r2=738184&view=diff ============================================================================== --- hadoop/hbase/trunk/bin/hbase (original) +++ hadoop/hbase/trunk/bin/hbase Tue Jan 27 18:20:09 2009 @@ -60,6 +60,7 @@ echo " regionserver run an HBase HRegionServer node" echo " rest run an HBase REST server" echo " thrift run an HBase Thrift server" + echo " zookeeper run a Zookeeper server" echo " migrate upgrade an hbase.rootdir" echo " or" echo " CLASSNAME run the class named CLASSNAME" @@ -181,36 +182,41 @@ # restore ordinary behaviour unset IFS -# figure out which class to run -if [ "$COMMAND" = "shell" ] ; then - CLASS="org.jruby.Main ${HBASE_HOME}/bin/hirb.rb" -elif [ "$COMMAND" = "master" ] ; then - CLASS='org.apache.hadoop.hbase.master.HMaster' -elif [ "$COMMAND" = "regionserver" ] ; then - CLASS='org.apache.hadoop.hbase.regionserver.HRegionServer' -elif [ "$COMMAND" = "rest" ] ; then - CLASS='org.apache.hadoop.hbase.rest.Dispatcher' -elif [ "$COMMAND" = "thrift" ] ; then - CLASS='org.apache.hadoop.hbase.thrift.ThriftServer' -elif [ "$COMMAND" = "migrate" ] ; then - CLASS='org.apache.hadoop.hbase.util.Migrate' +# We kill the ZK instance using a hard coded port, to be changed +if [ "$COMMAND" = "zookeeper" ] && [ "$@" = "start" ] ; then + exec "$JAVA" $JAVA_HEAP_MAX -classpath "$CLASSPATH" org.apache.zookeeper.server.quorum.QuorumPeerMain conf/zoo.cfg else - CLASS=$COMMAND -fi + # figure out which class to run + if [ "$COMMAND" = "shell" ] ; then + CLASS="org.jruby.Main ${HBASE_HOME}/bin/hirb.rb" + elif [ "$COMMAND" = "master" ] ; then + CLASS='org.apache.hadoop.hbase.master.HMaster' + elif [ "$COMMAND" = "regionserver" ] ; then + CLASS='org.apache.hadoop.hbase.regionserver.HRegionServer' + elif [ "$COMMAND" = "rest" ] ; then + CLASS='org.apache.hadoop.hbase.rest.Dispatcher' + elif [ "$COMMAND" = "thrift" ] ; then + CLASS='org.apache.hadoop.hbase.thrift.ThriftServer' + elif [ "$COMMAND" = "migrate" ] ; then + CLASS='org.apache.hadoop.hbase.util.Migrate' + else + CLASS=$COMMAND + fi -# Have JVM dump heap if we run out of memory. Files will be 'launch directory' -# and are named like the following: java_pid21612.hprof. Apparently it doesn't -# 'cost' to have this flag enabled. Its a 1.6 flag only. See: -# http://blogs.sun.com/alanb/entry/outofmemoryerror_looks_a_bit_better -HBASE_OPTS="$HBASE_OPTS -XX:+HeapDumpOnOutOfMemoryError" -HBASE_OPTS="$HBASE_OPTS -Dhbase.log.dir=$HBASE_LOG_DIR" -HBASE_OPTS="$HBASE_OPTS -Dhbase.log.file=$HBASE_LOGFILE" -HBASE_OPTS="$HBASE_OPTS -Dhbase.home.dir=$HBASE_HOME" -HBASE_OPTS="$HBASE_OPTS -Dhbase.id.str=$HBASE_IDENT_STRING" -HBASE_OPTS="$HBASE_OPTS -Dhbase.root.logger=${HBASE_ROOT_LOGGER:-INFO,console}" -if [ "x$JAVA_LIBRARY_PATH" != "x" ]; then - HBASE_OPTS="$HBASE_OPTS -Djava.library.path=$JAVA_LIBRARY_PATH" -fi + # Have JVM dump heap if we run out of memory. Files will be 'launch directory' + # and are named like the following: java_pid21612.hprof. Apparently it doesn't + # 'cost' to have this flag enabled. Its a 1.6 flag only. See: + # http://blogs.sun.com/alanb/entry/outofmemoryerror_looks_a_bit_better + HBASE_OPTS="$HBASE_OPTS -XX:+HeapDumpOnOutOfMemoryError" + HBASE_OPTS="$HBASE_OPTS -Dhbase.log.dir=$HBASE_LOG_DIR" + HBASE_OPTS="$HBASE_OPTS -Dhbase.log.file=$HBASE_LOGFILE" + HBASE_OPTS="$HBASE_OPTS -Dhbase.home.dir=$HBASE_HOME" + HBASE_OPTS="$HBASE_OPTS -Dhbase.id.str=$HBASE_IDENT_STRING" + HBASE_OPTS="$HBASE_OPTS -Dhbase.root.logger=${HBASE_ROOT_LOGGER:-INFO,console}" + if [ "x$JAVA_LIBRARY_PATH" != "x" ]; then + HBASE_OPTS="$HBASE_OPTS -Djava.library.path=$JAVA_LIBRARY_PATH" + fi -# run it -exec "$JAVA" $JAVA_HEAP_MAX $HBASE_OPTS -classpath "$CLASSPATH" $CLASS "$@" + # run it + exec "$JAVA" $JAVA_HEAP_MAX $HBASE_OPTS -classpath "$CLASSPATH" $CLASS "$@" +fi Added: hadoop/hbase/trunk/bin/hbase-zookeeper.sh URL: http://svn.apache.org/viewvc/hadoop/hbase/trunk/bin/hbase-zookeeper.sh?rev=738184&view=auto ============================================================================== --- hadoop/hbase/trunk/bin/hbase-zookeeper.sh (added) +++ hadoop/hbase/trunk/bin/hbase-zookeeper.sh Tue Jan 27 18:20:09 2009 @@ -0,0 +1,42 @@ +#!/usr/bin/env bash +# +#/** +# * Copyright 2009 The Apache Software Foundation +# * +# * Licensed to the Apache Software Foundation (ASF) under one +# * or more contributor license agreements. See the NOTICE file +# * distributed with this work for additional information +# * regarding copyright ownership. The ASF licenses this file +# * to you under the Apache License, Version 2.0 (the +# * "License"); you may not use this file except in compliance +# * with the License. You may obtain a copy of the License at +# * +# * http://www.apache.org/licenses/LICENSE-2.0 +# * +# * Unless required by applicable law or agreed to in writing, software +# * distributed under the License is distributed on an "AS IS" BASIS, +# * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# * See the License for the specific language governing permissions and +# * limitations under the License. +# */ +# +# Run a hbase command on all slave hosts. +# Modelled after $HADOOP_HOME/bin/hadoop-daemons.sh + +usage="Usage: hbase-daemons.sh [--config <hbase-confdir>] \ + [start|stop] command args..." + +# if no args specified, show usage +if [ $# -le 1 ]; then + echo $usage + exit 1 +fi + +bin=`dirname "$0"` +bin=`cd "$bin"; pwd` + +. $bin/hbase-config.sh + +exec "$bin/zookeeper.sh" --config "${HBASE_CONF_DIR}" \ + cd "${HBASE_HOME}" \; \ + "$bin/hbase-daemon.sh" --config "${HBASE_CONF_DIR}" "$@" Propchange: hadoop/hbase/trunk/bin/hbase-zookeeper.sh ------------------------------------------------------------------------------ svn:executable = * Modified: hadoop/hbase/trunk/bin/start-hbase.sh URL: http://svn.apache.org/viewvc/hadoop/hbase/trunk/bin/start-hbase.sh?rev=738184&r1=738183&r2=738184&view=diff ============================================================================== --- hadoop/hbase/trunk/bin/start-hbase.sh (original) +++ hadoop/hbase/trunk/bin/start-hbase.sh Tue Jan 27 18:20:09 2009 @@ -38,6 +38,8 @@ then exit $errCode fi +"$bin"/hbase-zookeeper.sh --config "${HBASE_CONF_DIR}" \ + start zookeeper "$bin"/hbase-daemon.sh --config "${HBASE_CONF_DIR}" start master "$bin"/hbase-daemons.sh --config "${HBASE_CONF_DIR}" \ --hosts "${HBASE_REGIONSERVERS}" start regionserver Modified: hadoop/hbase/trunk/bin/stop-hbase.sh URL: http://svn.apache.org/viewvc/hadoop/hbase/trunk/bin/stop-hbase.sh?rev=738184&r1=738183&r2=738184&view=diff ============================================================================== --- hadoop/hbase/trunk/bin/stop-hbase.sh (original) +++ hadoop/hbase/trunk/bin/stop-hbase.sh Tue Jan 27 18:20:09 2009 @@ -30,3 +30,5 @@ . "$bin"/hbase-config.sh "$bin"/hbase-daemon.sh --config "${HBASE_CONF_DIR}" stop master +"$bin"/hbase-zookeeper.sh --config "${HBASE_CONF_DIR}" \ + stop zookeeper Added: hadoop/hbase/trunk/bin/zookeeper.sh URL: http://svn.apache.org/viewvc/hadoop/hbase/trunk/bin/zookeeper.sh?rev=738184&view=auto ============================================================================== --- hadoop/hbase/trunk/bin/zookeeper.sh (added) +++ hadoop/hbase/trunk/bin/zookeeper.sh Tue Jan 27 18:20:09 2009 @@ -0,0 +1,63 @@ +#!/usr/bin/env bash +# +#/** +# * Copyright 2009 The Apache Software Foundation +# * +# * Licensed to the Apache Software Foundation (ASF) under one +# * or more contributor license agreements. See the NOTICE file +# * distributed with this work for additional information +# * regarding copyright ownership. The ASF licenses this file +# * to you under the Apache License, Version 2.0 (the +# * "License"); you may not use this file except in compliance +# * with the License. You may obtain a copy of the License at +# * +# * http://www.apache.org/licenses/LICENSE-2.0 +# * +# * Unless required by applicable law or agreed to in writing, software +# * distributed under the License is distributed on an "AS IS" BASIS, +# * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# * See the License for the specific language governing permissions and +# * limitations under the License. +# */ +# +# Run a shell command on all regionserver hosts. +# +# Environment Variables +# +# HADOOP_CONF_DIR Alternate conf dir. Default is ${HADOOP_HOME}/conf. +# HBASE_CONF_DIR Alternate hbase conf dir. Default is ${HBASE_HOME}/conf. +# HADOOP_SLAVE_SLEEP Seconds to sleep between spawning remote commands. +# HADOOP_SSH_OPTS Options passed to ssh when running remote commands. +# +# Modelled after $HADOOP_HOME/bin/slaves.sh. + +usage="Usage: zookeeper [--config <hbase-confdir>] command..." + +# if no args specified, show usage +if [ $# -le 0 ]; then + echo $usage + exit 1 +fi + +bin=`dirname "$0"` +bin=`cd "$bin"; pwd` + +. "$bin"/hbase-config.sh + +if [ -f "${HBASE_CONF_DIR}/hbase-env.sh" ]; then + . "${HBASE_CONF_DIR}/hbase-env.sh" +fi + +if [ "$HBASE_MANAGES_ZK" = "" ]; then + HBASE_MANAGES_ZK=true +fi + +if [ "$HBASE_MANAGES_ZK" = "true" ]; then + ssh $HBASE_SSH_OPTS 127.0.0.1 $"${@// /\\ }" \ + 2>&1 | sed "s/^/$zookeeper: /" & + if [ "$HBASE_SLAVE_SLEEP" != "" ]; then + sleep $HBASE_SLAVE_SLEEP + fi +fi + +wait Propchange: hadoop/hbase/trunk/bin/zookeeper.sh ------------------------------------------------------------------------------ svn:executable = * Modified: hadoop/hbase/trunk/conf/hbase-env.sh URL: http://svn.apache.org/viewvc/hadoop/hbase/trunk/conf/hbase-env.sh?rev=738184&r1=738183&r2=738184&view=diff ============================================================================== --- hadoop/hbase/trunk/conf/hbase-env.sh (original) +++ hadoop/hbase/trunk/conf/hbase-env.sh Tue Jan 27 18:20:09 2009 @@ -55,3 +55,6 @@ # can be useful in large clusters, where, e.g., slave rsyncs can # otherwise arrive faster than the master can service them. # export HBASE_SLAVE_SLEEP=0.1 + +# Tell HBase whether it should manage it's own instance of Zookeeper or not. +# export HBASE_MANAGES_ZK=true Added: hadoop/hbase/trunk/conf/zoo.cfg URL: http://svn.apache.org/viewvc/hadoop/hbase/trunk/conf/zoo.cfg?rev=738184&view=auto ============================================================================== --- hadoop/hbase/trunk/conf/zoo.cfg (added) +++ hadoop/hbase/trunk/conf/zoo.cfg Tue Jan 27 18:20:09 2009 @@ -0,0 +1,12 @@ +# The number of milliseconds of each tick +tickTime=2000 +# The number of ticks that the initial +# synchronization phase can take +initLimit=10 +# The number of ticks that can pass between +# sending a request and getting an acknowledgement +syncLimit=5 +# the directory where the snapshot is stored. +dataDir=/tmp/zookeeper +# the port at which the clients will connect +clientPort=2181