58 lines
1.5 KiB
Bash
58 lines
1.5 KiB
Bash
|
#!/bin/bash
|
||
|
#
|
||
|
# 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_SSH_OPTS Options passed to ssh when running remote commands.
|
||
|
#
|
||
|
# Modelled after $HADOOP_HOME/bin/slaves.sh.
|
||
|
|
||
|
usage="Usage: regionservers [--config=<confdir>] [--hbaseconfig=<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 the regionservers file is specified in the command line,
|
||
|
# then it takes precedence over the definition in
|
||
|
# hbase-env.sh. Save it here.
|
||
|
HOSTLIST=$HBASE_REGIONSERVERS
|
||
|
|
||
|
if [ -f "${HADOOP_CONF_DIR}/hadoop-env.sh" ]; then
|
||
|
. "${HADOOP_CONF_DIR}/hadoop-env.sh"
|
||
|
fi
|
||
|
if [ -f "${HBASE_CONF_DIR}/hbase-env.sh" ]; then
|
||
|
. "${HBASE_CONF_DIR}/hbase-env.sh"
|
||
|
fi
|
||
|
|
||
|
if [ "$HOSTLIST" = "" ]; then
|
||
|
if [ "$HBASE_REGIONSERVERS" = "" ]; then
|
||
|
export HOSTLIST="${HBASE_CONF_DIR}/regionservers"
|
||
|
else
|
||
|
export HOSTLIST="${HBASE_REGIONSERVERS}"
|
||
|
fi
|
||
|
fi
|
||
|
|
||
|
for regionserver in `cat "$HOSTLIST"`; do
|
||
|
ssh $HADOOP_SSH_OPTS $regionserver $"${@// /\\ }" \
|
||
|
2>&1 | sed "s/^/$regionserver: /" &
|
||
|
if [ "$HADOOP_SLAVE_SLEEP" != "" ]; then
|
||
|
sleep $HADOOP_SLAVE_SLEEP
|
||
|
fi
|
||
|
done
|
||
|
|
||
|
wait
|