环境:RHEL 6.5 + Oracle 11.2.0.4
说明:
- 本文默认安装软件前的步骤已经设置完毕 如果没有设置,可参考 《》1,2,3,4步进行设置。
- 静默安装只是不调用图形界面安装,静默安装数据库依然是调用的dbca,并不是手工建库。 手工建库可参考:
- 本次演示安装的规划目录 本次规划数据库软件安装目录:/u02/app/oracle 本次规划数据库存储目录:/u02/oradata
1. 初步处理应答文件
1.1 先备份原应答文件
cd database/responsemkdir rspbakcp *.rsp ./rspbak
1.2 删除应答文件中的注释行(以#开头)
#vi编辑替换或者直接使用sed命令快速替换$ sed -i 's/^#.*$//g' *.rsp
1.3 刪除沒有內容的空行(^$)
#vi编辑替换或者直接使用sed命令快速替换$ sed -i '/^$/d' *.rsp
2. 静默安装软件
2.1 编辑db_install.rsp文件
$ more /u02/soft/database/response/db_install.rsp
oracle.install.responseFileVersion=/oracle/install/rspfmt_dbinstall_response_schema_v11_2_0oracle.install.option=INSTALL_DB_SWONLYORACLE_HOSTNAME=JY-DB01UNIX_GROUP_NAME=oinstallINVENTORY_LOCATION=/u02/app/oraInventorySELECTED_LANGUAGES=enORACLE_HOME=/u02/app/oracle/product/11.2.0/dbhome_1ORACLE_BASE=/u02/app/oracleoracle.install.db.InstallEdition=EEoracle.install.db.EEOptionsSelection=falseoracle.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.0oracle.install.db.DBA_GROUP=dbaoracle.install.db.OPER_GROUP=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=AL32UTF8oracle.install.db.config.starterdb.memoryOption=trueoracle.install.db.config.starterdb.memoryLimit=oracle.install.db.config.starterdb.installExampleSchemas=falseoracle.install.db.config.starterdb.enableSecuritySettings=trueoracle.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_CONTROLoracle.install.db.config.starterdb.gridcontrol.gridControlServiceURL=oracle.install.db.config.starterdb.automatedBackup.enable=falseoracle.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=truePROXY_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=
2.2 静默安装软件
$ cd /u02/soft/database/$ ./runInstaller -silent -force -noconfig -responseFile /u02/soft/database/response/db_install.rsp
安装成功应有的输出提示:
Starting Oracle Universal Installer...Checking Temp space: must be greater than 120 MB. Actual 21313 MB PassedChecking swap space: must be greater than 150 MB. Actual 4015 MB PassedPreparing to launch Oracle Universal Installer from /tmp/OraInstall2015-11-30_11-40-10AM. Please wait ...[oracle@JY-DB01 database]$ [WARNING] [INS-13014] Target environment do not meet some optional requirements. CAUSE: Some of the optional prerequisites are not met. See logs for details. /u01/app/oraInventory/logs/installActions2015-11-30_11-40-10AM.log ACTION: Identify the list of failed prerequisite checks from the log: /u01/app/oraInventory/logs/installActions2015-11-30_11-40-10AM.log. Then either from the log file or from installation manual find the appropriate configuration to meet the prerequisites and fix it manually.You can find the log of this install session at: /u01/app/oraInventory/logs/installActions2015-11-30_11-40-10AM.logThe installation of Oracle Database 11g was successful.Please check '/u01/app/oraInventory/logs/silentInstall2015-11-30_11-40-10AM.log' for more details.As a root user, execute the following script(s): 1. /u02/app/oracle/product/11.2.0/dbhome_1/root.shSuccessfully Setup Software.
2.3 按提示root用户执行脚本
# /u02/app/oracle/product/11.2.0/dbhome_1/root.shCheck /u02/app/oracle/product/11.2.0/dbhome_1/install/root_JY-DB01_2015-11-30_11-48-22.log for the output of root script
注意:如果机器之前没有安装其他数据库,这里就应该是提示执行两个脚本,按具体提示执行即可。
2.4 配置环境变量
vi /home/oracle/jingyu
export ORACLE_SID=jingyuexport ORACLE_BASE=/u02/app/oracleexport ORACLE_HOME=/u02/app/oracle/product/11.2.0/dbhome_1export NLS_LANG="american_america.ZHS16GBK"export NLS_DATE_FORMAT="YYYY-MM-DD HH24:Mi:SS"export LD_LIBRARY_PATH=$ORACLE_HOME/libexport PATH=$ORACLE_HOME/bin:/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/home/oracle/binecho "--------------------------"echo "ORACLE_BASE"=$ORACLE_BASEecho "ORACLE_HOME"=$ORACLE_HOMEecho "ORACLE_SID"=$ORACLE_SIDecho "--------------------------"echo "NLS_LANG"=$NLS_LANGecho "NLS_DATE_FORMAT"=$NLS_DATE_FORMAT echo "LD_LIBRARY_PATH"=$LD_LIBRARY_PATH echo "PATH"=$PATHecho "--------------------------"
执行source jingyu即可切换到新数据库环境变量
$ source jingyu --------------------------ORACLE_BASE=/u02/app/oracleORACLE_HOME=/u02/app/oracle/product/11.2.0/dbhome_1ORACLE_SID=jingyu--------------------------NLS_LANG=american_america.ZHS16GBKNLS_DATE_FORMAT=YYYY-MM-DD HH24:Mi:SSLD_LIBRARY_PATH=/u02/app/oracle/product/11.2.0/dbhome_1/libPATH=/u02/app/oracle/product/11.2.0/dbhome_1/bin:/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/home/oracle/bin--------------------------
注意:如果需要默认用户变量,则oracle用户配置~/.bash_profile文件。
3. 静默安装监听
3.1 编辑netca.rsp文件
$ more /u02/soft/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=1LISTENER_NAMES={"LISTENER"}LISTENER_PROTOCOLS={"TCP;1521"}LISTENER_START=""LISTENER""NAMING_METHODS={"TNSNAMES","ONAMES","HOSTNAME"}NSN_NUMBER=1NSN_NAMES={"EXTPROC_CONNECTION_DATA"}NSN_SERVICE={"PLSExtProc"}NSN_PROTOCOLS={"TCP;HOSTNAME;1521"}
3.2 静默创建监听
$ORACLE_HOME/bin/netca /silent /responsefile /u02/soft/database/response/netca.rsp
Parsing command line arguments: Parameter "silent" = true Parameter "responsefile" = /u02/soft/database/response/netca.rspDone parsing command line arguments.Oracle Net Services Configuration:Profile configuration complete.Oracle Net Listener Startup: Running Listener Control: /u02/app/oracle/product/11.2.0/dbhome_1/bin/lsnrctl start LISTENER Listener Control complete. Listener started successfully.Listener configuration complete.Oracle Net Services configuration successful. The exit code is 0
4. 静默dbca建库
4.1 编辑dbca.rsp文件
$ more /u02/soft/database/response/dbca.rsp
[GENERAL]RESPONSEFILE_VERSION = "11.2.0"OPERATION_TYPE = "createDatabase"[CREATEDATABASE]GDBNAME = "jingyu"SID = "jingyu"TEMPLATENAME = "General_Purpose.dbc"[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"
上面就可以成功建库,但绝大多数情况[CREATEDATABASE]下还需要指定一些其他参数,
因为默认的可能不符合实际要求,尤其是你创建的数据库字符集必须要按你的设计需求显示指定:[CREATEDATABASE]gdbName = "jingyu"sid = "jingyu"templateName = "General_Purpose.dbc"characterSet = "ZHS16GBK" memoryPercentage = "60"emConfiguration = "LOCAL"sysPassword = "oracle"systemPassword = "oracle"dbsnmpPassword = "oracle"sysmanPassword = "oracle"
修改引用的通用模板General_Purpose.dbc
--本次规划数据库存储目录:/u02/oradata# mkdir -p /u02/oradata && chown oracle:oinstall /u02/oradata--修改模板$ cd $ORACLE_HOME/assistants/dbca/templates/$ cp General_Purpose.dbc General_Purpose.dbc.bak--vi替换{ORACLE_BASE}/oradata为新的存储路径/u02/oradata$ vi General_Purpose.dbc:%s#{ORACLE_BASE}/oradata#/u02/oradata#g --或者sed直接快速替换sed -i 's#{ORACLE_BASE}/oradata#/u02/oradata#g' General_Purpose.dbc
4.2 静默创建数据库
$ORACLE_HOME/bin/dbca -silent -responseFile /u02/soft/database/response/dbca.rsp
Enter SYS user password: Enter SYSTEM user password: Copying database files1% complete3% complete11% complete18% complete26% complete37% completeCreating and starting Oracle instance40% complete45% complete50% complete55% complete56% complete60% complete62% completeCompleting Database Creation66% complete70% complete73% complete85% complete96% complete100% completeLook at the log file "/u02/app/oracle/cfgtoollogs/dbca/jingyu/jingyu.log" for further details.
注意:如果已经在响应文件中配置sys和system密码,上面就不会提示你输入密码了。
4.3 静默删除数据库
$ dbca -silent -deleteDatabase -sourceDB jingyu -sysDBAUserName sys -sysDBAPassword oracle
Connecting to database4% complete9% complete14% complete19% complete23% complete28% complete47% completeUpdating network configuration files48% complete52% completeDeleting instance and datafiles76% complete100% completeLook at the log file "/u02/app/oracle/cfgtoollogs/dbca/jingyu.log" for further details.
至此,Oracle数据库静默安装相关内容已经完成。