#将以下脚本内容复制保存为installoracle.sh 并赋予可执行权限,在root用户下运行即可。
#!/bin/bash
touch /tmp/oracle_tmp
echo "create ORACLE Database "
echo "--------------------"
echo "--------------------"
echo " "
cat /etc/passwd | grep oracle > /tmp/oracle_tmp
if [ -s /tmp/oracle_tmp ]; then
echo "system have oracle user-----END"
exit
else
/usr/sbin/groupadd oinstall
/usr/sbin/groupadd dba
/usr/sbin/useradd -g oinstall -G dba oracle
echo "input oracle password"
echo `passwd oracle`
fi
echo " "
echo " "
echo "create oracle database path"
i=n
while [ $i != 'y' ]
do
echo -n "input ORACLE_BASE:"
read ORACLE_BASE
echo -n "Is right(y/n):"
read i
done
i=n
while [ $i != 'y' ]
do
echo -n "input ORACLE_HOME:"
read ORACLE_HOME
echo -n "Is right(y/n):"
read i
done
mkdir -p $ORACLE_HOME
chown -R oracle:oinstall $ORACLE_BASE
chmod -R 775 $ORACLE_BASE
if [ -e /etc/sysctl.conf ]; then
echo "Change/etc/sysctl.conf"
# touch /tmp/sysctl_tmp
# head -29 /etc/sysctl.conf > /tmp/sysctl_tmp
# cat /tmp/sysctl_tmp > /etc/sysctl.conf
# rm -fr /tmp/sysctl_tmp
cp /etc/sysctl.conf /etc/sysctl.conf_bak ##备份原有的系统参数配置文件
echo "########create by auto configure scipt #######
kernel.shmmni = 4096
kernel.sem = 250 32000 100 128
fs.file-max = 65536
net.ipv4.ip_local_port_range = 1024 65000
net.core.rmem_default = 262144
net.core.rmem_max = 262144
net.core.wmem_default = 262144
net.core.wmem_max = 262144" >> /etc/sysctl.conf
echo "check sysctl configure:"
sysctl -p
else
echo "no /etc/sysctl.conf file-----End"
exit
fi
if [ -e /etc/security/limits.conf ]; then
cp /etc/security/limits.conf /etc/security/limits.conf_bak #备份原有的系统参数文件
echo "Change/etc/security/limits.conf"
echo "##########create by auto configure scipt ################
oracle soft nproc 2047
oracle hard nproc 16384
oracle soft nofile 1024
oracle hard nofile 65536" >> /etc/security/limits.conf
else
echo "no /etc/security/limits.conf file-----end"
exit
fi
if [ -e /etc/pam.d/login ];then
cp /etc/pam.d/login /etc/pam.d/login_bak #备份原有的系统参数文件
echo "change /etc/pam.d/login"
echo "##############create by auto configure scipt ################
#session required /lib/security/pam_limits.so
session required pam_limits.so" >> /etc/pam.d/login
else
echo "no /etc/pam.d/login file-----End"
exit
fi
if [ -e /etc/profile ]; then
cp /etc/profile /etc/profile_bak #备份系统原有的参数文件
echo "change /etc/profile"
echo '###########create by auto configure scipt ####################
if [ $USER = "oracle" ]; then
if [ $SHELL = "/bin/ksh" ]; then
ulimit -p 16384
ulimit -n 65536
else
ulimit -u 16384 -n 65536
fi
umask 022
fi' >> /etc/profile
else
echo "no /etc/profile file-----end"
exit
fi
if [ -e /home/oracle/.bash_profile ];then
echo "Change user oracle's .bash_profile"
echo "############################################################################
export ORACLE_BASE=$ORACLE_BASE
export ORACLE_HOME=$ORACLE_HOME" >> /home/oracle/.bash_profile
echo '
export ORACLE_SID=syntong
export PATH=$PATH:/usr/sbin
export PATH=$PATH:$ORACLE_HOME/bin
export LD_LIBARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib
#export LD_LIBARY_PATH=$ORACLE_HOME/lib:/lib64:/usr/lib64
export LANG=en
umask 022' >> /home/oracle/.bash_profile
else
echo "no /home/oracle/.bash_profile file-----End"
exit
fi
echo "Change linux version"
cp /etc/redhat-release /etc/redhat-release_bak #备份系统原有的参数文件
echo "Red Hat Enterprise Linux Server release 4 (Tikanga)" > /etc/redhat-release #添加系统版本,让ORACLE安装程序验证通过
echo " "
echo " "
echo "ORACLE_BASE=$ORACLE_BASE"
echo "ORACLE_HOME=$ORACLE_HOME"
echo "ORACLE_SID=syntong"
rm -fr /tmp/oracle_tmp
echo "oracle database succeseful-----please press any key to exit"
read c
while [ -z c ]
do
continue
done