#!/bin/sh
########################################################################
# note
#the script is set parameters for set up oracle on redhat system.Iso image source,
#yum install rpm packages and you can vnc to install the Oracle database.
#version 1.0
#environment:
#1) sys - Red Hat Enterprise Linux Server release 6.3 (Santiago) x86_64 GNU/Linux
#2) oracle - linux.x64_11gR2_database
#3) run script: 1 chmod 777 setup_oracle11g_rh6.3_x64.sh 2 ./setup_oracle11g_rh6.3_x64.sh
########################################################################
#### set parameters config start!
#oracle setup dir
orasetdir=/u01/app;
dbsid=orcl;
packagefiles1='pdksh-5.2.14-37.el5_8.1.x86_64.rpm';
packserver=ServerSetOra;
sysbitstr="x86_64";
sysnamestr='Red Hat Enterprise Linux Server release 6';
#### set parameters config end!
## set
mypath=$PWD;
vardate=`date +%Y%m%d%H%M%S`;
i=0;
let i=$i+1;
printf "....................................................................$i \n";
printf "place wait installing package ..... \n";
#### Check the environment start !
##check
if [ ! $USER = root ];then
printf "Please rerun this script as root .";
exit;
fi
let i=$i+1;
printf "....................................................................$i \n";
##chck system
sysbit=/proc/version;
sysname=/etc/redhat-release;
if (grep "$sysnamestr" $sysname) && (grep $sysbitstr $sysbit) ; then
printf "chck system ok ! \n ";
cat $sysname;
cat $sysbit;
else
printf "chck system error ! \n ";
cat $sysname;
cat $sysbit;
exit;
fi
##Check yum(undo)
let i=$i+1;
printf "....................................................................$i \n";
##check package files
if [ -f $mypath"/"$packserver"/"$packagefiles1 ];
then
printf "check package files ok ! \n ";
else
printf "check package files error ! \n ";
exit;
fi
#### Check the environment end !
let i=$i+1;
printf "....................................................................$i \n";
printf "place wait installing package .................... \n";
if true ; then
#rpm
rpm -ivh $mypath"/"$packserver"/"$packagefiles1
#yum install pakage
yum install binutils -y
yum install compat-libstdc++-33 -y
yum install compat-libstdc++-33.i686 -y
yum install elfutils-libelf -y
yum install elfutils-libelf-devel -y
yum install gcc -y
yum install gcc-c++ -y
yum install glibc -y
yum install glibc.i686 -y
yum install glibc-common -y
yum install glibc-devel -y
yum install glibc-devel.i686 -y
yum install glibc-headers -y
yum install libaio -y
yum install libaio.i686 -y
yum install libaio-devel -y
yum install libaio-devel.i686 -y
yum install libgcc -y
yum install libgcc.i686 -y
yum install libstdc++ -y
yum install libstdc++.i686 -y
yum install libstdc++-devel -y
yum install make -y
yum install numactl-devel -y
yum install sysstat -y
yum install unixODBC -y
yum install unixODBC.i686 -y
yum install unixODBC-devel -y
yum install unixODBC-devel.i686 -y
yum install tigervnc-server -y
yum groupinstall 'X Window System' -y
yum groupinstall Desktop -y
fi
### add oracle group
let i=$i+1;
printf "....................................................................$i \n";
printf "create oracle user and oracle group .....\n ";
/usr/sbin/groupadd oinstall
/usr/sbin/groupadd -g 502 dba
/usr/sbin/useradd -u 502 -g oinstall -G dba oracle
printf "plase change user oracle pass word.....\n";
passwd oracle
### create oracle dir
let i=$i+1;
printf "....................................................................$i \n";
printf "create setup oracele directry $orasetdir \n";
mkdir -p $orasetdir
chown -R oracle:oinstall $orasetdir
chmod -R 775 $orasetdir
### edit files
let i=$i+1;
printf "....................................................................$i \n";
seclimit='/etc/security/limits.conf';
cp $seclimit $seclimit.$vardate;
if grep "oracle" $seclimit; then
printf "the file aready set $seclimit set next file ....\n ";
else
printf "edit file $seclimit \n";
echo "#the next rows install oracle add satrt !" >> $seclimit;
echo "oracle soft nofile 131072" >> $seclimit;
echo "oracle hard nofile 131072" >> $seclimit;
echo "oracle soft nproc 131072" >> $seclimit;
echo "oracle hard nproc 131072" >> $seclimit;
echo "oracle soft core unlimited" >> $seclimit;
echo "oracle hard core unlimited" >> $seclimit;
echo "oracle soft memlock 50000000" >> $seclimit;
echo "oracle hard memlock 50000000" >> $seclimit;
echo "#the next rows install oracle add end! " >> $seclimit;
fi
let i=$i+1;
printf "....................................................................$i \n";
sysconf='/etc/sysctl.conf';
cp $sysconf $sysconf.$vardate;
if grep "kernel.sem" $sysconf; then
printf "the file aready set $sysconf set next file ....\n ";
else
echo "#the next rows install oracle add" >> $sysconf;
echo "fs.aio-max-nr = 3145728" >> $sysconf;
echo "fs.file-max = 6815744" >> $sysconf;
echo "kernel.shmmni = 4096" >> $sysconf;
echo "kernel.sem = 250 32000 100 142" >> $sysconf;
echo "net.ipv4.ip_local_port_range = 9000 65500" >> $sysconf;
echo "net.core.rmem_default = 262144" >> $sysconf;
echo "net.core.rmem_max = 4194304" >> $sysconf;
echo "net.core.wmem_default = 262144" >> $sysconf;
echo "net.core.wmem_max = 1048576" >> $sysconf;
if grep "kernel.shmall" $sysconf; then
printf "the file aready set $sysconf kernel.shmall set next file ....\n ";
else
echo "kernel.shmall = 1073741824" >> $sysconf;
fi
if grep "kernel.shmmax" $sysconf; then
printf "the file aready set $sysconf kernel.shmmax set next file ....\n ";
else
echo "kernel.shmmax = 4398046511104" >> $sysconf;
fi
fi
let i=$i+1;
printf "....................................................................$i \n";
#note lines "net.bridge.bridge-nf-call"
sed -i 's/^net.bridge.bridge-nf-call/#net.bridge.bridge-nf-call/p' $sysconf
let i=$i+1;
printf "....................................................................$i \n";
sysctl -p
let i=$i+1;
printf "....................................................................$i \n";
pamlogin='/etc/pam.d/login';
cp $pamlogin $pamlogin.$vardate;
if grep "pam_limits.so" $pamlogin; then
printf "the file aready set $pamlogin set next file ....\n ";
else
echo "#the next rows install oracle add" >> $pamlogin;
echo "session required pam_limits.so" >> $pamlogin;
fi
let i=$i+1;
printf "....................................................................$i \n";
etcprofile='/etc/profile';
cp $etcprofile $etcprofile.$vardate;
if grep "oracle" $etcprofile; then
printf "the file aready set etc-profile set next file ....\n ";
else
echo "#the next rows install oracle add" >> $etcprofile;
echo 'if [ $USER = "oracle" ]; then' >> $etcprofile;
echo ' if [ $SHELL = "/bin/ksh" ]; then' >> $etcprofile;
echo " ulimit -p 16384" >> $etcprofile;
echo " ulimit -n 65536" >> $etcprofile;
echo " else" >> $etcprofile;
echo " ulimit -u 16384 -n 65536" >> $etcprofile;
echo " fi" >> $etcprofile;
echo "fi" >> $etcprofile;
fi
let i=$i+1;
printf "....................................................................$i \n";
printf "the change user oracle for add .bash_profile parameters.....\n ";
bashprofile='/home/oracle/.bash_profile';
cp $bashprofile $bashprofile.$vardate;
if grep "oracle" $bashprofile; then
printf "the file aready set bashprofile set next file ....\n ";
else
echo "#the next rows install oracle add" >> $bashprofile;
echo 'export TMP=/tmp' >> $bashprofile;
echo 'export TMPDIR=$TMP' >> $bashprofile;
echo "ORACLE_BASE=$orasetdir" >> $bashprofile;
echo 'ORACLE_HOME=$ORACLE_BASE/oracle11g' >> $bashprofile;
echo "ORACLE_SID=$dbsid" >> $bashprofile;
echo 'PATH=$ORACLE_HOME/bin:$PATH' >> $bashprofile;
echo 'NLS_LANG=AMERICAN_AMERICA.ZHS16GBK' >> $bashprofile;
echo 'export ORACLE_BASE ORACLE_HOME ORACLE_SID PATH NLS_LANG' >> $bashprofile;
fi
let i=$i+1;
printf "....................................................................$i \n";
printf "set is end ,reboot system too setup!! go to fly ~.~ ~.~ \n";