You are here

Oracle Linux and RHEL Kickstart Installation Guide

This chapter of the Oracle Cloud Cookbook describes how to implement a Linux kickstart and post build scripted configuration process for repeatable Oracle Linux and Red Hat Enterprise Linux installations. 

Author: Roddy Rodstein

Table of Contents

What will be covered?
Kickstart installation Overview
Tree structure
Kickstart File
Make the Kickstart File Available on the Network
Make the OS Installation Tree Available on the Network
The Syntax in Oracle VM Manager to Start a Kickstart Installation
How to kickstart an Oracle VM PVM Linux Install, using Network Boot Path Args for Kickstart and Installation Source
How to Kickstart a Physical Server, VMware Linux VM, and an Oracle HVM VM, using Network Boot Path Args for Kickstart, Network Config and Installation Source
Post Build Script Configuration
linux_setup.sh
Variables
Task Sections
Fix_Hosts
Setup_Admins
user_add_admins.sh
Base_Config
Base_Chkconfig
OL6_Update
SNMP_Setup
Oracle_11Pre & Oracle_12Pre
Oracle_Password
Oracle_Agent
user_add_oms.sh
12cR1_Pre, 12cR1_Stage, 12cR1_Profile, 12cR1_Install, 12cR1_Post
Main
How Main Works
Full Script

 

Kickstart installation Overview

What is kickstart? The kickstart installation process was developed by Red Hat to fulfill a system administrator need to use an automated installation method for linux installations. Using kickstart we can create a single file containing the answers to all the questions that would be asked of the installing user during a typical installation process.

What is needed for kickstart installation?
This chapter will demonstrate kickstart installations with Oracle VM, but the same method works with other hypervisors and physical server installations. In fact, with minor changes to the drive information section (OVM uses xvda for 1st drive) of the kickstart file, the same kickstart contents can be used for kickstart files for VMware and physical installs, providing a consistent basic installation across many environments.

Different platforms, i.e. Oracle VM, VMware or physical will have different kickstart disk device syntax. To determine the disk device syntax, do an OS installation as you usually would, and look at the your anaconda file (# cat /root/anaconda-ks.cfg). The anaconda-ks.cfg file will contain the proper disk device syntax for your kickstart file. 

Kickstart installation can be performed using a local CD-ROM, a local hard drive, or using NFS, FTP or HTTP.

This document will focus on HTTP as we set this up on our standard Oracle VM Manager installations as a yum repository and stage location for installation process. The Tree Structure is shown below.

To use kickstart, you need;

  • kickstart file
  • kickstart file available on network
  • OS installation tree available on network
  • string to start kickstart installation


Tree Structure

Below is a tree of the example http structure used in my environment. The process used throughout this document will refer to this tree structure for the paths.

Stage is, well a stage location for ISO, scripts, mountpoints, etc.

Yum is for the creation of date locked yum repositories. We patch servers off locked repos to ensure servers across the Enterprise are at same patch level. When we need to move to a new date locked yum repository we run a script, and create a new .repo file (repo_files) to use on the linux hosts and patch them to that new level.

# tree /var/www/html
/var/www/html
├── stage
│   ├── ISO                        Location for ISO files
│   │   ├── OL_6U5_x86_64.iso
│   │   └── OL_7_x86_64.iso
│   ├── kickstart                    Location for kickstart files
│   │   └── 6u5-09252014.cfg
│   ├── mount                        Location of mountpoints to mount ISO files
│   │   ├── ol6
│   │   └── ol7
│   ├── repo_files                    Location of repo files
│   │   └── 08262014_OL6_UEKR3.repo
│   └── scripts                        Location for scripts
│       └── linux_setup.tar
└── yum                        Location of Yum repositories
    ├── OracleLinux                    OL6 YUM
    │   ├── 08262014_OL6                Date Locked OL6 YUM Repo
    │   │  └── latest
    │   │     └── x86_64
    │   ├── createrepo_ol6.sh                script to create date locked OL6 yum repo
    │   └── OL6                        uln-yum-mirror - OL6 latest
    │       └── latest
    │            └── x86_64
    └── OracleVM                    OVM YUM
         ├── 08262014_OVM3                Date Locked OVM YUM Repo
         │   └── latest
         │       └── x86_64
         ├── createrepo_ovm3.sh                script to create date locked OVM3 yum repo
         └── OVM3                    uln-yum-mirror - OVM3 latest
               └── latest
                   └── x86_64


Kickstart File

A best practice is to keep the kickstart file simple with basic disk and package requirements. Anything that requires more detailed configuration should be done using a modular post installation script.

Before we move on, let's review the logic behind keeping a kickstart file simple.

  • Kickstart - Many folks use complex kickstart files, and end up commenting out sections of the kickstart files to setup different types of servers or worse, having multiple kickstart files, i.e. one kickstart file for each type of server. Complex kickstart files, or a collection of different kickstart files can be challenging to maintain.
  • Virtual Machine Templates - The same goes for virtual machine templates, multiple templates for different VM builds, and in different environments, and different clusters, or site locations (i.e. VMware, Oracle VM, Production, Test, DR, etc.). 

With complex kickstart files, if you want to make a change to your standard setup like permissions, new directory or a limits.conf change, it is necessary to make that change in one or more kickstart files and/or multiple virtual machine templates. These changes take lots of time and worse, if you miss the change in one or more kickstart files, or virtual machine templates, you end up with a non standard system build. Next, your DBAs or SAP Basis teams are putting the delay and blame on your team. 

Keeping OS build changes and details in one simple kickstart file with a modular post installation script could handle all your build needs without worrying about replicating changes in multiple kickstart files and virtual machine templates.

Now to the kickstart file. The example kickstart file presented below is a simple field tested standard build designed with simplicity and reproducibility. For details on available option refer to the Red Hat Enterprise Linux 6 documentation.

Replace xxx.xxx.xxx.xxx with your IP address, Netmask and Gateway for each build.
Replace yyy.yyy.yyy.yyy with your stage http server IP address for each build.
Replace hostname with your hostname for each build.
Replace xvda with your drive information. Oracle VM uses xvda for 1st drive, VMware or physical may use sda or a different syntax for 1st drive.

# cat /var/www/html/stage/kickstart/6u5-09252014.cfg
# Kickstart file automatically generated by anaconda.

#version=MokumSolutions.com    #root password is P@ssword1
install
url --url=http://yyy.yyy.yyy.yyy/stage/mount/ol6/
lang en_US.UTF-8
keyboard us
network --onboot yes --device eth0 --bootproto static --ip xxx.xxx.xxx.xxx --netmask xxx.xxx.xxx.xxx --gateway xxx.xxx.xxx.xxx --noipv6 --hostname hostname
rootpw  --iscrypted  $6$V4dgMRp3.Rq/Iv5F$CcNPvwj6kYzOopxup44il13BK2XMLFw5B0dwd2yr0Bs3SYUbPgpUk2wOFR33qUjr7YPQrSvI1488xFxlyOU/00
firewall --disabled
authconfig --enableshadow --passalgo=sha512
selinux --disabled
timezone --utc America/New_York
bootloader --location=mbr --driveorder=xvda --append="crashkernel=auto rhgb"
# The following is the partition information you requested
# Note that any partitions you deleted are not expressed
# here so unless you clear all partitions first, this is not guaranteed to work
clearpart  --all --drives=xvda
zerombr yes
part /boot --fstype=ext4 --asprimary --size=500 --ondisk xvda
part pv.root --asprimary --size=1 --grow --ondisk xvda

volgroup vg00 --pesize=4096 pv.root
logvol /home --fstype=ext4 --name=home --vgname=vg00 --size=10240
logvol / --fstype=ext4 --name=root --vgname=vg00 --size=12288
logvol swap --name=swap00 --vgname=vg00 --size=520
logvol /tmp --fstype=ext4 --name=tmp --vgname=vg00 --size=10240
logvol /u02 --fstype=ext4 --name=u02 --vgname=vg00 --size=6144

repo --name="UEK3 kernel repo"  --baseurl=http://yyy.yyy.yyy.yyy/stage/mount/ol6/UEK3/ --cost=1000

%packages
@Base
@Core
@base
@client-mgmt-tools
@console-internet
@core
@debugging
@directory-client
@hardware-monitoring
@java-platform
@large-systems
@network-file-system-client
@performance
@perl-runtime
@server-platform
@server-policy
certmonger
device-mapper-persistent-data
krb5-workstation
nmap
oddjob
pam_krb5
pax
perl-DBD-SQLite
python-dmidecode
samba-winbind
sgpio
tuned
tuned-utils
xauth
xorg-x11-apps

%post --log=/root/kickstart-post.log
cd /root
wget http://yyy.yyy.yyy.yyy/stage/scripts/linux_setup.tar
%end

Make the Kickstart File Available on the Network

The above example kickstart file is named 6u5-09252014.cfg and, per the previously discussed tree structure, it is located in /var/www/html/stage/kickstart/ and is available from a browser.
 
# ll /var/www/html/stage/kickstart/
total 8
-rwxr-xr-x 1 root root 1966 Sep 25 08:01 6u5-09252014.cfg
Figure 1
Oracle Linux Kickstart File
 
To validate access to this kickstart file from your server or hypervisor, you can use the wget command;

# wget http://yyy.yyy.yyy.yyy/stage/kickstart/6u5-09252014.cfg
--2014-09-25 11:21:21--  http://yyy.yyy.yyy.yyy/stage/kickstart/6u5-09252014.cfg
Connecting to yyy.yyy.yyy.yyy:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 1966 (1.9K) [text/plain]
Saving to: “6u5-09252014.cfg”

100%[======================================================================================================>] 1,966       --.-K/s   in 0s

2014-09-25 11:21:21 (188 MB/s) - “6u5-09252014.cfg” saved [1966/1966]

This validates that the kickstart file is accessible.


Make the OS Installation Tree Available on the Network

Per the previously discussed Tree structure, the example keeps the ISO files in /var/www/html/stage/ISO/, and mounts them to directories in /var/www/html/stage/mount/. In this instance, the OL6 Update 5 ISO file is mounted as described below and can be accessed with a web browser.
# mount -o loop /var/www/html/stage/ISO/OL_6U5_x86_64.iso /var/www/html/stage/mount/ol6/
# mount
...
/var/www/html/stage/ISO/OL_6U5_x86_64.iso on /var/www/html/stage/mount/ol6 type iso9660 (rw,loop=/dev/loop0)
 
To validate access to this installation tree, point your web browser to the mount point on the web server, i.e. http://IP_ADDRESS/stage/mount/ol6
Figure 2
Oracle Linux Kickstart Install Tree


The Syntax in Oracle VM Manager to Start a Kickstart Installation

How to kickstart an Oracle VM PVM Linux Install, using Network Boot Path Args for Kickstart and Installation Source

This kickstart example uses 1 - 39GB virtual disk for the installation. 
Figure 3
Oracle VM Linux Kickstart Install Disk Configuration

On the Boot Order Tab ensure PXE boot is at the top of the list and add --args string to Network Boot Path:
Figure 4
Oracle VM Linux Kickstart Install Boot Options

Next, start the VM and Launch the VM Console.
Figure 5
Oracle VM Linux Kickstart Install Virtual Machine VNC Console

When the kickstart installation completes do not click Reboot. First we need to Stop the VM in the Oracle VM Manager GUI and change the Boot Order to remove PXE so the VM will boot from the installed OS disk. Then we can start the VM.
Figure 6
Oracle VM Linux Kickstart Install Power Off the Virtual Machine
 
The VM is now built to the specification of the kickstart file.

# df -h
Filesystem             Size  Used Avail Use% Mounted on
/dev/mapper/vg00-root   12G  2.1G  9.1G  19% /
tmpfs                  495M     0  495M   0% /dev/shm
/dev/xvda1             477M   55M  398M  12% /boot
/dev/mapper/vg00-home  9.8G   23M  9.2G   1% /home
/dev/mapper/vg00-tmp   9.8G   23M  9.2G   1% /tmp
/dev/mapper/vg00-u02   5.8G   12M  5.5G   1% /u02

# free -m
             total       used       free     shared    buffers     cached
Mem:           988        101        887          0         10         41
-/+ buffers/cache:         49        939
Swap:          519          0        519

 

How to Kickstart a Physical Server, VMware Linux VM, and an Oracle HVM VM, using Network Boot Path Args for Kickstart, Network Config and Installation Source

This would be the same process to perform a kickstart in VMware or on a physical machine installation. The only difference would be the disk devices listed in the kickstart file. The rest of the process is exactly the same.

With an Oracle HVM machine we would boot from CD-ROM, just like a physical machine or a server with an ISO file attached through virtual media via ILO ot iDRAC if you prefer.

When booting from OL65 iso media we would see this screen.
Figure 7
Oracle Linux Boot Screen
 
We then have 1 minute to select from the options or hit “esc” to access the cli prompt.

boot:

From here we would type in the location of the kickstart file and network configuration for the system. 

linux ks =http://192.168.3.131/stage/kickstart/6u5-09252014.cfg ksdevice=eth0 ip=192.168.20.130 netmask=255.255.255.0 gateway=192.168.20.254

Note: Change the bold section to meet your environmental requirements. 

Figure 8
Oracle Linux Boot Screen Enter Kickstart Details

Now the system will configure the network, access the kickstart file and perform the kickstart installation.

In the above example, we were able to use the exact same kickstart file because the disk devices are the same, i.e. this was a Linux install on Oracle VM. The only difference for a physical or VMware kickstart install would be a change in the kickstart file for the disk devices. We have also used this same process for boot from SAN installs. Also, you just need to change the disk devices.

The next example shows the section of the kickstart file, i.e. xvda that would need to be changed for a physical or VMware kickstart install.
clearpart  --all --drives=xvda
zerombr yes
part /boot --fstype=ext4 --asprimary --size=500 --ondisk xvda
part pv.root --asprimary --size=1 --grow --ondisk xvda

Note: On boot from SAN installs, rename vg00 to vgSAN so it is easily identifiable that the system is boot from SAN.


Post Build Script Configuration

The post build script tar file was copied to the new Linux operating system (VM) via a wget command in %post section of the kickstart file. The tar file can be viewed on the new Linux operating system’s file system in the /root directory.

The next example shows the wget command in the post installation section of the example kickstart file. 
%post --log=/root/kickstart-post.log
cd /root
wget http://yyy.yyy.yyy.yyy/stage/scripts/linux_setup.tar
%end

Change into the /root directory and extract the linux_setup.tar file. Next, change into linux_setup directory.

# cd /root
# ll
total 84
-rw-------. 1 root root  2055 Sep 25 15:21 anaconda-ks.cfg
-rw-r--r--. 1 root root 28741 Sep 25 15:21 install.log
-rw-r--r--. 1 root root  7572 Sep 25 15:19 install.log.syslog
-rw-------. 1 root root   388 Sep 25 15:21 kickstart-post.log
-rw-r--r--. 1 root root 30720 Sep 25 10:38 linux_setup.tar
# tar -xvf linux_setup.tar
# cd linux_setup
# ll
total 32
-rw-r--r-- 1 root root   870 Aug  4 14:31 dbora
-rwxr--r-- 1 root root 12892 Sep 24 16:41 linux_setup.sh
-rw-r--r-- 1 root root   746 Aug  4 11:25 oracle_bash_profile.txt
-rwxr--r-- 1 root root   619 Feb 25  2012 user_add_admins.sh
-rwxr--r-- 1 root root  1358 Sep 24 16:24 user_add_oma.sh

 

linux_setup.sh

The portion of the script in is for basic installation and can be built upon for more complete coverage of your environment.

The script starts with Variables that would be defined per your environment. Replace the bold text with your environment information.


Variables

# Variables
flag=$1
SCRIPT="linux_setup.sh"
TARBALL="/root/linux_setup.tar"
HOST=`hostname`
SETUP_DIR="/root/linux_setup"
RPM_DIR="$SETUP_DIR/RPMS"
UNAME="uname -r"
TAR="/bin/tar"
CHMOD="/bin/chmod"
RPM="/bin/rpm"
CHKCONFIG="/sbin/chkconfig"
DOMAIN=.yourdomain.com  #notice the leading dot
SEARCH=yourdomain.com
DNS1=your.dns.ip.address
#DNS2=                            #if using 2nd DNS uncomment and add IP
#DNS3=                            #if using 3rd DNS uncomment and add IP

ROCOMMUNITY=Mokum_Mgmt                #replace with your rocommunity string
SYSLOCATION="Mokum HQ"                #replace with your syslocation string
ADMINGROUP=youradmingroup                #your admin group will have full sudo permissions
IPLOCAL=`ifconfig  | grep 'inet addr' | awk '{print $2}' | cut -d ':' -f2 | grep -v 127.0.0`
REPO1='http://yyy.yyy.yyy.yyy.yyy/stage/repo_files/08262014_OL6_UEKR3.repo'
MV="/bin/mv"
db12cR1_stage_file1="http://yyy.yyy.yyy.yyy.yyy/stage/oem/linuxamd64_12c_database_1of2.zip"    # used for Oracle12c staging
db12cR1_stage_file2="http://yyy.yyy.yyy.yyy.yyy/stage/oem/linuxamd64_12c_database_2of2.zip"    # used for Oracle12c staging

 

Task Sections

Each task section performs a specific function in the script. The Task sections are individually or in groups later in the Main section of the script by $flag (This will be discussed later).

Below we will discuss the individual task sections.


Fix_Hosts

This section fixes the hosts file such that # hostname returns shortname and # hostname -f returns the fqdn.

Fix_Hosts() {
        echo "#####################################################"
        echo " "
        echo "Fixing hosts file and hostname -f"
        echo $IPLOCAL   $HOSTNAME$DOMAIN  $HOSTNAME >> /etc/hosts
        hostname -f $HOSTNAME$DOMAIN
        echo " "
        echo "Done."

        }

Setup_Admins

This section calls the user_add_admins script and adds $ADMINGROUP to /etc/sudoers

Setup_Admins() {
        echo "#####################################################"
        echo " "
        echo "Creating admin users, adding $ADMINGROUP to sudoers"
        $SETUP_DIR/user_add_admins.sh

        #add $ADMINGROUP to sudoers file
        echo "%"$ADMINGROUP' ALL=(ALL)     ALL' >> /etc/sudoers

        echo " "
        echo "Done."

        }

user_add_admins.sh

This script adds the admin group and users and sets a default password. You could change this script to include hashed passwords that are used by your users for more security, but for simplicity, we provide this to start with.

Replace mokumadmin with your admin group name (also replace gid with your desired gid).
Replace username1 and username2 with your users (also replace uid with your desired uid).

# cat user_add_admins.sh
#!/bin/bash
#set -xv
###########################################################
#
#  name: user_add_admins.sh
#  author: Jeff Wilkins  jeff.wilkins@mokumsolutions.com
#  version: 1.1
#  Date: 07/16/2014
#
###########################################################

# add the mokumadmin group and mokumadmin users

groupadd -g 5000 mokumadmin
adduser -g mokumadmin -u 5000 -c "Roddy Rodstein - Mokum Admin" username1
adduser -g mokumadmin -u 5001 -c "Jeff Wilkins - Mokum Admin" username2
# setting the default password for everyone

for ADMINS in username1 username2
do

        echo "yourpassword" | passwd --stdin -f $ADMINS
done

Base_Config

This section will update /etc/resolv.conf with search and DNS information. I have $DNS2 and $DNS3 entries commented out. You can uncomment and set the variables for these as needed for your environment.

Note: I also disable Network Manager because I really do not like it.

SElinux is also disabled since most environments do not use it. I have only seen SElinux used for government systems. If you need it, just comment it out or move it to it’s own section and don’t call it in the Main section.

Base_Config() {
        echo "#####################################################"
        echo " "
        echo "Setting Base configurations"
        echo "Adding $DOMAIN, $DNS1, $DNS2 & $DNS3 to resolve.conf, disabling NetworkManager, disabling selinux"

        #add entries to resolv.conf
        cp /etc/resolv.conf /etc/resolv.conf.orig
        echo 'search '$SEARCH > /etc/resolv.conf
        echo 'nameserver '$DNS1 >> /etc/resolv.conf
        #echo 'nameserver '$DNS2 >> /etc/resolv.conf
        #echo 'nameserver '$DNS3 >> /etc/resolv.conf

        #disable NetworkManager
        $CHKCONFIG NetworkManager off
        /etc/init.d/NetworkManager stop

        #disable selinux
        setenforce 0
        cp /etc/selinux/config /etc/selinux/config.orig
        sed -e '/SELINUX/ s/^/#/' /etc/selinux/config > /etc/selinux/config.new
        mv -f /etc/selinux/config.new /etc/selinux/config
        echo SELINUX=disabled >> /etc/selinux/config
        rm -rf /etc/selinux/config.new

        echo " "
        echo "Done."

        }

Base_Chkconfig

This section is for chkconfig on/off and stopping or starting processes. You can add and remove per your requirements. We are currently just turning on ntpd and turning off iptables.

Base_Chkconfig() {
        echo "#####################################################"
        echo " "
        echo "Changing chkconfig settings"
        $CHKCONFIG ntpd on
        $CHKCONFIG iptables off
        $CHKCONFIG ip6tables off
        /etc/init.d/iptables stop
        /etc/init.d/ip6tables stop

        echo " "
        echo "Done."

        }

OL6_Update

This section disables the default Oracle public yum repository “public-yum-ol6.repo” in Oracle Linux 6 and does a wget of a date locked repo file from the the httpd server. Once this is done it will run yum update against the locked repo to patch the system to that date.

If you are using another version of Oracle Linux or version of Red Hat Enterprise Linux in your environment, make specific task section similar to this for those versions. You can create another $flag in the Main section to do the same for the other OS version you use (e.g OL7_Update).

OL6_Update() {
        echo "#####################################################"
        echo " "

        echo "Setting Up YUM repository and running yum updates"
        cd /etc/yum.repos.d
        wget $REPO1
        $MV public-yum-ol6.repo public-yum-ol6.repo.disabled
        yum clean all
        sleep 10
        echo "Running yum update, this could take a while."
        yum update -y
        sleep 10

        echo " "
        echo "Done."

        }

SNMP_Setup

This section installs and turns on snmp. It also sets the rocommunity and syslocation strings from the variables provided.

SNMP_Setup() {
        echo "#####################################################"
        echo " "
        echo "Setting Up snmp"

        #setup snmpd
        yum install net-snmp net-snmp-utils -y
        cp /etc/snmp/snmpd.conf /etc/snmp/snmpd.conf.orig
        echo rocommunity $ROCOMMUNITY >> /etc/snmp/snmpd.conf
        echo syslocation $SYSLOCATION >> /etc/snmp/snmpd.conf
        $CHKCONFIG snmpd on

        sleep 10

        echo " "
        echo "Done."

        }

Oracle_11Pre & Oracle_12Pre

These Task sections are to install prerequisites for Oracle 11g and 12c DB installs. 

The oracle-rdbms-server-11gR2-preinstall RPM, formally know as oracle-validated, simplifies meeting the software and system configuration prerequisites for installing the Oracle Database on Oracle Linux 6. Installing the oracle-rdbms-server-11gR2-preinstall RPM automatically installs all of the software RPM prerequisites for the Oracle Database, as well as meeting the system configuration prerequisites, such as creating an oracle user and the oinstall and dba groups, configuring the sysctl.conf settings, system startup parameters, user limits, and driver parameters. After the installation of the oracle-rdbms-server-11gR2-preinstall RPM, you can confidently start the Oracle Database product installer. The oracle-rdbms-server-11gR2-preinstall RPM is available at the Oracle Unbreakable Linux Network, on the Oracle Linux media, and from the Oracle public yum repository.

Unfortunately Oracle require their Unbreakable Enterprise Kernel (UEK) for the oracle-rdbms-server-11gR2-preinstall RPM install, the Red Hat Enterprise Linux kernel cannot be used on RHEL.

Oracle_11Pre() {
        echo "#####################################################"
        echo " "
        echo "Oracle RDBMS Preinstall"
        yum install oracle-rdbms-server-11gR2-preinstall.x86_64 -y
        sleep 10

        echo " "
        echo "Done."

        }

Oracle_12Pre() {
        echo "#####################################################"
        echo " "
        echo "Oracle RDBMS Preinstall"
        yum install oracle-rdbms-server-12cR1-preinstall.x86_64 -y
        sleep 10

        echo " "
        echo "Done."

        }

Oracle_Password

The oracle-rdbms-server-preinstall packages creates the oracle user, this just sets a password for the user and makes a dba group change in /etc/sudoers.

Oracle_Password() {
        echo "#####################################################"
        echo " "
        echo "Changing Oracle user password and dba group changes for /etc/sudoers"
        for USER in oracle
                do
                        echo "yourpassword" | passwd --stdin -f $USER
                done


        echo "%dba  ALL=(ALL)       NOPASSWD: ALL"   >> /etc/sudoers
        echo " "
        echo "Done."

        }

Oracle_Agent

This section calls the user_add_oma.sh script. We create this user as the Oracle Agent Install user for Oracle Enterprise Manager and use it for OEM management of hosts. You can change the username or use/not use this as your environment demands.

Oracle_Agent() {
        echo "#####################################################"
        echo " "
        echo "Oracle Management Agent user setup"
        $SETUP_DIR/user_add_oma.sh

        echo " "
        echo "Done."

        }

user_add_oms.sh

This script add oinstall group and oma user. It also performs some

# cat user_add_oma.sh
#!/bin/bash
#set -xv
###########################################################
#
#  name: user_add_oma.sh
#  author: Jeff Wilkins  jeff.wilkins@mokumsolutions.com
#  version: 1.1
#  Date: 07/16/2014
#
###########################################################

#groupadd, if not already created
groupadd -g 54322 oinstall

adduser -g oinstall -u 54322 -c "Oracle Management Agent user" oma
# setting the default password

for USER in oma
do
        echo "yourpassword" | passwd --stdin -f $USER
done

echo " "
echo "Modifying sudoers for dba group and oma user"
sleep 5
echo "oma ALL = NOPASSWD: /usr/bin/id, /bin/chmod, /bin/cp, /bin/mkdir, /bin/rm, /bin/tar, /bin/chmod, /usr/bin/yum, /usr/sbin/up2date, /bin/sed, /bin/rpm, /u01/app/oracle/product/agent_inst/bin/emctl, /u01/app/oracle/product/core/12.1.0.1.0/sysman/install/agentDeploy.sh, /u01/app/oracle/product/core/12.1.0.2.0/oui/bin/runInstaller, /u01/app/oracle/product/core/12.1.0.2.0/bin/unzip, /u01/app/oracle/product/*/unzipTmp/unzip, /u01/app/oracle/product/*/agentdeployroot.sh, /u01/app/oracle/product/*/agentDeploy.sh"   >> /etc/sudoers
echo 'Defaults:oma    !requiretty'  >> /etc/sudoers
sed -i '/Defaults   !visiblepw/s/!//' /etc/sudoers

12cR1_Pre, 12cR1_Stage, 12cR1_Profile, 12cR1_Install, 12cR1_Post

These following scripts show how to set and validate prerequisites, stage installers, setup the oracle user profile, start the installation of an Oracle 12cR1 database and to execute various database post install steps. The following scripts are a “work in progress” and should be considered as an example of things you could do in the script rather than a validated process. 

12cR1_Pre() {
        echo "#####################################################"
        echo " "
        echo "Oracle 12cR1 DB install pre-reqs for OEM"
        echo " "
        echo "Checking X11Forwarding"

        cat /etc/ssh/sshd_config | grep X11Forwarding
        read -p 'Is X11Forwarding set to Yes (yes/no?): '
        while true; do
                case $REPLY in
                        [yY]|[yY][eE][sS])      echo X11Forwarding yes Confirmed ; break ;;
                            [nN]|[nN][oO])      echo "/etc//ssh/sshd_config X11Forwarding must be set to X11Forwarding yes to continue. Exiting" ; exit ;;
                                        *)      echo "Invalid argument, Exiting. Please re-run script." ; exit;;
                esac
        done

        echo " "
        echo "Setting tmpfs to 4G"
        umount shmfs
        mount -t tmpfs shmfs -o size=4g /dev/shm
        DATE=`date +%m%d%y`
        cp /etc/fstab /etc/fstab.$DATE
        sed -e '/tmpfs/ s/^/#/' /etc/fstab > /etc/fstab.new
        echo "tmpfs        /dev/shm        tmpfs    size=4g        0 0" >> /etc/fstab.new
        mv -f /etc/fstab.new /etc/fstab
        echo "tmpfs set to 4G and fixed in fstab"
        sleep 5

        echo " "
        echo "Setting security limits in /etc/security/limits.d/oracle-rdbms-server-12cR1-preinstall.conf"
        echo "Note: oracle-rdbms-server-12cR1-preinstall has limits set in a new file /etc/security/limits.d/oracle-rdbms-server-12cR1-preinstall.conf"
        sleep 10
        sed -i.$DATE s/'nofile    1024'/'nofile    4096'/g /etc/security/limits.d/oracle-rdbms-server-12cR1-preinstall.conf
        echo "Setting security limits in /etc/security/limits.d/90-nproc.conf"
        sed -i.$DATE s/1024/16384/g /etc/security/limits.d/90-nproc.conf
        echo "security limits set"
        sleep 5
        echo " "
        wget http://download.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noa...
        rpm -ivh epel-release-6-8.noarch.rpm
        sed -i.$DATE s/'gpgcheck=1'/'gpgcheck=0'/g /etc/yum.repos.d/epel.repo
        yum install sshpass -y
        sleep 5
        echo "Now we need to validate oracle nofile limit is >= 4096."
        echo "To do this we will install and remove when done, epel and sshpass."
        echo " "
        sshpass -p $PASSWORD ssh oracle@localhost ulimit -n
        read -p 'Script just ran command to list ulimit -n for oracle user, was the value displayed >=4096 (yes/no?): '
        while true; do
                case $REPLY in
                        [yY]|[yY][eE][sS])      echo "ulimit -n setting validated." ; break ;;
                            [nN]|[nN][oO])      echo "If the oracle soft nofile limit is not set, an error will be received during OEM installation, you must correct this issue." ; break ;;
                                        *)      echo "Invalid argument, Exiting. Please verify ulimit -n >= 4096 for oracle user prior to OEM installation." ; break ;;
                esac
        done
        sleep 5
        rpm -e sshpass-1.05-1.el6.x86_64
        rpm -e epel-release-6-8.noarch
        rm -rf /etc/yum.repos.d/epel.repo.rpmsave
        rm -rf /root/linux_setup/epel-release-6-8.noarch.rpm
        echo " "
        echo "/etc/yum.repos.d/epel.repo.rpmsave removed."
        echo "Done with security limits."

        }

12cR1_Stage() {
        echo "#####################################################"
        echo " "
        echo "Staging Oracle 12cR1 install files."
        mkdir -p /u01/stage/db12c; cd /u01/stage/db12c; wget $db12cR1_stage_file1; wget $db12cR1_stage_file2
        unzip linuxamd64_12c_database_1of2.zip; unzip linuxamd64_12c_database_2of2.zip
        sleep 5
        echo " "
        echo "Removing zip files to save space."
        rm -rf /u01/stage/db12c/linuxamd64_12c_database*
        echo " "
        echo "Staging Done."

        }

12cR1_Profile() {
        echo "#####################################################"
        echo " "
        echo "Setting up ~/bash_profile for oracle user for 12cR1 and OEM 12cR4."
        DATE=`date +%m%d%y`
        cp /home/oracle/.bash_profile /home/oracle/.bash_profile.$DATE
        cat /root/linux_setup/oracle_bash_profile.txt >> /home/oracle/.bash_profile

        echo " "
        echo "oracle user ~/.bash_profile setup complete."

        }

12cR1_Install() {
        echo "#####################################################"
        echo " "
        echo "Creating oraInst.loc file in /etc."
        DATE=`date +%m%d%y`
        #cp /etc/oraInst.loc /etc/oraInst.loc.$DATE
        #cp /root/linux_setup/oraInst.loc /etc/oraInst.loc
        #chown oracle:oinstall /etc/oraInst.loc; chmod 664 /etc/oraInst.loc
        echo "Creating OFA standard directories."
        mkdir -p /u01/app/oracle/product/12.1.0/dbhome_1
        chown -R oracle:oinstall /u01/*
        chmod -R 775 /u01/*
        echo " "
        echo "OFA directories created'"
        echo " "
        echo "Beginning Oracle 12cR1 DB install using OUI. You will be required to type the oracle password to begin the install."
        sleep 10
        ssh -X oracle@localhost /u01/stage/db12c/database/runInstaller
        echo " "
        echo "Script call Oracle 12cR1 OUI install complete."

        }

12cR1_Post() {
        echo "#####################################################"
        mkdir /u01/app/oracle/product/redo_logs/
        echo " "
        echo "Modifying /etc/oratab for autostart."
        DATE=`date +%m%d%y`
        sed -i.$DATE s/:N/:Y/g /etc/oratab
        echo "Done"
        sleep 2
        echo " "
        echo "setting up dbora script in /etc/init.d and init.d soft links"
        chmod 750 /etc/init.d/dbora; chkconfig dbora on
        ln -s /etc/init.d/dbora /etc/rc.d/rc0.d/K01dbora
        ln -s /etc/init.d/dbora /etc/rc.d/rc3.d/S96dbora
        ln -s /etc/init.d/dbora /etc/rc.d/rc5.d/S96dbora
        echo " "
        echo "Done."
        sleep 2

        echo " "
        echo "The following is a list of sqlplus commands to configure the db for a small OEM environment. Please su - oracle and run the commands and return to complete the setup."
        echo " "; echo " "; echo " "; echo " "; echo " "; sleep 5
        echo "sqlplus / AS SYSDBA"
        echo "ALTER SYSTEM SET processes=300 SCOPE=SPFILE;"
        echo "ALTER SYSTEM SET pga_aggregate_target=1024M SCOPE=SPFILE;"
        echo "ALTER SYSTEM SET sga_target=2G SCOPE=SPFILE;"
        echo "ALTER SYSTEM SET shared_pool_size=600M SCOPE=SPFILE;"
        echo "ALTER SYSTEM SET db_securefile=PERMITTED SCOPE=BOTH;"
        echo "ALTER DATABASE force logging;"
        echo "ALTER TABLESPACE users FORCE LOGGING;"
        echo "ALTER DATABASE ADD LOGFILE ('/u01/app/oracle/product/redo_logs/log1a.rdo', '/u01/app/oracle/product/redo_logs/log1b.rdo', '/u01/app/oracle/product/redo_logs/log1c.rdo') SIZE 300M;"
        echo "ALTER DATABASE ADD LOGFILE GROUP 1 ('/u01/app/oracle/product/redo_logs/log1a.rdo', '/u01/app/oracle/product/redo_logs/log1b.rdo', '/u01/app/oracle/product/redo_logs/log1c.rdo') SIZE 300M REUSE;"
        echo "SHUTDOWN IMMEDIATE;"
        echo "STARTUP;"


        echo " "
        echo "Once above commands are run the oracle12post setup is complete."

        }

 

Main

This section describes each $flag that the script allows and what Task section are called from the $flag. Listed below are just 2 of the $flags I will discuss.

Main() {

        if [ "$flag" = "base" ]
        then
        echo "****************** Base configuration ********************"
        Fix_Hosts
        Setup_Admins
        Base_Config
        Base_Chkconfig

        elif [ "$flag" = "ol6" ]
        then
        echo "*************** Setting up YUM repository and running yum update -y ***************"
        OL6_Update
        SNMP_Setup
       ...
        else
        echo $SCRIPT
        echo "Usage: $SCRIPT | base | ol6 | oracle11pre | oracle12pre | oma | oracle12install |"
        echo "$SCRIPT: You must specify one of the options."

        fi

        }

Main

How Main works

When you run the script, it must be run with an option.

# ./linux_setup.sh
linux_setup.sh
Usage: linux_setup.sh | base | ol6 | oracle11pre | oracle12pre | oma | oracle12install |
linux_setup.sh: You must specify one of the options.

For example running with the base $flag would look like this;

# ./linux_setup.sh base

Now we can look at what Tasks section are called with the “base” $flag execution.

 if [ "$flag" = "base" ]
        then
        echo "****************** Base configuration ********************"
        Fix_Hosts
        Setup_Admins
        Base_Config
        Base_Chkconfig

From the Main section of $flag “base”, we see that running # ./linux_setup.sh base would call and execute the commands in the following Task sections and only these sections would be called and run.

Fix_Hosts
Setup_Admins
Base_Config
Base_Chkconfig

I could use this “base” execution on any flavor 5,6,7 Oracle Linux or RHEL to set the options in those Task sections called.


Now for my Oracle Linux 6 system I want to run “ol6”.

# ./linux_setup.sh ol6

This would call the following Task sections to execute, which would provide us with a patched OL6 system with our desired SNMP settings.

OL6_Update
SNMP_Setup

Do you have Oracle Linux 5 system instead? Duplicate the “ol6” $flag section and make changes for “ol5”. Create an “OL5_Update” Task section that is similar to the Oracle Linux 6 version. Then, run the following command to for OL5;

# ./linux_setup.sh ol5

That gets you started with the process. Add what you need and make it your own. More Tasks sections and more $flag calls in the same scripts. The scripts can be used for virtual builds in VMware and Oracle VM and for physical server builds as well. Have software that needs to installed, add that to an stage directory so you can wget it and install it. For example, I used it for installing anything from drivers to SANSurfer software, including base settings configuration for Oracle BI application to SAP configurations.

Make sure to document changes with comments. For instance, if you added/changed settings for SAP configuration, add a comment on the SAP Note showing where the settings came from. That way there is a reference to look back at in the future.

Full Script

#!/bin/bash

###########################################################
#
#  name: linux_setup.sh
#  author: Jeff Wilkins  jeff.wilkins@mokumsolutions.com
#  version: 1.1
#  Date: 07/16/2014
#
###########################################################


# Variables
flag=$1
SCRIPT="linux_setup.sh"
TARBALL="/root/linux_setup.tar"
HOST=`hostname`
SETUP_DIR="/root/linux_setup"
RPM_DIR="$SETUP_DIR/RPMS"
UNAME="uname -r"
TAR="/bin/tar"
CHMOD="/bin/chmod"
RPM="/bin/rpm"
CHKCONFIG="/sbin/chkconfig"
DOMAIN=.local.mokumsolutions.com
SEARCH=local.mokumsolutions.com
DNS1=your.dns.address
#DNS2=
#DNS3=
ROCOMMUNITY=Mokum_Mgmt
SYSLOCATION="Mokum HQ"
ADMINGROUP=mokumadmins
IPLOCAL=`ifconfig  | grep 'inet addr' | awk '{print $2}' | cut -d ':' -f2 | grep -v 127.0.0`
REPO1='http://192.168.3.131/stage/repo_files/08262014_OL6_UEKR3.repo'
MV="/bin/mv"
PASSWORD=yourpassword
db12cR1_stage_file1="http://your.ip.address/stage/oem/linuxamd64_12c_database_1of2.zip"
db12cR1_stage_file2="http://your.ip.address/stage/oem/linuxamd64_12c_database_2of2.zip"

Fix_Hosts() {
        echo "#####################################################"
        echo " "
        echo "Fixing hosts file and hostname -f"
        echo $IPLOCAL   $HOSTNAME$DOMAIN  $HOSTNAME >> /etc/hosts
        hostname -f $HOSTNAME$DOMAIN
        echo " "
        echo "Done."

        }

Setup_Admins() {
        echo "#####################################################"
        echo " "
        echo "Creating admin users, adding $ADMINGROUP to sudoers"
        $SETUP_DIR/user_add_admins.sh

        #add $ADMINGROUP to sudoers file
        echo "%"$ADMINGROUP' ALL=(ALL)     ALL' >> /etc/sudoers

        echo " "
        echo "Done."

        }

Base_Config() {
        echo "#####################################################"
        echo " "
        echo "Setting Base configurations"
        echo "Adding $DOMAIN, $DNS1, $DNS2 & $DNS3 to resolve.conf, disabling NetworkManager, disabling selinux"

        #add entries to resolv.conf
        cp /etc/resolv.conf /etc/resolv.conf.orig
        echo 'search '$SEARCH > /etc/resolv.conf
        echo 'nameserver '$DNS1 >> /etc/resolv.conf
        #echo 'nameserver '$DNS2 >> /etc/resolv.conf
        #echo 'nameserver '$DNS3 >> /etc/resolv.conf

        #disable NetworkManager
        $CHKCONFIG NetworkManager off
        /etc/init.d/NetworkManager stop

        #disable selinux
        setenforce 0
        cp /etc/selinux/config /etc/selinux/config.orig
        sed -e '/SELINUX/ s/^/#/' /etc/selinux/config > /etc/selinux/config.new
        mv -f /etc/selinux/config.new /etc/selinux/config
        echo SELINUX=disabled >> /etc/selinux/config
        rm -rf /etc/selinux/config.new

        echo " "
        echo "Done."

        }

Base_Chkconfig() {
        echo "#####################################################"
        echo " "
        echo "Changing chkconfig settings"
        $CHKCONFIG ntpd on
        $CHKCONFIG iptables off
        $CHKCONFIG ip6tables off
        /etc/init.d/iptables stop
        /etc/init.d/ip6tables stop

        echo " "
        echo "Done."

        }

OL6_Update() {
        echo "#####################################################"
        echo " "

        echo "Setting Up YUM repository and running yum updates"
        cd /etc/yum.repos.d
        wget $REPO1
        $MV public-yum-ol6.repo public-yum-ol6.repo.disabled
        yum clean all
        sleep 10
        echo "Running yum update, this could take a while."
        yum update -y
        sleep 10

        echo " "
        echo "Done."

        }

SNMP_Setup() {
        echo "#####################################################"
        echo " "
        echo "Setting Up snmp"

        #setup snmpd
        yum install net-snmp net-snmp-utils -y
        cp /etc/snmp/snmpd.conf /etc/snmp/snmpd.conf.orig
        echo rocommunity $ROCOMMUNITY >> /etc/snmp/snmpd.conf
        echo syslocation $SYSLOCATION >> /etc/snmp/snmpd.conf
        $CHKCONFIG snmpd on

        sleep 10

        echo " "
        echo "Done."

        }

Oracle_11Pre() {
        echo "#####################################################"
        echo " "
        echo "Oracle RDBMS Preinstall"
        yum install oracle-rdbms-server-11gR2-preinstall.x86_64 -y
        sleep 10

        echo " "
        echo "Done."

        }

Oracle_12Pre() {
        echo "#####################################################"
        echo " "
        echo "Oracle RDBMS Preinstall"
        yum install oracle-rdbms-server-12cR1-preinstall.x86_64 -y
        sleep 10

        echo " "
        echo "Done."

        }

Oracle_Password() {
        echo "#####################################################"
        echo " "
        echo "Changing Oracle user password and dba group changes for /etc/sudoers"
        for USER in oracle
                do
                        echo "yourpassword" | passwd --stdin -f $USER
                done


        echo "%dba  ALL=(ALL)       NOPASSWD: ALL"   >> /etc/sudoers
        echo " "
        echo "Done."

        }

Oracle_Agent() {
        echo "#####################################################"
        echo " "
        echo "Oracle Management Agent user setup"
        $SETUP_DIR/user_add_oma.sh

        echo " "
        echo "Done."

        }

12cR1_Pre() {
        echo "#####################################################"
        echo " "
        echo "Oracle 12cR1 DB install pre-reqs for OEM"
        echo " "
        echo "Checking X11Forwarding"

        cat /etc/ssh/sshd_config | grep X11Forwarding
        read -p 'Is X11Forwarding set to Yes (yes/no?): '
        while true; do
                case $REPLY in
                        [yY]|[yY][eE][sS])      echo X11Forwarding yes Confirmed ; break ;;
                            [nN]|[nN][oO])      echo "/etc//ssh/sshd_config X11Forwarding must be set to X11Forwarding yes to continue. Exiting" ; exit ;;
                                        *)      echo "Invalid argument, Exiting. Please re-run script." ; exit;;
                esac
        done

        echo " "
        echo "Setting tmpfs to 4G"
        umount shmfs
        mount -t tmpfs shmfs -o size=4g /dev/shm
        DATE=`date +%m%d%y`
        cp /etc/fstab /etc/fstab.$DATE
        sed -e '/tmpfs/ s/^/#/' /etc/fstab > /etc/fstab.new
        echo "tmpfs        /dev/shm        tmpfs    size=4g        0 0" >> /etc/fstab.new
        mv -f /etc/fstab.new /etc/fstab
        echo "tmpfs set to 4G and fixed in fstab"
        sleep 5

        echo " "
        echo "Setting security limits in /etc/security/limits.d/oracle-rdbms-server-12cR1-preinstall.conf"
        echo "Note: oracle-rdbms-server-12cR1-preinstall has limits set in a new file /etc/security/limits.d/oracle-rdbms-server-12cR1-preinstall.conf"
        sleep 10
        sed -i.$DATE s/'nofile    1024'/'nofile    4096'/g /etc/security/limits.d/oracle-rdbms-server-12cR1-preinstall.conf
        echo "Setting security limits in /etc/security/limits.d/90-nproc.conf"
        sed -i.$DATE s/1024/16384/g /etc/security/limits.d/90-nproc.conf
        echo "security limits set"
        sleep 5
        echo " "
        wget http://download.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noa...
        rpm -ivh epel-release-6-8.noarch.rpm
        sed -i.$DATE s/'gpgcheck=1'/'gpgcheck=0'/g /etc/yum.repos.d/epel.repo
        yum install sshpass -y
        sleep 5
        echo "Now we need to validate oracle nofile limit is >= 4096."
        echo "To do this we will install and remove when done, epel and sshpass."
        echo " "
        sshpass -p $PASSWORD ssh oracle@localhost ulimit -n
        read -p 'Script just ran command to list ulimit -n for oracle user, was the value displayed >=4096 (yes/no?): '
        while true; do
                case $REPLY in
                        [yY]|[yY][eE][sS])      echo "ulimit -n setting validated." ; break ;;
                            [nN]|[nN][oO])      echo "If the oracle soft nofile limit is not set, an error will be received during OEM installation, you must correct this issue." ; break ;;
                                        *)      echo "Invalid argument, Exiting. Please verify ulimit -n >= 4096 for oracle user prior to OEM installation." ; break ;;
                esac
        done
        sleep 5
        rpm -e sshpass-1.05-1.el6.x86_64
        rpm -e epel-release-6-8.noarch
        rm -rf /etc/yum.repos.d/epel.repo.rpmsave
        rm -rf /root/linux_setup/epel-release-6-8.noarch.rpm
        echo " "
        echo "/etc/yum.repos.d/epel.repo.rpmsave removed."
        echo "Done with security limits."

        }

12cR1_Stage() {
        echo "#####################################################"
        echo " "
        echo "Staging Oracle 12cR1 install files."
        mkdir -p /u01/stage/db12c; cd /u01/stage/db12c; wget $db12cR1_stage_file1; wget $db12cR1_stage_file2
        unzip linuxamd64_12c_database_1of2.zip; unzip linuxamd64_12c_database_2of2.zip
        sleep 5
        echo " "
        echo "Removing zip files to save space."
        rm -rf /u01/stage/db12c/linuxamd64_12c_database*
        echo " "
        echo "Staging Done."

        }


12cR1_Profile() {
        echo "#####################################################"
        echo " "
        echo "Setting up ~/bash_profile for oracle user for 12cR1 and OEM 12cR4."
        DATE=`date +%m%d%y`
        cp /home/oracle/.bash_profile /home/oracle/.bash_profile.$DATE
        cat /root/linux_setup/oracle_bash_profile.txt >> /home/oracle/.bash_profile

        echo " "
        echo "oracle user ~/.bash_profile setup complete."

        }

12cR1_Install() {
        echo "#####################################################"
        echo " "
        echo "Creating oraInst.loc file in /etc."
        DATE=`date +%m%d%y`
        #cp /etc/oraInst.loc /etc/oraInst.loc.$DATE
        #cp /root/linux_setup/oraInst.loc /etc/oraInst.loc
        #chown oracle:oinstall /etc/oraInst.loc; chmod 664 /etc/oraInst.loc
        echo "Creating OFA standard directories."
        mkdir -p /u01/app/oracle/product/12.1.0/dbhome_1
        chown -R oracle:oinstall /u01/*
        chmod -R 775 /u01/*
        echo " "
        echo "OFA directories created'"
        echo " "
        echo "Beginning Oracle 12cR1 DB install using OUI. You will be required to type the oracle password to begin the install."
        sleep 10
        ssh -X oracle@localhost /u01/stage/db12c/database/runInstaller
        echo " "
        echo "Script call Oracle 12cR1 OUI install complete."

        }

12cR1_Post() {
        echo "#####################################################"
        mkdir /u01/app/oracle/product/redo_logs/
        echo " "
        echo "Modifying /ehappier and easier

 
 
Document Created: 10/13/14
Last Update: 10/13/2014
 
Copyright © 2015 Mokum Solutions, Inc. All rights reserved.
Distribution of the Oracle Cloud Cookbook or derivative of the work in any form is prohibited unless prior permission is obtained from the copyright holder.