Fast Oracle 12c Installation on Linux with RPMs (1/2)

Installing Oracle Software is boring!

Obviously, if you use Oracle Linux, you know about oracle-validated, oracle-rdbms-server-11gR2-preinstall and oracle-rdbms-server-12cR1-preinstall RPMs which create users, set parameters and install the required packages… Still!

Once the prerequisites are fulfilled, installing Oracle Software requires you to
(1)upload the distribution to a staging location, (2) run the installer, (3) apply the « latest » PSU and (4) run the script. Obviously you can use Oracle cloning feature to speed-up the job. What about doing all this in one go?

The first part of this article explains how the whole installation process can be automated on Oracle Linux 6 x86_64 by creating a single RPM. Once the RPM built, the 2nd part of the article will be explaining how to create your own YUM repository so that the install can be as simple as a yum install command.

A few questions before you begin


Before you rush on the technical section of this article, there are a few questions, you might want to consider.

Question: Why hasn’t this been done before?
For most part, there is nothing new with this method. People have been using it for a couple of years now even if there is little on the Internet on the subject. 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 available as a RPM! However, with Oracle/Redhat Linux 5, this method was not as easy to use as it is with Oracle Linux 6 x86_64. That’s because up to RPM 4.6[2] and on Linux 32bits, RPM file size is limited to 2GB. On Oracle Linux 6 x86_64 which embarks RPM 4.8, it works fine.

Question: Why not provide the RPM for RHEL or Suse?
It is possible to do the same with RHEL and Suse that are supported by Oracle. However, because there is no oracle-rdbms-server-12cR1-preinstall RPM on those platforms that would require you build a RPM to make sure the prerequisites are met. Even if it’s no big deal, it is beyond the scope of this article. Another reason is that Oracle Linux is gaining momentum to run Oracle Software: it provides a single point of support, it’s usually less expensive and it adds value to the platform with UEK2 and KSplice.

Question: What are the cons with this method?
Unfortunately, the method isn’t a panacea. There are several reasons why you would/could prefer to use the regular installer. Reason #1 is when you want to use some advanced configuration including ASM or Grid Infrastructure. In this case, you will need to set some configuration parameters at install time and it makes the RPM method of little or no interest. Another issue is the location of the distribution on servers that can host several RDBMS (see section called “Step 2 – About the HOME, BASE and Inventory”). Last but not least you might be concerned with the way RPM manages updates. But in many ways, this method is very efficient, especially if you mix it with virtualized environments like OracleVM.

Question: Can you get the project code?
Yes. I plan to publish the project code on a public Git repository at some point with a GPL license. It still requires some work to make the build process go smoothly (there are a few known issues) and document the tool. If you’re interested, feel free to contact me twitter @ArKZoYd; I’ll share it with you, if you agree to provide your feedback. Obviously, we can also build some specific RPMs for you but that’s another story

Step 1 – Oracle Software Clone


The fastest way to install an Oracle Database Software is by cloning. It allows to provide the exact distribution you need with the right PSU. In order to build a clone, all you need is to perform a regular Installation with your method of choice. Once done, remove the log files from the software home and create a compressed tarball, like below:

In this procedure, we assume the ORACLE_HOME ends with the db_1 subdirectory. If that’s not the case, change the script above accordingly and change the curloc macro in the rpmbuild specification file. It’s also worth noticing that what you install, including the edition and the embedded languages are part of the clone. This article assumes that’s an Oracle Database Enterprise Edition that has been installed.

Step 2 – About the HOME, BASE and Inventory

Here comes the bad part of the story… RPMs should not take any parameter to install. You might come up with some workarounds including the use of the –prefix parameter to change the software location, like you’ll see Below. However one of RPM’s fundamental principles is that to be useful it should work without any parameters. The result is that you’ll have to make some assumption and they will be included in the distribution. That’s why you can probably only distribute those for a one-only organization. In the specification file of this example, you’ll assume the following:

  • INVENTORY_LOC=/u01/app/oraInventory
  • ORACLE_BASE=/u01/app/oracle
  • ORACLE_HOME=$ORACLE_BASE/product/12.1.0/db_1

Those values are defined as macros in the file so you can easily change them for a particular distribution. However, you might want to fix them organization-wide.

Step 3 – Rpmbuild Specification File


The next step consists in creating a specification file, called oracledb-ee-121010.spec, so that you can use it with rpmbuild to build the RPM. This is the content of that file, you can create it anywhere:

For more information about how to build a RPM, read “Maximum RPM” by Edward C. Bailey on[4]. However, below are a few comments about this file:

  • oracle owner and groups are hardcoded as it is the case with the oracle-rdbms-server-12cR1-preinstall RPM
  • curloc, inventory, base and home are macros. They are set at the beginning of the file so that you can easily change them to match your environment.
  • Here are a few notes about the header section:
    • Source0 defines the location of your database clone. Its name should be oracledb-ee-121010.tar.gz and it should be located in the ~/rpmbuild/SOURCES directory of your Oracle Linux server
    • The oracle-rdbms-server-12cR1-preinstall is mandatory for the RPM to be created. That’s why this program will only work with Oracle Linux and not RHEL
    • The Prefix allows to change the ORACLE_BASE and by it the ORACLE_HOME at install time. However that’s an optional parameter
    • AutoReqProv: no prevents the system from checking the required RPMs automatically.
  • The %prep section changes the distribution name to %curloc as the name of the directory containing the Oracle distribution in the oracledb-ee-121010.tar.gz file
  • The %build section move the content of the BUILD Directory to the BUILDROOT directory
  • The %file section defines that all the files from the BUILDROOT should be copied to the RPM and installed on the server with oracle:dba for owner.
  • The %pre section ensures there is enough space on the server and creates the inventory if it doesn’t exist yet
  • The %post section performs the cloning and runs

Step 4 – Here Comes the RPM

In order to build the RPM, one must put the oracledb-ee-121010.tar.gz file in the /home/oracle/rpmbuild/SOURCES directory of your server and run the rpmbuild -bb oracledb-ee-121010.spec command, as below:

The RPM is created in the /home/oracle/rpmbuild/RPMS/x86_64 directory. You’ll find some of its metadata by running the command below:

Step 5 – Testing the RPM


Last but not least, you should test the RPM on your server. In order to proceed, delete the previous installation and run different scenarios, assuming this is a test server and no Oracle Software was installed on it before:

  • Test #1: Install Oracle in its default location

  • Test #2: Install a relocated Oracle Software

Step 6 – It Ain’t Over Yet

One serious concern is *always* security. Consider signing your RPMs with PGP keys.

Once done, you should be able to deploy your database installation in a YUM repository. That’s the subject of the 2nd Part of this article…


[1] Provision Oracle RDBMS software via RPM, Martin Bach on December 13, 2011
[2] RPM 4.6.0 Release Notes
[3] Passing user defined argument to RPM is possible while installing? on
[4] Maximum RPM

Gregory Guillou

About Gregory Guillou

Gregory Guillou has written 767 post in this blog.

Senior Technical Architect at Easyteam

4 thoughts on “Fast Oracle 12c Installation on Linux with RPMs (1/2)

  1. Pingback: Cloning Oracle Database Home on new Oracle Linux machine | Pierre blog

  2. Gregory GuillouGregory Guillou Post author

    Hey Gleb,

    It looks like your doing good. You are obviously right and the 1st one to read the article afaik. tty


  3. Gleb

    Awesome article Gregory! I am definitely going to use it. Only one thing. Maybe I am wrong but the step:
    sudo tar -zcvf db_1 oracledb-ee-121010.tar.gz
    should be like:
    sudo tar -zcvf oracledb-ee-121010.tar.gz db_1

  4. Pingback: #DB12c by Gregory Guillou : Fast Oracle 12c Installation on Linux with RPMs – Part 1 | Database Scene

Laisser un commentaire

Votre adresse de messagerie ne sera pas publiée. Les champs obligatoires sont indiqués avec *