dcsimg

Unbreakable: Oracle on Linux

Six years ago, Oracle announced support for Linux, perhaps singlehandedly sparking the widespread adoption of Linux in the enterprise. Today, Oracle's Linux market share is growing by leaps and bounds, backed by the elegance, scalability, and low cost of Linux application clusters.

Chief technology officers of Fortune 1000 companies are constantly challenged to solve one overwhelming problem: boost productivity and reduce overall costs. Indeed, most of a CTO’s time is spent focused on that very quandary, providing guidance and solutions to company staff and upper management.

So, it’s no wonder that Linux and many other open source technologies have become so popular in the enterprise. In many cases, open source offers the same or greater power than equivalent commercial solutions at just a fraction of the cost. Instead of expensive licenses, annual maintenance subscriptions, and proprietary hardware, CTOs are opting for open source software and standardized, off-the-shelf, commodity hardware.

Today, the most common migration to standards (de facto or otherwise) replaces Solaris, Sun ONE, and Sun hardware with Linux, Apache, and Dell blades. Not only is the latter combination more scalable, the hardware arrives in days instead of weeks (or even months, when Sun closes down for the summer). Another common migration replaces BEA’s Weblogic, ATG’s Dynamo, or IBM’s WebSphere with Tomcat and JBoss.

Yet another popular migration runs Oracle on Linux, eschewing vendor-specific operating systems and hardware. Six years ago, Oracle announced support for Linux, perhaps singlehandedly sparking the widespread adoption of Linux in the enterprise. Today, Oracle’s Linux market share is growing by leaps and bounds, fueled by its “Unbreakable” marketing strategy and backed by the elegance, scalability, and low cost of real application clusters.

Because Linux is like Unix, is scalable via redundant arrays of inexpensive Linux-based hosts (RAIL), and is open, Oracle on Linux is a CTO’s wish come true.

How To Get Started

Installing Oracle can be a daunting procedure, even if you follow the instructions. However, if you read and study the instructions thoroughly beforehand, it’s a straightforward process. In general, it’s also recommended that you avoid the pretty, graphical Java interface for a complete install. It’s better to install the software manually, step-by-step.

What follows is an installation “cheat sheet.” If you’re a capable Linux administrator, this guide will get Oracle up and running quickly and provide a platform for further learning.

Oracle is only certified to run on several flavors of Linux. However, this shouldn’t dissuade you from installing it on your Debian unstable box — chances are that Oracle will work. For reference, the operating system used for this article was Red Hat Advanced Server 2.1. Other Oracle certified Linux distributions include UnitedLinux 1.0 SP3, SuSE SLES 8, SuSE SLES 7, Red Hat Enterprise AS/ES3, Red Hat Enterprise AS/ES 2.1, and a handful of Asian-centric distributions.

Step 1: Register for Oracle Technet

You must register to download the Oracle CD images. You must also confirm that you’re not a terrorist. (Nobody ever said being a DBA was easy: Oracle is now classified as a weapon! This ain’t your mamma’s MySQL here.) Oracle Technet (OTN) can be found at http://otn.oracle.com/index.html.

Step 2: Download the Oracle CD Images

Once you’ve registered for OTN, download the Oracle 9i images. (Yes, Oracle 10g was just released and has all kinds of neat features, but remember, Oracle is enterprise software. It’s never a good idea to run anything “dot zero” in the enterprise.) From OTN, click on “More Downloads,” “IOracle9i Database,” and “Oracle9i Database Release 2 Enterprise/Standard Edition for Linux.” Then confirm you’re not using the database to support terrorists, and download the three gzip archives to a temporary directory on your hard disk.

(Yes, that’s right. you just downloaded software worth potentially “millions” of dollars for free. Sure, Oracle requires a license, but you just downloaded the full version. Why do they let you do it? Well, that’s the trick. Oracle is essentially unusable without full vendor support. Without the use of the Oracle Metalink and the ability to create Technical Action Requests (TARs) with Oracle support, you will absolutely run into unmanageable problems within a month or two. Even the most astute Oracle DBA needs to submit TARs once in a while.)

If you happen to have a Customer Support Identifier (CSI) from Oracle, sign up for Metalink right now. Metalink is the most authoritative Oracle resource on the web. Oracle Metalink can be found at http://metalink.oracle.com.

Step 3: Uncompress the CD Images

To uncompress the Oracle CD images, change to the directory where you saved the tarballs, and type the following:


$ gunzip ship_9204_linux_disk1.cpio.gz
$ gunzip ship_9204_linux_disk2.cpio.gz
$ gunzip ship_9204_linux_disk3.cpio.gz
$ cpio -idmv < ship_9204_linux_disk1.cpio
$ cpio -idmv < ship_9204_linux_disk2.cpio
$ cpio -idmv < ship_9204_linux_disk3.cpio

This should create three directories named Disk1, Disk2, and Disk3.

Step 4: Create and Configure the Oracle User and Environment

There are quite a few pre-installation steps to follow before touching those CDs: the oracle user must be created, the environment must be configured, and kernel parameters must be set.

First, create the dba group and the oracle user:


$ groupadd dba
$ useradd -g dba oracle
$ passwd oracle
Pick a password
$ chfn oracle
Change as you like

Next, create oracle’s environment. Assuming oracle‘s shell is bash, a typical .bash_profile is shown in Listing One.




Listing One: A useful environment for the privileged oracle user

## glibc library compat
export LD_ASSUME_KERNEL=2.4.19

## BEGIN ORACLE SPECIFIC VARIABLES
# Set this parameter to whatever you like.
# It will be the instance name of your new database.
ORACLE_SID=aardvark

# You are the oracle user, thus “oracle”.
ORACLE_OWNER=oracle

# This fits our version of the Optimal Flexible
Architecture.
# A fancy way to say “put all your files in
these directories.”
ORACLE_BASE=/u01/app/oracle

# Again, this fits with our OFA.
ORACLE_HOME=$ORACLE_BASE/product/9i

export ORACLE_HOME ORACLE_OWNER ORACLE_SID
ORACLE_BASE SH_LIB_PATH=$ORACLE_HOME/lib
LD_LIBRARY_PATH=$ORACLE_HOME/lib:$ORACLE_HOME/
ctx/lib:/usr/lib:/usr/local/lib:.
TNS_ADMIN=$ORACLE_HOME/network/admin
export SH_LIB_PATH LD_LIBRARY_PATH TNS_ADMIN
PATH=$ORACLE_HOME/bin:$PATH
export PATH
CLASSPATH=.:$ORACLE_HOME/jdbc/lib/classes111.zip;
export CLASSPATH
ORA_NLS33=$ORACLE_HOME/ocommon/nls/admin/data;
export ORA_NLS33
NLS_LANG=american; export NLS_LANG
## END ORACLE SPECIFIC VARIABLES

For more information on these settings, consult the Oracle 9i online documentation at http://otn.oracle.com/documentation/oracle9i.html and the Oracle 9i Install Guide at http://download-east.oracle.com/docs/html/B13670_01/toc.htm.

Step 5: Set the User and Kernel Environment

There’s a Red Hat way and a non-Red Hat way to configure ulimits, semaphores, and memory. The script shown in Listing Two is the non-Red Hat way, which is more portable and works on Red Hat nonetheless.




Listing Two: A distribution-independent script to set suitable kernel parameters for Oracle

## BEGIN ORACLE KERNEL PARAMETERS
# semaphore settings
echo 250 32000 100 100 > /proc/sys/kernel/sem

# maximum shared memory
echo 2147483648 > /proc/sys/kernel/shmmax

# maximum shared memory segments for system
echo 4096 > /proc/sys/kernel/shmmni

# maximum shared memory for system
echo 2097152 > /proc/sys/kernel/shmall

# maximum open file handles
echo 65536 > /proc/sys/fs/file-max

# available port range
echo 1024 65000 > /proc/sys/net/ipv4/ip_local_port_range

# maximum number of user processes
ulimit -u 16384

# maximum number of open user files
ulimit -n 65536

## END ORACLE KERNEL PARAMETERS

Step 6: Create the Oracle Directory Skeleton

If you prefer, you can create these directories somewhere else and create soft-links from /u01 and /u02. It’s a good idea to keep the logical directory structure static even when the physical structure differs.


$ mkdir /u01 /u02
$ chown -R oracle:dba u01
$ chown -R oracle:dba u02

Step 7: Install the Compatibility RPMs from Red Hat

Grab the following RPMs from the Red Hat errata site at https://rhn.redhat.com: compat-egcs, compat-libs, and compat-glibc. Then install the libraries as root, using:


# rpm -Uvh compat*.rpm

Other Linux distributions may need equivalent libraries to proceed with installation.

Step 8: Configure Remote X

Login to your host as the oracle user and run /usr/bin/X11/xclock to confirm that X is working properly. A little clock should pop up.

If not, and you’re installing locally, you have some work to do! (Debugging X is beyond the scope of the article.) If you’re installing remotely, you have a couple of options. One is to configure remote X, export your DISPLAY, and install a local X server. This is a bad idea, because it’s horribly slow. In some cases, it takes ten seconds for a click to register.

VNC is definitely the way to go. Red Hat comes with VNC pre-installed, just login as oracle and type vncserver. The script prompts for a password, and then emits something like the following:


New ‘yourhost.yourdomain.net:1 (oracle)’
desktop is yourhost.yourdomain.net:

Starting applications specified in
/home/oracle/.vnc/xstartup

Log file is
/home/oracle/.vnc/yourhost.yourdomain.net
:1.log

This means that VNC is now running. Start a VNC client on your desktop and connect to your machines via yourhost. yourdomain.net:1.

For more information on VNC, visit RealVNC at http://www.realvnc.com, TightVNC at http://www.tightvnc.com, or Ultr@VNC at http://ultravnc.sourceforge.net.

Step 9: Install Oracle

To begin, either start X locally or login to VNC as oracle. Open an xterm and change to the Disk1 subdirectory created in Step 3.

Next, run ./runInstaller. A pretty GUI pops up. This is called the Oracle Universal Installer (OUI). The OUI is a full-featured GUI installer that’s very intuitive to use. Here’s how to proceed with the GUI:

1. Under “File Locations,” name your Oracle home. This can be whatever you like, say something descriptive like “home9i.”

(You can install multiple Oracle homes on the same machine. This is very useful for running different patch-sets simultaneously to test revisions.)

2. When prompted to select a product to install, select “Oracle 9i Database 9.2.0.4.0″ followed by “Custom.” Always use “Custom,” as it’s a good idea to never trust the manufacturer’s settings. You know your environment best.

3. Next, you’re presented with a horde of checkboxes. Uncheck “Oracle Advanced Security 9.2.0.1.0″ and “Legato Networker Single Server 6.1.0.0.0″ under “Enterprise Edition Options 9.2.0.1.0″ and uncheck “Enterprise Manager Web Site” and “Oracle Manager Server” under “Oracle Enterprise Manager Products 9.2.0.1.0.” Also uncheck the root of “Oracle HTTP Server 9.2.0.1.0.”

4. Next, set the OSDBA and OSOPER groups to dba.

5. Skip the setup of a new database. You don’t want to create a new database using Oracle’s GUI tools. It’s better to physically create the database yourself. (Leave the GUI for Windows SQL Server.)

6. As the installer runs, you may be prompted twice to run a shell script named root.sh as root. Do so, and accept the defaults for any questions.

At the end of the installation, the installer automatically starts the Oracle Net Configuration Assistant. Just hit “Cancel.” This is another step that’s best performed by hand.

Step 10: Post-Installation Tasks: Create a Database Instance

If you’ve gotten this far, the Oracle binaries are properly installed and linked. It’s now time to create a database instance. Let’s call it aardvark.

Login as the oracle user and create directories to hold the data files, control files, “redo” logs, and archive logs:


$ mkdir /u01/oradata
$ mkdir /u01/oradata/aardvark
$ mkdir /u02/oradata
$ mkdir /u02/oradata/aardvark
$ mkdir /u02/oradata/aardvark/arch
$ chown -R oracle:dba /u01
$ chown -R oracle:dba /u02

Now that the directories have been created, it’s time to configure the instance. An Oracle instance has several prerequisites. The first is an initSID.ora (or spfileSID.ora) file. This file contains all of the configuration data for the database instance. It is located in $ORACLE_HOME/dbs/initSID.ora. (The spfileSID.ora is basically the same thing, but is logically located within the database instance itself.) For this example, create the instance file shown in Listing Three.




Listing Three: An Oracle instance file


#### BEGIN INITAARDVARK.ORA ####

# This parameter allows you to login remotely as SYSDBA
remote_login_passwordfile = exclusive

# Directory specified for background dumps,
tracefiles, and the alert log
background_dump_dest = /u01/app/oracle/admin/aardvark/bdump

# Use all features as of oracle 9.2.0.4, ie,
the version we’re running.
compatible = 9.2.0.4.0
# location of controlfiles
control_files = (/u01/oradata/aardvark/control01.ctl,
/u02/oradata/aardvark/control02.ctl)

# Directory specified for core dumps
core_dump_dest = /u01/app/oracle/admin/aardvark/cdump

# The size of each database block in bytes.
db_block_size = 8192

# Size of default (8192 byte) buffer pool in megabytes
db_cache_size = 200M

# Number of blocks to be read each I/O
db_file_multiblock_read_count = 32

# Maximum number of files allowed
db_files = 1022

# Database name
db_name = aardvark
dml_locks = 500
global_names = FALSE

# Number of DBMS_JOBS that can be run.
job_queue_processes = 4

# The archive log destination.
log_archive_dest_1 =
“LOCATION=/u02/oradata/aardvark/arch/”
log_archive_format = aardvark_%S.ARC

# At least 1 archive log destination must be OK
for the instance to continue
# processing transactions.
log_archive_min_succeed_dest = 1

# Archiving is on
log_archive_start = TRUE
log_buffer = 512000
max_dump_file_size = 1024000
open_cursors = 2000
open_links = 128
optimizer_index_caching = 95
optimizer_index_cost_adj = 5
optimizer_mode = CHOOSE
parallel_max_servers = 8
parallel_min_servers = 0

# 100 user processes will be started
processes = 100
service_names = aardvark
session_cached_cursors = 100
java_pool_size = 50M
shared_pool_size = 100M
sort_area_size = 1048576
timed_statistics = TRUE

# We are using the 9i UNDO feature rather than the 8i and below rollback
# segments
undo_management = AUTO

# The name of the default undo tablespace is “undo”
undo_tablespace = undo
undo_suppress_errors = true
user_dump_dest = /u01/app/oracle/admin/aardvark/udump

#### END INITAARDVARK.ORA ####

Now you must create an Oracle password (orapwd) file, which allows for remote logins using the SYSDBA privilege. Run the following:


$ cd $ORACLE_HOME/dbs
$ orapwd file=orapwdaardvark.ora password=yourpass
entries=25

Next, the directories specified in your initSID.ora must be created:


$ mkdir /u01/app/oracle/admin
$ mkdir /u01/app/oracle/admin/aardvark
$ mkdir /u01/app/oracle/admin/aardvark/bdump
$ mkdir /u01/app/oracle/admin/aardvark/cdump
$ mkdir /u01/app/oracle/admin/aardvark/udump

Now, you need to create the instance. Log in to the idle Oracle instance as the superuser sysdba. At the bash prompt and as the oracle user, type:


$ export ORACLE_SID=aardvark
$ sqlplus “/ as sysdba”

At the SQL prompt, run…


startup nomount

… and you should see the following output:


SQL startup nomount
ORACLE instance started.

Total System Global Area 437249364 bytes
Fixed Size 451924 bytes
Variable Size 218103808 bytes
Database Buffers 218103808 bytes
Redo Buffers 589824 bytes

Congratulations! The instance has been started. Now the database needs to be created.

Paste the statements found in Listing Four at the SQL prompt. The first part takes a few minutes to run, and the four scripts at the end take twenty to forty minutes (depending on machine speed) to finish.




Listing Four: Creating a database

— BEGIN CR_AARDVARK.SQL

–SCRIPT TO CREATE THE aardvark DATABASE INSTANCE, TABLESPACES, AND USERS

SPOOL cr_aardvark.log
CREATE DATABASE aardvark
controlfile reuse
LOGFILE
GROUP 1 (‘/u01/oradata/aardvark/REDO0101.ORA’) SIZE 25M reuse,
GROUP 2 (‘/u01/oradata/aardvark/REDO0201.ORA’) SIZE 25M reuse,
GROUP 3 (‘/u01/oradata/aardvark/REDO0301.ORA’) SIZE 25M reuse,
GROUP 4 (‘/u01/oradata/aardvark/REDO0401.ORA’) SIZE 25M reuse
MAXDATAFILES 1022
ARCHIVELOG
DATAFILE ‘/u02/oradata/aardvark/SYSTEM01.ORA’ SIZE 200M EXTENT MANAGEMENT LOCAL
DEFAULT TEMPORARY TABLESPACE TEMP1
TEMPFILE ‘/u02/oradata/aardvark/temp1_01.dbf’ SIZE 100M AUTOEXTEND ON NEXT 10M MAXSIZE 2000M
UNDO TABLESPACE undo DATAFILE ‘/u02/oradata/aardvark/undo01.dbf’
SIZE 100M AUTOEXTEND ON NEXT 10M MAXSIZE 2000M;

CREATE TABLESPACE users
DATAFILE ‘/u02/oradata/aardvark/users01.dbf’ SIZE 50M REUSE AUTOEXTEND ON NEXT 5M MAXSIZE 1000M
EXTENT MANAGEMENT LOCAL UNIFORM SIZE 256K SEGMENT SPACE MANAGEMENT AUTO;

CREATE TABLESPACE tools
DATAFILE ‘/u02/oradata/aardvark/tools01.dbf’ SIZE 50M REUSE AUTOEXTEND ON NEXT 5M MAXSIZE 1000M
EXTENT MANAGEMENT LOCAL UNIFORM SIZE 256K SEGMENT SPACE MANAGEMENT AUTO;

CREATE TABLESPACE data
DATAFILE ‘/u02/oradata/aardvark/data01.dbf’ SIZE 10M REUSE AUTOEXTEND ON NEXT 10M MAXSIZE 2000M
EXTENT MANAGEMENT LOCAL UNIFORM SIZE 1M SEGMENT SPACE MANAGEMENT AUTO;

CREATE TABLESPACE 0
DATAFILE ‘/u02/oradata/aardvark/indx01.dbf’ SIZE 10M REUSE AUTOEXTEND ON NEXT 10M MAXSIZE 2000M
EXTENT MANAGEMENT LOCAL UNIFORM SIZE 1M SEGMENT SPACE MANAGEMENT AUTO;

alter user system temporary tablespace temp1;
alter user system default tablespace tools;
SPOOL OFF
SPOOL cr_aardvark_cats.log
@?/rdbms/admin/catalog
@?/rdbms/admin/catproc
@?/rdbms/admin/catrep
connect system/manager
@?/sqlplus/admin/pupbld
SPOOL OFF
— END CR_AARDVARK.SQL

Step 11: Configure the tnsnames.ora File

The Oracle tnsnames.ora file is analogous to /etc/hosts for DNS: it allows Oracle utilities to connect over TNS to remote services. The tnsnames.ora file is located in $ORACLE_HOME/ network/admin/tnsnames.ora.

Edit your tnsnames.ora to make it like something like Listing Five (making adjustments for your own local area network).




Listing Five: A sample tnsnames.ora file

# BEGIN TNSNAMES.ORA
AARDVARK =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST =
192.168.1.15)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = aardvark)
)
)
# END TNSNAMES.ORA

Listing Five defines a TNS entry for a service named aardvark listening on 192.168.1.15 on port 1521.

Step 12: Configure the listener.ora File

The Oracle network component is entirely separate from the database server itself. It listens for TNS connections and talks to the database locally over inter-process communication (IPC). The listener.ora file is located in $ORACLE_HOME/network/ admin/listener.ora. For this example, edit the file with:


vi $ORACLE_HOME/network/admin/listener.ora

Here are the contents of this file:


# BEGIN LISTENER.ORA
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST =
192.168.1.15)(PORT = 1521))
)
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = IPC)
(KEY = EXTPROC))
)
)
)
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(SID_NAME = PLSExtProc)
(ORACLE_HOME = /u01/app/oracle/
product/9i)
(PROGRAM = extproc)
)
(SID_DESC =
(GLOBAL_DBNAME = aardvark)
(ORACLE_HOME = /u01/app/oracle/
product/9i)
(SID_NAME = aardvark)
)
)
# END LISTENER.ORA

Step 13: Start the Listener

You created a non-named listener in Step 11, so you can start it simply by typing lsnrctl start.

Step 14: Test Listener and Connectivity

You have several tools at your disposal to test the listener. The first is tnsping. Try this out by typing tnsping aardvark. Additionally, you can connect to the listener remotely via SQL*PLUS by typing sqlplus system/manager@aardvark.

A Database In Your Future…

Congratulations! You just successfully installed Oracle Enterprise 9.2.0.4, created a database instance, and configured the TNS by hand.

This is only the tip of the iceberg, but you’ve now constructed a solid foundation to build your knowledge as a database administrator using an enterprise grade database on Linux. Or, perhaps you’re a systems administrator who can now share a DBA’s role.

Whatever the case, the skills required to install and maintain an Oracle database environment on Linux are highly desirable, especially within Fortune 1000 companies looking to save money and increase productivity.




Why Not Oracle on Linux?

There are a number of issues when running Oracle on Linux, but they all boil down to two factors: driver support and vertical scalability.

As you may find in your Oracle exploits, drivers created and supported by hardware vendors themselves often do not work correctly, causing kernel panics and data corruption. Before investing in a line of Linux servers, read and post in the hardware vendor’s customer forums and mailing lists. Even if you’re familiar with running other types of servers on Linux hardware, Oracle can cause faults that never happen with, say, Apache, even when Apache is under heavy load. Oracle can be a wild beast if not tamed at early stages.

Every major new Linux kernel release promises vertical scalability improvements. They do exist, but they just don’t match commercial solutions like Solaris or AIX (yet). As you begin to add CPUs and RAM to Linux hosts, performance increases, yet stability degrades.

The CPU scaling issue is ameliorated at the low-end to middle by fast and cheap Intel Xeons and AMD Opterons. For the money, take two 2.4 Ghz Opterons over four 1.06 Ghz UltraSPARCs any day of the week.




Sam Schlansky is a Senior Oracle and MySQL DBA at IPsoft and can be reached atIsam.schlansky@ip-soft.net. Michael Bordash is Linux Magazine’s “LAMP Post” columnist, and is an open-source integration specialist at IPsoft. Michael can be reached at michael.bordash@ip-soft.net. You can download the source code used in this article from http://www.linux-mag.com/downloads/2004-09/oracle.

Comments are closed.