Skip to content

Instantly share code, notes, and snippets.

@tobert
Last active December 21, 2015 09:48
Show Gist options
  • Save tobert/6287321 to your computer and use it in GitHub Desktop.
Save tobert/6287321 to your computer and use it in GitHub Desktop.
A quick & dirty script I used to install a Mesos cluster. It probably won't work for you, but might not be a bad place to start.
#!/bin/bash
APT_SERVER="apt.MYDOMAIN"
zookeepers="zk://localhost:2181"
export PATH=/bin:/sbin:/usr/sbin:/usr/bin:/usr/local/bin:/usr/local/sbin
export DEBIAN_FRONTEND=noninteractive
die () { echo "FATAL: $*"; exit 1; }
installed () {
dpkg -s $1 |grep -q '^Status:.*installed'
return $?
}
installpkg () {
to_install=""
for pkg in $*
do
installed $pkg && continue
to_install="$to_install $pkg"
done
[ -z "$to_install" ] && return 0
apt-get install --force-yes -y -o "DPkg::Options::=--force-confold" $*
}
set -x
need_update=0
if [ ! -e /etc/apt/sources.list.d/local-oracle-java.list ] ; then
echo "deb [arch=amd64] http://$APT_SERVER/oracle-java precise main" > /etc/apt/sources.list.d/local-oracle-java.list
need_update=1
fi
if [ ! -e /etc/apt/sources.list.d/local-mesos.list ] ; then
echo "deb [arch=amd64] http://$APT_SERVER/mesos precise main" > /etc/apt/sources.list.d/local-mesos.list
need_update=1
fi
if [ $need_update -eq 1 ] ; then
apt-get update
fi
# the masters are in VMs, everything else is slaves on bare metal (for now)
mode="slave"
if [[ $(hostname) =~ ^v ]] ; then
mode="master"
fi
installpkg oracle-java7 mesos-$mode python-mesos mesos-bin
cat > /etc/mesos/mesos.conf <<EOF
cluster=sj
zk=$zookeepers
master=$zookeepers
launcher_dir=/usr/lib/mesos
frameworks_home=/data/mesos/frameworks
work_dir=/data/mesos/work
log_dir=/data/mesos/log
EOF
cat > /etc/default/mesos <<EOF
MESOS_CONFIG_DIR=/etc/mesos/
MESOS_MASTER_PORT=5050
MESOS_SLAVE_PORT=5051
# See http://google-glog.googlecode.com/svn/trunk/doc/glog.html#flags
GLOG_minloglevel=0 # 0=INFO, 1=WARNING, 2=ERROR, 3=FATAL
GLOG_v=0 # Show all VLOG(m) messages where m <= GLOG_v
GLOG_vmodule="" # Per-module verbose level
EOF
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment