Skip to content

Instantly share code, notes, and snippets.

@meatcar
Forked from vanjos/datastax_cassandra.sh
Created May 10, 2013 18:22
Show Gist options
  • Save meatcar/5556350 to your computer and use it in GitHub Desktop.
Save meatcar/5556350 to your computer and use it in GitHub Desktop.
#!/bin/bash
###
#
# In order for this to work, tuned your firewall for the following:
#
# 7000-7001
# 1024 - 65535
# 7199 TCP
# 8012 TCP
# 8983 TCP
# 9160 TCP
# 22
# 8443
# 8888
#
###
#
# install some much needed software
sudo apt-get -y install git ntp
# fix date
sudo /etc/init.d/ntp stop && sudo ntpdate pool.ntp.org && sudo /etc/init.d/ntp start
# enable multiverse
old_IFS=$IFS
IFS=$'\n'
for line in `grep multiverse$ /etc/apt/sources.list`; do newline=$(echo $line | sed 's/# //'); sudo sed -i -e 's,'"$line"','"$newline"',' /etc/apt/sources.list; done
IFS=$old_IFS
sudo apt-get update
### install XFS and MDADM to RAID0 ephemeral disks
sudo apt-get -y install mdadm xfsprogs
# RAIIIIIIIIIIIIIID
sudo /sbin/mdadm --create -l0 -n2 -c 256 /dev/md0 /dev/xvdc /dev/xvdd
sudo mkdir /var/lib/cassandra
echo "/dev/md0 /var/lib/cassandra xfs noatime,comment=raid-eph-cassandra 0 0" | sudo tee -a /etc/fstab
echo DEVICE /dev/xvdb /dev/xvdc | sudo tee /etc/mdadm/mdadm.conf
sudo mkfs.xfs /dev/md0
sudo mount /var/lib/cassandra
sudo blockdev --setra 65536 /dev/md0
# allow installs of Datastax
echo "deb http://debian.datastax.com/community stable main" | sudo tee -a /etc/apt/sources.list
curl -L http://debian.datastax.com/debian/repo_key | sudo apt-key add -
# Install Opscenter
sudo apt-get update
sudo apt-get install -y libssl0.9.8 opscenter-free
# allow it to listen on public interface
sudo sed -i -e 's/interface = 127.0.0.1/interface = 0.0.0.0/' /etc/opscenter/opscenterd.conf
### START'ER UP!
sudo service opscenterd start
###
#
# And you're just about ready to go. You can now use OpsCenter to install any cluster
# of machines you'd like. By giving it your EC2 credentials, it will launch a whole
# new set of machines for you, OR you can point already existing machines to it.
#
###
###
#
# Installing Cassandra 1.2 on this machine
#
###
# let's install DSC12 (DataStax Cassandra 1.2)
sudo apt-get -y install dsc12
###
#
# Now that it's installed... Configure it just a wee bit
#
# Change /etc/default/dse (for hadoop - HADOOP_ENABLED=1, for Solr - SOLR_ENABLED=1, Each node should be ONE role
#
###
# There are a lot of Cassandra options, so look them up, but bare minimum:
sudo sed -i -e "/^rpc_address/c\rpc_address: 0.0.0.0" -e "/^initial_token/c# initial_token:" /etc/cassandra/cassandra.yaml
# start cassandra up
sudo service cassandra start
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment