6 数据库的启动与关闭.ppt
数据库的数据库的启动与关闭启动与关闭数据库的体系结构DatabaseInstanceSGARedo logbufferData buffercacheShared poolData dict.cacheLibrarycache PMON DBW0SMON LGWRCKPTOthersUserprocessServerprocessPGAControl filesData files Redo logfilesArchived log filesParameterfilePasswordfile TheInitializationParameterTheInitializationParameterFileFileControl_files参数与SGA设置有关的参数initU15.oraSQL CONNECT/AS SYSDBASQL STARTUP PFILE=/DISK1/initU15.oraInstanceSGARedo logbufferData buffercacheShared poolData dict.cacheLibrarycache PMON DBWRSMON LGWRCKPTARCHUNIX和NT下的定位及默认名DefaultNameinitSID.oratextfileUNIX$ORACLE_HOME/dbsNT%ORACLE_HOMEora81databaseandPointto%ORACLE_HOMEadminsidpfile控制文件控制文件:二进制文件,存储有关 数据库状态的信息。包括:数据库名表空间信息所有数据文件的名字和位置所有日志文件的名字和位置当前的日志序列号检查点信息等注意注意:不能用操作系统命令更改控制文件 内容,只能用ORACLE命令!Initialization Parameter FileslEntries are specific to the instance being startedlTwo types of parameters:lExplicit:Having an entry in the filelImplicit:No entry within the file,but assuming the Oracle default valueslMultiple initialization parameter files can existlChanges to entries in the file take effect based on the type of initialization parameter file used:lStatic parameter file,PFILE lPersistent server parameter file,SPFILEPFILEinitSID.oralText filelModified with an operating system editorlModifications made manuallylChanges take effect on the next start uplOnly opened during instance start uplDefault location is$ORACLE_HOME/dbs$ORACLE_HOME/DATABASECreating a PFILElCreated from a sample init.ora filelSample installed by the Oracle Universal InstallerlCopy sample using operating system copy commandlUniquely identified by database SIDlModify the initSID.oralEdit the parameterslSpecific to database needscp init.ora$ORACLE_HOME/dbs/initdba01.oraPFILE Example#Initialization Parameter File:initdba01.oradb_name =dba01instance_name =dba01control_files =(/home/dba01/ORADATA/u01/control01dba01.ctl,/home/dba01/ORADATA/u02/control01dba02.ctl)db_block_size =4096db_cache_size =4Mshared_pool_size =50000000java_pool_size =50000000 max_dump_file_size =10240background_dump_dest=/home/dba01/ADMIN/BDUMPuser_dump_dest =/home/dba01/ADMIN/UDUMPcore_dump_dest =/home/dba01/ADMIN/CDUMPundo_management =AUTOundo_tablespace =UNDOTBS.SPFILEspfileSID.oralBinary filelMaintained by the Oracle serverlAlways resides on the server sidelAbility to make changes persistent across shut down and start uplCan self-tune parameter valueslCan have Recovery Manager support backing up to the initialization parameter fileCreating an SPFILElCreated from a PFILE filewherelSPFILE-NAME:SPFILE to be createdlPFILE-NAME:PFILE creating the SPFILElCan be executed before or after instance start upCREATE SPFILE=$ORACLE_HOME/dbs/spfileDBA01.oraFROM PFILE=$ORACLE_HOME/dbs/initDBA01.ora;11SPFILE Example*.background_dump_dest=/home/dba01/ADMIN/BDUMP*.compatible=9.2.0*.control_files=/home/dba01/ORADATA/u01/ctrl01.ctl*.core_dump_dest=/home/dba01/ADMIN/CDUMP*.db_block_size=4096*.db_name=dba01*.db_domain=world*.global_names=TRUE*.instance_name=dba01*.remote_login_passwordfile=exclusive*.java_pool_size=50000000*.shared_pool_size=50000000*.undo_management=AUTO*.undo_tablespace=UNDOTBS.Modifying Parameters in SPFILEALTER SYSTEM SET undo_tablespace=UNDO2 SCOPE=BOTH|spfile|memory;lSpecifying temporary or persistent changeslDeleting or resetting valuesALTER SYSTEM SET undo_tablespace=UNDO2;ALTER SYSTEM SET undo_tablespace=UNDO2 SCOPE=BOTH;ALTER SYSTEM RESET undo_suppress_errors SCOPE=BOTH SID=*;STARTUP CommandlOrder of precedence:lspfileSID.oralDefault SPFILElinitSID.oralDefault PFILElSpecified PFILE can override precedence.lPFILE can indicate to use SPFILE.STARTUP PFILE=$ORACLE_HOME/dbs/initDBA1.oraSPFILE=/database/startup/spfileDBA1.oraStarting Up a DatabaseNOMOUNTOPENMOUNTNOMOUNTSHUTDOWNInstance startedSTARTUPSHUTDOWNStarting Up a DatabaseMOUNTOPENMOUNTNOMOUNTSHUTDOWNControl file opened for this instanceInstance startedSTARTUPSHUTDOWNStarting Up a DatabaseOPENOPENMOUNTNOMOUNTSHUTDOWNAll files opened as described by the control file for this instanceControl file opened for this instanceInstance startedSTARTUPSHUTDOWNSTARTUP CommandStart up the instance and open the database:STARTUP FORCE RESTRICT PFILE=filenameOPEN RECOVERdatabase|MOUNT|NOMOUNTSTARTUPSTARTUP PFILE=$ORACLE_HOME/dbs/initdb01.oraALTER DATABASE CommandlTo move the database from the NOMOUNT to a MOUNT stage or from the MOUNT to an OPEN stage:lALTER DATABASE MOUNT|OPEN lOpen the database as a read-only database:ALTER DATABASE db01 MOUNT;ALTER DATABASE db01 OPEN READ ONLY;ALTER DATABASE OPEN READ WRITE|READ ONLY;Opening a Database in Restricted ModelUse the STARTUP command to restrict access to a database:lUse the ALTER SYSTEM command to place an instance in restricted mode:STARTUP RESTRICTALTER SYSTEM ENABLE RESTRICTED SESSION;Opening a Database in Read-Only ModelOpening a database in read-only mode:lCan be used to:lExecute querieslExecute disk sorts using locally managed tablespaceslTake data files offline and online,but not tablespaceslPerform recovery of offline data files and tablespacesSTARTUP MOUNTALTER DATABASE OPEN READ ONLY;Shutting Down the DatabaseShutdown mode:lA=ABORTlI=IMMEDIATElT=TRANSACTIONALlN=NORMALANoNoNoNoTNoNoYesYesINoNoNoYesShutdown ModeAllow new connectionsWait until current sessions end Wait until current transactions endForce a checkpoint and close filesNNoYesYesYesShuttingDowntheDatabaseShuttingDowntheDatabaseSHUTDOWNNORMAL|TRANSACTIONAL|IMMEDIATE|ABORT与数据库启动有关的几个文件关闭 SHUTDOWN后台进程未运行数据库文件关闭未登陆 NOMOUNT进程运行没有数据库文件打开 打开 OPEN进程运行全部数据库文件打开 登陆 MOUNT 进程运行控制文件打开启动例程时读取参数文件