在没有图形界面的情况时,安装Oracle数据库软件和创建数据库就只能使用命令行的方式进行。
本文假设安装的前提条件都已经配置好。
一、静默安装数据库软件
1、准备参数文件
这个参数文件是用于安装软件使用的,里边配置了需要安装的版本、语言、ORACLE_HOME等信息。
这个文件的模版在database/response目录下的db_install.rsp,文件中的各个参数作用参考http://docs.oracle.com/cd/E11882_01/em.112/e12255/oui3_response_files.htm#OUICG183
#修改记录如下: oracle.install.option=INSTALL_DB_SWONLY#只安装软件 UNIX_GROUP_NAME=oinstall#安装的操作系统用户组 INVENTORY_LOCATION=/u01/app/oraInventory/#Inventory目录路径 SELECTED_LANGUAGES=en#安装语言 ORACLE_HOME=/u01/app/oracle/product/11.2.0/db#OracleHome路径 ORACLE_BASE=/u01/app/oracle/#OracleBase路径 oracle.install.db.InstallEdition=EE#数据库版本EE企业版 oracle.install.db.DBA_GROUP=dba#DBA组所属的操作系统用户组 oracle.install.db.OPER_GROUP=oinstall#OPER组所属的操作系统用户组 DECLINE_SECURITY_UPDATES=true#必须设置为true,否则需要修改其他信息 #创建Inventory目录 [oracle@rhel611.2.0.4_database]$cd/u01/app/ [oracle@rhel6app]$ls oracle [oracle@rhel6app]$mkdiroraInventory
2、静默安装
[oracle@rhel611.2.0.4_database]$./runInstaller-silent-force-responseFile/opt/soft/11g/11.2.0.4_database/response/install.rsp StartingOracleUniversalInstaller... CheckingTempspace:mustbegreaterthan120MB.Actual34496MBPassed Checkingswapspace:mustbegreaterthan150MB.Actual2047MBPassed PreparingtolaunchOracleUniversalInstallerfrom/tmp/OraInstall2016-12-21_05-02-49PM.Pleasewait...[oracle@rhel611.2.0.4_database]$[WARNING][INS-13014]Targetenvironmentdonotmeetsomeoptionalrequ irements.CAUSE:Someoftheoptionalprerequisitesarenotmet.Seelogsfordetails./tmp/OraInstall2016-12-21_05-02-49PM/installActions2016-12-21_05-02-49PM.log ACTION:IdentifythelistofFailedprerequisitechecksfromthelog:/tmp/OraInstall2016-12-21_05-02-49PM/installActions2016-12-21_05-02-49PM.log.Theneitherfromthelogfileorfrominstallationmanualf indtheappropriateconfigurationtomeettheprerequisitesandfixitmanually.Youcanfindthelogofthisinstallsessionat: /u01/app/oraInventory/logs/installActions2016-12-21_05-02-49PM.log #日志文件:/u01/app/oraInventory/logs/installActions2016-12-21_05-02-49PM.log [oracle@rhel611.2.0.4_database]$TheinstallationofOracleDatabase11gwassuccessful. Pleasecheck'/u01/app/oraInventory/logs/silentInstall2016-12-21_05-02-49PM.log'formoredetails. Asarootuser,executethefollowingscript(s): 1./u01/app/oraInventory/orainstRoot.sh 2./u01/app/oracle/product/11.2.0/db/root.sh SuccessfullySetupSoftware.
3、使用root执行脚本
[root@rhel6response]#/u01/app/oraInventory/orainstRoot.sh Changingpermissionsof/u01/app/oraInventory. Addingread,writepermissionsforgroup. Removingread,write,executepermissionsforworld. Changinggroupnameof/u01/app/oraInventorytooinstall. Theexecutionofthescriptiscomplete. [root@rhel6response]#/u01/app/oracle/product/11.2.0/db/root.sh Check/u01/app/oracle/product/11.2.0/db/install/root_rhel6_2016-12-21_17-12-23.logfortheoutputofrootscript [root@rhel6response]#cat/u01/app/oracle/product/11.2.0/db/install/root_rhel6_2016-12-21_17-12-23.log PerformingrootuseroperationforOracle11g Thefollowingenvironmentvariablesaresetas: ORACLE_OWNER=oracle ORACLE_HOME=/u01/app/oracle/product/11.2.0/db Copyingdbhometo/usr/local/bin... Copyingoraenvto/usr/local/bin... Copyingcoraenvto/usr/local/bin... Creating/etc/oratabfile... Entrieswillbeaddedtothe/etc/oratabfileasneededby DatabaseConfigurationAssistantwhenadatabaseiscreated Finishedrunninggenericpartofrootscript. Nowproduct-specificrootactionswillbeperformed. Finishedproduct-specificrootactions. Finishedproduct-specificrootactions. #测试sqlplus [oracle@rhel611.2.0.4_database]$sqlplus/assysdba sql*Plus:Release11.2.0.4.0ProductiononWedDec2117:16:192016 Copyright(c)1982,2013,Oracle.Allrightsreserved. Connectedtoanidleinstance. sql>
4、手工建库
官方文档:http://docs.oracle.com/cd/E11882_01/server.112/e25494/create.htm#CIAEJDBE
4.1 配置环境变量
exportORACLE_BASE=/u01/app/oracle exportORACLE_HOME=$ORACLE_BASE/product/11.2.0/db exportORACLE_SID=mydb exportPATH=$PATH:$ORACLE_HOME/bin #创建数据文件存储目录 [oracle@rhel6oracle]$cd$ORACLE_BASE [oracle@rhel6oracle]$mkdir-poradata/mydb
4.2 手工创建pfile
#此处只写必要的几个参数,生产上要按照实际情况写参数 [oracle@rhel6~]$catmydb.ora db_name=mydb control_files=/u01/app/oracle/oradata/mydb/control01.ctl,/u01/app/oracle/oradata/mydb/control02.ctl
4.3 启动实例到NOMOUNT状态
[oracle@rhel6~]$sqlplus/assysdba sql*Plus:Release11.2.0.4.0ProductiononWedDec2117:26:312016 Copyright(c)1982,Oracle.Allrightsreserved. Connectedtoanidleinstance. sql>startupnomountpfile=/home/oracle/mydb.ora; ORACLEinstancestarted. TotalSystemGlobalArea217157632bytes FixedSize 2251816bytes VariableSize 159384536bytes DatabaseBuffers 50331648bytes RedoBuffers 5189632bytes
4.4 创建spfile并重启到NOMOUNT状态
sql>createspfilefrompfile='/home/oracle/mydb.ora'; Filecreated. sql>shutdownimmediate; ORA-01507:databasenotmounted ORACLEinstanceshutdown. sql>startupnomount; ORACLEinstancestarted. TotalSystemGlobalArea217157632bytes FixedSize 2251816bytes VariableSize 159384536bytes DatabaseBuffers 50331648bytes RedoBuffers 5189632bytes
4.4 执行CREATE DATABASE语句创建数据库
sql>CREATEDATABASEmydb 2USERSYSIDENTIFIEDBYoracle 3USERSYSTEMIDENTIFIEDBYoracle 4LOGFILEGROUP1('/u01/app/oracle/oradata/redo01.log')SIZE100MBLOCKSIZE512,5GROUP2('/u01/app/oracle/oradata/redo02.log')SIZE100MBLOCKSIZE512,6GROUP3('/u01/app/oracle/oradata/redo03.log')SIZE100MBLOCKSIZE512 7MAXLOGFILES5 8MAXLOGMEMBERS5 9MAXLOGHISTORY1 10MAXDATAFILES100 11CHARACTERSETZHS16GBK 12NATIONALCHARACTERSETAL16UTF16 13EXTENTMANAGEMENTLOCAL 14DATAFILE'/u01/app/oracle/oradata/mydb/system01.dbf'SIZE325MREUSE 15SYSAUXDATAFILE'/u01/app/oracle/oradata/mydb/sysaux01.dbf'SIZE325MREUSE 16DEFAULTTABLESPACEusers 17DATAFILE'/u01/app/oracle/oradata/mydb/users01.dbf' 18SIZE500MREUSEAUTOEXTENDONMAXSIZEUNLIMITED 19DEFAULTTEMPORARYTABLESPACEtempts1 20TEMPFILE'/u01/app/oracle/oradata/mydb/temp01.dbf' 21SIZE20MREUSE 22UNDOTABLESPACEundotbs 23DATAFILE'/u01/app/oracle/oradata/mydb/undotbs01.dbf' 24SIZE200MREUSEAUTOEXTENDONMAXSIZEUNLIMITED; Databasecreated.
4.5 执行创建数据字典脚本
conn/assysdba @?/rdbms/admin/catalog.sql @?/rdbms/admin/catproc.sql @?/rdbms/admin/utlrp.sql connsystem/oracle @?/sqlplus/admin/pupbld.sql
5、创建监听并启动
[oracle@rhel6mydb]$cd$ORACLE_HOME/network/admin [oracle@rhel6admin]$ls samplesshrept.lst [oracle@rhel6admin]$vilistener.ora [oracle@rhel6admin]$catlistener.ora LISTENER= (DESCRIPTION= (ADDRESS_LIST= (ADDRESS=(PROTOCOL=tcp)(HOST=rhel6)(PORT=1521)) (ADDRESS=(PROTOCOL=ipc)(KEY=extproc)))) [oracle@rhel6admin]$lsnrctlstart LSNRCTLforLinux:Version11.2.0.4.0-Productionon21-DEC-201617:41:13 Copyright(c)1991,Oracle.Allrightsreserved. Starting/u01/app/oracle/product/11.2.0/db/bin/tnslsnr:pleasewait... TNSLSNRforLinux:Version11.2.0.4.0-Production Systemparameterfileis/u01/app/oracle/product/11.2.0/db/network/admin/listener.ora Logmessageswrittento/u01/app/oracle/diag/tnslsnr/rhel6/listener/alert/log.xml Listeningon:(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=rhel6)(PORT=1521))) Listeningon:(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=extproc))) Connectingto(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=rhel6)(PORT=1521))) STATUSoftheLISTENER ------------------------ AliasLISTENER VersionTNSLSNRforLinux:Version11.2.0.4.0-Production StartDate21-DEC-201617:41:15 Uptime0days0hr.0min.2sec TraceLeveloff SecurityON:LocalOSAuthentication SNMPOFF ListenerParameterFile/u01/app/oracle/product/11.2.0/db/network/admin/listener.ora ListenerLogFile/u01/app/oracle/diag/tnslsnr/rhel6/listener/alert/log.xml ListeningEndpointsSummary... (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=rhel6)(PORT=1521))) (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=extproc))) Thelistenersupportsnoservices Thecommandcompletedsuccessfully
6、测试
C:\Users\victor>sqlplussystem/oracle@192.168.56.3/mydb sql*Plus:Release12.1.0.1.0Productionon星期三12月2117:51:052016 Copyright(c)1982,Oracle.Allrightsreserved. 连接到: OracleDatabase11gEnterpriseEditionRelease11.2.0.4.0-64bitProduction WiththePartitioning,OLAP,DataMiningandRealApplicationTestingoptions sql>selectopen_modefromv$database; OPEN_MODE -------------------- READWRITE原文链接:https://www.f2er.com/oracle/211190.html