Redhat72静默安装oracle11gR2


操作系统:
[root@docker ~]# uname -m
x86_64
[root@docker ~]# cat /etc/redhat-release
Red Hat Enterprise Linux Server release 7.2 (Maipo)
 
安装软件包:
The following or later version of packages for Oracle Linux 7, and Red Hat Enterprise Linux 7 must be installed:
binutils-2.23.52.0.1-12.el7.x86_64
compat-libcap1-1.10-3.el7.x86_64
compat-libstdc++-33-3.2.3-71.el7.i686
compat-libstdc++-33-3.2.3-71.el7.x86_64
gcc-4.8.2-3.el7.x86_64
gcc-c++-4.8.2-3.el7.x86_64
glibc-2.17-36.el7.i686
glibc-2.17-36.el7.x86_64
glibc-devel-2.17-36.el7.i686
glibc-devel-2.17-36.el7.x86_64
ksh
libaio-0.3.109-9.el7.i686
libaio-0.3.109-9.el7.x86_64
libaio-devel-0.3.109-9.el7.i686
libaio-devel-0.3.109-9.el7.x86_64
libgcc-4.8.2-3.el7.i686
libgcc-4.8.2-3.el7.x86_64
libstdc++-4.8.2-3.el7.i686
libstdc++-4.8.2-3.el7.x86_64
libstdc++-devel-4.8.2-3.el7.i686
libstdc++-devel-4.8.2-3.el7.x86_64
libXi-1.7.2-1.el7.i686
libXi-1.7.2-1.el7.x86_64
libXtst-1.2.2-1.el7.i686
libXtst-1.2.2-1.el7.x86_64
make-3.82-19.el7.x86_64
sysstat-10.1.5-1.el7.x86_64
unixODBC-2.3.1-6.el7.x86_64 or later
unixODBC-2.3.1-6.el7.i686 or later
unixODBC-devel-2.3.1-6.el7.x86_64 or later
unixODBC-devel-2.3.1-6.el7.i686 or later

检测是否31个包都有安装,并列出未安装的包

[root@docker ~]# rpm -q binutils compat-libcap1 compat-libstdc++-33 gcc gcc-c++ glibc glibc-devel ksh libaio libaio-devel libgcc libstdc++ libstdc++-devel libXi libXtst make sysstat unixODBC unixODBC-devel |grep "not installed"
package compat-libcap1 is not installed
package compat-libstdc++-33 is not installed
package ksh is not installed
package libaio-devel is not installed
package unixODBC is not installed
package unixODBC-devel is not installed

版本号只能大于规定的版本,不能小于。

下面是根据以上要求整理出来的一段shell脚本,已经在redhat7.2版本验证,可以正确安装:

 

#!/bin/bash

#####################################################################
#
说明 #
#1
、前提条件新建oracle用户和组,将安装包上传到oracle用户下解压 #
#2
、内核参数值固定,可自行在脚本中更改 #
#3
、字符集固定为ZHS16GBK,安装版本固定为企业版 #
#4
、实例名和全局变量名一致,可设置 #
#5
Oracle_BASE默认设置为/home/oracle #
#####################################################################

#
使用方法如下
:'
1
、首先需要新建一个dba组和oracle用户,然后将oracle的安装包以oracle用户上传到/home/oracle下并进行解压,
解压出来的文件夹名用database
2
、以root用户上传脚本,目录无限制。
3
、执行脚本即可。
脚本执行过程中会进行rpm包的检查,对于rpm包缺少会在标红位置进行提醒,需要自己手动去安装
基本参数配置完成后,脚本提示需要输入要安装oracle的实例名,输入完成后,再输入Y进行确认,
然后进入到oracle软件的静默安装,提示的两个脚本会自动执行,无需手动操作
当看到安装成功字样后,进行监听的静默安装,看到返回值0表明安装成功
监听安装完成后进入到数据库实例的创建,看到100%完成后,表明实例创建完成
到这里为止oracle安装完成,可以直接使用了,后续脚本对oracle进行了包括审计、优化器、连接数等的优化
'

#hosts
文件添加,请手动添加,高版本系统不能使用一下命令
:'
local_ip=`ifconfig eno16777736 | grep Bcast | cut -d : -f2 | cut -d " " -f1`
local_name=`hostname`
cat /etc/hosts | grep $local_ip >/dev/null
if [ $? != 0 ];then
    echo "$local_ip $local_name" >>/etc/hosts
else
    sed -i '/'$local_ip'/d' /etc/hosts
    echo "$local_ip $local_name" >>/etc/hosts
fi
'
jishu=0
#RPM
包准备
echo "Start checking rpm software installation......"

rpm -qa | grep binutils >/dev/null
if [ $? != 0 ];then
    echo "binutils rpm software is not exist.Please check again."
    let jishu=jishu+1
fi

rpm -qa | grep compat-libcap1 >/dev/null
if [ $? != 0 ];then
    echo "compat-libcap1 rpm software is not exist.Please check again."
    let jishu=jishu+1
fi

rpm -qa | grep compat-libstdc++-33 >/dev/null
if [ $? != 0 ];then
    echo "compat-libstdc++-33 rpm software is not exist.Please check again."
    let jishu=jishu+1
fi

rpm -qa | grep elfutils-libelf >/dev/null
if [ $? != 0 ];then
    echo "elfutils-libelf rpm software is not exist.Please check again."
    let jishu=jishu+1
fi

rpm -qa | grep ^gcc >/dev/null
if [ $? != 0 ];then
    echo "gcc rpm software is not exist.Please check again."
    let jishu=jishu+1
fi

rpm -qa | grep ^gcc-c++ >/dev/null
if [ $? != 0 ];then
    echo "gcc-c++ rpm software is not exist.Please check again."
    let jishu=jishu+1
fi

rpm -qa | grep ^glibc >/dev/null
if [ $? != 0 ];then
    echo "glibc rpm software is not exist.Please check again."
    let jishu=jishu+1
fi

rpm -qa | grep ^glibc-devel >/dev/null
if [ $? != 0 ];then
    echo "glibc rpm software is not exist.Please check again."
    let jishu=jishu+1
fi

rpm -qa | grep ^libaio >/dev/null
if [ $? != 0 ];then
    echo "libaio rpm software is not exist.Please check again."
    let jishu=jishu+1
fi

rpm -qa | grep ^libaio-devel >/dev/null
if [ $? != 0 ];then
    echo "libaio-devel rpm software is not exist.Please check again."
    let jishu=jishu+1
fi

rpm -qa | grep ^libgcc >/dev/null
if [ $? != 0 ];then
    echo "libgcc rpm software is not exist.Please check again."
    let jishu=jishu+1
fi

rpm -qa | grep ^libstdc >/dev/null
if [ $? != 0 ];then
    echo "libstdc rpm software is not exist.Please check again."
    let jishu=jishu+1
fi

rpm -qa | grep ^libstdc++ >/dev/null
if [ $? != 0 ];then
    echo "libstdc++ rpm software is not exist.Please check again."
    let jishu=jishu+1
fi

rpm -qa | grep ^libstdc++-devel >/dev/null
if [ $? != 0 ];then
    echo "libstdc++-devel rpm software is not exist.Please check again."
    let jishu=jishu+1
fi

rpm -qa | grep ^libXi >/dev/null
if [ $? != 0 ];then
    echo "libXi rpm software is not exist.Please check again."
    let jishu=jishu+1
fi

rpm -qa | grep ^libXtst >/dev/null
if [ $? != 0 ];then
    echo "libXtst rpm software is not exist.Please check again."
    let jishu=jishu+1
fi

rpm -qa | grep ^make >/dev/null
if [ $? != 0 ];then
    echo "make rpm software is not exist.Please check again."
    let jishu=jishu+1
fi

rpm -qa | grep ^numactl >/dev/null
if [ $? != 0 ];then
    echo "numactl rpm software is not exist.Please check again."
    let jishu=jishu+1
fi

rpm -qa | grep ^sysstat >/dev/null
if [ $? != 0 ];then
    echo "sysstat rpm software is not exist.Please check again."
    let jishu=jishu+1
fi

rpm -qa | grep unixODBC >/dev/null
if [ $? != 0 ];then
    echo "unixODBC rpm software is not exist.Please check again."
    let jishu=jishu+1
fi

rpm -qa | grep unixODBC-devel >/dev/null
if [ $? != 0 ];then
    echo "unixODBC-devel rpm software is not exist.Please check again."
    let jishu=jishu+1
fi

rpm -qa | grep ksh >/dev/null
if [ $? != 0 ];then
    echo "ksh rpm software is not exist.Please check again."
    let jishu=jishu+1
fi

#rpm -qa | grep pdksh >/dev/null
#if [ $? != 0 ];then
#    echo "pdksh rpm software is not exist.Please check again."
#    let jishu=jishu+1
#fi

echo "Software inspenction is finished !"

if [ $jishu != 0 ];then
    exit
fi


#
配置核心参数
cat /etc/sysctl.conf | grep fs.aio-max-nr >/dev/null
if [ $? != 0 ];then
    echo "fs.aio-max-nr = 1048576" >>/etc/sysctl.conf
fi

cat /etc/sysctl.conf | grep fs.file-max >/dev/null
if [ $? != 0 ];then
    echo "fs.file-max = 6815744" >>/etc/sysctl.conf
fi

cat /etc/sysctl.conf | grep kernel.shmall >/dev/null
if [ $? != 0 ];then
    echo "kernel.shmall = 2097152" >>/etc/sysctl.conf
fi

cat /etc/sysctl.conf | grep kernel.shmmax >/dev/null
if [ $? != 0 ];then
    echo "kernel.shmmax = 536870912" >>/etc/sysctl.conf
fi

cat /etc/sysctl.conf | grep kernel.shmmni >/dev/null
if [ $? != 0 ];then
    echo "kernel.shmmni = 4096" >>/etc/sysctl.conf
fi

cat /etc/sysctl.conf | grep kernel.sem >/dev/null
if [ $? != 0 ];then
    echo "kernel.sem = 250 32000 100 128" >>/etc/sysctl.conf
fi

cat /etc/sysctl.conf | grep net.ipv4.ip_local_port_range >/dev/null
if [ $? != 0 ];then
    echo "net.ipv4.ip_local_port_range = 9000 65500" >>/etc/sysctl.conf
fi

cat /etc/sysctl.conf | grep net.core.rmem_default >/dev/null
if [ $? != 0 ];then
    echo "net.core.rmem_default = 262144" >>/etc/sysctl.conf
fi

cat /etc/sysctl.conf | grep net.core.rmem_max >/dev/null
if [ $? != 0 ];then
    echo "net.core.rmem_max = 4194304" >>/etc/sysctl.conf
fi

cat /etc/sysctl.conf | grep net.core.wmem_default >/dev/null
if [ $? != 0 ];then
    echo "net.core.wmem_default = 262144" >>/etc/sysctl.conf
fi

cat /etc/sysctl.conf | grep net.core.wmem_max >/dev/null
if [ $? != 0 ];then
    echo "net.core.wmem_max = 1048586" >>/etc/sysctl.conf
fi

/sbin/sysctl -p


#
设置Oracle用户参数
cat /etc/security/limits.conf |grep oracle >/dev/null
if [ $? != 0 ];then
    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
fi

cat /etc/pam.d/login | grep pam_limits.so >/dev/null
if [ $? != 0 ];then
    sysbit=`getconf LONG_BIT`
    if [ $sysbit = 32 ];then
        echo "session required /lib/security/pam_limits.so" >>/etc/pam.d/login
        echo "session required pam_limits.so" >>/etc/pam.d/login
    else
        echo "session required pam_limits.so" >>/etc/pam.d/login
    fi
fi

cat /etc/profile | grep oracle >/dev/null
if [ $? != 0 ];then
    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
fi


#
创建Oracle用户、组、安装目录

# cat /etc/group | grep dba >/dev/null
# if [ $? != 0 ];then
    # groupadd dba
# fi

# cat /etc/passwd | grep oracle >/dev/null
# if [ $? != 0 ];then
    # useradd -g dba oracle -d /home/oracle
# else
    # userdel -r oracle
    # useradd -g dba oracle -d /home/oracle
# fi
# passwd oracle <<EOF
# oracle
# oracle
# EOF

mkdir -p /home/oracle/oradata
mkdir -p /home/oracle/oraInventory
chown -R oracle:dba /home/oracle/oradata/ /home/oracle/oraInventory/
chmod -R 755 /home/oracle/oradata/ /home/oracle/oraInventory/


#
配置oracle用户环境变量
if [ ! -f /home/oracle/.bash_profile ];then
    echo "The oracle's file of .bash_profile is not exist."
else
    cat /home/oracle/.bash_profile | grep ORACLE_BASE >/dev/null
    if [ $? != 0 ];then
    echo 'export ORACLE_BASE=/home/oracle
export ORACLE_HOME=/home/oracle/product/11gR2
export ORACLE_SID=ora11g
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/lib64:/usr/lib:/usr/lib64:/usr/local/lib:/usr/local/lib64
export PATH=$PATH:$ORACLE_HOME/bin:.
export LANG=C
export NLS_LANG=AMERICAN_AMERICA.ZHS16GBK' >>/home/oracle/.bash_profile
    su - oracle -c "source /home/oracle/.bash_profile"
    fi
fi

#echo 'Oracle configure completely !'

#
响应文件配置

if [ -d /home/oracle/database ];then
    chmod -R 755 /home/oracle/database
    cp /home/oracle/database/response/* /home/oracle/
else
    echo "Oracle install file is not exist !"
    exit
fi

if [ ! -f /home/oracle/db_install.rsp ];then
    echo "db_install.rsp file is not exist !"
    exit
fi

if [ ! -f /home/oracle/dbca.rsp ];then
    echo "dbca.rsp file is not exist !"
    exit
fi

if [ ! -f /home/oracle/netca.rsp ];then
    echo "netca.rsp file is not exist !"
    exit
fi

echo ""
echo "##########################################"

while [ 0 ]
do
    echo -n "--Please input oracle sid:"
    read oracle_sid
    echo "ORACLE SID : $oracle_sid"
    echo -n "Are you sure (Y/N)?"
    read confirmation
    if [ $confirmation = Y ];then
        break
    fi
done

oracle_sid_old=`cat /home/oracle/.bash_profile | grep ORACLE_SID`
oracle_sid_new="export ORACLE_SID=$oracle_sid"
sed -i 's/'"$oracle_sid_old"'/'"$oracle_sid_new"'/g' /home/oracle/.bash_profile
oracle_home_old=`cat /home/oracle/.bash_profile | grep product`
oracle_home_new="export ORACLE_HOME=/home/oracle/product/$oracle_sid"
sed -i 's%'"$oracle_home_old"'%'"$oracle_home_new"'%g' /home/oracle/.bash_profile
su - oracle -c "source /home/oracle/.bash_profile"

cat /home/oracle/db_install.rsp | grep oracle.install.option=INSTALL_DB_SWONLY >/dev/null
if [ $? != 0 ];then
    value_old=`cat /home/oracle/db_install.rsp | grep oracle.install.option`
    value_new="oracle.install.option=INSTALL_DB_SWONLY"
    sed -i 's/'"$value_old"'/'"$value_new"'/g' /home/oracle/db_install.rsp
fi

cat /home/oracle/db_install.rsp | grep ORACLE_HOSTNAME >/dev/null
if [ $? = 0 ];then
    value_old=`cat /home/oracle/db_install.rsp | grep ORACLE_HOSTNAME`
    value_new="ORACLE_HOSTNAME=`hostname`"
    sed -i 's/'"$value_old"'/'"$value_new"'/g' /home/oracle/db_install.rsp
fi

cat /home/oracle/db_install.rsp | grep UNIX_GROUP_NAME >/dev/null
if [ $? = 0 ];then
    value_old=`cat /home/oracle/db_install.rsp | grep UNIX_GROUP_NAME`
    value_new="UNIX_GROUP_NAME=dba"
    sed -i 's/'"$value_old"'/'"$value_new"'/g' /home/oracle/db_install.rsp
fi

cat /home/oracle/db_install.rsp | grep INVENTORY_LOCATION >/dev/null
if [ $? = 0 ];then
    value_old=`cat /home/oracle/db_install.rsp | grep INVENTORY_LOCATION`
    value_new="INVENTORY_LOCATION=/home/oracle/oraInventory"
    sed -i 's%'"$value_old"'%'"$value_new"'%g' /home/oracle/db_install.rsp
fi

cat /home/oracle/db_install.rsp | grep ORACLE_HOME >/dev/null
if [ $? = 0 ];then
    value_old=`cat /home/oracle/db_install.rsp | grep ORACLE_HOME`
    value_new="ORACLE_HOME=/home/oracle/product/$oracle_sid"
    sed -i 's%'"$value_old"'%'"$value_new"'%g' /home/oracle/db_install.rsp
fi

cat /home/oracle/db_install.rsp | grep ORACLE_BASE >/dev/null
if [ $? = 0 ];then
    value_old=`cat /home/oracle/db_install.rsp | grep ORACLE_BASE`
    value_new="ORACLE_BASE=/home/oracle"
    sed -i 's%'"$value_old"'%'"$value_new"'%g' /home/oracle/db_install.rsp
fi

cat /home/oracle/db_install.rsp | grep oracle.install.db.InstallEdition >/dev/null
if [ $? = 0 ];then
    value_old=`cat /home/oracle/db_install.rsp | grep oracle.install.db.InstallEdition`
    value_new="oracle.install.db.InstallEdition=EE"
    sed -i 's/'"$value_old"'/'"$value_new"'/g' /home/oracle/db_install.rsp
fi

cat /home/oracle/db_install.rsp | grep oracle.install.db.DBA_GROUP >/dev/null
if [ $? = 0 ];then
    value_old=`cat /home/oracle/db_install.rsp | grep oracle.install.db.DBA_GROUP`
    value_new="oracle.install.db.DBA_GROUP=dba"
    sed -i 's/'"$value_old"'/'"$value_new"'/g' /home/oracle/db_install.rsp
fi

cat /home/oracle/db_install.rsp | grep oracle.install.db.OPER_GROUP >/dev/null
if [ $? = 0 ];then
    value_old=`cat /home/oracle/db_install.rsp | grep oracle.install.db.OPER_GROUP`
    value_new="oracle.install.db.OPER_GROUP=dba"
    sed -i 's/'"$value_old"'/'"$value_new"'/g' /home/oracle/db_install.rsp
fi

cat /home/oracle/db_install.rsp | grep oracle.install.db.config.starterdb.characterSet >/dev/null
if [ $? = 0 ];then
    value_old=`cat /home/oracle/db_install.rsp | grep oracle.install.db.config.starterdb.characterSet`
    value_new="oracle.install.db.config.starterdb.characterSet=ZHS16GBK"
    sed -i 's/'"$value_old"'/'"$value_new"'/g' /home/oracle/db_install.rsp
fi

cat /home/oracle/db_install.rsp | grep oracle.install.db.config.starterdb.password.SYS >/dev/null
if [ $? = 0 ];then
    value_old=`cat /home/oracle/db_install.rsp | grep oracle.install.db.config.starterdb.password.SYS | grep -v SYSTEM | grep -v SYSMAN`
    value_new="oracle.install.db.config.starterdb.password.SYS=oracle"
    sed -i 's/'"$value_old"'/'"$value_new"'/g' /home/oracle/db_install.rsp
    
    value_old=`cat /home/oracle/db_install.rsp | grep oracle.install.db.config.starterdb.password.SYSTEM`
    value_new="oracle.install.db.config.starterdb.password.SYSTEM=oracle"
    sed -i 's/'"$value_old"'/'"$value_new"'/g' /home/oracle/db_install.rsp
    
    value_old=`cat /home/oracle/db_install.rsp | grep oracle.install.db.config.starterdb.password.SYSMAN`
    value_new="oracle.install.db.config.starterdb.password.SYSMAN=oracle"
    sed -i 's/'"$value_old"'/'"$value_new"'/g' /home/oracle/db_install.rsp
    
    value_old=`cat /home/oracle/db_install.rsp | grep oracle.install.db.config.starterdb.password.DBSNMP`
    value_new="oracle.install.db.config.starterdb.password.DBSNMP=oracle"
    sed -i 's/'"$value_old"'/'"$value_new"'/g' /home/oracle/db_install.rsp
fi

cat /home/oracle/db_install.rsp | grep DECLINE_SECURITY_UPDATES >/dev/null
if [ $? = 0 ];then
    value_old=`cat /home/oracle/db_install.rsp | grep DECLINE_SECURITY_UPDATES | grep -v Example`
    value_new="DECLINE_SECURITY_UPDATES=true"
    sed -i 's/'"$value_old"'/'"$value_new"'/g' /home/oracle/db_install.rsp
fi

cat /home/oracle/dbca.rsp | grep ^GDBNAME >/dev/null
if [ $? = 0 ];then
    value_old=`cat /home/oracle/dbca.rsp | grep ^GDBNAME |head -n 1`
    value_new="GDBNAME = "$oracle_sid""
    sed -i 's/'"$value_old"'/'"$value_new"'/g' /home/oracle/dbca.rsp
fi

cat /home/oracle/dbca.rsp | grep ^SID >/dev/null
if [ $? = 0 ];then
    value_old=`cat /home/oracle/dbca.rsp | grep ^SID`
    value_new="SID = "$oracle_sid""
    sed -i 's/'"$value_old"'/'"$value_new"'/g' /home/oracle/dbca.rsp
fi

cat /home/oracle/dbca.rsp | grep SYSPASSWORD | grep -v Name >/dev/null
if [ $? = 0 ];then
    value_old=`cat /home/oracle/dbca.rsp | grep SYSPASSWORD | grep -v Name`
    value_new='SYSPASSWORD = "oracle"'
    sed -i 's/'"$value_old"'/'"$value_new"'/g' /home/oracle/dbca.rsp
fi

cat /home/oracle/dbca.rsp | grep SYSTEMPASSWORD | grep -v Name >/dev/null
if [ $? = 0 ];then
    value_old=`cat /home/oracle/dbca.rsp | grep SYSTEMPASSWORD | grep -v Name`
    value_new='SYSTEMPASSWORD = "oracle"'
    sed -i 's/'"$value_old"'/'"$value_new"'/g' /home/oracle/dbca.rsp
fi

cat /home/oracle/dbca.rsp | grep DATAFILEDESTINATION | grep -v Name >/dev/null
if [ $? = 0 ];then
    value_old=`cat /home/oracle/dbca.rsp | grep DATAFILEDESTINATION | grep -v Name`
    value_new='DATAFILEDESTINATION = /home/oracle/oradata'
    sed -i 's%'"$value_old"'%'"$value_new"'%g' /home/oracle/dbca.rsp
fi

cat /home/oracle/dbca.rsp | grep RECOVERYAREADESTINATION | grep -v Name >/dev/null
if [ $? = 0 ];then
    value_old=`cat /home/oracle/dbca.rsp | grep RECOVERYAREADESTINATION | grep -v Name`
    value_new='RECOVERYAREADESTINATION= /home/oracle/flash_recovery_area'
    sed -i 's%'"$value_old"'%'"$value_new"'%g' /home/oracle/dbca.rsp
fi

cat /home/oracle/dbca.rsp | grep CHARACTERSET | grep -v NATIONALCHARACTERSET | grep -v Name >/dev/null
if [ $? = 0 ];then
    value_old=`cat /home/oracle/dbca.rsp | grep CHARACTERSET | grep -v NATIONALCHARACTERSET | grep -v Name`
    value_new='CHARACTERSET = "ZHS16GBK"'
    sed -i 's/'"$value_old"'/'"$value_new"'/g' /home/oracle/dbca.rsp
fi


#
静默安装oracle软件
chmod 777 /home/oracle/db_install.rsp /home/oracle/dbca.rsp /home/oracle/netca.rsp
chown oracle:dba /home/oracle/db_install.rsp /home/oracle/dbca.rsp /home/oracle/netca.rsp

su - oracle <<EOF
cd /home/oracle/database
./runInstaller -silent -ignorePrereq -showProgress -responseFile /home/oracle/db_install.rsp
EOF

while [ 0 ]
do
    if [ -d /home/oracle/oraInventory/logs ];then
        cat /home/oracle/oraInventory/logs/oraInstall*.out | grep "Successfully Setup Software" >/dev/null
        if [ $? = 0 ];then
            sh /home/oracle/oraInventory/orainstRoot.sh
            sh /home/oracle/product/$oracle_sid/root.sh
            sleep 10
            break
        fi
    fi

    sleep 30
done

#
静默安装监听
su - oracle <<EOF
netca -silent -responseFile /home/oracle/netca.rsp
EOF

sleep 120

#
静默安装实例
su - oracle <<EOF
dbca -silent -responseFile /home/oracle/dbca.rsp
EOF

while [ 0 ]
do
    if [ -f /home/oracle/cfgtoollogs/dbca/$oracle_sid/$oracle_sid.log ];then
        cat /home/oracle/cfgtoollogs/dbca/$oracle_sid/$oracle_sid.log | grep "Database creation complete" >/dev/null
        if [ $? = 0 ];then
            sleep 10
            break
        fi
    fi

    sleep 30
done

#oracle 11g
的性能优化
su - oracle <<EOF
sqlplus / as sysdba
alter system set OPTIMIZER_MODE=RULE scope=both;
alter system set deferred_segment_creation=FALSE scope=both;
alter system set audit_trail=none scope=spfile;
truncate table aud$;
alter system set event= '10949 trace name context forever, level 1' scope=spfile;
alter system set processes=500 scope=spfile;
alter system set sessions=555 scope=spfile;
shutdown immediate;
startup;
EOF

#
生成配置文件
su - oracle <<EOF
cp $ORACLE_HOME/network/admin/samples/* $ORACLE_HOME/network/admin/
EOF

原文地址:https://www.cnblogs.com/skiing886/p/7683231.html