hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From st...@apache.org
Subject svn commit: r988342 - in /hbase/trunk/bin: master-backup.sh rolling-restart.sh
Date Mon, 23 Aug 2010 22:36:47 GMT
Author: stack
Date: Mon Aug 23 22:36:47 2010
New Revision: 988342

URL: http://svn.apache.org/viewvc?rev=988342&view=rev
Log:
HBASE-1660 need a rolling restart script -- forgot to add scripts

Added:
    hbase/trunk/bin/master-backup.sh
Modified:
    hbase/trunk/bin/rolling-restart.sh

Added: hbase/trunk/bin/master-backup.sh
URL: http://svn.apache.org/viewvc/hbase/trunk/bin/master-backup.sh?rev=988342&view=auto
==============================================================================
--- hbase/trunk/bin/master-backup.sh (added)
+++ hbase/trunk/bin/master-backup.sh Mon Aug 23 22:36:47 2010
@@ -0,0 +1,76 @@
+#!/usr/bin/env bash
+#
+#/**
+# * Copyright 2010 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 backup master hosts.
+#
+# Environment Variables
+#
+#   HBASE_BACKUP_MASTERS File naming remote hosts.
+#     Default is ${HADOOP_CONF_DIR}/backup-masters
+#   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: $0 [--config <hbase-confdir>] command..."
+
+# if no args specified, show usage
+if [ $# -le 0 ]; then
+  echo $usage
+  exit 1
+fi
+
+bin=`dirname "${BASH_SOURCE-$0}"`
+bin=`cd "$bin">/dev/null; pwd`
+
+. "$bin"/hbase-config.sh
+
+# If the master backup file is specified in the command line,
+# then it takes precedence over the definition in 
+# hbase-env.sh. Save it here.
+HOSTLIST=$HBASE_BACKUP_MASTERS
+
+if [ "$HOSTLIST" = "" ]; then
+  if [ "$HBASE_BACKUP_MASTERS" = "" ]; then
+    export HOSTLIST="${HBASE_CONF_DIR}/backup-masters"
+  else
+    export HOSTLIST="${HBASE_BACKUP_MASTERS}"
+  fi
+fi
+
+
+args=${@// /\\ }
+args=${args/master-backup/master}
+
+if [ -f $HOSTLIST ]; then
+  for hmaster in `cat "$HOSTLIST"`; do
+   ssh $HBASE_SSH_OPTS $hmaster $"$args --backup" \
+     2>&1 | sed "s/^/$hmaster: /" &
+   if [ "$HBASE_SLAVE_SLEEP" != "" ]; then
+     sleep $HBASE_SLAVE_SLEEP
+   fi
+  done
+fi 
+
+wait

Modified: hbase/trunk/bin/rolling-restart.sh
URL: http://svn.apache.org/viewvc/hbase/trunk/bin/rolling-restart.sh?rev=988342&r1=988341&r2=988342&view=diff
==============================================================================
--- hbase/trunk/bin/rolling-restart.sh (original)
+++ hbase/trunk/bin/rolling-restart.sh Mon Aug 23 22:36:47 2010
@@ -1,6 +1,91 @@
 #!/usr/bin/env bash
 #
 #/**
+# * Copyright 2007 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
+#
+#   HBASE_REGIONSERVERS    File naming remote hosts.
+#     Default is ${HADOOP_CONF_DIR}/regionservers
+#   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_SLAVE_TIMEOUT Seconds to wait for timing out a remote command. 
+#   HADOOP_SSH_OPTS Options passed to ssh when running remote commands.
+#
+# Modelled after $HADOOP_HOME/bin/slaves.sh.
+
+usage="Usage: $0 [--config <hbase-confdir>] commands..."
+
+bin=`dirname "$0"`
+bin=`cd "$bin">/dev/null; pwd`
+
+. "$bin"/hbase-config.sh
+
+# start hbase daemons
+errCode=$?
+if [ $errCode -ne 0 ]
+then
+  exit $errCode
+fi
+
+# quick function to get a value from the HBase config file
+distMode=`$bin/hbase org.apache.hadoop.hbase.HBaseConfTool hbase.cluster.distributed`
+if [ "$distMode" == 'false' ]; then
+  "$bin"/hbase-daemon.sh restart master
+else 
+  # stop all masters before re-start to avoid races for master znode
+  "$bin"/hbase-daemon.sh --config "${HBASE_CONF_DIR}" stop master 
+  "$bin"/hbase-daemons.sh --config "${HBASE_CONF_DIR}" \
+    --hosts "${HBASE_BACKUP_MASTERS}" stop master-backup
+
+  # make sure the master znode has been deleted before continuing
+  zparent=`$bin/hbase org.apache.hadoop.hbase.HBaseConfTool zookeeper.znode.parent`
+  if [ "$zparent" == "null" ]; then zparent="/hbase"; fi
+  zmaster=`$bin/hbase org.apache.hadoop.hbase.HBaseConfTool zookeeper.znode.master`
+  if [ "$zmaster" == "null" ]; then zmaster="master"; fi
+  zmaster=$zparent/$zmaster
+  echo -n "Waiting for Master ZNode to expire"
+  while bin/hbase zkcli stat $zmaster >/dev/null 2>&1; do
+    echo -n "."
+    sleep 1
+  done
+  echo #force a newline
+
+  # all masters are down, now restart
+  "$bin"/hbase-daemon.sh --config "${HBASE_CONF_DIR}" start master 
+  "$bin"/hbase-daemons.sh --config "${HBASE_CONF_DIR}" \
+    --hosts "${HBASE_BACKUP_MASTERS}" start master-backup
+
+  # unlike the masters, roll all regionservers one-at-a-time
+  export HBASE_SLAVE_PARALLEL=false
+  "$bin"/hbase-daemons.sh --config "${HBASE_CONF_DIR}" \
+    --hosts "${HBASE_REGIONSERVERS}" restart regionserver
+
+fi
+
+#!/usr/bin/env bash
+#
+#/**
 # * Copyright 2010 The Apache Software Foundation
 # *
 # * Licensed to the Apache Software Foundation (ASF) under one



Mime
View raw message