| DBA: Linux |
Installing Oracle Database 10g Release 2 on Linux x86
(RHEL4 and SLES9 covered)
by John Smiley
Learn the basics of installing Oracle Database 10g Release 2 on Red Hat Enterprise Linux or Novell SUSE Enterprise Linux, from the bare metal up (for evaluation purposes only).
Updated December 2007
Click here for a version covering Oracle Database 11g on OEL5/RHEL5.
The guide provides a walkthrough of installing an Oracle Database 10g Release 2 database on commodity hardware for the purpose of evaluation . If you are new to Linux and/or Oracle, this guide is for you. It starts with the basics and walks you through an installation of Oracle Database 10g Release 2 from the bare metal up.
This guide will take the approach of offering the easiest paths, with the fewest number of steps for accomplishing a task. This approach often means making configuration choices that would be inappropriate for anything other than an evaluation. For that reason, this guide is not appropriate for building production-quality environments, nor does it reflect best practices.
The Linux distributions certified for Oracle Database 10g Release 2 are:
We will cover the RHEL4 and SLES9 distributions only here.
Please note that as an alternative Novell offers the orarun package for installation of SLES9 and Oracle. To use that method instead of the one described here, refer to this Novell-supplied install guide.
This guide is divided into four parts: Part I covers the installation of the Linux operating system, Part II covers configuring Linux for Oracle, Part III discusses the essentials of installing the Oracle Database, and Part IV covers creating additional filesystems and Automatic Storage Management (ASM)—a new storage option in Oracle Database 10g that greatly simplifies storage administration and management. The Appendix provides information to help you get started using your new database including how to access the database interactively and how to stop and start the database and related services.
Part I: Installing Linux
This guide assumes a server with the following hardware:
Your hardware does not have to match this in order to use this guide. All that is necessary for a basic database install is a single CPU, 1024MB of RAM, and one disk drive (IDE, SCSI, or FireWire) with at least 7GB of free space.
Now, let's walk through the process of installing the Linux operating system on a server. The instructions assume a fresh install of Linux (as opposed to an upgrade), that the server will be dedicated to Oracle, and that no other operating systems or data are on the server.
Oracle Database 10g Release 2 is certified to run the base release of RHEL4 (Advanced Server and Enterprise Server) without updates. If you have update CDs, you can use the boot CD from the update instead of the boot CD from the base release to automatically apply all updates during the installation. All updates from Red Hat are supported by Oracle.
The easiest and fastest way to apply the updates for a fresh install of Linux is to perform the install by using the update CDs. If Linux is already installed or you don't have the updates on CDs, they can be applied through RHN. Because this guide is designed for a fresh Linux install, you'll use the update CDs.
Verifying Your Installation
Required kernel version: 2.6.9-5.0.5.EL This kernel, or any of the kernels supplied in updates, works with Oracle Database 10g Release 2 .
Check your kernel version by running the following command:
uname -r Ex: # uname -r 2.6.9-22.ELsmp
Once you've completed the steps above, all of the packages required for Oracle Database 10g Release 2 will have been installed. Verify this using the example below.Required package versions (or later):
rpm -q binutils compat-db control-center gcc gcc-c++ glibc glibc-common \ gnome-libs libstdc++ libstdc++-devel make pdksh sysstat xscreensaver libaio openmotif21
Ex: # rpm -q binutils compat-db control-center gcc gcc-c++ glibc glibc-common \ > gnome-libs libstdc++ libstdc++-devel make pdksh sysstat xscreensaver libaio openmotif21 binutils-18.104.22.168.2-15 compat-db-4.1.25-9 control-center-2.8.0-12.rhel4.2 gcc-3.4.4-2 gcc-c++-3.4.4-2 glibc-2.3.4-2.13 glibc-common-2.3.4-2.13 gnome-libs-22.214.171.124.90-44.1 libstdc++-3.4.4-2 libstdc++-devel-3.4.4-2 make-3.80-5 pdksh-5.2.14-30.3 sysstat-5.0.5-1 xscreensaver-4.18-5.rhel4.9 libaio-0.3.103-3 openmotif21-2.1.30-11.RHEL4.4
Oracle Database 10g Release 2 is certified to run on the base release of SLES9. Service Packs and package updates are available from Novell, either on CDs or online via its support portal. In this guide, we will install on the SLES9 base release.
If you've completed the steps above, you should have all the packages and updates required for Oracle Database 10g Release 2. However, you can take the steps below to verify your installation.
Required kernel version: 2.6.5-7.97 (or later)
Check your kernel version by running the following command:
uname -r Ex: # uname -r 2.6.5-7.97-smpOther required package versions (or later):
rpm -q binutils gcc gcc-c++ glibc gnome-libs libstdc++ libstdc++-devel make \ pdksh sysstat xscreensaver libaio Ex: # rpm -q binutils gcc gcc-c++ glibc gnome-libs libstdc++ libstdc++-devel make \ > pdksh sysstat xscreensaver libaio binutils-126.96.36.199.1.1-32.10 gcc-3.3.3-43.34 gcc-c++-3.3.3-43.34 glibc-2.3.3-98.47 gnome-libs-188.8.131.52-671.1 libstdc++-3.3.3-43.34 libstdc++-devel-3.3.3-43.34 make-3.80-184.1 pdksh-5.2.14-780.7 sysstat-5.0.1-35.4 xscreensaver-4.16-2.6 libaio-0.3.102-1.2If any of the package versions on your system are missing or the versions are earlier than those specified above, you can download and install the updates from the Novell SUSE Linux Portal.
Now that the Linux software is installed, you need to configure it for Oracle. This section walks through the steps required to configure Linux for Oracle Database 10g Release 2.
To verify that your system meets the minimum requirements for an Oracle Database 10g Release 2 database, log in as root and run the commands below.To check the amount of RAM and swap space available, run this:
grep MemTotal /proc/meminfo grep SwapTotal /proc/meminfo Ex: # grep MemTotal /proc/meminfo MemTotal: 1034680 kB # grep SwapTotal /proc/meminfo SwapTotal: 1534196 kB
The minimum RAM required is 1024MB, and the minimum required swap space is 1GB. Swap space should be twice the amount of RAM for systems with 2GB of RAM or less and between one and two times the amount of RAM for systems with more than 2GB.
You also need 2.5GB of available disk space for the Oracle Database 10g Release 2 software and another 1.2GB for the database. The /tmp directory needs at least 400MB of free space. To check the available disk space on your system, run the following command:
df -h Ex: # df -h Filesystem Size Used Avail Use% Mounted on /dev/sda3 6.8G 1.3G 5.2G 20% / /dev/sda1 99M 17M 77M 18% /boot
The example shows that the /tmp directory does not have its own filesystem. (It's part of the root filesystem for this guide.) With 5.2 GB available, the root filesystem has just enough space for the installation (2.5 + 1.2 + 0.4 = 4.1GB) with a little room left over.
Next, create the Linux groups and user account that will be used to install and maintain the Oracle Database 10g Release 2 software. The user account will be called oracle, and the groups will be oinstall and dba. Execute the following commands as root:
/usr/sbin/groupadd oinstall /usr/sbin/groupadd dba /usr/sbin/useradd -m -g oinstall -G dba oracle id oracle Ex: # /usr/sbin/groupadd oinstall # /usr/sbin/groupadd dba # /usr/sbin/useradd -m -g oinstall -G dba oracle # id oracle uid=501(oracle) gid=502(oinstall) groups=502(oinstall),503(dba)
Set the password on the oracle account:
passwd oracle Ex: # passwd oracle Changing password for user oracle. New password: Retype new password: passwd: all authentication tokens updated successfully.
Now create directories to store the Oracle Database 10g Release 2 software and the database files. This guide adheres to the Optimal Flexible Architecture (OFA) for the naming conventions used in creating the directory structure. For more information on OFA standards, see Appendix C of the Oracle Database Installation Guide 10g Release 2 (10.2) for Linux x86 .
The following assumes that the directories are being created in the root filesystem. This is done for the sake of simplicity and is not recommended as a general practice. These directories would normally be created as separate filesystems.
Issue the following commands as root:
mkdir -p /u01/app/oracle chown -R oracle:oinstall /u01/app/oracle chmod -R 775 /u01/app/oracle Ex: # mkdir -p /u01/app/oracle # chown -R oracle:oinstall /u01/app/oracle # chmod -R 775 /u01/app/oracle
The Linux kernel is a wonderful thing. Unlike most other *NIX systems, Linux allows modification of most kernel parameters while the system is up and running. There's no need to reboot the system after making kernel parameter changes. Oracle Database 10g Release 2 requires the kernel parameter settings shown below. The values given are minimums, so if your system uses a larger value, don't change it.
kernel.shmall = 2097152 kernel.shmmax = 536870912 kernel.shmmni = 4096 kernel.sem = 250 32000 100 128 fs.file-max = 65536 net.ipv4.ip_local_port_range = 1024 65000 net.core.rmem_default=262144 net.core.wmem_default=262144 net.core.rmem_max=262144 net.core.wmem_max=262144
If you're following along and have just installed Linux, the kernel parameters will all be at their default values and you can just cut and paste the following commands while logged in as root.
cat >> /etc/sysctl.conf <<EOF kernel.shmall = 2097152 kernel.shmmax = 536870912 kernel.shmmni = 4096 kernel.sem = 250 32000 100 128 fs.file-max = 65536 net.ipv4.ip_local_port_range = 1024 65000 net.core.rmem_default=262144 net.core.wmem_default=262144 net.core.rmem_max=262144 net.core.wmem_max=262144 EOF /sbin/sysctl -p Ex: # cat >> /etc/sysctl.conf <<EOF > kernel.shmall = 2097152 > kernel.shmmax = 536870912 > kernel.shmmni = 4096 > kernel.sem = 250 32000 100 128 > fs.file-max = 65536 > net.ipv4.ip_local_port_range = 1024 65000 > EOF # /sbin/sysctl -p net.ipv4.ip_forward = 0 net.ipv4.conf.default.rp_filter = 1 net.ipv4.conf.default.accept_source_route = 0 kernel.sysrq = 0 kernel.core_uses_pid = 1 kernel.shmall = 2097152 kernel.shmmax = 536870912 kernel.shmmni = 4096 kernel.sem = 250 32000 100 128 fs.file-max = 65536 net.ipv4.ip_local_port_range = 1024 65000 net.core.rmem_default = 262144 net.core.wmem_default = 262144 net.core.rmem_max = 262144 net.core.wmem_max = 262144
Run the following commands as root to verify your settings:
/sbin/sysctl -a | grep shm /sbin/sysctl -a | grep sem /sbin/sysctl -a | grep file-max /sbin/sysctl -a | grep ip_local_port_range
For Novell SUSE Linux releases, use the following to ensure that the system reads the /etc/sysctl.conf file at boot time:
/sbin/chkconfig boot.sysctl on
Oracle recommends setting limits on the number of processes and open files each Linux account may use. To make these changes, cut and paste the following commands as root:
cat >> /etc/security/limits.conf <<EOF oracle soft nproc 2047 oracle hard nproc 16384 oracle soft nofile 1024 oracle hard nofile 65536 EOF cat >> /etc/pam.d/login <<EOF session required /lib/security/pam_limits.so EOF
For RHEL4, use the following:
cat >> /etc/profile <<EOF if [ \$USER = "oracle" ]; then if [ \$SHELL = "/bin/ksh" ]; then ulimit -p 16384 ulimit -n 65536 else ulimit -u 16384 -n 65536 fi umask 022 fi EOF cat >> /etc/csh.login <<EOF if ( \$USER == "oracle" ) then limit maxproc 16384 limit descriptors 65536 umask 022 endif EOF
For SLES 9, use the following:
cat >> /etc/profile.local <<EOF if [ \$USER = "oracle" ]; then if [ \$SHELL = "/bin/ksh" ]; then ulimit -p 16384 ulimit -n 65536 else ulimit -u 16384 -n 65536 fi umask 022 fi EOF cat >> /etc/csh.login.local <<EOF if ( \$USER == "oracle" ) then limit maxproc 16384 limit descriptors 65536 umask 022 endif EOF
Part III: Installing Oracle
Oracle Database 10g Release 2 can be downloaded from OTN. Oracle offers a development and testing license free of charge. However, no support is provided and the license does not permit production use. A full description of the license agreement is available on OTN.
The easiest way to make the Oracle Database 10g Release 2 distribution media available on your server is to download them directly to the server.
Use the graphical login to log in as oracle.
Create a directory to contain the Oracle Database 10g Release 2 distribution:
To download Oracle Database 10g Release 2 from OTN, point your browser (Firefox works well) to http://www.oracle.com/technology/software/products/database/oracle10g/htdocs/10201linuxsoft.html. Fill out the Eligibility Export Restrictions page, and read the OTN License agreement. If you agree with the restrictions and the license agreement, click on I Accept.
Click on the 10201_database_linux32.zip link, and save the file in the directory you created for this purpose (10gR2_db)—if you have not already logged in to OTN, you may be prompted to do so at this point.
Unzip and extract the file:
cd 10gR2_db unzip 10201_database_linux32.zip
Log in using the oracle account.Change directory to the location where you extracted the Oracle Database 10g Release 2 software.
Ex: $ cd $HOME/10gR2_db
Change directory to Disk1.
Ex: $ cd database
Start the Oracle Universal Installer.
Part IV: Configuring Storage
The database we created in Part III used a single filesystem for disk storage. However, there are several other ways to configure storage for an Oracle database.
Part IV explores other methods of configuring disk storage for a database. In particular, it describes creating additional filesystems and using Automatic Storage Management (ASM). Use of raw devices and Oracle Cluster File System (OCFS) is covered in the next article in this series which walks through installing Oracle RAC Database 10g Release 2 on Linux x86.
Partition the Disks
In order to use either file systems or ASM, you must have unused disk partitions available. This section describes how to create the partitions that will be used for new file systems and for ASM.
WARNING: Improperly partitioning a disk is one of the surest and fastest ways to wipe out everything on your hard disk. If you are unsure how to proceed, stop and get help, or you will risk losing data.
This example uses /dev/sdb (an empty SCSI disk with no existing partitions) to create a single partition for the entire disk (36 GB).
Ex: # fdisk /dev/sdb Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel Building a new DOS disklabel. Changes will remain in memory only, until you decide to write them. After that, of course, the previous content won't be recoverable. The number of cylinders for this disk is set to 4427. There is nothing wrong with that, but this is larger than 1024, and could in certain setups cause problems with: 1) software that runs at boot time (e.g., old versions of LILO) 2) booting and partitioning software from other OSs (e.g., DOS FDISK, OS/2 FDISK) Command (m for help): p Disk /dev/sdb: 255 heads, 63 sectors, 4427 cylinders Units = cylinders of 16065 * 512 bytes Device Boot Start End Blocks Id System Command (m for help): n Command action e extended p primary partition (1-4) p Partition number (1-4): 1 First cylinder (1-4427, default 1): Using default value 1 Last cylinder or +size or +sizeM or +sizeK (1-4427, default 4427): Using default value 4427 Command (m for help): w The partition table has been altered! Calling ioctl() to re-read partition table. WARNING: If you have created or modified any DOS 6.x partitions, please see the fdisk manual page for additional information. Syncing disks.
Now verify the new partition:
Repeat the above steps for each disk to be partitioned. The following section on Filesystems uses a single disk partition, /dev/sdb1. The ASM example uses three partitions on three disks: /dev/sdb1, /dev/sdc1, and /dev/sdd1
Filesystems are the most widely used means of storing data file, redo logs, and control files for Oracle databases. Filesystems are easy to implement and require no third-party software to administer.
In most cases, filesystems are created during the initial installation of Linux. However, there are times when a new filesystem must be created after the initial installation, such as when a new disk drive is being installed.
This section describes building a new filesystem and using it in an Oracle database. Unless otherwise noted, all commands must be run as root.
Create the Filesystem
Use ext3 to create this new filesystem. Other filesystems work just as well, but ext3 offers the fastest recovery time in the event of a system crash.
Create the Mount Point
A filesystem must have a mount point, which is simply an empty directory where the new filesystem "attaches" to the system's directory tree. Mount points should be given names consistent with the Oracle Flexible Architecture (OFA) standard. For more information on OFA standards, see Appendix C of the Oracle Database Installation Guide 10g Release 2 (10.2) for Linux x86 .
Because you have already created the /u01 directory in Part I, use /u02 for this example.
Add the New Filesystem to /etc/fstab
So that the new filesystem will be mounted automatically when the system boots, you need to add a line to the /etc/fstab file that describes the new filesystem and where to mount it. Add a line similar to the one below to /etc/fstab, using a text editor.
/dev/sdb1 /u02 ext3 defaults 1 1
Mount the New Filesystem
Mounting the filesystem makes it available for use. Until the filesystem is mounted, files cannot be stored in it. Use the following commands to mount the filesystem and verify that it is available.
Create Oracle Directories and Set Permissions
Now you create a directory to store your Oracle files. The directory name used in the example follows the OFA standard naming convention for a database with ORACLE_SID=demo1.
mkdir -p /u02/oradata/demo1
Create a New Tablespace in the New Filesystem
The new filesystem is ready for use. Next you create a new tablespace in the filesystem to store your database objects. Connect to the database as the SYSTEM user, and execute the CREATE TABLESPACE statement, specifying the data file in the new filesystem.
Now you can use the new tablespace to store database objects such as tables and indexes.
Automatic Storage Management (ASM)
ASM was a new storage option introduced with Oracle Database 10gR1 that provides the services of a filesystem, logical volume manager, and software RAID in a platform-independent manner. ASM can stripe and mirror your disks, allow disks to be added or removed while the database is under load, and automatically balance I/O to remove "hot spots." It also supports direct and asynchronous I/O and implements the Oracle Data Manager API (simplified I/O system call interface) introduced in Oracle9i.
ASM is not a general-purpose filesystem and can be used only for Oracle data files, redo logs, and control files. Files in ASM can be created and named automatically by the database (by use of the Oracle Managed Files feature) or manually by the DBA. Because the files stored in ASM are not accessible to the operating system, the only way to perform backup and recovery operations on databases that use ASM files is through Recovery Manager (RMAN).
ASM is implemented as a separate Oracle instance that must be up if other databases are to be able to access it. Memory requirements for ASM are light: only 64 MB for most systems.
On Linux platforms, ASM can use raw devices or devices managed via the ASMLib interface. Oracle recommends ASMLib over raw devices for ease-of-use and performance reasons. ASMLib 2.0 is available for free download from OTN. This section walks through the process of configuring a simple ASM instance by using ASMLib 2.0 and building a database that uses ASM for disk storage.
Determine Which Version of ASMLib You Need
ASMLib 2.0 is delivered as a set of three Linux packages:
First, determine which kernel you are using by logging in as root and running the following command:
uname -rm Ex: # uname -rm 2.6.9-22.ELsmp i686
The example shows that this is a 2.6.9-22 kernel for an SMP (multiprocessor) box using Intel i686 CPUs.
Use this information to find the correct ASMLib packages on OTN:
Before using ASMLib, you must run a configuration script to prepare the driver. Run the following command as root, and answer the prompts as shown in the example below.
# /etc/init.d/oracleasm configure Configuring the Oracle ASM library driver. This will configure the on-boot properties of the Oracle ASM library driver. The following questions will determine whether the driver is loaded on boot and what permissions it will have. The current values will be shown in brackets (''). Hitting <ENTER> without typing an answer will keep that current value. Ctrl-C will abort. Default user to own the driver interface : oracle Default group to own the driver interface : dba Start Oracle ASM library driver on boot (y/n) [n]: y Fix permissions of Oracle ASM disks on boot (y/n) [y]: y Writing Oracle ASM library driver configuration: [ OK ] Creating /dev/oracleasm mount point: [ OK ] Loading module "oracleasm": [ OK ] Mounting ASMlib driver filesystem: [ OK ] Scanning system for ASM disks: [ OK ]
Next you tell the ASM driver which disks you want it to use. Oracle recommends that each disk contain a single partition for the entire disk. See Partitioning the Disks at the beginning of this section for an example of creating disk partitions.
You mark disks for use by ASMLib by running the following command as root:
/etc/init.d/oracleasm createdisk DISK_NAME device_name
Tip: Enter the DISK_NAME in UPPERCASE letters.
Ex: # /etc/init.d/oracleasm createdisk VOL1 /dev/sdb1 Marking disk "/dev/sdb1" as an ASM disk: [ OK ] # /etc/init.d/oracleasm createdisk VOL1 /dev/sdc1 Marking disk "/dev/sdc1" as an ASM disk: [ OK ] # /etc/init.d/oracleasm createdisk VOL1 /dev/sdd1 Marking disk "/dev/sdd1" as an ASM disk: [ OK ]
Verify that ASMLib has marked the disks:
# /etc/init.d/oracleasm listdisks VOL1 VOL2 VOL3
Create the ASM Instance
ASM runs as a separate Oracle instance which can be created and configured using the Oracle Universal Installer. Now that ASMLib is installed and the disks are marked for use, you can create an ASM instance.
Log in as oracle and start runInstaller:
Once the ASM instance has been created, create a database that uses ASM for storage:
Log in as oracle and start runInstaller:
Now that your database is up and running, you can begin exploring the many new features offered in Oracle Database 10g Release 2. A great place to start is Oracle Enterprise Manager, which has been completely re-written with a crisp new Web-based interface. If you're unsure where to begin, the Oracle Database Concepts 10g Release 2 and the 2-Day DBA Guide will help familiarize you with your new database. OTN also has a number of guides designed to help you get the most out of Oracle Database 10g Release 2.
Accessing the Database with SQL*Plus
Log into Linux as oracle. Set the environment.
Set the Oracle environment variables:
$ . oraenv ORACLE_SID = [oracle] ? demo1
$ sqlplus SQL*Plus: Release 10.2.0.1.0 - Production on Sun Nov 27 15:40:29 2005 Copyright (c) 1982, 2005, Oracle. All rights reserved. Enter user-name: / as sysdba Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production With the Partitioning, OLAP and Data Mining options SQL>
Using Oracle Enterprise Manager 10g Database Control
In a Web browser, connect to the URL provided during the installation.
User Name: SYS
Click on <Login>
Welcome to the world of Oracle Enterprise Manager 10g Database Control!
Starting and Stopping Oracle Enterprise Manager Database Control:
$ emctl start dbconsole $ emctl stop dbconsole
Accessing the Database Using iSQL*Plus
iSQL*Plus is a Web-based version of the venerable SQL*Plus interactive tool for accessing databases. To use iSQL*Plus, click on the iSQL*Plus link in the Related Links section of the OEM console or point your browser to the iSQL*Plus URL provided during installation.
User Name: SYSTEM
Click on <Login>.
Enter SQL commands in the Workspace box, and click on Execute.
Starting and Stopping iSQL*Plus:
$ isqlplusctl start $ isqlplusctl stop
Starting and Stopping the Listener:
The listener accepts connection requests from clients and creates connections to the database once the credentials have been authenticated. Before you can use OEM or iSQL*Plus, the listener must be up.
$ lsnrctl start $ lsnrctl stop
Starting and Stopping the Database:
The easiest way to start and stop the database is from the OEM Console. To do that from the command line, use SQL*Plus while logged in as oracle, as follows:
$ sqlplus SQL*Plus: Release 10.2.0.1.0 - Production on Sun Nov 27 15:39:27 2005 Copyright (c) 1982, 2005, Oracle. All rights reserved. Enter user-name: / as sysdba Connected to an idle instance. SQL> startup ORACLE instance started. Total System Global Area 285212672 bytes Fixed Size 1218968 bytes Variable Size 96470632 bytes Database Buffers 180355072 bytes Redo Buffers 7168000 bytes Database mounted. Database opened. SQL> exit
$ sqlplus SQL*Plus: Release 10.2.0.1.0 - Production on Sun Nov 27 15:40:29 2005 Copyright (c) 1982, 2005, Oracle. All rights reserved. Enter user-name: / as sysdba Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production With the Partitioning, OLAP and Data Mining options SQL> shutdown immediate Database closed. Database dismounted. ORACLE instance shut down. SQL> exit
John Smiley [ firstname.lastname@example.org] works as a senior database engineer for a major online retailer and is an Oracle Certified Master DBA with over 19 years of experience with Oracle databases running on all major platforms. He specializes in engineering high-volume Oracle databases, advanced performance tuning methods, and RAC, and enjoys developing with PL/SQL, C, and Perl.