provision.sh 2.34 KB
Newer Older
Lukáš Lalinský's avatar
Lukáš Lalinský committed
1 2 3 4
#!/usr/bin/env bash

set -e

5
#PHOENIX_VERSION=4.7.0-HBase-1.1
Lukáš Lalinský's avatar
Lukáš Lalinský committed
6
#PHOENIX_VERSION=4.8.2-HBase-1.2
7 8
#PHOENIX_VERSION=4.9.0-HBase-1.2
PHOENIX_VERSION=4.10.0-HBase-1.2
9 10 11 12 13 14 15

case $PHOENIX_VERSION in
4.7.*)
    PHOENIX_NAME=phoenix
    ;;
4.8.*)
    PHOENIX_NAME=apache-phoenix
Lukáš Lalinský's avatar
Lukáš Lalinský committed
16 17 18
    ;;
4.9.*)
    PHOENIX_NAME=apache-phoenix
19 20 21
    ;;
4.10.*)
    PHOENIX_NAME=apache-phoenix
22 23 24 25 26 27 28 29 30
    ;;
*)
    echo "! Unsupported Phoenix version - $PHOENIX_VERSION"
    exit 1
;;
esac

case $PHOENIX_VERSION in
*-HBase-1.2)
31
    HBASE_VERSION=1.2.5
32 33
    ;;
*-HBase-1.1)
34
    HBASE_VERSION=1.1.9
35 36 37 38 39 40
    ;;
*)
    echo "! Unsupported HBase version - $PHOENIX_VERSION"
    exit 1
;;
esac
41

Lukáš Lalinský's avatar
Lukáš Lalinský committed
42 43 44 45
export DEBIAN_FRONTEND=noninteractive

echo "> Installing java"
sudo apt-get -y update
46
sudo apt-get -y install wget openjdk-8-jdk-headless python
Lukáš Lalinský's avatar
Lukáš Lalinský committed
47

48 49 50 51
if [ -z "$APACHE_MIRROR" ]
then
    APACHE_MIRROR="$(python -c 'import json, urllib2; a = json.load(urllib2.urlopen("http://www.apache.org/dyn/closer.cgi?as_json=1")); print a["preferred"].rstrip("/")')"
fi
Lukáš Lalinský's avatar
Lukáš Lalinský committed
52 53 54 55 56 57 58 59 60
echo "> Using Apache mirror: $APACHE_MIRROR"

if [ ! -d /opt/hbase ]
then
	echo "> Downloading HBase $HBASE_VERSION"
	wget --no-verbose -P /tmp -c -N $APACHE_MIRROR/hbase/$HBASE_VERSION/hbase-$HBASE_VERSION-bin.tar.gz

	echo "> Extracting HBase"
	sudo mkdir /opt/hbase
61
	sudo chown ubuntu:ubuntu -R /opt/hbase
62
	tar xf /tmp/hbase-$HBASE_VERSION-bin.tar.gz --strip-components=1 -C /opt/hbase
Lukáš Lalinský's avatar
Lukáš Lalinský committed
63 64 65 66 67
fi

if [ ! -d /opt/phoenix ]
then
	echo "> Downloading Phoenix $PHOENIX_VERSION"
68
	wget --no-verbose -P /tmp -c -N $APACHE_MIRROR/phoenix/$PHOENIX_NAME-$PHOENIX_VERSION/bin/$PHOENIX_NAME-$PHOENIX_VERSION-bin.tar.gz
Lukáš Lalinský's avatar
Lukáš Lalinský committed
69 70 71

	echo "> Extracting Phoenix"
	sudo mkdir /opt/phoenix
72 73
	sudo chown ubuntu:ubuntu -R /opt/phoenix
	tar xf /tmp/$PHOENIX_NAME-$PHOENIX_VERSION-bin.tar.gz --strip-components=1 -C /opt/phoenix
Lukáš Lalinský's avatar
Lukáš Lalinský committed
74 75 76
fi

echo "> Linking Phoenix server JAR file to HBase lib directory"
77
ln -svfT /opt/phoenix/phoenix-$PHOENIX_VERSION-server.jar /opt/hbase/lib/phoenix-$PHOENIX_VERSION-server.jar
Lukáš Lalinský's avatar
Lukáš Lalinský committed
78 79

echo "> Setting JAVA_HOME for HBase"
80
perl -pi -e 's{^\#?\s*export\s*JAVA_HOME\s*=.*$}{export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64}' /opt/hbase/conf/hbase-env.sh
Lukáš Lalinský's avatar
Lukáš Lalinský committed
81 82 83 84

if ! pgrep -f proc_master >/dev/null
then
	echo "> Starting HBase"
85
	sudo -u ubuntu /opt/hbase/bin/start-hbase.sh
Lukáš Lalinský's avatar
Lukáš Lalinský committed
86 87 88 89 90
fi

if ! pgrep -f proc_phoenixserver >/dev/null
then
	echo "> Starting Phoenix query server"
91
	sudo -u ubuntu /opt/phoenix/bin/queryserver.py start
Lukáš Lalinský's avatar
Lukáš Lalinský committed
92
fi