HBase

From GeilThings

Jump to: navigation, search
HBase
General
Version 0.94.6.1-security
Stable 0.94.10-security
Function Database
SQL NoSQL
Files
Config File /opt/hbase/conf/*
Data File /var/hbase/*
Log File /opt/hbase/logs/*
Scripts
Start /opt/hbase/bin/start-hbase.sh

/opt/hbase/bin/hbase-daemon.sh start thrift -nonblocking

Stop /opt/hbase/bin/stop-hbase.sh

/opt/hbase/bin/hbase-daemon.sh stop thrift

Cli hbase shell


Contents

General

Install HBase

APPNAME=hbase
NEWVERSION=0.92.1
cd /opt
wget http://apache.lehtivihrea.org//${APPNAME}/stable/hbase-${NEWVERSION}.tar.gz
tar xvfz hbase-${NEWVERSION}.tar.gz
 
# Create HBase database directory.
mkdir /var/hbase
# Edit /opt/hbase-${NEWVERSION}/conf/hbase-site.xml
# Set hbase.rootdir to file:///var/hbase
 
# Create softlink to facilitate administration.
cd /opt
ln -s hbase-${NEWVERSION} /opt/hbase

Running HBase

  • HBase Default Configuration: http://hbase.apache.org/docs/r0.20.6/hbase-conf.html
  • Start: /opt/hbase/bin/start-hbase.sh
  • Stop: /opt/hbase/bin/stop-hbase.sh
  • Reduce memory consumption:
    • No immediate effect: hbase.client.write.buffer = 8192
    • Effect: Modify /opt/hbase/conf/hbase-env.sh, set
      • export HBASE_HEAPSIZE=64
      • (HEAPSIZE=16 did not work; hbase started but the logs reported only the master server was started, the region server failed)
  • Set log4j.logger.org.apache.hadoop.hbase=INFO in /opt/hbase/conf/log4j.properties

Upgrade HBase

  • Started with 0.90.4.
######### START OF EDIT #########
 
APPNAME=hbase
# The directory where I want to download the files to be installed.
DOWNLOADDIRECTORY=/opt
# If I want to backup, set it to TRUE.
ISBACKUP=TRUE
# BACKUPROOTDIR is only relevant if ISBACKUP=TRUE
BACKUPROOTDIR=/home/backup
DATE=`date +%Y-%m-%d`
 
######### END OF EDIT #########
 
OLDVERSION=`sed '3!d' /opt/hbase/CHANGES.txt | grep -Po '^.*?\K(?<=Release ).*?(?= )'`
echo $OLDVERSION
 
RAWNEWVERSION=`curl -sd "action=ask&query=[[HBase]]|%3FStable&format=json" http://www.geilthings.com/api.php` 
NEWVERSION=`echo "$RAWNEWVERSION" | grep -Po '^.*?\K(?<=Stable\":\[\").*?(?=\")'`  
echo $NEWVERSION
 
if [[ ${ISBACKUP} == "TRUE" ]]; then
  # The script breaks if variable names are not enclosed with {}
  BACKUPDIR=${BACKUPROOTDIR}/${APPNAME}/${APPNAME}_${OLDVERSION}_${DATE}
  echo $BACKUPDIR
  # Create backup directory if it does not exist.
  if [ ! -d "${BACKUPDIR}/conf" ]; then
    mkdir -m 755 -p ${BACKUPDIR}/conf
  fi
  # Backup configuration files.
  cp -p /opt/hbase/conf/* $BACKUPDIR/conf
  # Stop the server before copying the data files.
  /opt/hbase/bin/stop-hbase.sh
  # Stop the HBase thrift server as well.
  /opt/hbase/bin/hbase-daemon.sh stop thrift 
  # Backup the data files.
  # Create backup directory if it does not exist.
  if [ ! -d "${BACKUPDIR}/data" ]; then
    mkdir -m 755 -p ${BACKUPDIR}/data
  fi
  cp -pr /var/hbase/* $BACKUPDIR/data/
fi
 
cd ${DOWNLOADDIRECTORY}
# Get the file.
wget http://mirror.netcologne.de/apache.org//hbase/stable/hbase-${NEWVERSION}.tar.gz
 
tar -zxvf hbase-${NEWVERSION}.tar.gz
cd hbase-${NEWVERSION}
 
# Read the /opt/hbase-$NEWVERSION/CHANGES.txt file.
vi /opt/hbase-$NEWVERSION/CHANGES.txt
# :q 
# to leave vi.
 
# Read the /opt/hbase-$NEWVERSION/README.txt file.
vi /opt/hbase-$NEWVERSION/README.txt
# :q 
# to leave vi.
 
# Copy any changes from the configuration files from
# /opt/hbase-${OLDVERSION}/conf/*
# to
# /opt/hbase-${NEWVERSION}/conf/*
# e.g. small machine: 
# In /opt/hbase/conf/hbase-env.sh, add the line (uncommented):
### export HBASE_HEAPSIZE=64
# In the config file /opt/hbase/conf/hbase-site-xml
### <configuration>
###  <property>
###    <name>hbase.rootdir</name>
###    <value>file:///var/hbase</value>
###  </property>
###    <property>
###    <name>hbase.client.write.buffer</name>
###    <value>8192</value>
###  </property>
### </configuration>
# In /opt/hbase/conf/log4j.properties
### log4j.logger.org.apache.hadoop.hbase=INFO
 
# Modify the HBase soft link.
rm -f /opt/hbase
ln -s /opt/hbase-${NEWVERSION} /opt/hbase
 
# Generate again the Thrift libraries. This is maybe not always necessary.
thrift --gen php /opt/hbase/src/main/resources/org/apache/hadoop/hbase/thrift/Hbase.thrift
 
# Move everything under gen-php/Hbase to /opt/thrift/lib/php/src/packages/Hbase
if [ ! -d "/opt/thrift/lib/php/src/packages/Hbase" ]
then
    mkdir -m 755 -p /opt/thrift/lib/php/src/packages/Hbase
fi
 
# mv -f: Do not ask before overwriting.
mv -f /opt/hbase/gen-php/* /opt/thrift/lib/php/src/packages/Hbase
 
# Start.
/opt/hbase/bin/start-hbase.sh
 
# +++ Start HBase thrift server, otherwise calling HBase from PHP & Co. would not work +++
/opt/hbase/bin/hbase-daemon.sh start thrift
 
# Check that the services are running.
ps aux | grep hbase
# 2 mega long lines with the services appear.
 
# Test applications.
 
# Rename the old files.
cd /opt
mv hbase-${OLDVERSION}-security old_hbase-${OLDVERSION}-security

Errors

  • Starting the Thrift Server: java.lang.AssertionError
Version HBase 0.94.1-security
Exception in thread "main" java.lang.AssertionError: 
Exactly one option out of [-hsha, -nonblocking, -threadpool, -threadedselector] has to be specified
at org.apache.hadoop.hbase.thrift.ThriftServerRunner$ImplType.setServerImpl(ThriftServerRunner.java:204)
Solution: Specify one of the options. They should be optional. ???

Hello World HBase

/opt/hbase/bin/hbase shell
create 'test', 'HelloWorld'
# 0 row(s) in 0.5300 seconds
# Example at http://hbase.apache.org/book/quickstart.html: 1.2200 seconds
 
# List all tables
list
 
# Add rows.
put 'test', 'php', 'HelloWorld:language', 'php'
# 0.1610 secs against 0.0560 secs in http://hbase.apache.org/book/quickstart.html
put 'test', 'php', 'HelloWorld:message_text', 'Hello World from PHP and HBase'
# 0.0070 secs
put 'test', 'perl', 'HelloWorld:language', 'perl'
# 0.0090 secs
put 'test', 'perl', 'HelloWorld:message_text', 'Hello World from Perl, mod_perl and HBase'
# 0.0060 secs
 
# Check.
scan 'test'
# 0.0150 secs
 
# Get a row
get 'test', 'php'
# 0.0100 secs

Programming HBase


Versions

Software name Version number Version date
HBase 0.94.3-security
0.94.4-security
0.94.5-security
0.94.6-security
0.94.6.1-security
8 December 2012
17 January 2013
16 February 2013
23 March 2013
6 April 2013

Comments

blog comments powered by Disqus