This post shows you how to setup an Oracle 11g database VM with the use of Vagrant and Puppet in straightforward steps. Anybody can execute this without knowledge of the internal workings of the products at hand. Even my manager, who isn’t known to be very skillful in the technical field, is able to do it.
All info in this blog is essentially an excerpt of the outstanding work in Edwin Biemond’s Github repository https://github.com/biemond/vagrant-wls12.1.2-coherence-goldengate. In fact it is a stripped down version of exactly that repository with only the Puppet module oradb with some helper modules left in place.
Having said that no knowledge of Vagrant and Puppet is necessary to execute the steps in this post, everyone is strongly encouraged to gather good understanding of these products and their publicly available excellent learning material at https://docs.vagrantup.com/v2/ and http://docs.puppetlabs.com/
Yes, we will have to install some software to be able to fulfill the tasks at hand. But once installed you will enjoy the capability of having any type of VM – available on internet Puppet modules and Vagrant repos – up and running in just minutes. Here’s a list of what you need to install:
- Oracle VirtualBox version 4.3.6 or higher at https://www.virtualbox.org/
- Vagrant version 1.5.x or higher at https://www.vagrantup.com/downloads.html
- Puppet version 3.0 or higher including Facter and Hiera at http://puppetlabs.com/download-puppet-enterprise-expand
- Access to internet in order to be able to download the prepared initial centOS box into your local installation of Vagrant (approximately 600 Mb)
- Oracle database 126.96.36.199 binaries in the form of p13390677_112040_Linux-x86-64_[1..7]of7.zip from https://support.oracle.com . It is more than 5Gb so you prefer to be at a solid and fast connection.
- The zip file from this post’s resources containing the Vagrant and Puppet configuration. Note that this zip is not (yet) available on Github.
- To make the command “vagrant ssh <nodename>” work on Windows you must install Git and put its bin directory in your global path (see: https://gist.github.com/haf/2843680).
Installing the VM named “oradb” by running Vagrant/Puppet provisioning
Assuming we are working from the windows directory C:\Vagrant follow the steps below:
- Create a directory name C:\Vagrant\__Software
- Put the Oracle binaries in the __Software directory
- Place the file biemond-oradb-vagrant-master.zip from this post in directory C:\Vagrant and extract it there.
- Check the contents of a file named “Vagrantfile” for a definition of a “synced_folder” named “__Software” and edit to “C:/Vagrant/__Software” (yes, with forward slashes on Windows).
- Open a command window and change to directory C:\Vagrant\biemond-oradb-vagrant-master
- Run the command “vagrant up oradb” and watch the magic unfold. See, now even my manager is capable of setting up an Oracle database.
When you have Git for Windows installed and have put its bin path in your global path you may execute command “vagrant up oradb | tee vagrant_up_oradb.log” to capture the prolific screen output also to a log file for later inspection.
- The location where Oracle VirtualBox creates its VM files is default “~/VirtualBOX VMs”. If you like to change that start the VirtualBox graphical user interface and under “File -> Preferences” change that default location to your likings.
- When installing an Oracle database you are normally presented with an option to create sample schema’s. This option has been turned off in this example’s install-silent-response-file and instead a little Puppet manifest (schema.pp) is run that creates an empty hr schema by running simply sysdba sql commands.
- Stripping down Edwin’s Github repository did not go without breaking some code. So there are some Puppet manifests changed and added in order to restore a working set of Puppet manifests.
Check the running db host
After a successful run of Vagrant/Puppet with the guest VM port forward on port 1521 in place you can now connect to the Oracle database running in your guest VM.
Run command ‘ netstat –an | find “LISTEN” | find “1521” ’ on Windows to check for the correct port forward.
Run command ‘ netstat –an | grep LISTEN | grep 1521 on *Nix – or Git bin in path – to check for the correct port forward.
You may run command “vagrant ssh oradb” to open an ssh windows directly to your guest VM.
Screenshot 4: Vagrant SSH session to the VM showing the Oracle instance processes
Closing the VM
To shut down your VM you may suspend it (save its running state) or destroy it. From the directory C:\Vagrant run: “vagrant suspend oradb” or “vagrant destroy oradb [-f]”. Of course you can accomplish this by using the VirtualBox graphical interface as well.
Well, because Edwin deserves most of the credits I named this resource respectfully after him.
In a following article I will explain how Puppet can be used to keep an eye on oracle structure objects with Puppet custom resource types. That’s based on Bert Hajee’s Github repository https://github.com/hajee/easy_type and Oracle custom Puppet resource types like “user” and “tablespace”and more of those.