Oracle 11g 静默安装
Oracle 11g 静默安装
在有些特殊场合,比如堡垒机环境下,不方便开启图形界面,或者为了实现安装自动化,推荐使用静默方式快速安装配置oracle数据库。
1.安装环境
Centos7.9+Oracle 11.2.0.4
注意:开始静默安装前,默认已经完成了OS层面的设置部署。
本次规划数据库软件安装目录:/u01/app/oracle
本次规划数据库存储目录:/oradata
2.处理应答文件
2.1 先备份原应答文件
cd database/response
mkdir rspbak
cp *.rsp ./rspbak
2.2 删除应答文件中的注释行(以#开头)
#vi编辑替换或者直接使用sed命令快速替换
$ sed -i 's/^#.*$//g' *.rsp
2.3 刪除沒有內容的空行(^$)
#vi编辑替换或者直接使用sed命令快速替换
$ sed -i '/^$/d' *.rsp
3.静默安装数据库软件
3.1 编辑db_install.rsp文件
$ vi /media/database/response/db_install.rsp oracle.install.responseFileVersion=/oracle/install/rspfmt_dbinstall_response_schema_v11_2_0 oracle.install.option=INSTALL_DB_SWONLY ORACLE_HOSTNAME=Dbsrv UNIX_GROUP_NAME=oinstall INVENTORY_LOCATION=/u01/app/oraInventory SELECTED_LANGUAGES=en ORACLE_HOME=/u01/app/oracle/product/11.2.0/dbhome_1 ORACLE_BASE=/u01/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=oinstall oracle.install.db.CLUSTER_NODES= oracle.install.db.isRACOneInstall= oracle.install.db.racOneServiceName= oracle.install.db.config.starterdb.type= oracle.install.db.config.starterdb.globalDBName= oracle.install.db.config.starterdb.SID= oracle.install.db.config.starterdb.characterSet=AL32UTF8 oracle.install.db.config.starterdb.memoryOption=true oracle.install.db.config.starterdb.memoryLimit= oracle.install.db.config.starterdb.installExampleSchemas=false oracle.install.db.config.starterdb.enableSecuritySettings=true oracle.install.db.config.starterdb.password.ALL= 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= oracle.install.db.config.starterdb.fileSystemStorage.dataLocation= oracle.install.db.config.starterdb.fileSystemStorage.recoveryLocation= 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= oracle.installer.autoupdates.downloadUpdatesLoc= AUTOUPDATES_MYORACLESUPPORT_USERNAME= AUTOUPDATES_MYORACLESUPPORT_PASSWORD=
注意:标红的行为需要修改的行。
3.2 静默安装软件
$ cd /media/database/
$ ./runInstaller -silent -force -noconfig -ignoreSysPrereqs -showProgress -responseFile /media/database/response/db_install.rsp
安装快结束的时候,会提示使用root用户执行脚本,例如:
/u01/app/oracle/product/11.2.0/dbhome_1/root.sh
4.静默配置监听
4.1 编辑netca.rsp文件
$ vi /media/database/response/netca.rsp [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"}
注意:如果规划的监听端口是默认值的话,那么就不需要修改该监听响应文件。
4.2 静默创建监听
$ORACLE_HOME/bin/netca -silent -responsefile /media/database/response/netca.rsp
5. 静默dbca建库
5.1 编辑dbca.rsp文件
$ vi /media/database/response/dbca.rsp [GENERAL] RESPONSEFILE_VERSION = "11.2.0" OPERATION_TYPE = "createDatabase" [CREATEDATABASE] gdbName = "myorcl" sid = "myorcl" templateName = "General_Purpose.dbc" characterSet = "ZHS16GBK" memoryPercentage = "60" emConfiguration = "LOCAL" sysPassword = "oracle" systemPassword = "oracle" dbsnmpPassword = "oracle" sysmanPassword = "oracle" [createTemplateFromDB] SOURCEDB = "myhost:1521:orcl" SYSDBAUSERNAME = "system" TEMPLATENAME = "My Copy TEMPLATE" [createCloneTemplate] SOURCEDB = "orcl" TEMPLATENAME = "My Clone TEMPLATE" [DELETEDATABASE] SOURCEDB = "orcl" [generateScripts] TEMPLATENAME = "New Database" GDBNAME = "orcl11.us.oracle.com" [CONFIGUREDATABASE] [ADDINSTANCE] DB_UNIQUE_NAME = "orcl11g.us.oracle.com" NODELIST= SYSDBAUSERNAME = "sys" [DELETEINSTANCE] DB_UNIQUE_NAME = "orcl11g.us.oracle.com" INSTANCENAME = "orcl11g" SYSDBAUSERNAME = "sys"
注意:标红的行为需要修改的行。
5.2 修改引用的通用模板General_Purpose.dbc
$ cd $ORACLE_HOME/assistants/dbca/templates/
$ cp General_Purpose.dbc General_Purpose.dbc.bak
--vi替换{ORACLE_BASE}/oradata为新的存储路径/oradata
$ vi General_Purpose.dbc
:%s#{ORACLE_BASE}/oradata#/oradata#g
5.3 静默创建数据库
$ORACLE_HOME/bin/dbca -silent -responseFile /media/database/response/dbca.rsp Enter SYS user password: Enter SYSTEM user password: Copying database files 1% complete 3% complete 11% complete 18% complete 26% complete 37% complete Creating and starting Oracle instance 40% complete 45% complete 50% complete 55% complete 56% complete 60% complete 62% complete Completing Database Creation 66% complete 70% complete 73% complete 85% complete 96% complete 100% complete Look at the log file "/u01/app/oracle/cfgtoollogs/dbca/myorcl/myorcl.log" for further details.
数据库静默安装完成。