Martins Blog

Trying to explain complex things in simple terms

Provision Oracle RDBMS software via RPM

Posted by Martin Bach on December 13, 2011

I have always asked myself why Oracle doesn’t package their software as an RPM-surely such a large organisation has the resources to do so!

Well the short answer is they don’t give you an RPM, except for the XE version of the database which prompted me to do it myself. The big problem anyone faces with RPM is that the format doesn’t seem to support files larger than 2GB. Everybody knows that the Oracle database installation is > 2G which requires a little trick on our side. And the trick is not even obscure in any way as I remembered: some time ago I read an interesting article written by Frits Hoogland about cloning Oracle homes. It’s still very relevant and can be found here:

http://fritshoogland.wordpress.com/2010/07/03/cloning-your-oracle-database-software-installation/

Now that gave me the idea:

  1. You install the oracle binaries on a reference host
  2. Apply any patches and PSUs you need
  3. Wrap the oracle home up in a tar-ball just the way Frits describes by descending into $ORACLE_HOME and creating a tar archive of all files, excluding those ending in “*.log”, network config files in $ORACLE_HOME/network/admin and anything in $ORACLE_HOME/dbs. We don’t want to proliferate our database initialisation files …
  4. You make that tarball available on a central repository and export that with CIFS/NFS or whatever other mechanism you like
  5. Mount this exported file system in /media, so that /media/db11.2.0.3/ has the database.tar.gz file available
  6. Install the RPM

Simple! Piet de Visser would be proud.As it turned out creating (or building) the RPM is the hard part! I have spent a fair amount of time to understand it, and realised that it’s amazing! However IMO RPM is primarly aimed at packaging/building software from the source, something the oracle installer doesn’t really do in the same way.

To get you started, here’s a sample spec file I used, named Oracle11203.spec.

%define name            Oracle11203EE
# package release
%define release         1.0
# vendor release
%define version         11.2.0.3

Buildroot:              %{_topdir}/BUILDROOT/%{name}-%{release}-rootdir
Summary:                Oracle Database 11.2.0.3 EE
License:                Commercial
Name:                   %{name}
Version:                %{version}
Release:                %{release}
Group:                  Applications/Databases
Vendor:                 Martin Bach Consulting
URL:                    https://martincarstenbach.wordpress.com
Requires:               oracle-validated

%description
Oracle 11.2.0.3 Enterprise Edition installation. Requires the binaries
in tar-compressed format in /media/db11.2.0.3/database.tar.gz ready for
cloning. A good source for how to package your system up for cloning can
be found here:

http://fritshoogland.wordpress.com/2010/07/03/cloning-your-oracle-database-software-installation/

The oracle-validated is used on Oracle Linux 5 to create a sensible installation
environment. Ensure you review the environment before you build oracle!

%post
if [ -d "/u01/app/oracle/product/11.2.0.3/" ];
then echo "ORACLE_HOME directory exists-aborting";
exit 127
fi

echo "cloning the oracle home now to /u01/app/oracle/product/11.2.0.3/"
mkdir -p /u01/app/oracle/product/11.2.0.3
tar --gzip -xvf /media/db11.2.0.3/database.tar.gz -C /u01/app/oracle/product/11.2.0.3
cd /u01/app/oracle/product/11.2.0.3/clone/bin
./clone.pl ORACLE_HOME="/u01/app/oracle/product/11.2.0.3" ORACLE_BASE="/u01/app/oracle" -defaultHomeName

%files
%defattr(-,root,root,-)

How RPM normally works

When building RPMs, a certain directory structure is assumed, such as a top directory (/home/martin/rpm) and certain subdirectories:

  • BUILD
  • BUILDROOT
  • RPMS
  • SOURCES
  • SPECS
  • SRPMS
  • tmp

The RPM build process is controlled via a “SPEC” file. Documentation of these isn’t too great, especially since the format and process has changed over time (see references). The SPEC file follows the process you would normally follow when compiling a piece of software from source. The SPEC file puts more structure around it.

Your source code goes into SOURCES (still tar-compressed). RPM can be instructed to prepare (=uncompress and patch) the tarball, which by default goes into BUILD. When running the configure command, you usually set the prefix to BUILDROOT. After the build completed (using make), you install the package in BUILDROOT. RPM then catalogs the files inside BUILDROOT and uses the defattr() clause in the SPEC file to assign permissions. This is a big relief-in earlier versions of RPM each file that went into the RPM had to be listed under the %files section.

How this process works

The above SPEC skips almost all of these steps. In our example it’s not necessary to download any sources, all the logic is contained in the SPEC file %POST section.In other words, all you need to do to build the RPM is to copy and paste the above code into the Oracle11203EE.spec file. You build the actual RPM using “rpmbuild -ba Oracle11203EE.spec”. At the end, you find a RPM file in the RPMS/x86-64 directory which can from then on be used to install Oracle on any server. And yes, the RPM is empty except for some header information and a few lines of code.

Note that the SPEC file isn’t really complete: add mount commands and error checking as you see fit. You might also want to replace literals with variables etc-the idea was to give the principle away.

Reference

5 Responses to “Provision Oracle RDBMS software via RPM”

  1. […] concernant ce thème précis, vous serez certainement intéressés par cet article de Martin Bach[1] ! Toujours pas convaincu ? Si vous êtes familier d’Oracle, vous aurez certainement […]

  2. […] By the way, it’s worth mentioning the most interesting blog post on the matter by Martin Bach[1]! Still not convinced? If you’re familiar with Oracle, you’ve already noticed Oracle XE is […]

  3. UX-admin said

    What is the point of creating the rpm, if the files cannot be queried? It defeats the entire purpose, which is to be able to plug it into Kickstart, do configuration management, and perform in-place upgrades with rpm -U, not to mention doing rpm -ql … The OS has an empty RPM without any payload in it. The only thing you automated with it is cloning, but you cannot do configuration management (CFengine, Puppet and Chef are not the answer; rpm is).

    • Martin Bach said

      The point is that you can run a single command to deploy an Oracle database on Linux. A similar process can be implemented on all major UNIX platforms, I did it for AIX and Solaris/SPARC. Instead of an Oracle DBA (who doesn’t have root access) a system administrator can deploy the package. It is 100% consistent, every deployment is the same, the version can be queried in the RPM database, although-as you correctly said-you can’t see the package contents. But since you agreed by means of a corporate standard where the binaries are going to be, you know where the files are.

      I have researched the topic exhaustively and came to the conclusion that RPM is not made for the likes of Oracle, it is designed for smaller software packages. AFAIK there is a size limitation in RPM of 2 GB that makes an Oracle deployment following the spirit of RPM impossible. Regarding the other questions: I deploy Oracle using kickstart in the way described in the article. Regarding in-place upgrades: although possible for the RDBMS without Grid Infrastructure they are not a good idea with Oracle. I am not sure I understand what you mean by “configuration management”, can you elaborate?

  4. UX-admin said

    …And your blogging software cut off my reply. I give up.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: