以下脚本的手动安装连接: https://www.cnblogs.com/leihongnu/p/12698593.html
【
#/bin/bash
#安装日志
touch /root/message.txt
message=/root/message.txt
#安装依赖
yum -y install 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
#检查依赖安装是否完成
if [ `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" | wc -l` -ge 1 ]
then
echo "依赖未全部安装,请检查" >> $message
exit 0
fi
#关闭selinux
sed -i "s/SELINUX=enforcing/SELINUX=disabled/" /etc/selinux/config
setenforce 0
#创建用户、密码和组
groupadd oinstall
groupadd dba
groupadd oper
useradd -g oinstall -G dba oracle
echo "Aa123456" | passwd --stdin oracle &> /dev/null
#配置内核参数和资源限制,修改 /etc/sysctl.conf 文件,添加以下内容
echo "##oracle" >> /etc/sysctl.conf
echo "fs.aio-max-nr = 1048576" >> /etc/sysctl.conf
echo "fs.file-max = 6815744" >> /etc/sysctl.conf
echo "kernel.shmall = 2097152" >> /etc/sysctl.conf
echo "kernel.shmmax = 536870912" >> /etc/sysctl.conf
echo "kernel.shmmni = 4096" >> /etc/sysctl.conf
echo "kernel.sem = 250 32000 100 128" >> /etc/sysctl.conf
echo "net.ipv4.ip_local_port_range = 9000 65500" >> /etc/sysctl.conf
echo "net.core.rmem_default = 262144" >> /etc/sysctl.conf
echo "net.core.rmem_max = 4194304" >> /etc/sysctl.conf
echo "net.core.wmem_default = 262144" >> /etc/sysctl.conf
echo "net.core.wmem_max = 1048576" >> /etc/sysctl.conf
sysctl -p
#在 /etc/security/limits.conf 文件,添加以下内容
echo "##oracle" >> /etc/security/limits.conf
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
#在 /etc/pam.d/login 文件,添加以下内容
echo "##oracle" >> /etc/pam.d/login
echo "session required /lib64/security/pam_limits.so" >> /etc/pam.d/login
echo "session required pam_limits.so" >> /etc/pam.d/login
#在 /etc/profile 文件,添加以下内容
echo "##oracle" >> /etc/profile
echo "if [ $USER = "oracle" ]; then" >> /etc/profile
echo "if [ $SHELL = "/bin/ksh" ]; then" >> /etc/profile
echo "ulimit -p 16384" >> /etc/profile
echo "ulimit -n 65536" >> /etc/profile
echo "else" >> /etc/profile
echo "ulimit -u 16384 -n 65536" >> /etc/profile
echo "fi" >> /etc/profile
echo "fi" >> /etc/profile
source /etc/profile
#禁用使用Transparent HugePages,在 /etc/grub.conf 文件,添加以下内容
echo never > /sys/kernel/mm/transparent_hugepage/enabled
#创建oracle安装目录
mkdir -p /data/app/
chown -R oracle:oinstall /data/app/
chmod -R 775 /data/app/
#配置 oracle 用户的环境变量,在 /home/oracle/.bash_profile 文件中,添加以下内容
echo "##oracle" >> /home/oracle/.bash_profile
echo "umask 022" >> /home/oracle/.bash_profile
echo "export ORACLE_HOSTNAME=$HOSTNAME" >> /home/oracle/.bash_profile
echo "export ORACLE_BASE=/data/app/oracle" >> /home/oracle/.bash_profile
echo "export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/" >> /home/oracle/.bash_profile
echo "export ORACLE_SID=ORCL" >> /home/oracle/.bash_profile
echo "export PATH=.:$ORACLE_HOME/bin:$ORACLE_HOME/OPatch:$ORACLE_HOME/jdk/bin:$PATH" >> /home/oracle/.bash_profile
echo "export LC_ALL="en_US"" >> /home/oracle/.bash_profile
echo "export LANG="en_US"" >> /home/oracle/.bash_profile
echo "export NLS_LANG="AMERICAN_AMERICA.ZHS16GBK"" >> /home/oracle/.bash_profile
echo "export NLS_DATE_FORMAT="YYYY-MM-DD HH24:MI:SS"" >> /home/oracle/.bash_profile
source /home/oracle/.bash_profile
#解压下载好的两个文件
cd /root
unzip -q linux.x64_11gR2_database_1of2.zip -d /data
unzip -q linux.x64_11gR2_database_2of2.zip -d /data
mkdir -p /data/etc
cp /data/database/response/* /data/etc/
#在 /data/etc/db_install.rsp 文件中,添加以下内容
echo "##oracle" >> /data/etc/db_install.rsp
sed -i "s/^.*oracle.install.option.*$/oracle.install.option=INSTALL_DB_SWONLY/" /data/etc/db_install.rsp
sed -i "s/^.*DECLINE_SECURITY_UPDATES.*$/DECLINE_SECURITY_UPDATES=true/" /data/etc/db_install.rsp
sed -i "s/^.*UNIX_GROUP_NAME.*$/UNIX_GROUP_NAME=oinstall/" /data/etc/db_install.rsp
sed -i "s/^.*INVENTORY_LOCATION.*$/INVENTORY_LOCATION=/data/app/oracle/inventory/" /data/etc/db_install.rsp
sed -i "s/^.*SELECTED_LANGUAGES.*$/SELECTED_LANGUAGES=en,zh_CN/" /data/etc/db_install.rsp
sed -i "s/^.*ORACLE_HOSTNAME.*$/ORACLE_HOSTNAME=$HOSTNAME/" /data/etc/db_install.rsp
sed -i "s/^.*ORACLE_HOME.*$/ORACLE_HOME=/data/app/oracle/product/11.2.0/" /data/etc/db_install.rsp
sed -i "s/^.*ORACLE_BASE.*$/ORACLE_BASE=/data/app/oracle/" /data/etc/db_install.rsp
sed -i "s/^.*oracle.install.db.InstallEdition.*$/oracle.install.db.InstallEdition=EE/" /data/etc/db_install.rsp
sed -i "s/^.*oracle.install.db.isCustomInstall.*$/oracle.install.db.isCustomInstall=true/" /data/etc/db_install.rsp
sed -i "s/^.*oracle.install.db.DBA_GROUP.*$/oracle.install.db.DBA_GROUP=dba/" /data/etc/db_install.rsp
sed -i "s/^.*oracle.install.db.OPER_GROUP.*$/oracle.install.db.OPER_GROUP=dba/" /data/etc/db_install.rsp
#将 /data/* 文件更改所有者所属组
chown -R oracle:oinstall /data/*
#切换用户为 oracle(一般的,有关 oracle 数据库的操作,要使用oracle 为当前用户)
su - oracle
#安装
cd /data/database
./runInstaller -silent -responseFile /data/etc/db_install.rsp -ignorePrereq
#根据上图的提示,需要在 root 账号下执行两个脚本
su - root
/data/app/oracle/inventory/orainstRoot.sh sh
/data/app/oracle/product/11.2.0/root.sh
#配置监听
su - oracle
netca /silent /responsefile /data/etc/netca.rsp
#静默创建数据库,在 /data/etc/dbca.rsp 文件中,添加以下内容
echo "##oracle" >> /data/etc/dbca.rsp
sed -i "s/^.*RESPONSEFILE_VERSION.*$/RESPONSEFILE_VERSION = "11.2.0"/" /data/etc/dbca.rsp
sed -i "s/^.*OPERATION_TYPE.*$/OPERATION_TYPE = "createDatabase"/" /data/etc/dbca.rsp
sed -i "s/^.*GDBNAME.*$/GDBNAME = "orcl"/" /data/etc/dbca.rsp
sed -i "s/^.*SID.*$/SID = "orcl"/" /data/etc/dbca.rsp
sed -i "s/^.*SYSPASSWORD.*$/SYSPASSWORD = "oracle"/" /data/etc/dbca.rsp
sed -i "s/^.*SYSTEMPASSWORD.*$/SYSTEMPASSWORD = "oracle"/" /data/etc/dbca.rsp
sed -i "s/^.*SYSMANPASSWORD.*$/SYSMANPASSWORD = "oracle"/" /data/etc/dbca.rsp
sed -i "s/^.*DBSNMPPASSWORD.*$/DBSNMPPASSWORD = "oracle"/" /data/etc/dbca.rsp
sed -i "s/^.*DATAFILEDESTINATION.*$/DATAFILEDESTINATION =/data/app/oracle/oradata/" /data/etc/dbca.rsp
sed -i "s/^.*RECOVERYAREADESTINATION.*$/RECOVERYAREADESTINATION=/data/app/oracle/fast_recovery_area/" /data/etc/dbca.rsp
sed -i "s/^.*CHARACTERSET.*$/CHARACTERSET = "AL32UTF8"/" /data/etc/dbca.rsp
sed -i "s/^.*TOTALMEMORY.*$/TOTALMEMORY = "1638"/" /data/etc/dbca.rsp
#执行配置好的静默数据库(需要在oracle用户下执行)
su - oracle
dbca -silent -responseFile /data/etc/dbca.rsp
#执行完成后,查看 oracle 进程
if [ `ps -ef | grep ora_ | grep -v grep | wc -l` -gt 20 ]
then
echo "oracle 进程启动!" >> $message
fi
】