Create your own Oracle Staging Environment, Part 2: Kickstart File(s) and Profiles

December 15, 2014 — Leave a comment

Having completed the intial setup of the staging server now is the time to prepare the kickstart file for the boot isos.

Let’s review our test system on the cobbler server:

cobbler system report list
Name                           : test
TFTP Boot Files                : {}
Comment                        : 
Enable gPXE?                   : 0
Fetchable Files                : {}
Gateway                        : 192.168.56.1
Hostname                       : test.lab.ch
Image                          : 
IPv6 Autoconfiguration         : False
IPv6 Default Device            : 
Kernel Options                 : {}
Kernel Options (Post Install)  : {}
Kickstart                      : <>
Kickstart Metadata             : {}
LDAP Enabled                   : False
LDAP Management Type           : authconfig
Management Classes             : <>
Management Parameters          : <>
Monit Enabled                  : False
Name Servers                   : []
Name Servers Search Path       : []
Netboot Enabled                : True
Owners                         : ['admin']
Power Management Address       : 
Power Management ID            : 
Power Management Password      : 
Power Management Type          : ipmitool
Power Management Username      : 
Profile                        : oel66-x86_64
Proxy                          : <>
Red Hat Management Key         : <>
Red Hat Management Server      : <>
Repos Enabled                  : False
Server Override                : <>
Status                         : production
Template Files                 : {}
Virt Auto Boot                 : <>
Virt CPUs                      : <>
Virt Disk Driver Type          : <>
Virt File Size(GB)             : <>
Virt Path                      : <>
Virt PXE Boot                  : 0
Virt RAM (MB)                  : <>
Virt Type                      : <>
Interface =====                : eth0
Bonding Opts                   : 
Bridge Opts                    : 
CNAMES                         : []
DHCP Tag                       : 
DNS Name                       : test.lab.ch
Per-Interface Gateway          : 
Master Interface               : 
Interface Type                 : 
IP Address                     : 192.168.56.201
IPv6 Address                   : 
IPv6 Default Gateway           : 
IPv6 MTU                       : 
IPv6 Prefix                    : 
IPv6 Secondaries               : []
IPv6 Static Routes             : []
MAC Address                    : 
Management Interface           : False
MTU                            : 
Subnet Mask                    : 255.255.255.0
Static                         : True
Static Routes                  : []
Virt Bridge                    : 

What we want to modify now is the kickstart parameter:

Kickstart                      : <>

As profiles are the core unit for provisioning and kickstart files can be accociated with profiles let’s check our current profiles:

 cobbler profile list
   oel66-x86_64

This one got created when we imported our distribution. As this name does not tell that much about the purpose of the profile lets create a new profile with a more descriptive name:

cobbler profile add --name=OracleDatabaseServer --distro=oel66-x86_64
cobbler profile list
   OracleDatabaseServer
   oel66-x86_64

Let’s see what the newly created profile looks like:

cobbler profile report --name=OracleDatabaseServer
Name                           : OracleDatabaseServer
TFTP Boot Files                : {}
Comment                        : 
DHCP Tag                       : default
Distribution                   : oel66-x86_64
Enable gPXE?                   : 0
Enable PXE Menu?               : 1
Fetchable Files                : {}
Kernel Options                 : {}
Kernel Options (Post Install)  : {}
Kickstart                      : /var/lib/cobbler/kickstarts/default.ks
Kickstart Metadata             : {}
Management Classes             : []
Management Parameters          : <>
Name Servers                   : []
Name Servers Search Path       : []
Owners                         : ['admin']
Parent Profile                 : 
Proxy                          : 
Red Hat Management Key         : <>
Red Hat Management Server      : <>
Repos                          : []
Server Override                : <>
Template Files                 : {}
Virt Auto Boot                 : 1
Virt Bridge                    : xenbr0
Virt CPUs                      : 1
Virt Disk Driver Type          : raw
Virt File Size(GB)             : 5
Virt Path                      : 
Virt RAM (MB)                  : 512
Virt Type                      : xenpv

As we did not specify anything for the kickstart file when we created the profile, the default was applied:

Kickstart                      : /var/lib/cobbler/kickstarts/default.ks

Time to create our first kickstart file and assign it to our profile. The kickstart file below is pretty much default, except:

  • the oracle recommended OS groups are created
  • the oracle recommended OS users are created
  • the oracle required OS packages are installed

We could do much more here, e.g. creating a custom filesystem layout, creating the limits for the oracle users and so on. For the scope of this post, the below shall be sufficiant:

# save to /var/lib/cobbler/kickstarts/oracledatabaseserver.ks
auth  --useshadow  --enablemd5
# System bootloader configuration
bootloader --location=mbr --driveorder=sda --append="audit=1"
# Partition clearing information
clearpart --all --initlabel
# Use text mode install
text
# Firewall configuration
firewall --disabled
# Run the Setup Agent on first boot
firstboot --disable
# System keyboard
keyboard sg-latin1
# System language
lang en_US.UTF-8
# Use network installation
url --url=$tree
# If any cobbler repo definitions were referenced in the kickstart profile, include them here.
$yum_repo_stanza
# Network information
$SNIPPET('network_config')
# Reboot after installation
reboot

#Root password
rootpw --iscrypted $default_password_crypted
# SELinux configuration
selinux --disabled
# Do not configure the X Window System
skipx
# System timezone
timezone  Europe/Zurich
# Install OS instead of upgrade
install
# Clear the Master Boot Record
zerombr
# Allow anaconda to partition the system as needed
autopart

%pre
$SNIPPET('log_ks_pre')
$SNIPPET('kickstart_start')
$SNIPPET('pre_install_network_config')
# Enable installation monitoring
$SNIPPET('pre_anamon')
%end

%packages --excludedocs --nobase
## $SNIPPET('func_install_if_enabled')
kernel
yum
openssh-server
openssh-clients
audit
logrotate
tmpwatch
vixie-cron
crontabs
ksh
ntp
perl
bind-utils
sudo
which
sendmail
wget
redhat-lsb
rsync
authconfig
lsof
unzip
logwatch
libacl
nfs-utils
dhclient
# oracle prereqs begin
gcc
binutils
compat-libcap1
compat-libstdc++-33
glibc
glibc-devel
libX11
libXau
libXext
libXi
libXtst
libaio
libaio-devel
libstdc++
libstdc++-devel
libxcb
make
sysstat
# oracle prereqs end
-firstboot
-tftp-server
-system-config-soundcard
-squashfs-tools
-device-mapper-multipath
-aspell-en
-aspell
-rdate
-dhcpv6-client
-NetworkManager
-rsh
-sysreport
-irda-utils
-rdist
-anacron
-bluez-utils
-talk
-system-config-lvm
-wireless-tools
-setroubleshoot-server
-setroubleshoot-plugins
-setroubleshoot
-ppp
-GConf2
-dhcpv6-client
-iptables-ipv6
-libselinux-python
-setools
-selinux-policy
-libselinux-utils
-chkfontpath
-urw-fonts
-xorg-x11-xfs
-policycoreutils
-selinux-policy-targeted
-ypbind
-yp-tools
-smartmontools
-pcsc-lite
-trousers
-oddjob
-yum-updatesd
-readahead
-pcsc-lite
-gpm
-at
-cpuspeed
-conman
-system-config-securitylevel-tui
-tcsh
-firstboot-tui
-ppp
-rp-pppoe
-system-config-network-tui
-syslinux
-pcsc-lite-libs
-pcmciautils
-pam_smb
-mkbootdisk
-jwhois
-ipsec-tools
-ed
-crash
-Deployment_Guide-en-US
-hal
-pm-utils
-dbus
-dbus-glib
%end

%post --nochroot
$SNIPPET('log_ks_post_nochroot')
%end

%post
$SNIPPET('log_ks_post')
# Start yum configuration
$yum_config_stanza
# End yum configuration

/usr/sbin/groupadd -g 54321 oinstall
/usr/sbin/groupadd -g 54322 dba
/usr/sbin/groupadd -g 54323 oper
/usr/sbin/groupadd -g 54324 backupdba
/usr/sbin/groupadd -g 54325 asmdba
/usr/sbin/groupadd -g 54326 dgdba
/usr/sbin/groupadd -g 54327 kmdba
/usr/sbin/groupadd -g 54328 asmadmin
/usr/sbin/groupadd -g 54329 asmoper
/usr/sbin/useradd -u 54322 -g oinstall -G asmadmin,asmdba grid
/usr/sbin/useradd -u 54323 -g oinstall -G dba,asmdba oracle
/usr/sbin/usermod -p "oracle" oracle
/usr/sbin/usermod -p "oracle" grid

$SNIPPET('post_install_kernel_options')
$SNIPPET('post_install_network_config')
$SNIPPET('func_register_if_enabled')
$SNIPPET('download_config_files')
$SNIPPET('koan_environment')
$SNIPPET('redhat_register')
$SNIPPET('cobbler_register')
# Enable post-install boot notification
$SNIPPET('post_anamon')
# Start final steps
$SNIPPET('kickstart_done')
# End final steps
%end

Assign the kickstart file to the profile:

cobbler profile edit --name=OracleDatabaseServer --kickstart=/var/lib/cobbler/kickstarts/oracledatabaseserver.ks
cobbler profile report --name=OracleDatabaseServer | grep -i kickstart
Kickstart                      : /var/lib/cobbler/kickstarts/oracledatabaseserver.ks
Kickstart Metadata             : {}

Do a cobbler sync:

cobbler sync

And finally create the new boot.iso:

cobbler buildiso --systems="test" --iso=/var/www/html/iso_store/test.iso

Fire up the vm on your workstation as in the previous post:

################## CONFIGURATION SECTION START ##############################

## The name for the VM in VirtualBox
VM_NAME="oel6_test"
## The VMHome for VirtualBox, usually in $HOME
VM_HOME="/media/dwe/My Passport/vm/${VM_NAME}"
## The hard disk to use for the VM, can be anywhere but might
## use up to 60gb. We need plenty of space for hosting the 
## the OEL 6.6 yum repository and any source files for the oracle
## database and gi installation zip files
VM_HARDDISK="/media/dwe/My Passport/vm/${VM_NAME}/oel_test.vdi"
BOOTIMAGEFILE="test.iso"
# we get the boot iso directly from the cobbler server
BOOTIMAGEURL="http://192.168.56.101/iso_store/${BOOTIMAGEFILE}"

################## CONFIGURATION SECTION END  ##############################
################  NO NEED TO EDIT FROM HERE ON ############################X

## Clean up everything before starting the setup
echo ".. Clean up everything before starting the setup"
vboxmanage unregistervm ${VM_NAME} --delete >> /dev/null 2>&1
vboxmanage closemedium disk "${VM_HARDDISK}" --delete >> /dev/null 2>&1
rm -f "${VM_HOME}/*"
mkdir -p "${VM_HOME}"

## Creating Virtual Box Maschine
echo ".. Creating Virtual Box Maschine"
vboxmanage createvm --name ${VM_NAME}  --register --ostype Oracle_64
vboxmanage modifyvm ${VM_NAME} --boot1 disk
vboxmanage modifyvm ${VM_NAME} --boot2 dvd

## Creating Hard Disk for the Virtual Machine
echo "Creating Hard Disk for the Virtual Machine"
vboxmanage createhd --filename "${VM_HARDDISK}" --size 8192

## get the boot iso
cd "${VM_HOME}"
wget ${BOOTIMAGEURL}

## Creating a storage controller and attaching the Hard Disk to the VM
echo "Creating a storage controller and attaching the Hard Disk to the VM"
vboxmanage storagectl ${VM_NAME} --name ctl1 --add sata
vboxmanage storageattach ${VM_NAME} --storagectl ctl1 --type hdd --medium "${VM_HARDDISK}" --port 1

## Creating DVD Drive and attachinf the ISO
echo "Creating DVD Drive and attaching the ISO"
vboxmanage storagectl ${VM_NAME} --name ctl2 --add ide
vboxmanage storageattach ${VM_NAME} --storagectl ctl2 --type dvddrive --port 1 --device 1 --medium "${VM_HOME}/${BOOTIMAGEFILE}"

## Setting VM parameters
echo "Setting VM parameters"
vboxmanage modifyvm ${VM_NAME} --memory 1024 --cpus 1 --nic1 hostonly --cableconnected1 on --hostonlyadapter1 vboxnet0
vboxmanage modifyvm ${VM_NAME} --audio none
vboxmanage modifyvm ${VM_NAME} --usb off

echo "Booting and installing VM"
vboxmanage startvm ${VM_NAME} --type sdl

Sit back, relax and once the VM setup completed: login and check the users and groups:

id -a oracle
uid=54323(oracle) gid=54321(oinstall) groups=54321(oinstall),54322(dba),54325(asmdba)
id -a grid
uid=54322(grid) gid=54321(oinstall) groups=54321(oinstall),54325(asmdba),54328(asmadmin)

Wouldn’t it be nice to have the oracle installation source files already available on the newly created vms? Well, pretty easy:

On the cobbler server create a directory to host the files:

uid=54322(grid) gid=54321(oinstall) groups=54321(oinstall),54325(asmdba),54328(asmadmin)

Transfer the files you want to make available on the VMs to this directory from your workstation (I’ll just copy opatch for now):

scp p6880880_121011_Linux-x86-64.zip root@192.168.56.101:/var/www/html/sources/

Extend the kickstart file for getting the source file in the post section:

...
/usr/sbin/useradd -u 54322 -g oinstall -G asmadmin,asmdba grid
/usr/sbin/useradd -u 54323 -g oinstall -G dba,asmdba oracle
/usr/sbin/usermod -p "oracle" oracle
/usr/sbin/usermod -p "oracle" grid
...
/usr/bin/wget http://192.168.56.101/sources/p6880880_121011_Linux-x86-64.zip -O /var/tmp/p6880880_121011_Linux-x86-64.zip
...

Re-Stage the VM and you’re done.

In the next post I’ll setup a complete lab environment depending on the amount of people who should attend the lab and depending on the amount of VMs they shall get.

No Comments

Be the first to start the conversation!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.