# Oracle数据库启动和关闭

+关注继续查看

• 数据库(database)：物理操作系统文件或磁盘(disk)的集合。

• 实例(instance)：一组Oracle后台进程/线程以及一个共享内存区，这些内存由同一个计算机上运行的线程/进程所共享。

Oracle System Identifier (SID)

SID是Oracle实例在服务器上的唯一名字，在UNIX和Linux机器上，Oracle用SID和Oracle home值来创建共享内存的键值，即SID和Oracle home指定一个实例，SID也是用来定位参数文件。

1、Oracle实例和数据库的启动

1) 启动实例，不mount数据库

1. Searches for a server parameter file in a platform-specific default location and, if not found, for a text initialization parameter file (specifying STARTUP with the SPFILE or PFILE parameters overrides the default behavior)

2. Reads the parameter file to determine the values of initialization parameters

3. Allocates the SGA based on the initialization parameter settings

4. Starts the Oracle background processes

5. Opens the alert log and trace files and writes all explicit parameter settings to the alert log in valid parameter syntax

2) 数据库被mount

To mount the database, the instance obtains the names of the database control files specified in the CONTROL_FILES initialization parameter and opens the files. Oracle Database reads the control files to find the names of the data files and the online redo log files that it will attempt to access when opening the database.

In a mounted database, the database is closed and accessible only to database administrators. Administrators can keep the database closed while completing specific maintenance operations. However, the database is not available for normal operations.

3) 数据库被open

• Opens the online data files in tablespaces other than undo tablespaces

If a tablespace was offline when the database was previously shut down (see "Online and Offline Tablespaces"), then the tablespace and its corresponding data files will be offline when the database reopens.

• Acquires an undo tablespace

If multiple undo tablespaces exists, then the UNDO_TABLESPACE initialization parameter designates the undo tablespace to use. If this parameter is not set, then the first available undo tablespace is chosen.

• Opens the online redo log files

2、Oracle实例和数据库的关闭

1) 数据库被关闭

The database close operation is implicit in a database shutdown. The nature of the operation depends on whether the database shutdown is normal or abnormal.

When a database is closed as part of a SHUTDOWN with any option other than ABORT, Oracle Database writes data in the SGA to the data files and online redo log files. Next, the database closes online data files and online redo log files. Any offline data files of offline tablespaces have been closed already. When the database reopens, any tablespace that was offline remains offline.

At this stage, the database is closed and inaccessible for normal operations. The control files remain open after a database is closed.

##### If a SHUTDOWN ABORT or abnormal termination occurs, then the instance of an open database closes and shuts down the database instantaneously. Oracle Database does not write data in the buffers of the SGA to the data files and redo log files. The subsequent reopening of the database requires instance recovery, which Oracle Database performs automatically.

2) 数据库被umount

After the database is closed, Oracle Database unmounts the database to disassociate it from the instance. After a database is unmounted, Oracle Database closes the control files of the database. At this point, the instance remains in memory.

3) 实例被shutdown

The final step in database shutdown is shutting down the instance. When the database instance is shut down, the SGA is removed from memory and the background processes are terminated.

Database Behavior ABORT IMMEDIATE TRANSACTIONAL NORMAL

Permits new user connections

No

No

No

No

Waits until current sessions end

No

No

No

Yes

Waits until current transactions end

No

No

Yes

Yes

Performs a checkpoint and closes open files

No

Yes

Yes

Yes

• SHUTDOWN ABORT

This mode is intended for emergency situations, such as when no other form of shutdown is successful. This mode of shutdown is the fastest. However, a subsequent open of this database may take substantially longer because instance recovery must be performed to make the data files consistent.

Note:

Because SHUTDOWN ABORT does not checkpoint the open data files, instance recovery is necessary before the database can reopen. The other shutdown modes do not require instance recovery before the database can reopen.

• SHUTDOWN IMMEDIATE

This mode is typically the fastest next to SHUTDOWN ABORT. Oracle Database terminates any executing SQL statements and disconnects users. Active transactions are terminated and uncommitted changes are rolled back.

• SHUTDOWN TRANSACTIONAL

This mode prevents users from starting new transactions, but waits for all current transactions to complete before shutting down. This mode can take a significant amount of time depending on the nature of the current transactions.

• SHUTDOWN NORMAL

This is the default mode of shutdown. The database waits for all connected users to disconnect before shutting down.

1、启动数据库

《9I10G11G编程艺术  深入数据库体系结构 》

本文转自hbxztc 51CTO博客，原文链接：http://blog.51cto.com/hbxztc/1932703，如需转载请自行联系原作者

Oracle数据库的增删改操作介绍

803 0

831 0
oracle数据库带或不带数据导入导出操作大全
oracle数据库带或不带数据导入导出操作大全
0 0
+关注

ORACLE 10g 数据库体系结构图

Oracle 至PostgreSQL案例分享

PolarDB的Oracle平滑迁移之路