| DBA: Linux
Automating Installation of Oracle Database 10g and Red Hat Enterprise Linux
Get an introduction to the tools and processes involved in building a Linux server from the ground up via scripts and configuration files.
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:
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:
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:
When the Kickstart Configurator is run, you will need to answer the same set of questions that are asked during a standard, interactive installation.
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=18.104.22.168 --netmask=255.255.251.0 --gateway=22.214.171.124 --nameserver=126.96.36.199 --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 SupportWhen 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
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 -pSee 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:
This script will add entries, edit existing entries, and re-start the network services.
# # Edit /etc/hosts # echo "188.8.131.52 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 restartSet 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.xmlThere 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.xmlAfter an import of either type, the printer services need to be restarted:
/sbin/service cups restartCreate "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/motdOther 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:
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:
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:
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.