Installing and Configuring Oracle9i on the Linux Platform

by Robert Townsend and Roger Schrag
Database Specialists, Inc.

About Database Specialists, Inc.
Database Specialists, Inc. provides remote DBA services and onsite database support for your mission critical Oracle systems. Since 1995, we have been providing Oracle database consulting in Solaris, HP-UX, Linux, AIX, and Windows environments. We are DBAs, speakers, educators, and authors. Our team is continually recognized by Oracle, at national conferences and by leading trade publications. Learn more about our remote DBA, database tuning, and consulting services. Or, call us at 415-344-0500 or 888-648-0500.

Introduction

This paper will walk you through the steps of installing Oracle9i release 2 (Oracle version 9.2.0) in a Linux environment. About 90% of the material presented here applies to other platforms as well. Everything you read in this document is hands on, roll-up-your-sleeves-and-get-busy material for Oracle users who want to get an Oracle database up and running quickly and want the database to be scalable and to perform well.

These steps are meant to get you up and running as fast as possible, while leveraging best practices in order to set up a scalable, robust database environment that offers high performance. In order to keep the steps reasonably simple, this paper does not cover Real Application Clusters (RAC), nor does it cover Oracle Internet Directory or Oracle Management Server installation.

For our installations we used the Oracle 9.2.0.4 release. This is Oracle9i release 2 with the 9.2.0.4 patchset bundled in. If you use the 9.2.0.1 release instead (the initial release of Oracle9i release 2 without any patchsets), you may encounter some glitches that will be resolved when you apply a 9.2.0.4 or later patchset.

We ran our Oracle installations on an Intel x86 server running Red Hat Enterprise Linux ES release 3. Oracle9i installation is supported on other Linux distributions as well. Note that with Red Hat Enterprise Linux, the ES and AS varieties are supported while WS is not. The conventional wisdom is that Oracle9i installs more easily on Red Hat Enterprise Linux release 2.1, but you should not have problems using release 3 if you follow all of the steps listed here.

There are four phases to getting Oracle up and running on your server:

  1. Prepare the server
  2. Install the Oracle software and create a starter database
  3. Fine tune the starter database (optional)
  4. Complete the server configuration
We will walk through these phases one at a time, detailing all the steps involved. The end result will be a very usable database that can be scaled up quite large. Of course, every implementation is unique, and you will need to evaluate each step carefully against your particular requirements. However, this paper will get you off to a very solid start.

Prepare the Server

These steps configure your database server so that it will be ready to accept the Oracle software and database. In this section, we will make sure your server meets Oracle's minimum requirements, create a Linux user and group to "own" the software, and create some directories that will be used by the Oracle software and database. All of the steps in this section are run as the root user.

  1. Make sure that your Linux distribution is certified by Oracle Corporation for use with Oracle9i. As of April 2004, the supported Linux distributions are as follows:

    Supported Linux Distributions for Oracle9i Release 2
    Red Hat Enterprise Linux AS/ES 3
    Red Hat Enterprise Linux AS/ES 2.1
    SuSE SLES8
    SuSE SLES7
    United Linux 1.0 SP3
    RedFlag DC Server 4.0 (China and Hong Kong only)
    Monta Vista Carrier Grade Linux 3.0 (embedded only)
    Miracle Linux Standard Edition 2.1 (Japan only)

  2. Some steps of preparing your server for Oracle will vary depending on which Linux distribution you are using. If you are using Red Hat Enterprise Linux AS or ES release 2.1 or 3, then you should review Metalink bulletin 225710.1 to verify that your kernel will be supported by Oracle. Basically, for Red Hat Enterprise Linux AS or ES release 2.1, you should use kernel 2.4.9-e.12 or higher, and for release 3 you should use kernel version 2.4.21-4.EL or higher.

    If you are running Red Hat Enterprise Linux AS or ES release 3, you also need to perform the following steps (as listed in Metalink bulletin 252217.1):

    1. Make sure that the following software packages have been installed. Do not worry if you have a newer version of a package than is listed here.

      Required Packages
      compat-db-4.0.14-5
      compat-gcc-7.3-2.96.122
      compat-gcc-c++-7.3-2.96.122
      compat-libstdc++-7.3-2.96.122
      compat-libstdc++-devel-7.3-2.96.122
      openmotif21-2.1.30-8
      setarch-1.3-1

      You can use the following command to see if these packages are installed, and what version they are:

              $ rpm -q compat-db compat-gcc compat-gcc-c++ compat-libstdc++ \
                       compat-libstdc++-devel openmotif21 setarch

      If you are missing a package, you may download and install it with the up2date command. For example:

              $ up2date -i compat-db
    2. Oracle requires the older version of the gcc and g++ compilers for linking. One easy way to ensure that the correct gcc and g++ are used is to run commands like the following:
              $ mv -i /usr/bin/gcc /usr/bin/gcc323
              $ mv -i /usr/bin/g++ /usr/bin/g++323
              $ ln -s /usr/bin/gcc296 /usr/bin/gcc
              $ ln -s /usr/bin/g++296 /usr/bin/g++

      You will probably want to reverse this step after the Oracle installation is complete. You can verify which version of gcc or g++ is on your path with the following commands:

              $ gcc -v
              $ g++ -v
    3. Download and apply patch 3006854 from Metalink. This patch places two small files in the /etc directory on the database server, and the Oracle installer will not start without this patch.

  3. You will need to perform the installation from an X window environment. You cannot perform the installation from a character mode environment such as a telnet or ssh session. There is a facility for performing non-interactive installations ("silent" installs), but we won't be covering that technique here. Besides, it appears that even the silent install still needs access to X libraries. Your X environment can be the console on the database server, but it does not need to be. You can also use a Windows X emulator like Hummingbird Exceed, but see page 1-15 of the Oracle9i Installation Guide for UNIX (in the Oracle documentation set) for possible issues with Hummingbird Exceed. We ran the installation from the console of our database server, running Red Hat Enterprise Linux ES release 3.

  4. Make sure that your hardware is sufficient. You'll need at least 512 Mb RAM, a swap space of at least 1 Gb or equal to the amount of RAM (whichever is larger), and a bare minimum of 4 Gb of disk space. This will let you perform a typical Enterprise Edition software installation and create a starter database. A production implementation will almost always require more RAM and more disk space. Additionally, you will need close to 3200 Mb for copying and unpacking the distribution media should you choose to download the Oracle software instead of installing from CD ROM. The following commands will allow you to check RAM and swap space:
            $ grep MemTotal /proc/meminfo
            $ cat /proc/swaps
  5. Make sure that the following executables exist in the /usr/bin directory: make, ar, ld, and nm.

  6. Make sure that the Linux kernel has parameters set sufficiently high for Oracle. The Oracle architecture makes extensive use of shared memory segments for sharing data among multiple processes and semaphores for handling locking. Many operating systems, including Linux, do not by default offer sufficient shared memory or semaphores for maintaining an Oracle database. Thankfully, you can change kernel parameters in Linux simply by editing the /etc/sysctl.conf file and rebooting the server.

    Kernel ParameterSetting To Get
    You Started
    Purpose
    SHMMAX2147483648 Maximum size of a single shared memory segment
    SHMMIN1 Minimum size of a single shared memory segment
    SHMINI100 Maximum number of shared memory segments in entire system
    SEMMNS2000 Maximum number of semaphores in entire system
    SEMMSL250 Maximum number of semaphores per set
    SEMMNI100 Maximum number of semaphore sets in entire system
    SEMOPM250 Maximum number of operations per semop call
    SEMVMX32767 Maximum value of a semaphore

    The first three kernel parameters configure shared memory segments. The recommended settings shown here should be appropriate for almost any Oracle database implementation. The SHMMAX setting may seem excessive, but there is no penalty for setting SHMMAX larger than you actually need.

    The last five kernel parameters configure semaphores. Each Oracle instance requires one semaphore for each process, plus ten extras. Additionally, the largest instance requires a second semaphore for each process. If you will only be setting up one database on your server, the upshot is that you will need two semaphores for each process plus ten extras.

    The recommended settings for the first two semaphore kernel parameters, SEMMNS and SEMMSL, should be appropriate for most Oracle implementations. For systems with large numbers of concurrent database connections, you may need to increase these values. The recommended setting shown here for SEMMNI, SEMOPM, and SEMVMX should be appropriate for just about any Oracle database implementation.

    Use the following command to see the configuration of shared memory and semaphores currently in use:

            $ ipcs -lms

    In general, if your Linux kernel already has any of these parameters set larger than recommended here, you should not reduce the settings. If you do change any kernel parameter settings in /etc/sysctl.conf, then reboot the server so that the new settings will take effect.

    We added the following lines to the end of our /etc/sysctl.conf file:

            # Begin Oracle settings.
            #
            kernel.shmmax = 2147483648
            # Next line contains values for SEMMSL, SEMMNS, SEMOPM, and SEMMNI.
            # Note that our system's default settings were 250, 32000, 32, and 128.
            kernel.sem = 250 32000 250 128
            #
            # End Oracle settings.
  7. Create a Linux group that will be used by the Oracle software owner and database administrators. You can call it anything you like, but the standard is "dba". If you will be installing Oracle on multiple servers on your network, you might want to keep the groupid the same on all servers. You can create your dba group with a command like:
            $ groupadd -g 300 dba
  8. Create a Linux user that will be the Oracle software owner. You can call it anything you like, but the standard is "oracle". If you will be installing Oracle on multiple servers on your network, you might want to keep the userid the same on all servers. Note that this user's home directory will not be the ORACLE_HOME or where the actual Oracle software is installed; this user's home directory should be in the same place as other users' home directories. You should make dba the primary group. You can create your oracle user with commands like:
            $ useradd -c 'Oracle software owner' -d /home/oracle \
                      -g dba -m -u 300 -s /bin/bash oracle 
            $ passwd oracle
  9. Create a Linux group and user that will be used by the Apache HTTP listener integrated into the Oracle9i database. Running the Apache HTTP listener as the Oracle software owner or a member of the dba group can compromise security. You can call the group and user anything you like. At this time there seems to be no clear standard for what to call this group and user. You can create your group and user with commands like:
            $ groupadd -g 60300 apache
            $ useradd -c 'Oracle Apache user' -d /home/apache -g apache \
                      -m -u 60300 -s /bin/bash apache
            $ passwd apache
  10. Create mount points for the Oracle software and the Oracle database. Each mount point should correspond to a separate physical device or set of devices. You'll need at least one mount point. Typically you use one mount point for the Oracle software and as many as you can afford for each database. (More physical devices allow better performance.) A nice convention is to call the mount points /u01, /u02, and so on. Because mount points are typically owned by root and the Oracle installer will run as the oracle user and not root, you should create some subdirectories now to avoid permission problems later. Create an app subdirectory below the software mount point and oradata subdirectories below the mount points to be used for databases. (You can put software and a database on the same mount point if you wish.) Make these subdirectories owned by the oracle user and dba group, and give them 755 permissions.

  11. If you downloaded the Oracle software off of the Internet, then use gunzip and cpio to unpack the distribution. Use commands like:
            $ gunzip ship_9204_linux_diskN.cpio.gz
            $ cpio -idm < ship_9204_linux_diskN.cpio
    If you have the software on CD ROM, then mount the first CD ROM now.

Install the Oracle Software and Create a Starter Database

These steps install the Oracle software on your server and create a "starter" database. In this section, we will prepare the oracle user's environment, run the Oracle Universal Installer, and tidy up a few minor loose ends. All of the steps in this section, except where noted, are run as the oracle user.

  1. Edit the oracle user's login file on the database server so that the environment will be configured automatically on login. If you are using Bourne or Korn shell, then edit .profile. If you are using Bash, then edit the .bash_profile file. You can also use C shell and edit .cshrc, but the syntax will be different from the examples you see here. For now, we will hardcode certain things. But after the Oracle software is installed we will come back and eliminate all hardcodings. Here is what we added to our .bash_profile for the Oracle9i install:
            umask 022
            # Substitute your Oracle software mount point in the line below.
            export ORACLE_BASE=/u01/app/oracle 
            export ORACLE_HOME=$ORACLE_BASE/product/9.2.0
            # Substitute the name of your Oracle database below.
            export ORACLE_SID=dev920
            # Fill in the following line as you wish, but make sure that
            # $ORACLE_HOME/bin, /usr/bin, /bin, /usr/bin/X11/, and 
            # /usr/local/bin are all in the PATH (in that order).
            export PATH=...
            # Ensure that TWO_TASK is not set.
            unset TWO_TASK
            # Enable glibc optimizations (Red Hat Enterprise Linux 3 only).
            export LD_ASSUME_KERNEL=2.4.19
  2. Log out and log back in as the oracle user from an X window so that the environment is set correctly.

  3. Set your DISPLAY variable to the IP address or proper host name of your X server plus the X server and screen numbers. If you are working from a workstation (and not the console of the database server where you are installing Oracle) do not accidentally set the DISPLAY variable to the IP address of your database server. We set the DISPLAY variable as follows:
            export DISPLAY=192.168.1.6:0.0
  4. If you are not using the console of the database server, then ensure that the X server on your workstation will allow your database server to open windows on your display. The easiest way to do this is to issue an xhost command from a session on your workstation. (Don't get confused and issue the command in a window that is logged onto your database server.) You can issue a command like:
            xhost +192.168.1.6
  5. Use ftp to transfer a small file from your database server to a remote host to prove to yourself that TCP/IP networking is installed, configured, and working properly.

  6. Ensure that the mount point you plan to use for the Oracle software and starter database have sufficient free space. The starter database will be created entirely on one mount point. For an Enterprise Edition installation, allow 2.6 Gb for the software mount point and 1.4 Gb for the database mount point as bare minimums. If you are installing the Standard Edition of Oracle9i, you will need slightly less space.

  7. If you have an active installation of Oracle8i on the database server, then you should make a backup copy of the jre and oui directories under ORACLE_BASE. We found that installing Oracle9i overwrites the JRE and code used by the Oracle8i installer. This means that after you install Oracle9i, you might have difficulties using the Oracle8i tools (such as Database Configuration Assistant or Net8 Configuration Assistant) to manage your Oracle8i databases. After we installed Oracle9i, our Oracle8i tools continued to work properly. But according to postings on Metalink, other users were not as lucky.

  8. Double check that you are logged in as oracle and not root. Then change to your home directory and start the Oracle Universal Installer with these commands:
            $ cd
            $ <full path to first CD ROM>/runInstaller

    We'll walk through the installer prompts one at a time:

    1. The Welcome window appears. Click Next.
    2. If the Inventory Location window appears, verify that the base directory is set to the oraInventory subdirectory of the directory referenced by the ORACLE_BASE environment variable you set in the login script. Click OK. You won't see this window if you have previously installed Oracle software on the database server.
    3. If the Unix Group Name window appears, enter the name of your dba group and click Next. You won't see this window if you have previously installed Oracle software on the database server. If your /etc directory is not writable by the oracle user (which it probably isn't), you will be asked to run a short script as the root user to create an oraInst.loc file in /etc.
    4. The File Locations window appears. Leave the Source field unchanged. The Destination field will show the ORACLE_HOME value you set in your environment. Give your ORACLE_HOME a name if you like, and change the mount point if you don't like what you see. Click Next.
    5. The Available Products window appears. Choose Oracle9i Database and click Next.
    6. The Installation Types window appears. We will perform a "typical" install to get a basic set of Oracle software installed and a starter database. You can rerun the installer again later and choose Custom to install additional products individually. For now, choose Standard Edition or Enterprise Edition. The Enterprise Edition of Oracle9i has some very sophisticated features missing from Standard Edition, and the opportunity to purchase additional options that might be valuable to a large enterprise. However, the Enterprise Edition is much more expensive than Standard Edition. It is very important that you choose the edition that matches your license, as this will be difficult to fix later. (In preparing this paper we chose Enterprise Edition.) Click Next.
    7. The Database Configuration window appears. We will go the easy route here and choose a General Purpose database and click Next. Alternatively, you could choose Customized and tailor the starter database to your own specifications. Or you could choose Software Only and not create a starter database at all. (You can always run the Database Configuration Assistant later to create, drop, or reconfigure databases.)
    8. If you have any existing Oracle databases on your server that are at a version prior to what you are now installing, the installer will ask if you would like to run the Database Upgrade Assistant at the end of the installation to migrate or upgrade these older databases to the current version. Make your decision and click Next. (We won't be covering the Database Upgrade Assistant here.)
    9. The Database Identification window appears. You need to specify both a global database name and an SID (instance name) for the starter database that will be created. The SID will default to the setting of the ORACLE_SID environment variable, but you can override it here if you wish. You should give your database a global name that is the same as the SID, with your domain name appended. Click Next.
    10. The Database File Location window appears. Enter the name of one of the mount points you chose for holding your database, followed by "/oradata". For example, if your mount point is called /u02, then enter /u02/oradata. The starter database will have all of its files in one directory under this mount point. This may or may not be a good design for high performance and availability, but it is fine for a starter database. Click Next.
    11. The Database Character Set window appears. Choose the Unicode character set (AL32UTF8) or another character set from the dropdown list if you prefer not to use Unicode. Note that AL32UTF8 complies with the Unicode 3.1 standard, while the UTF8 character set used in Oracle8i complies with the older Unicode 2.0 standard. Click Next.
    12. The Summary window appears. Review all of the selections you have made to confirm they are correct. Click Install.
    13. If you are installing from CD ROM, you'll be prompted to mount the second and third CD ROMs at various points during the install. Use a separate window to eject the current CD ROM and mount the next.
    14. During the installation a Setup Privileges window will appear. (The installation process took about 20 minutes to get to this point on our server.) The installation will be paused at this point, waiting for you to run a script as root. The script will be called root.sh and can be found in the ORACLE_HOME directory. You should open another window, log in to the database server as root, review the root.sh script thoroughly, run the script, and click OK in the Setup Privileges window.
    15. A Configuration Tools window appears a minute later and the Oracle Net Configuration Assistant launches to configure networking so that your database will be able to accept requests from remote clients. No action is required on your part, and this step completes quickly.
    16. The Database Configuration Assistant launches to create a starter database. A progress window will show you how the database creation is going. Although this step ran fine on our server, the progress window updated very infrequently and gave the appearance the process was hung. (It pays to be patient.) Database creation took about five minutes on our server, but will take substantially longer if you chose a customized database configuration. When database creation is complete, a window will appear telling you that most user accounts on the database have been locked and that you must change the passwords for the SYS and SYSTEM database users. You may enter the new passwords and click OK. Alternatively, you may click the Password Management button and unlock accounts and set passwords for all database users as you wish.
    17. The Agent Configuration Assistant launches to configure Oracle's "intelligent agent", a monitoring and job-running agent that you control through Oracle's Enterprise Manager tool. No action is required on your part, and this step completes quickly. If the Agent Configuration Assistant does not complete successfully, then you are probably encountering one of a few known bugs in the intelligent agent's make file. We will address this problem in a later step.
    18. The Apache HTTP listener will now start. No action is required on your part, and this step completes quickly.
    19. The End of Installation window appears. You may click Exit to exit the installer or Next Install to begin another installation. You might click Next Install, for example, to perform a custom installation to install individual products that did not get installed as part of the "typical" installation—such as Pro*C/C++.
    20. It is important to note that the default Enterprise Edition install loads certain extra cost options, such as table partitioning, onto your database server. If you are not licensed to use these options, then you should deinstall them. To deinstall products, click the Deinstall Products button on the Welcome window.
    21. Exit the installer when you have completed installations and deinstallations.

  9. If you want to be able to use the intelligent agent but the Agent Configuration Assistant did not run successfully during the Oracle installer session, then you will need to apply Oracle patches. If you have installed release 9.2.0.1 of the Oracle9i software, then we encourage you to apply the most recent patchset available. If you have installed release 9.2.0.4 of the Oracle9i software (or applied the 9.2.0.4 patchset on top of release 9.2.0.1), then do the following:

    1. Go to Metalink and download patches 2617419 and 3238244. The first patch is really just a tool used to apply the second patch.
    2. Unzip the two patch files.
    3. Locate the directory containing a file called "opatch" in the area where you unzipped patch 2617419. Put this directory, and /sbin onto your path with a command like:
              $ PATH=$PATH:/home/oracle/patches/2617419/OPatch:/sbin
    4. Go to the directory where you unzipped patch 3238244.
    5. Run the following command to shut down the Oracle database:
              $ sqlplus /nolog
              SQL> CONNECT / AS SYSDBA
              SQL> SHUTDOWN
              SQL> EXIT
    6. Run the following command to apply patch 3238244:
              $ opatch apply
    7. Relink the intelligent agent with the following commands:
              $ cd $ORACLE_HOME/network/lib 
              $ make -f ins_oemagent.mk install
    8. Restart the database:
              $ sqlplus /nolog
              SQL> CONNECT / AS SYSDBA
              SQL> STARTUP
              SQL> EXIT
    9. Start the intelligent agent:
              $ agentctl start

  10. In $ORACLE_HOME/bin you will find a shell script called oraenv. This script can be called from .profile or .bash_profile to set up a user's environment. Unfortunately, there are a few variables that the script does not set—some handy, some very important. Make a backup copy of the script and then edit it, adding the following lines to the very end:
            # Begin customizations
            ORACLE_BASE=`dirname $ORACLE_HOME`
            ORACLE_BASE=`dirname $ORACLE_BASE`
            DBA=$ORACLE_BASE/admin
            # Substitute the database character set you chose in following line.
            NLS_LANG=american_america.AL32UTF8
            export ORACLE_BASE DBA NLS_LANG
            # End customizations
  11. In the same directory, you'll also find a shell script called coraenv that can be called from .cshrc. If you use C shell, you will want to back up and edit coraenv with similar changes to the oraenv script.

  12. The root.sh script copied oraenv and coraenv from $ORACLE_HOME/bin to /usr/local/bin. You just updated these scripts in $ORACLE_HOME/bin. Copy the updated versions to /usr/local/bin.

  13. In $ORACLE_HOME/bin you'll find a script called dbstart. This is a utility that you can run to start up databases on the server. Later we will add a call to this script from /etc/rc.d/init.d/dbora so that the databases start up automatically whenever the server reboots. Unfortunately, the dbstart script has a bug that will cause it to fail with the error message "Can't find init file for Database" in certain situations. One way to fix this bug is to add the following line immediately after line 55:
            SPFILE=${ORACLE_HOME}/dbs/spfile${ORACLE_SID}.ora
    and change line 117 to read:
            if [ -f $PFILE -o -f $SPFILE ] ; then
  14. In $ORACLE_HOME/bin you'll find a script called dbshut. This is a utility that you can run to shut down databases on the server. Unfortunately, it shuts down databases with normal priority. This means that if any users are logged into a database, the shutdown will hang until they log out. You might want to change this script to shut down databases with immediate priority. To do this, find the lines in the script that contain just the word "shutdown". Change these to read "shutdown immediate".

Fine Tune the Starter Database

These steps modify the configuration of the starter database to tailor it to your needs and to make it better comply with industry-proven best practices. You can skip this entire section if initially you just want to work with the starter database as is. In this section, we will change configured database options, adjust file locations and server parameters, create application users and tablespaces, and configure Oracle Net. All of the steps in this section are run as the oracle user.

  1. Set up your environment the same way you did when you ran the Oracle installer: Log in as the oracle user on the database server from an X window. Set your DISPLAY variable appropriately. Make sure that your ORACLE_HOME, PATH, and other variables are set correctly based on your login file.

  2. You may run the Database Configuration Assistant to configure database options that were not pre-configured in the starter database, or remove options that were included in the starter database which you don't need. Launch the Database Configuration Assistant with the following commands:
            $ cd $ORACLE_HOME/bin
            $ ./dbca
    Choose to configure an existing database and select your starter database from the list. You will be presented with a list of database options. The options that are checked have already been configured in the database. Add a check mark beside those options you wish to add, and uncheck those options which you wish to remove. Note that some options will be grayed out. This can happen for three reasons:

    1. The option has already been configured in the database and cannot be removed once configured. In this situation you could choose to delete the entire database and create a new one with only the options you wish.
    2. Software products required to support the database option have not been installed. Run the Oracle Universal Installer again and install the appropriate products before trying to configure the option in the database.
    3. The option is only available with the Enterprise Edition and you have installed the Standard Edition software.

  3. The starter database comes with 100 Mb online redo logs. These might be much larger than you need. You cannot resize online redo logs, but you can drop and recreate them with commands like:
            $ sqlplus /nolog
            SQL> CONNECT / AS SYSDBA
            SQL> ALTER DATABASE DROP LOGFILE '/u02/oradata/dev920/redo01.log';
            SQL> HOST rm -i /u02/oradata/dev920/redo01.log
            SQL> ALTER DATABASE ADD LOGFILE GROUP 1 
              2  '/u02/oradata/dev920/redo01.log' SIZE 10m;
            SQL> ALTER DATABASE DROP LOGFILE '/u02/oradata/dev920/redo02.log';
            SQL> HOST rm -i /u02/oradata/dev920/redo02.log
            SQL> ALTER DATABASE ADD LOGFILE GROUP 2 
              2  '/u02/oradata/dev920/redo02.log' SIZE 10m;
            SQL> ALTER DATABASE DROP LOGFILE '/u02/oradata/dev920/redo03.log';
            SQL> HOST rm -i /u02/oradata/dev920/redo03.log
            SQL> ALTER DATABASE ADD LOGFILE GROUP 3 
              2  '/u02/oradata/dev920/redo03.log' SIZE 10m;
    Do not answer an rm prompt affirmatively unless the corresponding ALTER DATABASE DROP LOGFILE command completed successfully without an error message. If you get an error that a log file is in use when you try to drop it, switch the database to the next online redo log with the commands:
            SQL> ALTER SYSTEM SWITCH LOGFILE;
            SQL> ALTER SYSTEM CHECKPOINT;
  4. The starter database has all data files and online redo logs in the same directory. If you would like to move any of these files to another directory, use commands like the following:
            $ sqlplus /nolog
            SQL> CONNECT / AS SYSDBA
            SQL> SHUTDOWN IMMEDIATE
            SQL> STARTUP MOUNT
            SQL> HOST mv -i /u02/oradata/dev920/users01.dbf /u03/oradata/dev920/users01.dbf
            SQL> ALTER DATABASE RENAME FILE
              2  '/u02/oradata/dev920/users01.dbf' TO
              3  '/u03/oradata/dev920/users01.dbf';
            SQL> HOST mv -i /u02/oradata/dev920/redo01.log /u03/oradata/dev920/redo01.log
            SQL> ALTER DATABASE RENAME FILE
              2  '/u02/oradata/dev920/redo01.log' TO
              3  '/u03/oradata/dev920/redo01.log';
            SQL> ALTER DATABASE OPEN;
    Note that this procedure does not work for control files. Relocating database control files will be covered in a later step.

  5. In the starter database, all data files have the "auto-extend" feature turned on. This means that when a data file becomes full, it will automatically grow larger as needed. The problem with this is that an application can get out of control and fill up an entire disk partition. It also means that you need to manage your free space at the operating system level. Many DBAs prefer to manage free space at the database level by pre-allocating space to data files and not using the auto-extend feature. You may resize data files and disable auto-extend with commands like:
            $ sqlplus /nolog
            SQL> CONNECT / AS SYSDBA
            SQL> ALTER DATABASE DATAFILE '/u02/oradata/dev920/system01.dbf' AUTOEXTEND OFF;
            SQL> ALTER DATABASE DATAFILE '/u02/oradata/dev920/undotbs01.dbf' AUTOEXTEND OFF;
            SQL> ALTER DATABASE DATAFILE '/u02/oradata/dev920/cwmlite01.dbf' AUTOEXTEND OFF;
            SQL> ALTER DATABASE DATAFILE '/u02/oradata/dev920/drsys01.dbf' AUTOEXTEND OFF;
            SQL> ALTER DATABASE DATAFILE '/u02/oradata/dev920/example01.dbf' AUTOEXTEND OFF;
            SQL> ALTER DATABASE DATAFILE '/u02/oradata/dev920/users01.dbf' AUTOEXTEND OFF;
            SQL> ALTER DATABASE DATAFILE '/u02/oradata/dev920/indx01.dbf' AUTOEXTEND OFF;
            SQL> ALTER DATABASE DATAFILE '/u02/oradata/dev920/tools01.dbf' AUTOEXTEND OFF;
            SQL> ALTER DATABASE DATAFILE '/u02/oradata/dev920/odm01.dbf' AUTOEXTEND OFF;
            SQL> ALTER DATABASE DATAFILE '/u02/oradata/dev920/xdb01.dbf' AUTOEXTEND OFF;
            SQL> ALTER DATABASE TEMPFILE '/u02/oradata/dev920/temp01.dbf' AUTOEXTEND OFF;
            SQL> ALTER DATABASE DATAFILE '/u02/oradata/dev920/system01.dbf' RESIZE 500m;
            SQL> ALTER DATABASE TEMPFILE '/u02/oradata/dev920/temp01.dbf' RESIZE 100m;
    Note that if you are using the Enterprise Edition, you should not resize the system01.dbf data file to be any smaller than about 500 Mb.

  6. Oracle uses a server parameter file or "spfile" to store configuration settings that affect the instance. The parameter settings in the starter database are not bad, but you will probably want to make some changes. Unfortunately, you cannot edit the spfile. Instead, you must export the contents of the spfile to a plain text file called a "pfile". You can then edit the pfile and convert it back to an spfile for use on your starter database. (This might sound confusing, but is actually pretty straightforward.)

    Shut down the database and export the contents of the spfile into a pfile that you can edit with commands like:

            $ sqlplus /nolog
            SQL> CONNECT / AS SYSDBA
            SQL> CREATE PFILE='/home/oracle/dev920params.txt'
              2  FROM SPFILE;
            SQL> SHUTDOWN IMMEDIATE
  7. Make a backup copy of the pfile you created in the previous step and edit the pfile to change parameters as you wish, based on your needs and your server's capabilities. You can always change parameters again in the future, so you are not locking yourself into anything right now. Here is the pfile that we ended up with:
            *.background_dump_dest='/u01/app/oracle/admin/dev920/bdump'
            *.compatible='9.2.0.0.0'
            *.control_files='/u02/oradata/dev920/control01.ctl','/u02/oradata/dev920/control02.ctl',
            '/u02/oradata/dev920/control03.ctl'
            *.core_dump_dest='/u01/app/oracle/admin/dev920/cdump'
            *.db_block_size=8192
            *.db_cache_size=32m
            *.db_domain='dbspecialists.com'
            *.db_name='dev920'
            *.dispatchers='(PROTOCOL=TCP) (SERVICE=dev920XDB)'
            *.fast_start_mttr_target=300
            *.instance_name='dev920'
            *.java_pool_size=64m
            *.job_queue_processes=10
            *.large_pool_size=16m
            *.max_dump_file_size=10240
            *.open_cursors=300
            *.os_authent_prefix=''
            *.pga_aggregate_target=24m
            *.processes=50
            *.query_rewrite_enabled='FALSE'
            *.remote_login_passwordfile='EXCLUSIVE'
            *.shared_pool_size=80m
            *.sort_area_size=1048576
            *.star_transformation_enabled='FALSE'
            *.timed_statistics=TRUE
            *.undo_management='AUTO'
            *.undo_retention=10800
            *.undo_tablespace='UNDOTBS1'
            *.user_dump_dest='/u01/app/oracle/admin/dev920/udump'
  8. The starter database has three control files. The control file is a pretty small file that contains crucial configuration and synchronization information that Oracle needs in order to locate all the files that make up the database and keep them consistent. All three copies of the control file are kept identical—whatever Oracle writes to one control file it also writes to the other two. (Think of it like software mirroring.) It is a good idea to move at least one of the control files to another location. With the database shut down, you can go ahead and move the control files around as you wish. Be sure to change the control_files entry in your pfile accordingly.

  9. Remove the existing spfile that the Database Configuration Assistant created, and the bogus pfile that it left behind, with the following commands:
            $ rm -i $ORACLE_HOME/dbs/spfile$ORACLE_SID.ora
            $ rm -i $ORACLE_BASE/admin/$ORACLE_SID/pfile/init$ORACLE_SID.ora*
  10. Create a symbolic link from the location where Oracle looks for the spfile to the location where you will actually maintain the spfile:
            $ ln -s $ORACLE_BASE/admin/$ORACLE_SID/pfile/spfile$ORACLE_SID.ora \
                    $ORACLE_HOME/dbs/spfile$ORACLE_SID.ora
  11. Now convert the pfile that you edited back into an spfile that Oracle can use with the following commands:
            $ sqlplus /nolog
            SQL> CONNECT / AS SYSDBA
            SQL> CREATE SPFILE='$ORACLE_BASE/admin/$ORACLE_SID/pfile/spfile$ORACLE_SID.ora'
              2  FROM PFILE='/home/oracle/dev920params.txt';
  12. You are now ready to restart your database using your newly created spfile. Use the following commands to start the database and view the parameters that are in effect. These settings should match what you put in your pfile a few steps back:
            $ sqlplus /nolog
            SQL> CONNECT / AS SYSDBA
            SQL> STARTUP
            SQL> SET PAGESIZE 100
            SQL> SELECT   name, value, isdefault
              2  FROM     v$parameter
              3  ORDER BY isdefault, name;
  13. You can follow the above few steps at any time to make further changes to the parameters. However, if you only have a few changes to make, there is a much easier way than exporting the spfile into a pfile, editing the pfile, and converting back to an spfile. You can simply:
            $ sqlplus /nolog
            SQL> CONNECT / AS SYSDBA
            SQL> ALTER SYSTEM SET parameter = value
              2  SCOPE = SPFILE;
    This will update the setting in your spfile, and the change will take effect the next time you restart the database. Many parameters are dynamic, meaning that you can change them on the fly without restarting the database. For dynamic parameters, you can omit the SCOPE = line above and Oracle will change the parameter setting immediately and in the spfile.

  14. Adjust the configuration of the Oracle Net listener if necessary. You can edit the listener.ora file in $ORACLE_HOME/network/admin to suit your needs, although you may find the default file to be totally acceptable. Depending on your network topology, you might want to change the hostname or IP. (In our case our server is multi-homed, but we only want the database to accept connections from the internal network.) You should leave the extproc settings as they are; extproc is part of the mechanism that allows PL/SQL to call out to procedures outside the database. Our listener.ora file looks like this:
            #
            # Filename: listener.ora
            # 
            LISTENER =
              (DESCRIPTION_LIST =
                (DESCRIPTION =
                  (ADDRESS_LIST =
                    (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC))
                  )
                  (ADDRESS_LIST =
                    (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.6)(PORT = 1521))
                  )
                )
              )
            
            SID_LIST_LISTENER =
              (SID_LIST =
                (SID_DESC =
                  (SID_NAME = PLSExtProc)
                  (ORACLE_HOME = /u01/app/oracle/product/9.2.0)
                  (PROGRAM = extproc)
                )
                (SID_DESC =
                  (GLOBAL_DBNAME = dev920.dbspecialists.com)
                  (ORACLE_HOME = /u01/app/oracle/product/9.2.0)
                  (SID_NAME = dev920)
                )
              )
  15. Prepare a tnsnames.ora file in $ORACLE_HOME/network/admin on the database server and distribute it to all clients. Edit the default file to suit your needs. Change the hostname or IP if needed. Our tnsnames.ora file looks like this:
            #
            # Filename: tnsnames.ora 
            #  
            EXTPROC_CONNECTION_DATA.DBSPECIALISTS.COM =
              (DESCRIPTION =
                (ADDRESS_LIST =
                  (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC))
                )
                (CONNECT_DATA =
                  (SID = PLSExtProc)
                  (PRESENTATION = RO)
                )
              )
            
            DEV920.DBSPECIALISTS.COM =
              (DESCRIPTION =
                (ADDRESS_LIST =
                  (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.3)(PORT = 1521))
                )
                (CONNECT_DATA =
                  (SERVICE_NAME = dev920.dbspecialists.com)
                )
              )
  16. At this point the database has two tablespaces available to hold your application tables and indexes: USERS and INDX. However, we recommend that you create new tablespaces for holding application segments instead of using these two tablespaces. Create separate tablespaces with data files on separate physical devices for tables and indexes. You may want to split your application segments into several tablespaces, based on object size, permanence, volatility, I/O volume, or any of a number of other criteria. In the past, choosing storage parameters and allocation schemes for database objects was extremely complex. Now it is quite simple because you can have Oracle do the space allocation and management automatically, and it will do a pretty good job. Here is a sample tablespace creation statement:
            CREATE TABLESPACE small_tables
            DATAFILE '/u02/oradata/dev920/small_tables01.dbf' SIZE 500m
            EXTENT MANAGEMENT LOCAL AUTOALLOCATE 
            SEGMENT SPACE MANAGEMENT AUTO;
  17. Create application roles if desired. Alternatively, you can use the default roles CONNECT, RESOURCE, and DBA.

  18. Create your application users that will own the application schemas. Set the default tablespace to one of your application tablespaces designated to hold tables. Assign quotas on all of the application tablespaces where the user will need to be able to create schema objects. (You can use the keyword UNLIMITED.) You should not set any quota on the temporary tablespace. Do not plan to create any application objects in the SYS or SYSTEM schemas, or store any application objects in the SYSTEM or TEMP tablespaces. Here is a sample application user creation statement:
            CREATE USER bob IDENTIFIED BY bob123
            DEFAULT TABLESPACE small_tables 
            QUOTA UNLIMITED ON small_tables QUOTA UNLIMITED ON large_tables
            QUOTA UNLIMITED ON small_indexes QUOTA UNLIMITED ON large_indexes;
  19. Grant roles and/or system privileges to the application users. Note that if you grant the RESOURCE role to a user, that user will also receive the UNLIMITED TABLESPACE system privilege. This will let the user create objects in any tablespace they wish, regardless of quotas. We recommend you revoke UNLIMITED TABLESPACE from all application users you create. Sample statements to grant and revoke privileges are as follows:
            GRANT connect, resource TO bob;
            REVOKE unlimited tablespace FROM bob;
  20. Review the overall security of your database. Oracle Corporation has published a handy ten-page listing of security checks that you should perform against your database. Download from the Oracle Technology Network at http://otn.oracle.com/deploy/security/oracle9i/pdf/9iR2_checklist.pdf.

Complete the Server Configuration

These steps complete the configuration of your server for smooth Oracle operation. In this section, we will change the oracle user's login script to eliminate hardcoding, create individual operating system accounts for each database user, and configure the server to start the database and listeners automatically whenever the server is rebooted.

  1. Edit the /etc/oratab file to verify that the entry for your database is correct. Lines starting with a pound sign are considered comments and are ignored. Each non-comment line contains the name of one Oracle instance, its ORACLE_HOME, and a Y or N. A Y indicates that the database should be started automatically on server reboot, and an N indicates that it should not. The three fields should be separated by colons. A sample /etc/oratab file looks like this:
            #
            # /etc/oratab
            # ===========
            #
            dev920:/u01/app/oracle/product/9.2.0:Y
  2. Edit the login file (.profile or .bash_profile) for the oracle user to eliminate hardcodings and call the oraenv script to set the environment instead. The following will work with Bourne shell, Korn shell, or Bash:
            # Settings for Oracle environment
            ORACLE_SID=dev920   # Put your instance name here
            ORAENV_ASK=NO
            export ORACLE_SID ORAENV_ASK
            . oraenv
    Note that this script assumes that the /usr/local/bin directory is on your path. Also, if you use C shell then you should edit .cshrc and have it source coraenv.

  3. Create separate Linux accounts for DBAs and database users who will log onto the database server directly. You should only log in as oracle when installing or patching software. The Linux accounts for DBAs should be members of the dba group, and other users should not be members of the dba group. Give each of these accounts a login file like oracle's so that their environment initializes correctly when they log in.

  4. The Database Configuration Assistant configured the HTTP listener that is integrated into the Oracle9i database and started it up for you. Unfortunately, the HTTP listener was started by the oracle Linux user. Running the HTTP listener as the oracle user and a member of the dba Linux group can be a big security hole. Earlier we created a separate Linux user and group to run the HTTP listener. At this time, we need to stop the HTTP listener, clean up file ownership problems, and restart the HTTP listener as the apache user. The steps are as follows:

    1. Run the following command as the oracle user to stop the HTTP listener:
              $ $ORACLE_HOME/Apache/Apache/bin/apachectl stop
    2. Review the httpd.conf file in $ORACLE_HOME/Apache/Apache/conf and comment out modules that you will not be using. (The default httpd.conf file includes everything under the sun.)
    3. Change the ownership of certain files from oracle to apache so that the apache Linux user will not get permission problems when trying to run the HTTP listener. Which files need a change of ownership depends on which modules you kept active in the httpd.conf file. In our system, we use the mod PL/SQL feature but none of the others. Here are the commands we ran to change file ownership:
              $ cd $ORACLE_HOME/Apache/Apache
              $ su 
              $ chown apache:apache logs logs/* 
              $ cd ../modplsql
              $ chown apache:apache log log/* cfg/wdbsvr.app
    4. Edit the login file (.profile or .bash_profile) for the apache user to call the oraenv script at login time. (This is the same as what we did for the oracle user's login script in a previous step.) The following will work with Bourne shell, Korn shell, or Bash:
              # Settings for Oracle environment
              ORACLE_SID=dev920   # Put your instance name here
              ORAENV_ASK=NO
              export ORACLE_SID ORAENV_ASK
              . oraenv
    5. Start the HTTP listener from the apache Linux user by running the following command while logged in as the apache user:
              $ $ORACLE_HOME/Apache/Apache/bin/apachectl start

  5. To make the database and listeners start up automatically when the server reboots and shut down automatically when the server shuts down, you'll need to create a dbora file in /etc/rc.d/init.d and link it to the various /etc/rc.d/rcN.d directories. You'll need to do this as the root user. First create a file called dbora in /etc/rc.d/init.d as follows:
            #!/bin/sh
            ORA_HOME=/u01/app/oracle/product/9.2.0 
            ORA_OWNER=oracle
            HTTP_OWNER=apache
            if [ ! -f $ORA_HOME/bin/dbstart ]
            then
              echo "Oracle startup: cannot start"
              exit
            fi
            case "$1" in
               'start') # Start the Oracle databases and listeners
                        su - $ORA_OWNER -c "$ORA_HOME/bin/dbstart" 
                        su - $ORA_OWNER -c "$ORA_HOME/bin/lsnrctl start" 
                        su - $HTTP_OWNER -c "DISPLAY='192.168.1.6:0.0'; export DISPLAY; $ORA_HOME/Apache/Apache/bin/apachectl start"
                        su - $ORA_OWNER -c "$ORA_HOME/bin/agentctl start"
                        ;;
               'stop')  # Stop the Oracle databases and listeners
                        su - $ORA_OWNER -c "$ORA_HOME/bin/agentctl stop"
                        su - $ORA_OWNER -c "$ORA_HOME/bin/lsnrctl stop" 
                        su - $ORA_OWNER -c "$ORA_HOME/bin/dbshut" 
                        su - $HTTP_OWNER -c "$ORA_HOME/Apache/Apache/bin/apachectl stop"
                        ;;
            esac
    After creating the dbora file, you need to link it to the various /etc/rc.d/rcN.d directories:
            $ ln -s /etc/rc.d/init.d/dbora /etc/rc.d/rc0.d/K10dbora
            $ ln -s /etc/rc.d/init.d/dbora /etc/rc.d/rc1.d/K10dbora
            $ ln -s /etc/rc.d/init.d/dbora /etc/rc.d/rc2.d/K10dbora
            $ ln -s /etc/rc.d/init.d/dbora /etc/rc.d/rc3.d/S99dbora
            $ ln -s /etc/rc.d/init.d/dbora /etc/rc.d/rc4.d/K10dbora
            $ ln -s /etc/rc.d/init.d/dbora /etc/rc.d/rc5.d/S99dbora
            $ ln -s /etc/rc.d/init.d/dbora /etc/rc.d/rc6.d/K10dbora
    Note that this script starts the HTTP listener as the apache user. If you want your HTTP listener to listen on a privileged port, then you will need to have root start the HTTP listener and hand off ownership to the apache user by setting the User and Group parameters in the Apache configuration file $ORACLE_HOME/Apache/Apache/conf/httpd.conf.

  6. If you are using Red Hat Enterprise Linux release 3, then you will recall that in an earlier step you moved the gcc and g++ executables around so that Oracle would be relinked using the older binaries. Now that you are done linking Oracle, you probably want to restore the current versions of these binaries to the path. You can do this by running the following commands as root:
            $ rm -i /usr/bin/gcc /usr/bin/g++
            $ mv -i /usr/bin/gcc323 /usr/bin/gcc
            $ mv -i /usr/bin/g++323 /usr/bin/g++
Conclusion

This paper walks you through the intricate details of getting Oracle9i up and running on a database server running Linux. It may look complicated, but that's only because this paper goes down to a nitty-gritty level of detail.

Please keep in mind, though, that the requirements are different for every Oracle implementation. And a lot seems to depend on which distribution of Linux you are using as well. We are extremely confident that if you follow these steps to install Oracle9i release 2 bundled with the 9.2.0.4 patchset on a server running Red Hat Enterprise Linux release 3, the process will go very smoothly for you. However, no single document can address every specific hardware configuration and every set of business needs. Please use this paper as a starting point to get Oracle up and running in your shop. To get the best performance and scalability, each system needs to be considered individually. Good luck!

About the Authors

Robert Townsend is a Senior Staff Consultant with Database Specialists, Inc. and has over twenty years of professional experience as a DBA and programmer. He also has over ten years of experience in support of Oracle Financials and Manufacturing applications running on Unix, Linux, and Windows platforms. You may contact Robert by email at rtownsend@dbspecialists.com.

Roger Schrag, OCP, has been an Oracle DBA and application architect for over 15 years. He started at Oracle Corporation on the Oracle Financials development team. Subsequent positions in the San Francisco Bay Area included DBA and database architect. In 1995, Roger founded Database Specialists, Inc. He is a frequent speaker at OracleWorld and the International Oracle Users Group (IOUG) Live conferences, where he has been voted Top 10% of speakers multiple times. Also, Roger was an Oracle Masters Class instructor for the IOUG. Roger is the current president of the Northern California Oracle Users Group (NoCOUG). He can be reached at rschrag@dbspecialists.com.

Still Looking for Help on this Subject?

Get a Consultation
We would be happy to talk with you about our services and how our senior-level database team might help you. Call Database Specialists at 415-344-0500 or 888-648-0500 or fill out a free consultation request form.
Complimentary Newsletter
If you'd like to receive our complimentary monthly newsletter with database tips and new white paper announcements, sign up for The Specialist.


Copyright © 2005 Database Specialists, Inc. http://www.dbspecialists.com