Created
September 2, 2014 08:57
-
-
Save gerritjvv/03a6f94101acb897acfe to your computer and use it in GitHub Desktop.
Cassandra Vagrant bootstrap
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
!/usr/bin/env bash | |
NODE="$1" | |
echo "Bootstrapping node $1" | |
function install_setup(){ | |
yum update | |
yum -y install wget vim snappy-devel snappy lzo lzop elinks glibc.i686 | |
} | |
function install_java() { | |
#see http://tecadmin.net/steps-to-install-java-on-centos-5-6-or-rhel-5-6/# | |
cd /opt/ | |
JAVA_TAR="jdk-7u60-linux-x64.tar.gz" | |
JAVA_FOLDER="jdk1.7.0_60" | |
if [ ! -a "/opt/$JAVA_FOLDER" ]; then | |
if [ ! -f "/opt/$JAVA_TAR" ]; then | |
echo "/opt/$JAVA_TAR does not exist" | |
wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie" "http://download.oracle.com/otn-pub/java/jdk/7u60-b19/$JAVA_TAR" -o log.log | |
fi | |
tar xzf $JAVA_TAR | |
cd /opt/$JAVA_FOLDER | |
alternatives --install /usr/bin/java java /opt/$JAVA_FOLDER/bin/java 1 | |
alternatives --config java | |
alternatives --install /usr/bin/jar jar /opt/$JAVA_FOLDER/bin/jar 1 | |
alternatives --install /usr/bin/javac javac /opt/$JAVA_FOLDER/bin/javac 1 | |
alternatives --install /usr/bin/javac javac /opt/$JAVA_FOLDER/bin/javac 1 | |
alternatives --set jar /opt/$JAVA_FOLDER/bin/jar | |
alternatives --set javac /opt/$JAVA_FOLDER/bin/javac | |
java -version | |
export JAVA_HOME=/opt/$JAVA_FOLDER | |
export JRE_HOME=/opt/$JAVA_FOLDER/jre | |
export PATH=$PATH:/opt/$JAVA_FOLDER/bin:/opt/$JAVA_FOLDER/jre/bin | |
echo "export JAVA_HOME=/opt/$JAVA_FOLDER" >> /etc/profile.d/java.sh | |
fi | |
cd - | |
} | |
function install_dse(){ | |
DSE_TAR="`find /vagrant -iname "dse*bin.tar.gz" | tail -n 1`" | |
DSE_TAR_NAME=`basename $DSE_TAR` | |
cd /opt | |
rm -rf /opt/dse* | |
cp $DSE_TAR /opt/ | |
tar -xzf $DSE_TAR | |
DSE_NAME=${DSE_TAR_NAME%-bin.tar.gz} | |
echo $DSE_NAME | |
ln -s /opt/$DSE_NAME /opt/dse | |
mv /opt/dse/resources/cassandra/conf /opt/dse/resources/cassandra/conf-org | |
ln -s "/vagrant/dev-conf/$NODE" /opt/dse/resources/cassandra/conf | |
mkdir -p /etc/dse | |
echo "export DSE_HOME=\"/opt/dse\"" >> /etc/dse/dse-env.sh | |
echo "export CASSANDRA_CONF=\"/opt/dse/resources/cassandra/conf\"" >> /etc/dse/dse-env.sh | |
. /etc/dse/dse-env.sh | |
ln -s /vagrant/build/classes /opt/dse/build | |
cd - | |
} | |
function stop_dse(){ | |
/opt/dse/bin/dse cassandra-stop | |
} | |
function start_cassandra(){ | |
/opt/dse/bin/dse cassandra | |
echo "see /var/log/cassandra/system.log" | |
} | |
function start_cassandra_solr(){ | |
/opt/dse/bin/dse cassandra -s | |
echo "see /var/log/cassandra/system.log" | |
} | |
install_setup | |
install_java | |
install_dse | |
#stop any running dse instances | |
stop_dse | |
#start services | |
#start_cassandra | |
start_cassandra_solr |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment