#!/usr/bin/env bash # # 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. # # Configure Apache HBase after the cluster has started. # # Call with the following arguments # -m # -q # -p # -c set -x set -e ################################################################################ # Initialize variables ################################################################################ ROLES=$1 shift MASTER_HOST= ZOOKEEKER_QUORUM= CLOUD_PROVIDER= PORT= while getopts "m:q:p:c:" OPTION; do case $OPTION in m) MASTER_HOST="$OPTARG" ;; q) ZOOKEEPER_QUORUM="$OPTARG" ;; p) PORT="$OPTARG" ;; c) CLOUD_PROVIDER="$OPTARG" ;; esac done case $CLOUD_PROVIDER in ec2) # Use public hostname for EC2 SELF_HOST=`wget -q -O - http://169.254.169.254/latest/meta-data/public-hostname` ;; *) SELF_HOST=`/sbin/ifconfig eth0 | grep 'inet addr:' | cut -d: -f2 | awk '{ print $1}'` ;; esac HBASE_VERSION=${HBASE_VERSION:-0.89.20100924} HBASE_HOME=/usr/local/hbase-$HBASE_VERSION HBASE_CONF_DIR=$HBASE_HOME/conf # Configure HBase by setting up disks and site file function configure_hbase() { case $CLOUD_PROVIDER in ec2) MOUNT=/mnt ;; *) MOUNT=/data ;; esac mkdir -p $MOUNT/hbase chown hadoop:hadoop $MOUNT/hbase if [ ! -e $MOUNT/tmp ]; then mkdir $MOUNT/tmp chmod a+rwxt $MOUNT/tmp fi mkdir /etc/hbase ln -s $HBASE_CONF_DIR /etc/hbase/conf ############################################################################## # Modify this section to customize your HBase cluster. ############################################################################## cat > $HBASE_HOME/conf/hbase-site.xml < hbase.rootdir hdfs://$MASTER_HOST:8020/hbase hbase.cluster.distributed true hbase.zookeeper.quorum $ZOOKEEPER_QUORUM hbase.regionserver.handler.count 100 dfs.replication 3 zookeeper.session.timeout 60000 hbase.tmp.dir $MOUNT/tmp/hbase-\${user.name} EOF # Override JVM options cat >> $HBASE_HOME/conf/hbase-env.sh < $HBASE_HOME/conf/hadoop-metrics.properties <> $HADOOP_HOME/conf/hadoop-env.sh < $HADOOP_HOME/conf/hadoop-metrics.properties < /dev/null; then AS_HADOOP="su -s /bin/bash - hadoop -c" elif which rpm &> /dev/null; then AS_HADOOP="/sbin/runuser -s /bin/bash - hadoop -c" fi $AS_HADOOP "$HBASE_HOME/bin/hbase-daemon.sh start $1" } configure_hbase for role in $(echo "$ROLES" | tr "," "\n"); do case $role in hbase-master) start_daemon master ;; hbase-regionserver) start_daemon regionserver ;; hbase-restserver) start_daemon rest -p $PORT ;; hbase-avroserver) start_daemon avro -p $PORT ;; hbase-thriftserver) start_daemon thrift -p $PORT ;; esac done