Skip to content

Instantly share code, notes, and snippets.

@niccolox
Last active April 13, 2016 20:58
Show Gist options
  • Save niccolox/423fb3e07e3020ef749d to your computer and use it in GitHub Desktop.
Save niccolox/423fb3e07e3020ef749d to your computer and use it in GitHub Desktop.
# login to http://10.211.55.100:7180
# swappiness needs to be fixed, its set to 60, should be less than 10
# vagrant plugin install vagrant-hostmaster
# also cachier, this can bork
$master_script = <<SCRIPT
#!/bin/bash
apt-get install curl -y
REPOCM=${REPOCM:-cm5}
CM_REPO_HOST=${CM_REPO_HOST:-archive.cloudera.com}
CM_MAJOR_VERSION=$(echo $REPOCM | sed -e 's/cm\\([0-9]\\).*/\\1/')
CM_VERSION=$(echo $REPOCM | sed -e 's/cm\\([0-9][0-9]*\\)/\\1/')
OS_CODENAME=$(lsb_release -sc)
OS_DISTID=$(lsb_release -si | tr '[A-Z]' '[a-z]')
if [ $CM_MAJOR_VERSION -ge 5 ]; then
cat > /etc/apt/sources.list.d/cloudera-$REPOCM.list <<EOF
deb [arch=amd64] http://$CM_REPO_HOST/cm$CM_MAJOR_VERSION/$OS_DISTID/$OS_CODENAME/amd64/cm $OS_CODENAME-$REPOCM contrib
deb-src http://$CM_REPO_HOST/cm$CM_MAJOR_VERSION/$OS_DISTID/$OS_CODENAME/amd64/cm $OS_CODENAME-$REPOCM contrib
EOF
curl -s http://$CM_REPO_HOST/cm$CM_MAJOR_VERSION/$OS_DISTID/$OS_CODENAME/amd64/cm/archive.key > key
apt-key add key
rm key
fi
apt-get update
export DEBIAN_FRONTEND=noninteractive
apt-get -q -y --force-yes install oracle-j2sdk1.7 cloudera-manager-server-db cloudera-manager-server cloudera-manager-daemons
service cloudera-scm-server-db initdb
service cloudera-scm-server-db start
service cloudera-scm-server start
SCRIPT
$hosts_script = <<SCRIPT
cat > /etc/hosts <<EOF
127.0.0.1 localhost
10.211.55.100 cloudera-cluster-master1
10.211.55.101 cloudera-cluster-slave1
10.211.55.102 cloudera-cluster-slave2
10.211.55.103 cloudera-cluster-slave3
10.211.55.104 cloudera-cluster-slave4
10.211.55.105 cloudera-cluster-slave5
# The following lines are desirable for IPv6 capable hosts
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
EOF
sudo bash -c "echo 'vm.swappiness = 0' >> /etc/sysctl.conf"
SCRIPT
Vagrant.configure("2") do |config|
# Define base image
config.vm.box = "ubuntu/trusty64"
config.vm.define :master do |master|
master.vm.provider :virtualbox do |v|
v.name = "cloudera-cluster-master1"
v.customize ["modifyvm", :id, "--memory", "8192"]
end
master.vm.network :private_network, ip: "10.211.55.100"
master.vm.hostname = "cloudera-cluster-master1"
master.vm.provision :shell, :inline => $hosts_script
master.vm.provision :shell, :inline => $master_script
master.vm.network :public_network, bridge: "eth0"
end
config.vm.define :slave1 do |slave1|
slave1.vm.box = "ubuntu/trusty64"
slave1.vm.provider :virtualbox do |v|
v.name = "cloudera-cluster-slave1"
v.customize ["modifyvm", :id, "--memory", "4096"]
end
slave1.vm.network :private_network, ip: "10.211.55.101"
slave1.vm.hostname = "cloudera-cluster-slave1"
slave1.vm.provision :shell, :inline => $hosts_script
end
config.vm.define :slave2 do |slave2|
slave2.vm.box = "ubuntu/trusty64"
slave2.vm.provider :virtualbox do |v|
v.name = "cloudera-cluster-slave2"
v.customize ["modifyvm", :id, "--memory", "4096"]
end
slave2.vm.network :private_network, ip: "10.211.55.102"
slave2.vm.hostname = "cloudera-cluster-slave2"
slave2.vm.provision :shell, :inline => $hosts_script
end
config.vm.define :slave3 do |slave3|
slave3.vm.box = "ubuntu/trusty64"
slave3.vm.provider :virtualbox do |v|
v.name = "cloudera-cluster-slave3"
v.customize ["modifyvm", :id, "--memory", "4096"]
end
slave3.vm.network :private_network, ip: "10.211.55.103"
slave3.vm.hostname = "cloudera-cluster-slave3"
slave3.vm.provision :shell, :inline => $hosts_script
end
config.vm.define :slave4 do |slave4|
slave4.vm.box = "ubuntu/trusty64"
slave4.vm.provider :virtualbox do |v|
v.name = "cloudera-cluster-slave4"
v.customize ["modifyvm", :id, "--memory", "4096"]
end
slave4.vm.network :private_network, ip: "10.211.55.104"
slave4.vm.hostname = "cloudera-cluster-slave4"
slave4.vm.provision :shell, :inline => $hosts_script
end
config.vm.define :slave5 do |slave5|
slave5.vm.box = "ubuntu/trusty64"
slave5.vm.provider :virtualbox do |v|
v.name = "cloudera-cluster-slave5"
v.customize ["modifyvm", :id, "--memory", "4096"]
end
slave5.vm.network :private_network, ip: "10.211.55.105"
slave5.vm.hostname = "cloudera-cluster-slave5"
slave5.vm.provision :shell, :inline => $hosts_script
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment