#!/bin/sh
#Theme: 11gR2 Preinstallation Operations On RHEL6.2 64bit Only
#Author: Majesty.
#MyBlog: http://majesty.blog.51cto.com for more research about oracle.
#Before Anything:
# If you assure you install all os packages already, you could skip this step.
# You had batter mount RHEL6 64bit on /mnt
#Main Dir
#1 add essential user and group for O11gR2 installation.
#2 modify ~/.bash_profile
#3 modify /etc/sysctl.conf
#4 modify /etc/security/limits.conf
#5 /etc/profile
#6 /etc/pam.d/login
#7 modify /etc/csh.login , which is not shell script
#8 modify the /etc/system-release
#9 install essential os packages for oracle installation.
#set -x
#assure you already configure the yum
#1 add essential user and group for O11gR2 installation.
groupadd dba
groupadd oper
groupadd oinstall
useradd oracle
usermod -g oinstall -G dba oracle
echo "oracle" | passwd --stdin oracle
mkdir -p /u01/app/oracle
chown -R oracle:oinstall /u01
chmod -R 775 /u01/app
#2 modify ~/.bash_profile
cat > /home/oracle/.bash_profile <<'EOF'
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# User specific environment and startup programs
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=$ORACLE_BASE/product/11.2.0
export ORACLE_SID=ocm11g
export ORACLE_UNQNAME=ocm11g
export ORACLE_OWNER=oracle
export ORACLE_TERM=vt100
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib:/usr/local/lib
export CLASSPATH=$ORACLE_HOME/JRE:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib
export CLASSPATH=$CLASSPATH:$ORACLE_HOME/network/jlib
export PATH=$PATH:$ORACLE_HOME/bin:$HOME/bin
export PATH=$ORACLE_HOME/bin:$ORACLE_HOME/Apache/Apache/bin:$PATH
export PATH=$PATH:/usr/sbin:/usr/bin;
export NLS_LANG=american_america.AL32UTF8
export LANG=en_US
export EDITOR=vim
export TNS_ADMIN=$ORACLE_HOME/network/admin
export NLS_DATE_FORMAT="yyyy-mm-dd hh24:mi:ss"
EOF
#3 modify /etc/sysctl.conf
cat > /etc/sysctl.conf <<MARK01
net.ipv4.ip_forward = 0
net.ipv4.conf.default.rp_filter = 1
net.ipv4.conf.default.accept_source_route = 0
kernel.sysrq = 0
kernel.core_uses_pid = 1
net.ipv4.tcp_syncookies = 1
kernel.msgmnb = 65536
kernel.msgmax = 65536
fs.aio-max-nr = 1048576
fs.file-max = 6815744
kernel.shmall = 2097152
##set this parameter to half of your physical memory size, here is byte
kernel.shmmax = 1056870912
kernel.shmmni = 4096
kernel.sem = 250 32000 100 128
net.ipv4.ip_local_port_range = 9000 65500
net.core.rmem_default = 262144
net.core.rmem_max = 4194304
net.core.wmem_default = 262144
net.core.wmem_max = 1048576
MARK01
#4 modify /etc/security/limits.conf
# It is the resource limit for the number of processes available to a user.
cat > /etc/security/limits.conf <<EOF
oracle soft nproc 65546
oracle hard nproc 65536
oracle soft nofile 65536
oracle hard nofile 65536
oracle soft stack 65536
EOF
#5 /etc/profile
check_profile=`grep "ulimit -p 16384" /etc/profile`
if [ "$check_profile" == '' ]; then
cat >> /etc/profile <<'EYY'
if [ $USER = "oracle" ]; then
if [ $SHELL = "/bin/ksh" ]; then
ulimit -p 16384
ulimit -n 65536
else
ulimit -u 16384 -n 65536
fi
fi
EYY
else
echo "Negative........../etc/profile ware already modified!!"
fi
#6 /etc/pam.d/login
check_pam=`grep "session required pam_limits.so" /etc/pam.d/login | awk {'print $3'}`
if [ $? = 0 ]; then
echo "Negative........../etc/pam.d/login ware already modified!!"
else
cat >> /etc/pam.d/login <<EFF
session required pam_limits.so
EFF
fi
#7 modify /etc/csh.login , which is not shell script
check_csh=`grep "limit maxproc 16384" /etc/csh.login`
if [ $? = 0 ]; then
echo "Negative........../etc/csh.login was modified!!!"
else
cat >> /etc/csh.login <<'EXX'
#Oracle need setting:
if ( $USER == "oracle" ) then
limit maxproc 16384
limit descriptors 65536
umask 022
endif
EXX
fi
#8 modify the /etc/system-release
cat > /etc/system-release <<EOF
Red Hat Enterprise Linux Server release 5 (Tikanga)
EOF
cat > /etc/redhat-release <<EOF
Red Hat Enterprise Linux Server release 5 (Tikanga)
EOF
#please mount RHEL6 64bit cdrom to /mnt directory!!!
#9 install essential os packages for oracle installation.
cat > /etc/yum.repos.d/base.repo <<EXX
[server]
name=server
baseurl=file:/mnt/Server
gpgcheck=0
enabled=1
EXX
cd /mnt/Packages
sleep 2 && yum -y localinstall --skip-broken binutils*
sleep 2 && yum -y localinstall --skip-broken compat*
sleep 2 && yum -y localinstall --skip-broken gcc-*
sleep 2 && yum -y localinstall --skip-broken glibc*
sleep 2 && yum -y localinstall --skip-broken glibc*
sleep 2 && yum -y localinstall --skip-broken ksh*
sleep 2 && yum -y localinstall --skip-broken libgcc*
sleep 2 && yum -y localinstall --skip-broken libstdc++*
sleep 2 && yum -y localinstall --skip-broken libaio*
sleep 2 && yum -y localinstall --skip-broken libw*
sleep 2 && yum -y localinstall --skip-broken libn*
sleep 2 && yum -y localinstall --skip-broken libp*
sleep 2 && yum -y localinstall --skip-broken libr*
sleep 2 && yum -y localinstall --skip-broken libi*
sleep 2 && yum -y localinstall --skip-broken libj*
sleep 2 && yum -y localinstall --skip-broken libl*
sleep 2 && yum -y localinstall --skip-broken libm*
sleep 2 && yum -y localinstall --skip-broken libu*
sleep 2 && yum -y localinstall --skip-broken libx*
sleep 2 && yum -y localinstall --skip-broken libv*
sleep 2 && yum -y localinstall --skip-broken libt*
sleep 2 && yum -y localinstall --skip-broken libs*
sleep 2 && yum -y localinstall --skip-broken libi*
sleep 2 && yum -y localinstall --skip-broken libX*
sleep 2 && yum -y localinstall --skip-broken libI*
sleep 2 && yum -y localinstall --skip-broken libs*
sleep 2 && yum -y localinstall --skip-broken liba*
sleep 2 && yum -y localinstall --skip-broken libb*
sleep 2 && yum -y localinstall --skip-broken libc*
sleep 2 && yum -y localinstall --skip-broken libd*
sleep 2 && yum -y localinstall --skip-broken libg*
sleep 2 && yum -y localinstall --skip-broken make*
sleep 2 && yum -y localinstall --skip-broken libh*
sleep 2 && yum -y localinstall --skip-broken sysstat*
sleep 2 && yum -y localinstall --skip-broken unixODBC*
sleep 2 && yum -y localinstall --skip-broken libgomp*
sleep 2 && yum -y localinstall --skip-broken kernel-headers*
sleep 2 && yum -y localinstall --skip-broken elfutils*