Skip to content

Instantly share code, notes, and snippets.

@ederoyd46
Last active September 3, 2015 08:06
Show Gist options
  • Save ederoyd46/23dc63f328a4271d455d to your computer and use it in GitHub Desktop.
Save ederoyd46/23dc63f328a4271d455d to your computer and use it in GitHub Desktop.
Vagrant 2 Instances with Binary Replication using DRBD
# All Vagrant configuration is done below. The "2" in Vagrant.configure
# configures the configuration version (we support older styles for
# backwards compatibility). Please don't change it unless you know what
# you're doing.
Vagrant.configure(2) do |config|
config.vm.box = "ubuntu/trusty64"
config.vm.synced_folder "../", "/home/vagrant/fall_manager_provisioning"
config.vm.provider "virtualbox" do |vb|
vb.gui = false
vb.memory = "4096"
end
config.vm.provision "file", source: "./replication.res", destination: "/tmp/replication.res"
config.vm.provision "shell", inline: <<-SHELL
export DEBIAN_FRONTEND=noninteractive
sudo apt-get update
sudo apt-get install -y make git linux-source drbd8-utils
curl -sSL https://get.docker.com/ubuntu/ | sh
curl -L https://github.com/docker/compose/releases/download/1.1.0/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose
groupadd --gid 5000 software
groupadd --gid 5100 data
usermod -a -G docker vagrant
dd if=/dev/zero of=/home/vagrant/my_fs bs=1M count=2048
losetup /dev/loop5 /home/vagrant/my_fs
mkdir /repl
echo "192.168.0.101 live" >> /etc/hosts
echo "192.168.0.102 backup" >> /etc/hosts
cd /root
git clone git://git.drbd.org/drbd-8.4
cd drbd-8.4 && git checkout drbd-8.4.5
make && make install
modprobe drbd
mv /tmp/replication.res /etc/drbd.d/replication.res
drbdadm create-md codecat
service drbd start
mkdir -p /repl
SHELL
config.vm.define "live" do |live|
live.vm.hostname = "live"
live.vm.network "public_network", ip: "192.168.0.101", bridge: "en0: Wi-Fi (AirPort)"
live.vm.provision "shell", inline: <<-SHELL
drbdadm -- --overwrite-data-of-peer primary all
mkfs.ext3 /dev/drbd0
mount /dev/drbd0 /repl
chown root:data /repl
chmod g+w /repl
SHELL
end
config.vm.define "backup" do |backup|
backup.vm.hostname = "backup"
backup.vm.network "public_network", ip: "192.168.0.102", bridge: "en0: Wi-Fi (AirPort)"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment