Oracle database startup process and state details (nomount, mount and open)


Let's take a brief look at the Oracle database architecture for in-depth understanding later. Oracle Server is mainly composed of an instance (instance) and a database (database) . An instance consists of a shared memory (SGA) and background process system , and a database is a series of physical files stored on disk.

oracle-system

SGA is mainly composed of Share Pool (shared pool, divided into Library Cache and Data Dictionary Cache, the former temporarily stores recently executed statement code, etc., the latter temporarily stores data location, table definition and user permissions, etc.), Database Buffer Cache (data buffer Area, temporarily store read data blocks), Redo Log Buffer (redo log buffer, temporarily store database modification operations), Large Pool (large pool, share part of the work of Share Pool for shared server processes, such as backup recovery, large I /O operations, parallel queries, etc.) and Java Pool (Java pool, analyze Java statements).

The background process is the communication channel between the database and the operating system. The name of the background process is determined by ORACLE_SID, and ORACLE searches for the parameter file to start the instance according to the ORACLE_SID. It is set by the Oracle database to maintain the best performance and coordinate multi-user requests, mainly DBWR (write Database Buffer Cache data to Data Files), LGWR (Write Redo Log Buffer data to Redo Log Files), CKPT (Coordination data ) File, control file and redo log, write System Change Number (SCN) to the header of control file and data file, prompting DBWR and LGWR to execute), SMON (System Monitor, 3 aspects: instance recovery instance failure data recovery, merge Free fragmented space, reclaiming temporary segments), PMON (processing transactions when user routines terminate unexpectedly, such as rolling back transactions, releasing locks and other resources, etc.), ARCH (writing Redo Log Files to Archive Log Files), CJQ0 (job queue coordinator), RVWR (recover writer, providing logging for the flashback database) and other processes.

Database (database) refers to a set of physical files stored on disk, such as data files (Data files, used to store data), control files (Control files, stored data files, redo log files, archived log file location and maintenance Information required for database integrity) and redo log files (Redo Log files, which store all operation records of modified data for recovery after failure), these three files are necessary to start the database; in addition, there are parameter files (Parameter file, Setting the startup of memory background processes, etc.), archived log files (Archived Log files, the contents of the redo log files that are filled with archive records) and password files (Password file, verifying the user name and password), these three files are not necessary files.

Oracle startup is divided into three processes nomount, mount and open. The specific work performed by these three processes is as follows:

nomount state : Start the instance.

Reading the initialization file from $ORACLE_HOME/dbs in the following order:

The initialization files are read from the dbs directory under the environment variable in the following order:

-first  spfileSID.ora

First, read spfile+instance name.ora

-if not found then, spfile.ora

Read spfile.ora if file not found

-if not found then, initSID.ora

If no file is found, read init+instance name.ora

Specifying the PFILE parameter with STARTUP overrides the default behavior.

指定pfile参数文件启动以替代默认启动方式

*  Allocating the SGA

分配SGA

*  Starting the background processes

启动后台进程

*  Opening the alertSID.log file and the trace files

启动预警日志文件(记录实例生命周期内事件,如系统内部错误、数据块损坏、系统参数修改等)和追踪文件(记录SQL操作及时间消耗等)

The database must be named with the DB_NAME parameter either in the initialization Parameter file or in the STARTUP command.

数据库必须用初始参数文件或启动命令中的DB_NAME参数命名。

mount状态:关联实例与数据库,读取控制文件并获取数据文件和重做日志文件名称状态。

Mounting a database includes the following tasks:

装载数据库包括以下任务:

* Associating a database with a previously started instance

将先前启动的实例与数据库相关联

* Locating and opening the control files specified in the parameter file

从参数文件中找到控制文件位置并打开

* Reading the control files to obtain the names and status of the data files and online redo log files.However,no checks are performed to verify the existence of the data files and online redo log files at this time.

从控制文件中读取数据文件及重做日志文件名称与状态,但是,此时并不检查数据文件与重做日志文件的存在性。

open状态

opening the database includes the following tasks:

打开数据库包含以下任务:

opening the online data log files

打开数据文件

opening the onling redo log files

打开重做日志文件

If any of the datafiles or noline redo log files are not present when you attempt to open the database ,the oracle server returns an error.

若在打开数据库时数据文件或重做日志文件任何一个不存在,则Oracle服务器返回一个错误。

During this final stage,the oracle server verfies that all the data files and online redo log files can be opened and checks the consistency of the database. If necessary,the SMON background process initiates instance recovery.

在最后阶段,Oracle数据库验证数据文件和重做日志文件可否打开并检验数据库的一致性,若不一致,SMON后台进程将启动实例恢复。

shutdown或startup状态可执行的操作:

shutdown有四个参数:normal、transactional、immediate、abort,不带参数默认为normal。

shutdown normal:不断开现在连接用户,阻止任何用户建立新的连接,包括管理员在内。已经连接的用户能够继续他们当前的工作,如递交新的更新事务,直到此用户自行断开连接。这样需要等待的时间长,可以查出现连用户,再通知其自行断开。所有的用户都断开连接,数据库才进行关闭操作,即关闭数据库、卸载数据库、终止例程。在这种情况下关闭的数据库在重新启动后,不会出现问题。启动时不需要实例恢复。

shutdown transactional:阻止任何用户建立新连接,等待所有当前连接用户的未递交的活动事务提交完毕,然后立即断开用户的连接。所有的用户都断开连接则立即关闭数据库,进行关闭数据库、卸载数据库、终止进程等操作。这种方式,用户有可能正在算账,做复杂报表!一次数据库操作做不完的,在刚做了一次数据库操作后,将被断开,这样对用户有一定影响,启动时不需要实例恢复。

shutdown immediate:阻止任何用户新的连接,同时限制当前连接用户开始新的事务。如果已连接用户有未完成的事务,则数据库系统不会等待他们完成,而是直接把当前未递交的事务回退。数据库系统不再等待用户主动断开连接,当未递交的事务回退成功后,系统会直接关闭、卸载数据库,并终止数据库进程,启动时不需要实例恢复。

shutdown abort:当数据库出现故障时,可能以上三种方式都无法正常关闭数据库,则使用这种方法。强制结束当前正在执行的SQL语句,任何未递交的事务都不被回退!这种方法基本上不会对控制文件或者参数文件造成破坏,这比强制关机要好一点(在无法正常关闭数据库的时候),启动时自动进行实例恢复。

startup有7个参数:nomount、mount、open、pfile、force、restrict和

startup nomount:通过参数文件,分配sga,启动数据库后台进程,不打开控制文件和数据文件,不能访问数据库。

startup mount:仅给dba进行管理操作,不允许数据库用户访问。仅当前实例的控制文件被打开,数据文件未打开,在这个模式下可以进行如下操作:重命名数据文件、添加取消或重命名重做日志文件、设置归档模式、设置闪回、执行完整的数据库恢复操作等。

startup open:startup的默认参数就是open,打开数据库,允许数据库的访问,当前实例控制文件中所描述的所有文件都已经打开。

startup pfile=FILENAME:以FILENAME为初始化文件启动数据库,不是采用默认初始化文件。

startup force:中止当前数据库的运行,并开始重新正常的启动数据库。

startup restrict : Only users with restricted session privileges are allowed to access the database. In this mode, the login user can perform the following operations: export or import database data, perform data loading operations using SQL*Loader, temporarily prevent general users from using data, During a migration process and an upgrade operation, you can use the ALTER SYSTEM statement to disable the RESTRICTED SESSION feature ALTER SYSTEM DISABLE RESTRICTED SESSION after logging in to a restricted session. This is done using the ALTER SYSTEM statement with the ENABLE RESTRICTED SESSION clause.

startup recover : The database starts and media recovery begins.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325732401&siteId=291194637