Provisioning an Oracle 11g database VirtualBox VM with Vagrant and Puppet for dummies

4
Share this on .. Tweet about this on TwitterShare on LinkedIn0Share on Facebook0Share on Google+0Email this to someoneShare on Tumblr0Buffer this page

Outline

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.

Preface

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.

Prerequisites

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/

Ingredients

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 11.2.0.4 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:

  1. Create a directory name C:\Vagrant\__Software
  2. Put the Oracle binaries in the __Software directory
  3. Place the file biemond-oradb-vagrant-master.zip from this post in directory C:\Vagrant and extract it there.
  4. 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).
  5. Open a command window and change to directory C:\Vagrant\biemond-oradb-vagrant-master
  6. Run the command “vagrant up oradb” and watch the magic unfold. See, now even my manager is capable of setting up an Oracle database.

Screenshot 1: Vagrant/Puppet provisioning screen output

AMIS_Vagrant_OraDB_blog_p01

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.

Notes:

  • 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.

Screenshot 2: Port 1521 forwarded from VM to your Windows host
AMIS_Vagrant_OraDB_blog_p02

Screenshot 3: SQL Developer connection to the VM Oracle database

AMIS_Vagrant_OraDB_blog_p03

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

AMIS_Vagrant_OraDB_blog_p04

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.

Resources:

Well, because Edwin deserves most of the credits I named this resource respectfully after him.

biemond-oradb-vagrant-master

Follow up:

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.

Share this on .. Tweet about this on TwitterShare on LinkedIn0Share on Facebook0Share on Google+0Email this to someoneShare on Tumblr0Buffer this page

About Author

4 Comments

  1. Very neat package. This worked almost flawlessly for me with the exception that on the first attempt to provision, the Oracle setup failed due to some ‘yum install’ problems on libXext and libXtst. I corrected this with:

    1. With the VM still up, run ‘vagrant ssh oradb’
    2. In the SSH shell, run ‘sudo yum install libXext’
    3. In the SSH shell, run ‘sudo yum install libXtst’
    4. Exit the SSH shell
    5. Run ‘vagrant provision oradb’

    This resumed neatly from extracting the Oracle content from the install zips and finishing with the DB up responding to ‘tnsping test’.

    As a variation, I use Cygwin 64-bit ssh.exe, and added the following to my Windows PATH variable for all the commands to work neatly: D:cygwin64bin;D:Vagrantbin;C:Program FilesOracleVirtualBox

  2. sunnystate on

    Thanks for the information. I had tried provisioning oracle database using vagrant as per this blog. I seem to hit the below error towards the end when i try to do a vagrant up or a vagrant provision.:

    Notice: /Stage[main]/Oradb_11g/Oradb::Net[config net8]/File[/install/netca_11.2.rsp]/ensure: created
    Notice: /Stage[main]/Oradb_11g/Oradb::Net[config net8]/Exec[install oracle net config net8]/returns: UnsatisfiedLinkError exception loading native library: njni11
    Notice: /Stage[main]/Oradb_11g/Oradb::Net[config net8]/Exec[install oracle net config net8]/returns: java.lang.UnsatisfiedLinkError: /oracle/product/11.2/db/lib/libnjni11.so: libclntsh.so.11.1: cannot open shared object file: No such file or directory
    Notice: /Stage[main]/Oradb_11g/Oradb::Net[config net8]/Exec[install oracle net config net8]/returns: java.lang.UnsatisfiedLinkError: jniGetOracleHome
    Notice: /Stage[main]/Oradb_11g/Oradb::Net[config net8]/Exec[install oracle net config net8]/returns: at oracle.net.common.NetGetEnv.jniGetOracleHome(Native Method)
    Notice: /Stage[main]/Oradb_11g/Oradb::Net[config net8]/Exec[install oracle net config net8]/returns: at oracle.net.common.NetGetEnv.getOracleHome(Unknown Source)
    Notice: /Stage[main]/Oradb_11g/Oradb::Net[config net8]/Exec[install oracle net config net8]/returns: at oracle.net.ca.NetCALogger.getOracleHome(NetCALogger.java:230)
    Notice: /Stage[main]/Oradb_11g/Oradb::Net[config net8]/Exec[install oracle net config net8]/returns: at oracle.net.ca.NetCALogger.initOracleParameters(NetCALogger.java:215)
    Notice: /Stage[main]/Oradb_11g/Oradb::Net[config net8]/Exec[install oracle net config net8]/returns: at oracle.net.ca.NetCALogger.initLogger(NetCALogger.java:130)
    Notice: /Stage[main]/Oradb_11g/Oradb::Net[config net8]/Exec[install oracle net config net8]/returns: at oracle.net.ca.NetCA.main(NetCA.java:427)
    Notice: /Stage[main]/Oradb_11g/Oradb::Net[config net8]/Exec[install oracle net config net8]/returns:
    Notice: /Stage[main]/Oradb_11g/Oradb::Net[config net8]/Exec[install oracle net config net8]/returns: Error: jniGetOracleHome
    Notice: /Stage[main]/Oradb_11g/Oradb::Net[config net8]/Exec[install oracle net config net8]/returns: Oracle Net Services configuration failed. The exit code is 1

    Did you encounter the above issue when you built this?

Leave a Reply