#!/bin/bash
for name in /etc/yum.repos.d/*.repo; do
mv $name $name.bak
done
echo -e "\033[32m开始配置本地YUM源\033[0m"
cat <<EOF >/etc/yum.repos.d/local.repo
[RHEL]
name=RHEL
baseurl=https://yum.oracle.com/repo/OracleLinux/OL7/latest/x86_64/
enabled=1
gpgcheck=0
EOF
chmod -R 755 /etc/yum.repos.d/local.repo
echo -e "\033[32m本地YUM源配置完成\033[0m"
yum clean all
RPM=oracle-rdbms-server-11gR2
PACKAGE=`rpm -qa | grep $RPM`
if [ `rpm -qa | grep $RPM | wc -l` -ne 0 ];then
echo -e "\033[32mThe package already installed and latest version\033[0m"
else
echo "The package $RPM install"
yum install -y $RPM*
echo -e "\033[32mThe oracle-rdbms-server-11gR2-preinstall installation completed\033[0m"
fi
cat <<EOF >>/etc/sysctl.conf
fs.file-max = 6815744
kernel.sem = 250 32000 100 128
kernel.shmmni = 4096
kernel.shmall = 1073741824
kernel.shmmax = 4398046511104
kernel.panic_on_oops = 1
net.core.rmem_default = 262144
net.core.rmem_max = 4194304
net.core.wmem_default = 262144
net.core.wmem_max = 1048576
net.ipv4.conf.all.rp_filter = 2
net.ipv4.conf.default.rp_filter = 2
fs.aio-max-nr = 1048576
net.ipv4.ip_local_port_range = 9000 65500
EOF
cat <<EOF >>/etc/security/limits.conf
oracle soft nofile 1024
oracle hard nofile 65536
oracle soft nproc 16384
oracle hard nproc 16384
oracle soft stack 10240
oracle hard stack 32768
oracle hard memlock 134217728
oracle soft memlock 134217728
EOF
mkdir -p /home/app/oracle
chown -R oracle:oinstall /home/app/oracle
chmod -R 755 /home/app/oracle
mkdir -p /home/app/oracle/oradata
chown -R oracle:oinstall /home/app/oracle/oradata
chmod -R 755 /home/app/oracle/oradata
mkdir -p /home/app/oraInventory
chown -R oracle:oinstall /home/app/oraInventory
chmod -R 755 /home/app/oraInventory
mkdir -p /home/app/oracle/product/11.2.0/dbhome_1
chown -R oracle:oinstall /home/app/oracle/product/11.2.0/dbhome_1
chmod -R 755 /home/app/oracle/product/11.2.0/dbhome_1
echo -e "\033[32m数据库安装所需目录创建完成 \033[0m"
cat <<EOF >/home/oracle/.bash_profile
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
PATH=\$PATH:\$HOME/bin
export PATH
export ORACLE_BASE=/home/app/oracle
export ORACLE_HOME=\$ORACLE_BASE/product/11.2.0/dbhome_1
export ORACLE_SID=orcl
export LD_LIBRARY_PATH=\$ORACLE_HOME/lib
export NLS_LANG=AMERICAN_AMERICA.AL32UTF8
export LANG=C
export PATH=\$PATH:\$ORACLE_HOME/bin:\$HOME/bin
EOF
echo -e "\033[32m查看oracle环境变量 \033[0m"
cat /home/oracle/.bash_profile
source /home/oracle/.bash_profile
echo -e "\033[32m查看ORACLE_BASE、ORACLE_HOME环境变量 \033[0m"
echo "ORACLE_BASE:$ORACLE_BASE"
echo "ORACLE_HOME:$ORACLE_HOME"
if [ -d /home/database/ ]; then
du -sh /home/database
else
cd /home/
unzip linux_64_112010_database_1of2.zip
unzip linux_64_112010_database_2of2.zip
fi
echo -e "\033[32m数据库oracle安装包解压完成 \033[0m"
echo "1" | passwd --stdin oracle &>/dev/null
echo "oracle用户默认密码:1,为了安全请及时修改"
echo -e "\033[32m数据库oracle11.2安装环境配置完成 \033[0m"
sleep 5
echo -e "\033[32m数据库进行静默安装配置\033[0m"
cat <<EOF >/home/database/response/db_install.rsp
oracle.install.responseFileVersion=/oracle/install/rspfmt_dbinstall_response_schema_v11_2_0
oracle.install.option=INSTALL_DB_AND_CONFIG
ORACLE_HOSTNAME=localhost.localdomain
UNIX_GROUP_NAME=oinstall
INVENTORY_LOCATION=/home/app/oraInventory
SELECTED_LANGUAGES=en,zh_CN
ORACLE_HOME=/home/app/oracle/product/11.2.0/dbhome_1
ORACLE_BASE=/home/app/oracle
oracle.install.db.InstallEdition=EE
oracle.install.db.isCustomInstall=false
oracle.install.db.customComponents=oracle.server:11.2.0.1.0,oracle.sysman.ccr:10.2.7.0.0,oracle.xdk:11.2.0.1.0,oracle.rdbms.oci:11.2.0.1.0,oracle.network:11.2.0.1.0,oracle.network.listener:11.2.0.1.0,oracle.rdbms:11.2.0.1.0,oracle.options:11.2.0.1.0,oracle.rdbms.partitioning:11.2.0.1.0,oracle.oraolap:11.2.0.1.0,oracle.rdbms.dm:11.2.0.1.0,oracle.rdbms.dv:11.2.0.1.0,orcle.rdbms.lbac:11.2.0.1.0,oracle.rdbms.rat:11.2.0.1.0
oracle.install.db.DBA_GROUP=dba
oracle.install.db.OPER_GROUP=oinstall
oracle.install.db.CLUSTER_NODES=
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.characterSet=AL32UTF8
oracle.install.db.config.starterdb.memoryOption=true
oracle.install.db.config.starterdb.memoryLimit=512
oracle.install.db.config.starterdb.installExampleSchemas=false
oracle.install.db.config.starterdb.enableSecuritySettings=true
oracle.install.db.config.starterdb.password.ALL=oracle
oracle.install.db.config.starterdb.password.SYS=
oracle.install.db.config.starterdb.password.SYSTEM=
oracle.install.db.config.starterdb.password.SYSMAN=
oracle.install.db.config.starterdb.password.DBSNMP=
oracle.install.db.config.starterdb.control=DB_CONTROL
oracle.install.db.config.starterdb.gridcontrol.gridControlServiceURL=
oracle.install.db.config.starterdb.dbcontrol.enableEmailNotification=false
oracle.install.db.config.starterdb.dbcontrol.emailAddress=
oracle.install.db.config.starterdb.dbcontrol.SMTPServer=
oracle.install.db.config.starterdb.automatedBackup.enable=false
oracle.install.db.config.starterdb.automatedBackup.osuid=
oracle.install.db.config.starterdb.automatedBackup.ospwd=
oracle.install.db.config.starterdb.storageType=FILE_SYSTEM_STORAGE
oracle.install.db.config.starterdb.fileSystemStorage.dataLocation=/home/app/oracle/oradata
oracle.install.db.config.starterdb.fileSystemStorage.recoveryLocation=/home/app/oracle/flash_recovery_area
oracle.install.db.config.asm.diskGroup=
oracle.install.db.config.asm.ASMSNMPPassword=
MYORACLESUPPORT_USERNAME=
MYORACLESUPPORT_PASSWORD=
SECURITY_UPDATES_VIA_MYORACLESUPPORT=
DECLINE_SECURITY_UPDATES=true
PROXY_HOST=
PROXY_PORT=
PROXY_USER=
PROXY_PWD=
EOF
echo -e "\033[32m数据库进行静默安装配置完成\033[0m"
echo -e "\033[32m用oracle用户登录系统\033[0m"
echo -e "\033[32m在终端执行./runInstaller -silent -ignorePrereq -responseFile /home/database/response/db_install.rsp\033[0m"
export LANG=C