Sunday, November 3, 2013

Oracle 12c Cheat Sheet for Linux (part one)

This blog post will cover the basic steps that will get you to the point where you have Oracle12c up and running on a Linux system. I am assuming Oracle Linux, but I have also verified that (with a few tweaks here and there, perhaps) things work pretty much the same with CentOs.

In Part Two I will talk about accessing "pluggable" databases (which you need to get to the sample schemas, such as "hr", etc), and also getting SQL Developer up and running.

1. Install latest version of Oracle Linux. I did this on a virtual machine using Vmware Workstation 10 running on Windows 8 Pro. More details are here : Installing Oracle Linux on a virtual machine.

2. Apply Oracle's set up scripts via yum (see https://blogs.oracle.com/wim/entry/easily_install_oracle_rdbms_12cr1) for some more details:

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

3. Create directory /home/OraDB12c and download the two installation zip files here. (look here if you don't know how to do this: http://www.oracle.com/technetwork/articles/servers-storage-admin/ginnydbinstallonlinux-488779.html).

4. IMPORTANT: Before installation you must manually create /oradata as root (or at least this was the case when I did it - despite the claim that the "setup" scripts were supposed to take care of this kind of thing):

mkdir /oradata
chown oracle /oradata
chgrp oinstall /oradata

5. Depending on what other configuration you have done on your linux box, there might be one more mthing before the install! Execute this command as root:

xhost +SI:localuser:oracle

6. Now run the installation script as the "oracle" user. The script is called "runInstall", and it should be found in the directory /home/OraDB12c/database. If you get a "DISPLAY" error, see step #5 above. During installation there is a step that requires manually running some more scripts (AS ROOT). These scripts get installed as part of the installation process - you will be prompted to do this at the appropriate time.

7. After installation completes successfully you must still manually set the the environment variables ORACLE_HOME, ORACLE_BASE, and ORACLE_SID, and also update your path (and when updating the path you should explicitly add ORACLE_HOME/bin). Here is what I put in my .bashrc file (for the "oracle" user) to accomplish this:

ORACLE_SID="orcl"; export ORACLE_SID
ORACLE_HOME="/home/oracle/app/oracle/product/12.1.0/dbhome_1/"; export ORACLE_HOME
ORACLE_BASE="/home/oracle/app/oracle/product/12.1.0/"; export ORACLE_BASE
PATH=$PATH:$ORACLE_BASE:$ORACLE_HOME:$ORACLE_HOME/bin; export PATH


7. At this point you should log in as the "oracle" user and you should be able to fire up sqlplus as usual:

sqlplus / as sysdba

8. If that doesn't work then you can either google the error message(s) you get, and/or leave a comment below and I'll try to help you out!

9. Note that Oracle has apparently changed the default locations for ORACLE_HOME and ORACLE_BASE. If you are unsure about what to set these environment variables to, check out this blog post by Kevin Closson: "Using Linux /proc To Identify ORACLE_HOME and Instance Trace Directories."

Here is the two step process for discovering where ORACLE_HOME is using /proc:

Step 1: ps -ef | grep lgwr | grep -v grep

Step 2: ls -l /proc/<PID>/exe

In my case the oracle home turned out to be, very reasonably, /home/oracle/app/oracle/product/12.1.0/dbhome_1/. In other words, it is the same as the "old style" ORACLE_HOME, but with "/u01/" replaced by "/home/oracle/". ORACLE_BASE is just the directory immediately above ORACLE_HOME.

No comments:

Post a Comment