#!/bin/bash
echo "Set up the installation environment for oracle..."
echo "-------------------------------------------------"
echo "-----------------------------------------"
echo -e "add Users and Groups\n\n"
groupadd oinstall
groupadd dba
useradd -g oinstall -G dba oracle
passwd oracle
if [ $? -eq 0 ];then
echo "-----------------------------------------"
else
echo "ERROR!!!"
fi
echo "Modify the kernel parameters: /etc/sysctl.conf"
echo "----------------------------------------------"
echo -e "fs.aio-max-nr = 1048576
fs.file-max = 6815744
#kernel.shmall = 2097152
#kernel.shmmax = 536870912
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 = 1048586">>/etc/sysctl.conf
if [ $? -eq 0 ]; then
/sbin/sysctl -p
echo "----Modify done----"
fi
echo "-----------/etc/security/limits.conf------------------"
echo "oracle soft nproc 2047
oracle hard nproc 16384
oracle soft nofile 1024
oracle hard nofile 65536
oracle soft stack 10240">>/etc/security/limits.conf
if [ $? -eq 0 ];then
echo "----Modify done----"
fi
echo "-----------/etc/pam.d/login------------------"
echo "session required pam_limits.so">>/etc/pam.d/login
if [ $? -eq 0 ];then
echo "----Modify done----"
fi
echo "-----------/etc/profile------------------"
echo "if [ \$USER = "oracle" ]; then
if [ \$SHELL = "/bin/ksh" ]; then
ulimit -p 16384
ulimit -n 65536
else
ulimit -u 16384 -n 65536
fi
fi">>/etc/profile
if [ $? -eq 0 ];then
echo "----Modify done----"
fi
echo -e "\n-----------Set Install Directory----------"
mkdir -p /u01
chown -R oracle:oinstall /u01/
chmod -R 775 /u01
echo -e "\n----------Modify .bash_profile-------------"
su - oracle<<EOF
echo "export ORACLE_BASE=/u01/app
export ORACLE_HOME=\\\$ORACLE_BASE/oracle
export ORACLE_SID=orcl
export PATH=\\\$ORACLE_HOME/bin:\\\$PATH:\\\$HOME/bin">>.bash_profile
EOF
echo "----Modify done----"
rpm -q binutils compat-libstdc++-33 elfutils-libelf elfutils-libelf-devel elfutils-libelf-devel-static gcc gcc-c++ glibc glibc-common glibc-devel glibc-headers kernel-headers ksh libaio libaio-devel libgcc libgomp libstdc++ libstdc++-devel make numactl-devel sysstat unixODBC unixODBC-devel>>/root/need_rpm.log
echo "The Path of rpm needed:/root/need_rpm.log"