首先写好配置环境脚本
cd /opt
vi oraclesetup
#!/bin/bash
echo "back file to filebackup"
mkdir -p /opt/filebackup
cp /etc/sysctl.conf /opt/filebackup/sysctl.conf
cp /etc/security/limits.conf /opt/filebackup/limits.conf
cp /etc/pam.d/login /opt/filebackup/pamd_login
#create groups and users
groupadd -g 880 oinstall
groupadd -g 881 dba
groupadd -g 882 oper
useradd -g oinstall -G dba,oper oracle
echo oracle | passwd --stdin pgloracle >>output.log 2>&1
cat >> /etc/hosts << EOF
10.10.7.68 oracletest
EOF
#edit /etc/sysctl.conf
cat >> /etc/sysctl.conf << EOF
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
EOF
/sbin/sysctl -p >>/dev/null
cat >> /etc/security/limits.conf << EOF
oracle soft nproc 2047
oracle hard nproc 16384
oracle soft nofile 1024
oracle hard nofile 65536
EOF
cat >> /etc/pam.d/login << EOF
required pam_limits.so
EOF
cat >> /home/oracle/.bash_profile << EOF
export ORACLE_SID=hzmk
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=$ORACLE_BASE/product/db_1
export PATH=$ORACLE_HOME/bin:/usr/bin:$PATH
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:$ORACLE_HOME/oracm/lib:/lib:/usr/local/lib
export CLASSPATH=$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib:$ORACLE_HOME/network/jlib
export THREADS_FLAG=native;
export NLS_LANG=AMERICAN_AMERICA.AL32UTF8
EOF
--配置YUM源
cat >> /etc/yum.repos.d/syssetup.repo << EOF
[base]
name=Red Hat Enterprise Linux $releasever - $basearch - Debug
baseurl=file:///root/isoServer/Server
enabled=1
gpgcheck=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
EOF
--使用YUM命令安装依赖包
yum -y install make
yum -y install gcc
yum -y install gcc-c++
yum -y install binutils
yum -y install compat-libstdc++-33
yum -y install elfutils-libelf
yum -y install elfutils-libelf-devel
yum -y install elfutils-libelf-devel-static
yum -y install glibc
yum -y install glibc-common
yum -y install glibc-devel
yum -y install ksh
yum -y install libaio
yum -y install libaio-devel
yum -y install libgcc
yum -y install libstdc++
yum -y install libstdc++-devel
yum -y install numactl-devel
yum -y install sysstat
yum -y install unixODBC
yum -y install unixODBC-devel
yum -y install kernel-headers
yum -y install ksh
--配置静默文件
cat >> /opt/database/db_install.rsp << EOF
oracle.install.option=INSTALL_DB_SWONLY ORACLE_HOSTNAME=ruo UNIX_GROUP_NAME=oinstall INVENTORY_LOCATION=/u01/app/oracle/oraInventory SELECTED_LANGUAGES=en,zh_CN,zh_TW ORACLE_HOME=/u01/app/oracle/product/11.2.0/db_1 ORACLE_BASE=/u01/app/oracle oracle.install.db.InstallEdition=EE oracle.install.db.isCustomInstall=true oracle.install.db.DBA_GROUP=dba oracle.install.db.OPER_GROUP=oinstall oracle.install.db.config.starterdb.type=GENERAL_PURPOSE oracle.install.db.config.starterdb.globalDBName=orcl oracle.install.db.config.starterdb.SID=orcl oracle.install.db.config.starterdb.memoryLimit=512 oracle.install.db.config.starterdb.password.ALL=oracle DECLINE_SECURITY_UPDATES=true
EOF
/opt/database/runInstaller -silent -force -responseFile /opt/database/db_install.rsp -ignorePrereq