DBA: Linux

Automating Installation of Oracle Database 10g and Red Hat Enterprise Linux
by Casimir Saternos

Get an introduction to the tools and processes involved in building a Linux server from the ground up via scripts and configuration files.

Downloads for this article:
 Oracle Database 10g
 Free 30-day Evaluation Subscription to RHEL4

One of the well accepted best practices in system administration is to automate routine tasks whenever possible. Oracle Database 10g includes a number of enhancements and new features that automate common deployment and configuration activities. For example:

  • Oracle Enterprise Manager no longer requires a manual setup, as relevant subsystems are now automatically configured.
  • Routine administration tasks (such as statistics generation) can be easily scheduled.
  • A system of alerts based upon user-defined thresholds can be configured to inform the DBA of conditions requiring human intervention.
  • Parameters related to the System Global Area (SGA) can be automatically configured through Automatic Shared Memory Tuning.
  • Required patchsets can be automatically identified, downloaded from Metalink, and applied.
  • Usage of various database features is automatically tracked to provide assistance in decision making related to future releases.

Numerous other automation features are described in detail in the Oracle documentation; see the Oracle Database New Features Guide for further information.

Furthermore, with Oracle 10g, database installations can be performed more quickly and require less system resources than previous versions. In addition, a DBA can take advantage of tools available in Oracle and Red Hat Enterprise Linux that allow for the use of configuration files and scripts (rather than the monotonous procedure of navigation a GUI as is required by typical, interactive installations). Server installation is an excellent candidate for automation for several reasons:

  • The uniformity offered by automated server installations makes future administration and troubleshooting easier.
  • Automated installs generate configuration files that serve as up-to-date documentation of installation procedures.
  • Administrator can effectively manage larger numbers of installations in a shorter period of time.
  • Perhaps most important, automated installs free up the administrator's time for other jobs that will benefit the organization and further professional development.

Both Red Hat and Oracle provide solutions that support automated installation and configuration of their products. In this article, I will briefly provide some insight into the tools and processes involved in building a Linux server from the ground up via this process. Specifically, I will describe an approach that will install Oracle Database 10g and the Red Hat Enterprise Linux (RHEL) operating system on a test server.

An Outline of RHEL

A " kickstart" is Red Hat's method for automating the installation of the operating system. Rather than answering the questions that are presented during a typical interactive installation, the answers to the relevant questions are stored in a "kickstart" file. This file can then be placed on a boot diskette, boot CD-ROM, or network. For our example here, you will create a configuration file and save it to a boot diskette (in MS-DOS format).

The kickstart configuration file is a text file and thus can be created and modified using a text editor. (A copy of the sample.ks file can be obtained from the RH-DOCS directory of the Red Hat Linux Documentation CD.) If you decide to edit the sample.ks file for your installation, keep in mind that sections within the file must be kept in order, although items within a section generally may be in an arbitrary order. If a required option is omitted, the installation will prompt the user for input—which is not desirable in a fully automated solution. (See the Red Hat documentation for details if you decide to go this route).

The kickstart configuration file can also be created by running a tool called the Kickstart Configurator:

figure 1

When the Kickstart Configurator is run, you will need to answer the same set of questions that are asked during a standard, interactive installation.

figure 2

The Kickstart Configurator also allows for the creation of pre-installation and post-installation scripts that can be called in the process of running the kickstart. (If manually editing the kickstart file, these commands would appear in the %pre or %post section at the end of the file.) One example of a scripted pre-installation task would be the partitioning of disks based on the number of disks on a given server; post-installation tasks could include the creation of users, configuration of mount points, or adding scheduled tasks to the crontab.

To begin an installation, create the kickstart file (named ks.cfg) and save it in the root directory of a boot diskette. Next, put the disk in the floppy drive and the Linux software CD is in the CD Drive. At the boot prompt, run the command linux ks=floppy. If you do not enter this command correctly, a regular installation with the Red Hat GUI will ensue. If you are installing using the CD set, you will be prompted periodically to supply the appropriate CDs that are required for the installation options you specified in your kickstart file.

Below is an example of a simple kickstart file created with the Kickstart Configurator for a test server:

                               
#Generated by Kickstart Configurator

#System  language
lang en_US
#Language modules to install
langsupport  --default=en_US
#System keyboard
keyboard us
#System mouse
mouse generic3ps/2
#Sytem timezone
timezone America/New_York
#Root password
rootpw --iscrypted $1$WSGKfbye$QOEidXByh2fVQPOycas8h/
#Reboot after installation
reboot
#Install Red Hat Linux instead of upgrade
install
#Use CDROM installation media
cdrom
#System bootloader configuration
bootloader --location=mbr 
#Clear the Master Boot Record
zerombr yes
#Partition clearing information
clearpart --all --initlabel 
#Disk partitioning information
part /boot --fstype ext3 --size 99 
part swap --recommended 
part / --fstype ext3 --size 1 --grow 
#System authorization infomation
auth  --useshadow  --enablemd5 
#Network information
network --bootproto=static --ip=128.165.101.107 --netmask=255.255.251.0
                                
--gateway=128.165.109.130 --nameserver=128.165.106.3 --device=eth0 #Firewall configuration firewall --disabled #XWindows configuration information xconfig --depth=32 --resolution=1024x768 --defaultdesktop=GNOME --startxonboot #Run the Setup Agent on first boot firstboot --enable #Package install information %packages --resolvedeps @ X Window System @ GNOME Desktop Environment @ KDE Desktop Environment @ Editors @ Engineering and Scientific @ Graphical Internet @ Text-based Internet @ Office/Productivity @ Sound and Video @ Graphics @ Games and Entertainment @ Authoring and Publishing @ Server Configuration Tools @ Web Server @ Mail Server @ Windows File Server @ FTP Server @ Development Tools @ Kernel Development @ X Software Development @ GNOME Software Development @ KDE Software Development @ Administration Tools @ System Tools @ Printing Support
When the server is started following the initial installation, you will be prompted to complete some initial basic configuration steps. There will be options presented concerning
  • Licensing agreement
  • Setting the date and time (including an option to synchronize with a remote time server using Network Time Protocol)
  • Setting up a user account (including options related to various network authentication methods)
  • A test for the sound card
  • An option to register the system with the Red Hat Network. This option expedites the downloading of software from Red Hat.
  • An option to install additional packages (including documentation)

Configuration Script

You can automate much of the additional initial server setup via shell scripting. Below are some examples to get you started creating scripts that are relevant to your particular installation and network environment. They are not exhaustive or universally relevant, but they represent tasks that commonly need to be performed following the installation of the operating system.

These can be included in a separate script from the kickstart configuration, although most (if not all) of the functionality described could be included in the "Post-Installation Script" section of the Kickstart file.

Add Oracle users and groups for Oracle Database 10g installation. For a typical Oracle 10g installation, two groups and an Oracle user need to be added.

groupadd -g 499 oinstall;
groupadd -g 502 dba;
useradd  -u 499 -p oracle -g oinstall -G dba oracle; 
Configure kernel parameter for database installation. Ideally, you could write a script that would check the existing kernel parameter settings. If any of the kernel parameters were set higher than the value recommended by Oracle for the installation, the value would not be changed. If the value of the parameter was lower than the recommended minimum value, you would adjust it to meet the required threshold.

The following example simply sets some of the values that needed to be changed on a test server:

echo "# " >> /etc/sysctl.conf
echo "# Required for Oracle 10g " >> /etc/sysctl.conf
echo "# " >> /etc/sysctl.conf
echo "kernel.shmall = 2097152" >> /etc/sysctl.conf
echo "kernel.shmmax = 2147483648" >> /etc/sysctl.conf
echo "kernel.shmmni = 4096" >> /etc/sysctl.conf 
echo "kernel.sem = 250 32000 100 128" >> /etc/sysctl.conf
echo "fs.file-max = 65536" >> /etc/sysctl.conf
echo "net.ipv4.ip_local_port_range = 1024 65000" >> /etc/sysctl.conf
/sbin/sysctl -p
See the Oracle Database 10g installation documentation for more details on the configuration of kernel parameters.

Set environmental variables for database installation. When a user logs in, the .bash_profile in their home directory (typically /home/<username>) is executed and environmental variables such as ORACLE_BASE, ORACLE_HOME, and PATH variables are set.

echo "ORACLE_BASE=/oracle/home" >> /home/oracle/.bash_profile
echo "ORACLE_HOME=/oracle/home/OraHome_1" >> /home/oracle/.bash_profile 
echo "export ORACLE_HOME ORACLE_BASE" >> /home/oracle/.bash_profile 
echo "PATH=$PATH:$ORACLE_HOME/bin" >> /home/oracle/.bash_profile 
echo "export PATH"
There are a variety of other variables that you might want to set in a user's .bash_profile. For instance, you may also want to set JAVA_HOME or other variables depending upon your installation and the user's responsibilities.

Other pre-installation tasks. You could add a number of additional verification/configuration steps to the script to perform the following:

  • Check that sufficient memory is installed
  • Verify that the amount of swap spaced configured meets minimum requirements
  • Check for sufficient disk space and in various directories (e.g. /tmp) to accommodate the installation in question
  • Confirm that required software packages are installed
  • Create directories required for the Oracle Database installation
Configure network settings. Network settings can be configured within the Kickstart file itself, under the "Network Information" section as well as in the %post section. In the following examples, the new server's name will be "test-server" and the domain will be "my-domain." In this example three files need to be edited: /etc/hosts, /etc/sysconfig/network, and /etc/resolv.conf.

This script will add entries, edit existing entries, and re-start the network services.

                               
# 
# Edit /etc/hosts
#
echo "128.165.101.107 test-server.my-domain.us test-server" >> /etc/hosts;

#
# Edit /etc/sysconfig/network
#
echo "NETMASK = 255.255.251.0 " >> /etc/sysconfig/network;

#
#     Example using Perl
#
perl �i -p -e 's/localhost/test-server/g' /etc/sysconfig/network;
perl �I -p -e 's/localdomain/my-domain.us/g' /etc/sysconfig/network; 

#
#     Example using sed
# 
sed -e 's/localdomain/my-domain.us/g' /etc/sysconfig/network >/tmp/$$ && mv /tmp/$$ /etc/sysconfig/network;
sed -e 's/localhost/test-server/g' /etc/sysconfig/network >/tmp/$$ && mv /tmp/$$ /etc/sysconfig/network;

#
# Edit /etc/resolv.conf
#
echo "search my-domain.us" > /etc/resolv.conf;
echo "nameserver 10.64.106.1" >> /etc/resolv.conf;
echo "nameserver 10.64.6.1" >> /etc/resolv.conf;
 
#
# Following the editing of the configuration files,
# restart Network services
#
/etc/init.d/network restart

                            
Set up mount points. Now set-up mount points from the new server (test-server) to some remote server on our network (called remote-server). The task involves editing the /etc/fstab file and mounting the new mount point.

                               
mkdir /mp_other_server;
echo 
"remote-server:test-server / mp_other_server nfs rsize=8192,wsize=8192,timeo=:4,intr" 
>> /etc/fstab;
mount -a;

                            

Add network printers. After setting up printers with the GUI setup on a system a user export the configuration (in XML format) and later import the configuration into the same or a different server. (See Red Hat docs for more details. ) To export the configuration from a server that has already been configured run the following command:

/usr/sbin/Red Hat-config-printer-tui --Xexport > settings.xml      
There are options to either import and overwrite any existing printer settings or to update the existing settings with new entries.
/usr/sbin/Red Hat-config-printer-tui --Ximport < settings.xml
/usr/sbin/Red Hat-config-printer-tui --Ximport --merge < settings.xml
After an import of either type, the printer services need to be restarted:
/sbin/service cups restart
Create "message of the day." If you would like a message displayed when a user initially logs on to the server, the /etc/motd file must be edited to contain the desired message.
                               
echo "################################################### "  > /etc/motd
echo "" >> /etc/motd
echo "      Welcome to 'hostname'                         "  >> /etc/motd
echo "       'date'                                       "  >> /etc/motd
echo "" >> /etc/motd
echo "################################################### "  >> /etc/motd
echo "" >> /etc/motd

                            
Other configuration tasks. The tasks listed above are representative but by no means exhaustive; you could consider installation automation and configuration strategies for additional software such as Web servers, Web browsers, and mail servers. For example, some tasks could be completed to satisfy security concerns:
  • Stop specific processes and/or configure them not to sta
  • Uninstall software packages
  • Set up monitoring jobs
Other, miscellaneous tasks could include
  • Setting up aliases (for commonly used commands)
  • Application of patches
  • Scheduling of administrative tasks via cron
Automating Oracle Installations

The Oracle Universal Installer has a number of features that might be leveraged in the automation process. It utilizes an XML-based central repository that allows third party applications to identify what products are installed. Besides simple installations, it allows the cloning of existing Oracle homes to new locations. More information about this product can be found in the Oracle Universal Installer Concepts Guide .

Oracle's solution to automating the installation and configuration of software and even the database itself involves the use of a response file, which serves a similar purpose to Red Hat's kickstart file. Rather than interactively answering questions that are posed by interactive dialogs, a user's answers are stored in a text file that is then used by Oracle Universal Installer (OUI) when the installation program is run. Such an installation is called a "silent installation." The OUI is used to install a variety of applications, so response files are not limited to the installation of databases.

Response files can be created by running the software in record mode or by manually editing a sample response file. Here's a basic demo:

  1. Start the OUI with this command to create the response file:
  2.  ./runInstaller -record -destinationFile /tmp/recorded.rsp
    
  3. Make all the selections you want to (source destination, home, home name, products).
  4. When you get to the Summary screen, instead of clicking on Install, click on Cancel.
  5. Examine the resulting response file created in tmp/recorded.rsp. If desired, you can manually edit this file as long as you adhere to the prescribed format (see documentation).
  6. Now perform the silent installation like this:
    ./runInstaller -silent -responseFile /tmp/recorded.rsp
    
    The progress of the installation will be reported as the script is being run.
If you have a problem with the installation due to incorrect entries in the response file, the installation will fail with a diagnostic message. Further information can be found in the oraInventory/logs directory. Logs with names in the format installActions-<date-timestamp>.log and silentInstall<date-timestamp>.log are created each time the OUI is run using a response file.

Oracle Database Post-Installation

After the database software (and optionally an Oracle database) has been installed and configured, you can use utilize additional automation approaches. For example:

  1. A database might be created using an RMAN restore and recovery.
  2. Database imports using traditional or Data Pump import can be used to populate an existing database.
  3. Database users can be added and configured within the database.
Shell scripts, SQL scripts, and PL/SQL packages can be used to accomplish these tasks as well as many others.

Conclusion

Red Hat and Oracle have designed their products with the intention of being effectively managed in large, enterprisewide installation. Simply using Red Hat kickstart files and Oracle response files (along with a bit of shell scripting) can allow you to make the most efficient, optimal use of your time as you administer your servers and databases. And through developing a disciplined installation process required to make use of these automated installations, you might learn a thing or two about Linux, Oracle, and the tools and techniques available that are applicable to other areas of your work.


Casimir Saternos is an Oracle Certified DBA, IBM Certified Enterprise Developer and Sun Certified Java Programmer based in Allentown, Pa.