Pages

Wednesday, February 19, 2014

Kickstart - Setting required dynamic options for Oracle Database install

When setting up a RHEL server to be an Oracle database, there is a ton of stuff that has to be done post install that takes quite a bit of time.  I found a nice guide from Red Hat at the following URL:

http://www.redhat.com/resourcelibrary/reference-architectures/deploying-oracle-11gr2-on-rhel-6

Since I have my new fancy Satellite setup at work, I want to utilize a kickstart process to deploy these servers so they're always the same.  The issue I ran into was that different machines have different amounts of RAM and other things, so hard coding a bunch of kernel parameters into a kickstart post section wouldn't work out on multiple machine types.

I came up with the following, chrooted, post script for kickstart that will dynamically figure out what the required kernel parameters should be and build /etc/sysctrl.conf with that information. It also creates the required oracle user, groups and directory structure.

#config kernel params

#math section

#get system ram
TOTALRAM=`free|grep Mem|awk '{ print $2 }'`

#get page_size
PAGESIZE=`getconf PAGE_SIZE`

#figure out shmall
((SHMALL=$TOTALRAM / $PAGESIZE))

#figure out shmax
((SHMAX=$TOTALRAM / 2))

#shmini oracle recommendation
SHMINI=4096

#get file max
CURFILEMAX=`cat /proc/sys/fs/file-max`
TOTALPROC=300
((ADDEDPROC=512 * $TOTALPROC))
((FILEMAX=$CURFILEMAX + $ADDEDPROC))



#build sysctl.conf
echo "net.ipv4.ip_forward = 0" > /etc/sysctl.conf
echo "net.ipv4.conf.default.rp_filter = 1" >> /etc/sysctl.conf
echo "net.ipv4.conf.default.accept_source_route" = 0 >> /etc/sysctl.conf
echo "net.ipv4.conf.eth0.rp_filter = 2" >> /etc/sysctl.conf
echo "net.ipv4.conf.eth2.rp_filter = 2" >> /etc/sysctl.conf
echo "kernel.sysrq = 0" >> /etc/sysctl.conf
echo "kernel.core_uses_pid = 1" >> /etc/sysctl.conf
echo "net.ipv4.tcp_syncookies = 1" >> /etc/sysctl.conf
echo "net.ipv4.ip_local_port_range = 9000 65500" >> /etc/sysctl.conf
echo "kernel.msgmnb = 65536" >> /etc/sysctl.conf
echo "kernel.msgmax = 65536" >> /etc/sysctl.conf
echo "kernel.shmmax = $SHMAX" >> /etc/sysctl.conf
echo "kernel.shmall = $SHMALL" >> /etc/sysctl.conf
echo "kernel.shmmni = $SHMINI" >> /etc/sysctl.conf
echo "kernel.sem = 250 32000 100 128" >> /etc/sysctl.conf
echo "vm.swappiness = 0" >> /etc/sysctl.conf
echo "vm.dirty_background_ratio = 3" >> /etc/sysctl.conf
echo "vm.dirty_ratio = 80" >> /etc/sysctl.conf
echo "vm.dirty_expire_centisecs = 500" >> /etc/sysctl.conf
echo "vm.dirty_writeback_centisecs = 100" >> /etc/sysctl.conf
echo "net.core.rmem_default = 262144" >> /etc/sysctl.conf
echo "net.core.rmem_max = 4194304" >> /etc/sysctl.conf
echo "net.core.wmem_default = 262144" >> /etc/sysctl.conf
echo "net.core.wmem_max = 1048576" >> /etc/sysctl.conf
echo "fs.aio-max-nr = 1048576" >> /etc/sysctl.conf
echo "fs.file-max = $FILEMAX" >> /etc/sysctl.conf

#make sure time is right and turn on ntp
ntpdate 10.3.254.20
service ntpd start
chkconfig ntpd on

#add oracle groups and users. I hardset the GID and UID so that they match up on NFS
#exports that are mounted between multiple servers
groupadd --gid 501 oinstall
groupadd --gid 502 dba
groupadd --gid 503 asmdba
groupadd --gid 504 asmoper
groupadd --gid 505 asmadmin
groupadd --gid 506 oper
useradd --uid 501 --gid oinstall --groups dba,oper,asmdba,asmoper oracle
useradd --uid 502 --gid oinstall --groups dba,asmadmin,asmdba,asmoper grid

#set limits for oracle and grid. add to the bottom of limits.conf
echo "oracle soft nproc 2047" >> /etc/security/limits.conf
echo "oracle hard nproc 16384" >> /etc/security/limits.conf
echo "oracle soft nofile 1024" >> /etc/security/limits.conf
echo "oracle hard nofile 65536" >> /etc/security/limits.conf
echo "oracle soft stack 10240" >> /etc/security/limits.conf
echo "oracle hard stack 32768" >> /etc/security/limits.conf
echo "grid soft nproc 2047" >> /etc/security/limits.conf
echo "grid hard nproc 16384" >> /etc/security/limits.conf
echo "grid soft nofile 1024" >> /etc/security/limits.conf
echo "grid hard nofile 65536" >> /etc/security/limits.conf
echo "grid soft stack 10240" >> /etc/security/limits.conf
echo "grid hard stack 32768" >> /etc/security/limits.conf

#require pam
echo "session required pam_limits.so" >> /etc/pam.d/login

#create directories for oracle
mkdir --parents /u01/app/grid
chown --recursive grid.oinstall /u01/

Force yum to refresh it's cache

Sometimes yum misbehaves and needs to be cleaned. I have found that running these commands will sometimes help resolve weird issues with yum not seeing updates/packages at all or seeing updates/packages it should not see!


  1. yum clean all
  2. yum makecache
After running these commands, yum should have refreshed it's data on the local system and will hopefully have cleaned up the issue.

Red Hat Satellite - Regenerating repository data

I've been running into a problem where the web interface says there are updated packages available for a system, but yet when I sign on to the system and do a yum update, it reports no updates available.  If I try to deploy the updates from the web interface, the process fails with

Error while executing packages action: empty transaction [[6]]

After digging around, someone suggested rebuilding the repodata for the channel in question might fix it. I tried it out and it worked for me.

To do this process, a python script is needed. It can be obtained from here:
https://github.com/FDewaleyne/regen-repodata/blob/master/regen-repodata.py

Download the script to the satellite server. On the satellite server, delete the repodata that is there already and then run the script to regenerate it.

  1. Repodata is kept in  /var/cache/rhn/repodata by default
    • Doing an "ls" here will show directories for each channel that is sync'd to the satellite. Change directory to the channel to be regenerated.
  2. Delete all files within the directory.
  3. Run the python script
    • python /path/to/regen-repodata.py -c channelname --cleandb --force --db --url https://satellite.domain.local/rpc/api
    • The username and password it asks for is the admin account for the Satellite web interface.
  4. Depending on how large the channel is, this process could take a while.


Friday, February 7, 2014

Red Hat Kickstart - Prompting for input

I have progressed in my implementation of Red Hat Satellite to the point of setting up a kickstart file for automated deployments.  Setting up the kickstart file throught he Satellite web interface was pretty easy to do. I was deploying a fully automated RHEL installation fairly quickly.

I wanted more though. I want all the normal stuff that I normally have to do after installation to already be done.  Such as setting the hostname and IP Address.  From my research, the way to do this is with pre and post scripts in the kickstart file.

To start off simple, I wanted the kickstart process to prompt me for hostname, IP and gateway.  Here is what I came up with for my pre and post sections:

%pre
#change to tty6 to get input
chvt 6
exec </dev/tty6 > /dev/tty6

#Get hostname
echo "What is my hostname?"
read NAME

#Get IP
echo "What is my IP?"
read ADDR 

#Get Gateway
echo "What is the Gateway?"
read GW


#build /etc/sysconfig/network
echo "NETWORKING=yes" > network
echo "HOSTNAME=${NAME}" >> network
echo "GATEWAY=${GW}" >> network

#build /etc/sysconfig/network-scripts/ifcfg-eth0
echo "DEVICE=eth0" > ifcfg-eth0
echo "BOOTPROTO=none" >> ifcfg-eth0
echo "IPV6INIT=no" >> ifcfg-eth0
echo "MTU=1500" >> ifcfg-eth0
echo "NM_CONTROLLED=no" >> ifcfg-eth0
echo "ONBOOT=yes" >> ifcfg-eth0
echo "TYPE=Ethernet" >> ifcfg-eth0
echo "IPADDR=${ADDR}" >> ifcfg-eth0
echo "NETMASK=255.255.254.0" >> ifcfg-eth0

#change back to tty1 and continue script
chvt 1
exec < /dev/tty1 > /dev/tty1
%end

%post --nochroot
# bring in hostname collected from %pre
cp network /mnt/sysimage/etc/sysconfig/network
. /mnt/sysimage/etc/sysconfig/network
# force hostname change
/mnt/sysimage/bin/hostname $HOSTNAME

#copy prebuilt ifcfg-eth0 script to set IP
cp ifcfg-eth0 /mnt/sysimage/etc/sysconfig/network-scripts/ifcfg-eth0

%end

After I made these changes to my pre and post scripts, the kickstart processed asked me for the IP, Gateway and hostname.  When the install completed, all 3 were set correctly.

Monday, February 3, 2014

Red Hat Satellite 5.6 - Create RHN tools child channel for a custom cloned channel

When creating a custom cloned channel in Satellite, which would be done to keep subscribed systems at a specific release level, you have to clone the RHN Tools child channel as well. The RHN Tools channel provides the osad daemon as well as other important packages that allow the satellite to perform better management of subscribed systems.

This process can only be completed if there is already a base channel with the rhn-tools child channel and a cloned channel created.  Run this command on the command line of the Satellite server.

The command:

spacewalk-clone-by-date --parents=rhel-x86_64-server-6 rhel-x86_64-server-6.4 --channels=rhn-tools-rhel-x86_64-server-6 tools-rhel-x86_64-server-6.4 --to_date=2013-02-21 -u username

Explanation:

  • rhel-x86_64-server-6                = original base channel
  • rhel-x86_64-server-6.4             = name of custom clone channel
  • rhn-tools-rhel-x86_64-server-6 = original base tools channel
  • tools-rhel-x86_64-server-6.4    = what you want to name the rhn-tools channel. Note, this channel name cannot start with "rhel" or "rhn"
  • 2013-02-21                              = locks packages to 6.4.
  • username                                   = admin user of the Satellite