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/

No comments: