阿里云 ecs云主机 静默安装oracle11g

1 hosts主机配置
echo "neiwangip 主机名" >> /etc/hosts

2 配置英文环境变量
echo "export LANG=en_US.UTF8" >> ~/.bash_profile

export NLS_LANG=SIMPLIFIED CHINESE_CHINA.ZHS16GBK

#SWAP 交换空间
#2G-:*2 2-8G:*1 8G-16G:*0.5 16G+:4~8G

#dd if=/dev/zero of=/home/swap bs=1M count=4200
#mkswap /home/swap
#swapon /home/swap

3 创建用户与目录

/usr/sbin/groupadd -g 60001 oinstall
/usr/sbin/groupadd -g 60002 dba
/usr/sbin/groupadd -g 60003 oper
useradd -u 61001 -g oinstall -G dba,oper oracle

mkdir /oracle
mkdir /oradata
mkdir -p /oracle/app/oracle/product/11.2.0/db_1
mkdir -p /oracle/app/oraInventory
chown -R oracle:oinstall /oracle
chown -R oracle:oinstall /oradata
chmod -R 775 /oracle
chmod -R 775 /oradata

4 装依赖
yum -y install autoconf
yum -y install automake
yum -y install binutils
yum -y install binutils-devel
yum -y install bison
yum -y install cpp
yum -y install dos2unix
yum -y install ftp
yum -y install gcc
yum -y install gcc-c++
yum -y install lrzsz
yum -y install python-devel
yum -y install compat-db*
yum -y install compat-gcc-34
yum -y install compat-gcc-34-c++
yum -y install compat-libcap1
yum -y install compat-libstdc++-33
yum -y install compat-libstdc++-33.i686
yum -y install glibc-*
yum -y install glibc-*.i686
yum -y install libXpm-*.i686
yum -y install libXp.so.6
yum -y install libXt.so.6
yum -y install libXtst.so.6
yum -y install libXext
yum -y install libXext.i686
yum -y install libXtst
yum -y install libXtst.i686
yum -y install libX11
yum -y install libX11.i686
yum -y install libXau
yum -y install libXau.i686
yum -y install libxcb
yum -y install libxcb.i686
yum -y install libXi
yum -y install libXi.i686
yum -y install libgcc_s.so.1
yum -y install libstdc++.i686
yum -y install libstdc++-devel
yum -y install libstdc++-devel.i686
yum -y install libaio
yum -y install libaio.i686
yum -y install libaio-devel
yum -y install libaio-devel.i686
yum -y install ksh
yum -y install libXp
yum -y install libaio-devel
yum -y install numactl
yum -y install numactl-devel
yum -y install make -y
yum -y install sysstat -y
yum -y install unixODBC
yum -y install unixODBC-devel
yum -y install elfutils-libelf-devel-0.97
yum -y install elfutils-libelf-devel
yum -y install redhat-lsb-core
yum -y install unzip

5 修改操作系统相关参数

cat /etc/security/limits.conf


root soft nproc 16384
root hard nproc 16384
root soft nofile 16384
root hard nofile 65536
root soft stack 10240
root hard stack 32768
#ORACLE SETTING
oracle soft nproc 16384
oracle hard nproc 16384
oracle soft nofile 16384
oracle hard nofile 65536
oracle soft stack 10240
oracle hard stack 32768

6 修改内核参数 
cat /etc/sysctl.conf

fs.aio-max-nr = 1048576
fs.file-max = 6553600
kernel.shmall = 2147483648
kernel.shmmax = 34359738368   
kernel.shmmni = 4096
kernel.sem = 2010 285420 100 142
net.ipv4.ip_local_port_range = 1024 65000
net.core.rmem_default = 262144
net.core.rmem_max = 4194304
net.core.wmem_default = 262144
net.core.wmem_max = 1048586

vm.swappiness=10

sysctl -p

7 配置安全

--防火墙

systemctl status firewalld.service

systemctl stop firewalld.service

systemctl disable firewalld.service

--SELINUX(阿里云默认关闭)
vi /etc/selinux/config SELINUX=disabled
setenforce 0

8 设置oracle环境变量

su - oracle
vi .bash_profile


PS1="[`whoami`@`hostname`:"'$PWD]$'
export PS1
export TMP=/tmp
export LANG=en_US
export TMPDIR=$TMP
export ORACLE_UNQNAME=orcl ORACLE_SID=orcl;
export ORACLE_SID ORACLE_BASE=/oracle/app/oracle;
export ORACLE_BASE ORACLE_HOME=$ORACLE_BASE/product/11.2.0/db_1;
export ORACLE_HOME ORACLE_TERM=xterm;
export ORACLE_TERM NLS_DATE_FORMAT="yyyy-mm-dd HH24:MI:SS";
export NLS_DATE_FORMAT NLS_LANG="SIMPLIFIED CHINESE_CHINA.ZHS16GBK";
export NLS_LANG PATH=.:$PATH:$HOME/.local/bin:$HOME/bin:$ORACLE_HOME/bin;
export PATH THREADS_FLAG=native;
export THREADS_FLAG
umask=022

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

env | grep ORACLE 检查环境变量

9 静默安装 db_install.rsp 

11g模板  #(AL32UTF8)

cat db_install.rsp |grep -Ev "^#|^$"   

-------------------------------------------------------------------------

oracle.install.responseFileVersion=/oracle/install/rspfmt_dbinstall_response_schema_v11_2_0
oracle.install.option=INSTALL_DB_AND_CONFIG
ORACLE_HOSTNAME=ecs-af6a-0005.novalocal
UNIX_GROUP_NAME=oinstall
INVENTORY_LOCATION=/oracle/app/oraInventory
SELECTED_LANGUAGES=en
ORACLE_HOME=/oracle/app/oracle/product/11.2.0/db_1
ORACLE_BASE=/oracle/app/oracle
oracle.install.db.InstallEdition=EE
oracle.install.db.EEOptionsSelection=false
oracle.install.db.optionalComponents=oracle.rdbms.partitioning:11.2.0.4.0,oracle.oraolap:11.2.0.4.0,oracle.rdbms.dm:11.2.0.4.0,oracle.rdbms.dv:11.2.0.4.0,oracle.rdbms.lbac:11.2.0.4.0,oracle.rdbms.rat:11.2.0.4.0
oracle.install.db.DBA_GROUP=dba
oracle.install.db.OPER_GROUP=oper
oracle.install.db.CLUSTER_NODES=
oracle.install.db.isRACOneInstall=
oracle.install.db.racOneServiceName=
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=ZHS16GBK   
oracle.install.db.config.starterdb.memoryOption=true
oracle.install.db.config.starterdb.memoryLimit=400
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.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=/oracle/app/oracle/oradata
oracle.install.db.config.starterdb.fileSystemStorage.recoveryLocation=/oracle/app/oracle/fast_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=
PROXY_REALM=
COLLECTOR_SUPPORTHUB_URL=
oracle.installer.autoupdates.option=SKIP_UPDATES
oracle.installer.autoupdates.downloadUpdatesLoc=
AUTOUPDATES_MYORACLESUPPORT_USERNAME=
AUTOUPDATES_MYORACLESUPPORT_PASSWORD=

------------------------------------------------------------------------

su - root
vi /etc/oraInst.loc inventory=/oracle/app/oraInventory inst_group=oinstall
chown oracle:oinstall /etc/oraInst.loc   (免除1 orainstRoot.sh)

安装命令

./runInstaller -silent -ignoreSysPrereqs -showProgress -responseFile /home/oracle/db_install.rsp

其中-silent指的是静默安装,-ignorePrereq忽略prerequisite的检查结果,showProgress显示进度,responseFile是种子文件

最后,需root用户手动执行以下两个文件:

    1. /u01/app/oracle/oraInventory/orainstRoot.sh

    2. /u01/app/oracle/product/11.2.0.1/db_1/root.sh

    当然,也可查看/u01/app/oracle/oraInventory/logs/installActions2015-04-01_10-13-42PM.log了解具体的安装信息。

10 dbca创建 用最少参数建了一个库

dbca -silent -createDatabase -templateName General_Purpose.dbc -gdbName orcl -sysPassword oracle -systemPassword oracle

11 监听配置模板

[GENERAL]
RESPONSEFILE_VERSION="11.2"
CREATE_TYPE="CUSTOM"
[oracle.net.ca]
INSTALLED_COMPONENTS={"server","net8","javavm"}
INSTALL_TYPE=""typical""
LISTENER_NUMBER=1
LISTENER_NAMES={"LISTENER"}
LISTENER_PROTOCOLS={"TCP;1521"}
LISTENER_START=""LISTENER""
NAMING_METHODS={"TNSNAMES","ONAMES","HOSTNAME"}
NSN_NUMBER=1
NSN_NAMES={"EXTPROC_CONNECTION_DATA"}
NSN_SERVICE={"PLSExtProc"}
NSN_PROTOCOLS={"TCP;HOSTNAME;1521"}

安装命令

netca -silent -responsefile /oracle/response/netca.rsp

11 后期调整

180天密码过期 alter profile default limit PASSWORD_LIFE_TIME unlimited;

关闭审计 alter system set audit_trail=none scope=spfile;

相关参数修改

 -------------------------------------------------------------------------------

遇到的问题

1 db_install模板11g和12c 不同版本必要的参数不一致 导致安装失败

2 dbca模板也是一样不同版本建立不一致导致失败,导致实例出现问题,没有控制文件,启动也启动不起来,解决方法用最小化dbca重新安装重建

3 ORA-00205: error in identifying control file, check alert log for more info  控制文件损坏错误

4 启动数据库时遇到ORA-01102: cannot mount database in EXCLUSIVE mode

      a、 Oracle的共享内存段或信号量没有被释放;

      b、 Oracle的后台进程(如SMON、PMON、DBWn等)没有被关闭;

      c、 用于锁内存的文件lk<sid>和sgadef<sid>.dbf文件没有被删除。 关闭数据库实例,删除/u01/app/oracle/product/10.2.0/db_1/dbs/lkEPPS文件

静默安装Oracle11gR2 [FATAL] [INS-32015]报错   模板问题版本不同  [FATAL] [INS-32015] The location specified for Oracle home Location is invalid.

建议

1 如果条件允许,oracle安装尽量使用图形化界面操作,静默安装虽然效率快方便部署,但是出现问题太多不好解决,图形化安装不容易出现问题

16G 内存修改内核参数 40-60%
cat /etc/sysctl.conf

fs.aio-max-nr = 1048576
fs.file-max = 6553600
kernel.shmall = 644245094
kernel.shmmax =  10307921510
kernel.shmmni = 4096
kernel.sem = 2010 285420 100 142
net.ipv4.ip_local_port_range = 1024 65000
net.core.rmem_default = 262144
net.core.rmem_max = 4194304
net.core.wmem_default = 262144
net.core.wmem_max = 1048586

show parameter process
show parameter sessions
show parameter open_cursors
show parameter session_cached_cursors
alter system set processes=3000 scope=spfile;
alter system set open_cursors=2000 scope=spfile;
alter system set session_cached_cursors=300 scope=spfile;
alter system set db_files=8192 scope=spfile;

原文地址:https://www.cnblogs.com/daizhengyang/p/10100591.html