Oracle Database 12c: quickly create a virtual machine with OEL 6.4 and Oracle Database 12c (for dummies)

7

I am first and foremost a developer. I am not an administrator. I know more about IDEs and GUIs than about command line. I have always been a little scared of system administration and non-wizard (next-next-finish) based installations. I am not proud of it. I have other skills and interests. I know how to drive my car but I cannot do engine maintenance. Something like that. Now Oracle has released Oracle Database 12c. And the only way for me to run it today is to install it on Linux. So I have a big impetus to finally get started. First with the creation of a Virtual Machine (VirtualBox) with Oracle Enterprise Linux inside (I wrote about my baby steps in this article http://technology.amis.nl/2013/06/29/how-to-create-a-virtual-box-vm-with-oracle-enterprise-linux-inside-a-dummy-guide/) and next with the installation of the Oracle Database 12c in that machine.

This article describes how I went from a clean Oracle Enterprise Linux 6.4 environment in a VirtualBox VM to a VM with additional hard disk, volume group and logical volume with the Oracle Database 12c up and running. The steps are:

  • add hard disk to VM
  • leverage the new disk in the Linux file system (through physical device, file partition, volume group, logical volume, directory with mount of disk)
  • make some pre-install preparations
  • download the Oracle Database 12c installation archives and extract them
  • run the installer and provide the proper configuration details
  • perform post-installation activities
  • verify access to the database is available

image

Our objective:

image

1. import VirtualBox appliance with Oracle Enterprise Linux 6.4

In the article http://technology.amis.nl/2013/06/29/how-to-create-a-virtual-box-vm-with-oracle-enterprise-linux-inside-a-dummy-guide/ I have shown in quite some detail how to set up a Virtual Box VM with Oracle Enterprise Linux 6.4 inside. At the end of this article, I have exported the VM as an Appliance that can be used as the starting point for new VMs.

Here I am using that appliance as the foundation for the Oracle Database 12c installation. So my first step in this article, is the import of that appliance. If you already have a Linux environment at your disposal, you can skip this section as well as the next and go straight to section 4.

Start Virtual Box. From the File menu, choose Import Appliance:

image

Find the .ova file for the appliance:

SNAGHTML9df11af

Change some of the settings, such as the name and the target location for the .vmdk file:

SNAGHTML9df25cb

Press Import to start the import of the appliance:

SNAGHTML9df4482

When the import is done, you have a new virtual machine with OEL 6.4 inside, ready to rock!

2. Add a new hard disk to the VM to hold the Oracle Database software and data

It makes sense to extend the VM with a hard disk on which the Oracle software will be installed. Go to the Settings for the VM, select the Storage tab and click on the hard disk icon:

SNAGHTML9dfedda

Create a new disk.

SNAGHTML9e016ed

I have used the VMDK type and it worked for my purpose – I am not sure about the other types.

SNAGHTML9e02e25

I selected Dynamically allocated:

SNAGHTML9e0429e

Provide the name and location of the file that is the virtual hard disk. Also specify its maximum size. 20 GB should do the trick is my guess. Extending a physical hard disk later on is not possible. Adding disks and using them to extend the logical volume certainly is possible.

SNAGHTML9e05d8d

Click Create. The hard disk is added.

SNAGHTML9e07ea4

Click OK to close the Settings dialog.

3. Start the VM and leverage the new disk in the Linux file system

image

connect as root user.

image

 

Making use of the new hard disk inside the Virtual Machine takes a few steps that for the non-Linux initiated such as myself is a little peculiar at first:

as root, open a terminal window

image

The new hard disk is available inside the VM at dev/sdd. In order to actually make use of it, we create a physical partition inside this device:

fdisk /dev/sdb

then go through the following dialog:

image

Now the physical partition has been set up.

Type the next statement to create the Physical Volume

pvcreate /dev/sdb1

Type this statement to create a volume group:

vgcreate -v vg_oracledb /dev/sdb1

and this one to create a logical volume that currently has about 18GB of space (more can be added to it later on):

lvcreate -v –size 18g –name lv_oracledb vg_oracledb

A file system has to be set up (similar to format I believe) on the logical volume. The next statement takes care of this:

mkfs.ext4 -v /dev/mapper/vg_oracledb-lv_oracledb

Finally, we need to mount the logical volume somewhere in a directory. First create the directory /u01 that will be the mount point:

mkdir -v /u01

then perform the mount itself:

mount -t ext4 /dev/vg_oracledb/lv_oracledb /u01

and verify whether it succeeded:

df -h /u01

image

In order to ensure that /u01 is mounted correctly when the system reboots, we need to edit the file /etc/fstab. Add a line for the /dev/mapper/vg_oracledb-lv_oracledb to be mounted at /u01:

image

Finally, as root, grant ownership of /u01 to user oracle:

chown oracle:oracle /u01

4. Pre-install Preparations

This article on OTN – http://www.oracle.com/technetwork/articles/servers-storage-admin/ginnydbinstallonlinux6-1845247.html – was a big help in preparing my Linux environment for the installation of the Oracle Database 12c. The article outlined a number of things to put in place and especially introduces an RPM that will take care of most of these preparations. All I had to do – in order for my environment to meet the installer’s requirements – was start a terminal session as root and execute this line:

yum install oracle-rdbms-server-11gR2-preinstall

I accepted all proposals put before me and a lot of packages were installed (that the Oracle Database installers checks for) and other configuration actions (creation of group, update of system parameters) were performed:

image

Enter y to confirm the installation of the required packages:

image

and finally

image

I later found out in Tim’s article that there is a comparable rpm for Database 12c. It seems that for me this 11gR2 RPM did the job, but for completeness sake:

yum install oracle-rdbms-server-12cR1-preinstall -y

The hostname of the Linux machine should be mapped to an IP address in the /etc/hosts file. Edit this file:

gedit /etc/hosts

and make sure that the hostname (look it up through the hostname command in the terminal) is added to the line for 127.0.0.1:

image

 

5. download the Oracle Database 12c installation archives and extract them

Configure Firefox to always ask where to download files (otherwise these files may end up on a device that may not have enough space):

image

Go to the OTN Download page (or to eDelivery) and download the two zip files for Linux 64 bit

image

Before the download commences, Firefox asks where to save the file:

image

Create new directory /u01/download and use it as target for both files:

image

These downloads are pretty fast these days:

image

As soon as the first of downloads is complete, open the file to extract it.

image

Extract the two archives two another new directory /u01/installer:

image

After both files are extracted, everything is prepared to start the installer.

 

6. Run the installer and provide the proper configuration details

As user oracle from the terminal run the installer:

image

At this point, I ran into a problem. One of the check carried out by the installer failed with this message: Could not execute auto check for display colors using command /usr/X11R6/bin/xdpyinfo. Check if the DISPLAY variable is set. Failed.

After quite some googling, I found a solution that worked for me:image

  • open terminal as root
  • DISPLAY=:0.0
  • export DISPLAY
  • xhost +
  • su – oracle
  • DISPLAY=:0.0
  • export DISPLAY
  • goto /u01/installer/database
  • sh runInstaller

 

And now the installer will run.

Press Next on each page except the few highlighted below:

image

image

image

image

image

Here is some important information about where the installation should write the files – both data files for the initial database and the database product itself – and what the name is of the database (service). Also the character set (!), the administrator password (for SYS and SYSTEM) and the decision whether the database is a container database or a ‘normal’ database. If a container database, then the name of the pluggable database must be provided as well.

image

image

image

image

Press Install to kick things off for real.

image

After some time, the installer prompts us to run two scripts – as root:

image

Open a terminal as root and run both scripts.

Then press OK in the popup window and the installer resumes.

image

After installation of all the software is done, a database will be created by the Database Configuration Assistant.

image

When it is done, a window is presented with some important details about the database was created and how it can be accessed:

image

The URL https://localhost:5500/em is where the Database Express tool can be reached.

In case you are interested: a log file of the installation is available in /u01/app/oraInventory/logs.

7. Perform post-installation activities

Remove installation zip files and the extracted installation files. They are no longer required and occupy a lot of diskspace (about 2.5 GB each)

Configure automatic startup of the database – using Tim Hall’s article: http://www.oracle-base.com/articles/linux/automating-database-startup-and-shutdown-on-linux.php

First step:

edit the file /etc/oratab and change the :N to :Y for the orcl database that was created by the DBCA:

image

8. Verify access to the database is available

From the terminal window, as oracle, you can run many database related tools and utilities, such as DBCA, lstnrctl and sqlplus.

Make sure that the ORACLE_BASE and ORACLE_HOME are set in your terminal session like this:

ORACLE_BASE=/u01/app/oracle
export ORACLE_BASE
ORACLE_HOME=$ORACLE_BASE/product/12.1.0/dbhome_1
export ORACLE_HOME

Then run the lsnctl like this:

$ORACLE_HOME/bin/lsnrctl

image

and ask with status for an overview of the database services listened for:

image

 

To gain entry into the database and actually perform DBA or developer activities, you can use sqlplus; start it up using:

$ORACLE_HOME/bin/sqlplus ‘sys/Oracle123@orcl as sysdba’

(where Oracle123 is to be replaced with the administrative password you provided during installation)

image

 

After shutting down the VM and restarting it, I do not immediately get access to the database. In fact, it is not automatically started yet. I have to look into that. What I had to do was:

open a terminal as oracle

enter:

. oraenv

then respond with the ORACLE_SID, which is orcl in my case.

Next, type:

$ORACLE_HOME/bin/sqlplus ‘/  as sysdba’

then when sqlplus starts, connected to an idle instance, then type:

startup

 

[oracle@myoel64 ~]$ . oraenv
ORACLE_SID = [oracle]? orcl
The Oracle base remains unchanged with value /u01/app/oracle
[oracle@myoel64 ~]$ $ORACLE_HOME/bin/sqlplus ‘/  as sysdba’

SQL*Plus: Release 12.1.0.1.0 Production on Sun Jun 30 08:53:55 2013

Copyright (c) 1982, 2013, Oracle.  All rights reserved.

Connected to an idle instance.

SQL> startup
ORACLE instance started.

Total System Global Area  839282688 bytes

Next steps

Run Database Control through browser

Open Firefox and enter the url: https://localhost:5500/em/login.

image

The browser will protest a little, because of the https connection. Accept the risk and add an exception:

image

Now depending on whether the Flash-player is already installed in your browser, you may see this:

image

or much better, this:

image

image

Download SQL Developer and start accessing the database to try out new administration or development facilities

One very easy way to get access to the database and give it a spin is through SQL Developer. I decided to grab it and install it (still a bit of a GUI girl rather than a command line boy I guess).

Go to OTN and download SQL Developer for Linux:

image

Run the package installer for this download:

image

Once the download is complete, the RPM installer kicks in and asks for confirmation:

image

After click on Install, the installation takes place:

image

Provide the root password to proceed with the actual installation:

image

When the installation is done, SQL Developer can be started from the command line with $ORACLE_HOME/sqldeveloper/sqldeveloper.sh:

image

The first thing you are likely to require is a connection. Create it using the following dialog:

image

When you open the DBA window (using View | DBA) you get an overview of the CDB and PDBs:

image

 

Credits

While working my way through the installation of first Linux and then Oracle Database 12c, I received a tremendous amount of help. Through articles on the internet, discussion forum threads and community members in real time – through Twitter and many inside my own organization (AMIS). I would like to mention Job Oprel, Frits Hoogland, Jaap Poot, Lonneke Dikmans, Chris Gralike, Hans IJssenbout, Marco Gralike who all, at some point, helped me with small suggestions or big breakthroughs. I understand it is a small step for mankind, but for me this has been a pretty substantial leap forward.

Resources

To resolve the DISPLAY issue with OUI: https://forums.oracle.com/thread/571326

Create a Virtual Box VM with Oracle Enterprise Linux 6.4 inside – http://technology.amis.nl/2013/06/29/how-to-create-a-virtual-box-vm-with-oracle-enterprise-linux-inside-a-dummy-guide/

The article I  noticed only after I had written the above story myself – I could have saved myself a lot of trouble! – by Tim Hall about installing Oracle Database 12c on Linux 6: http://www.oracle-base.com/articles/12c/oracle-db-12cr1-installation-on-oracle-linux-6.php

OTN: How I Simplified Oracle Database 11g Installation on Oracle Linux 6 – http://www.oracle.com/technetwork/articles/servers-storage-admin/ginnydbinstallonlinux6-1845247.html

Oracle Linux Hands On Lab – Hands-on lab – Storage Managementhttps://wikis.oracle.com/display/oraclelinux/Hands-on+lab+-+Storage+Management

Share.

About Author

Lucas Jellema, active in IT (and with Oracle) since 1994. Oracle ACE Director for Fusion Middleware. Consultant, trainer and instructor on diverse areas including Oracle Database (SQL & PLSQL), Service Oriented Architecture, BPM, ADF, Java in various shapes and forms and many other things. Author of the Oracle Press book: Oracle SOA Suite 11g Handbook. Frequent presenter on conferences such as JavaOne, Oracle OpenWorld, ODTUG Kaleidoscope, Devoxx and OBUG. Presenter for Oracle University Celebrity specials.

7 Comments

  1. Hi, How to add more volume. I got errors during the installation and I installed twice so it consumed almost all my space.
    Please let me know how to add more volume and resume my installation.

  2. I am getting this error, From the terminal window, as oracle, you can run many database related tools and utilities, such as DBCA, lstnrctl and sqlplus.

    Make sure that the ORACLE_BASE and ORACLE_HOME are set in your terminal session like this:

    ORACLE_BASE=/u01/app/oracle
    export ORACLE_BASE
    ORACLE_HOME=$ORACLE_BASE/product/12.1.0/dbhome_1
    export ORACLE_HOME

    Then run the lsnctl like this:

    $ORACLE_HOME/bin/lsnrctl

    I am unable to set this… I get -bash: /bin/lsnrctl: No sch file or directory, even for Sqlplus, I get the same error. please help.

    • Lucas Jellema on

      I am afraid that I did not. However, I know of some of my colleagues who did. I will ask them and add a link to their reply. Thanks for your kind comment.

      Lucas

  3. Martin Scholz on

    Hello Mr. Jellema,
    I encountered a problem in the third step: lvcreate -v –size 18g –name lv_oracledb vg_oracledb

    I copied the command from Firefox and an illegal character (the ‘–’ hyphen instead of two minus characters) crept in.
    Naturally Linux refused the command and I had a moment of panic. Other users could also be disturbed.

    I solved this issue and continue to follow your instructions when the downloads of the database files are ready…

    Thank you very much.

Leave a Reply