Last active
November 20, 2017 23:53
-
-
Save jongsma/083d86c85a5f423e8058da19cb8c9b10 to your computer and use it in GitHub Desktop.
Vagrant file for creating 2 virtual box VM's as the basis for an Oracle RAC cluster. This setup has 2 nodes with 4 shared disks and the needed network interfaces. Explanation of this file is here: https://jongsma.wordpress.com/2016/08/12/vagrant-for-you-rac-test-environment
This file contains 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
# -*- mode: ruby -*- | |
# vi: set ft=ruby : | |
VAGRANTFILE_API_VERSION = "2" | |
ASM_LOC = "/pathto/vagrant/rac/asmdisk" | |
num_disks = 4 | |
servers = 2 | |
mem = 4096 | |
cpu = 2 | |
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| | |
config.vm.box = "oel68" | |
config.ssh.forward_x11 = true | |
config.ssh.forward_agent = true | |
(1..servers).each do |rac_id| | |
config.vm.define "rac#{rac_id}" do |config| | |
config.vm.hostname = "rac#{rac_id}" | |
# Do Virtualbox configuration | |
config.vm.provider :virtualbox do |vb| | |
vb.customize ['modifyvm', :id, '--nic2', 'intnet', '--intnet2', 'rac-priv'] | |
vb.customize ['modifyvm', :id, '--nic3', 'hostonly', '--hostonlyadapter3', 'vboxnet0'] | |
# Change NIC type (https://www.virtualbox.org/manual/ch06.html#nichardware) | |
vb.customize ['modifyvm', :id, '--nictype1', '82545EM'] | |
vb.customize ['modifyvm', :id, '--nictype2', '82545EM'] | |
vb.customize ['modifyvm', :id, '--nictype3', '82545EM'] | |
# Change RAC node specific settings | |
vb.customize ['modifyvm', :id, '--cpus', cpu] | |
vb.customize ['modifyvm', :id, '--memory', mem] | |
# Increase SATA port count | |
vb.customize ['storagectl', :id, '--name', 'SATA', '--portcount', 5] | |
(1..num_disks).each do |disk| | |
if ARGV[0] == "up" && ! File.exist?(ASM_LOC + "#{disk}.vdi") | |
if rac_id == 1 | |
vb.customize ['createmedium', | |
'--filename', ASM_LOC + "#{disk}.vdi", | |
'--format', 'VDI', | |
'--variant', 'Fixed', | |
'--size', 5 * 1024] | |
vb.customize ['modifyhd', | |
ASM_LOC + "#{disk}.vdi", | |
'--type', 'shareable'] | |
end # End createmedium on rac1 | |
vb.customize ['storageattach', :id, | |
'--storagectl', 'SATA', | |
'--port', "#{disk}", | |
'--device', 0, | |
'--type', 'hdd', | |
'--medium', ASM_LOC + "#{disk}.vdi"] | |
end # End if exist | |
end # End of EACH iterator for disks | |
# Workaound for Perl bug with root.sh segmentation fault, | |
# see this blogpost from Danny Bryant http://dbaontap.com/2016/01/13/vbox5/ | |
vb.customize ['setextradata', :id, "VBoxInternal/CPUM/HostCPUID/Cache/Leaf", "0x4"] | |
vb.customize ['setextradata', :id, "VBoxInternal/CPUM/HostCPUID/Cache/SubLeaf", "0x4"] | |
vb.customize ['setextradata', :id, "VBoxInternal/CPUM/HostCPUID/Cache/eax", "0"] | |
vb.customize ['setextradata', :id, "VBoxInternal/CPUM/HostCPUID/Cache/ebx", "0"] | |
vb.customize ['setextradata', :id, "VBoxInternal/CPUM/HostCPUID/Cache/ecx", "0"] | |
vb.customize ['setextradata', :id, "VBoxInternal/CPUM/HostCPUID/Cache/edx", "0"] | |
vb.customize ['setextradata', :id, "VBoxInternal/CPUM/HostCPUID/Cache/SubLeafMask", "0xffffffff"] | |
end # End of config.vm.provider | |
# Create disk partitions | |
if rac_id == 1 | |
config.vm.provision "shell", inline: <<-SHELL | |
if [ -f /etc/SFDISK_CREATE_DATE ]; then | |
echo "Partition creation already done." | |
exit 0 | |
fi | |
for i in `ls /dev/sd* | grep -v sda`; do echo \\; | sudo sfdisk -q $i; done | |
date > /etc/SFDISK_CREATE_DATE | |
SHELL | |
end # End create disk partions | |
if rac_id == servers | |
# Start Ansible provisioning | |
config.vm.provision "ansible" do |ansible| | |
#ansible.verbose = "-v" | |
ansible.limit = "all" | |
ansible.playbook = "ansible/rac_gi_db.yml" | |
end # End of Ansible provisioning | |
end | |
end # End define VM config | |
end # End each iterator RAC hosts | |
end # End of Vagrant.configure |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment