广告
返回顶部
首页 > 资讯 > 数据库 >Oracle数据库启动和关闭
  • 232
分享到

Oracle数据库启动和关闭

2024-04-02 19:04:59 232人浏览 独家记忆
摘要

要了解oracle数据库的启动和停止需要先了解“实例”(instance)和“数据库”(database)这两个名词的定义:数据库(database):物理操作系统文件或磁盘(disk)的集合。实例(ins

要了解oracle数据库的启动和停止需要先了解“实例”(instance)和“数据库”(database)这两个名词的定义:

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

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

这两个词有时可以互换使用,不过二者的概念完全不同。实例和数据库之间的关系是:数据库可以由多个实例mount和open,而实例可以在任何时间点mount和open一个数据库。

Oracle System Identifier (SID)

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

有了对以上概念的认识,下面来看Oracle数据库的启动和关闭过程。

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

启动Oracle数据库的方式有很多种,最简单的启动Oracle数据库的方式是就是使用sqlplus执行startup命令。

先来看官方给的图:

Oracle数据库启动和关闭

从上图可以看出库Oracle从shutdown状态到open状态经历以下阶段:

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

实例被启动,但还没关联数据库,对应的命令是startup nomount

  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

实例被启动,打开数据库的控制文件关联一个数据库。数据库对用户还是close状态。对就的命令是alter database 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

实例被启动,关联的数据库被open。数据库中的数据可以被用户访问。对应的命令是alter database 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实例和数据库的关闭

通常关闭Oracle数据库使用sqlplus执行shutdown命令

再看官方给的图:

Oracle数据库启动和关闭

从上图中也可以看出从数据库open状态到shutdown状态也经历三个阶段:

1) 数据库被关闭

数据库还是mount状态,但在线数据文件和日志文件被关闭了。

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

实例被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.

数据库关闭的4种模式:ABORT、IMMEDIATE、TRANSACTIONAL、NORMAL。下面的表格介绍了各模式下数据库的行为。

Database BehaviorABORTIMMEDIATETRANSACTIONALNORMAL

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.

下面通过实例演示Oracle数据库的启动和关闭过程,例子中Oracle版本为11.2.0.1

1、启动数据库

当前没有任何进程和共享内存,设置好ORACLE_SID和ORACLE_HOME环境变量

Oracle数据库启动和关闭

执行sqlplus / as sysdba连接到一个空实例,当前仍然没有共享内存,只增加了一个进程oracletest的进程

Oracle数据库启动和关闭

使用startup nomount启动数据库实例,该命令默认查找spfile参数文件启动实例,也可以使用startup nomount pfile='/dir/init.ora'指定参数文件启动,在内存中分配共享内存并创建后台进程。

Oracle数据库启动和关闭查看当前的实例状态,当前状态只能查少量的视图如v$instance,但大部分视图无法查询如v$database、v$datafile,会报错:ORA-01507: database not mounted

Oracle数据库启动和关闭

使用alter database mount命令mount数据库,这种状态只能查询部分视图,dba开头的大部分视图都不能查询会报错:ORA-01219: database not open: queries allowed on fixed tables/views only

Oracle数据库启动和关闭

使用alter database open命令open数据库:

Oracle数据库启动和关闭

当前数据库被打开,可以对外提供服务。

2、关闭数据库

Oracle数据库启动和关闭整个启动和关闭的过程都会记录在alert日志文件中。11g的alert日志目录是$ORACLE_BASE/diag/rdbms/dbname/sid/trace。文件名为alert_sid.log。


参考:Http://docs.oracle.com/cd/E11882_01/server.112/e40540/startup.htm#CNCPT89043

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

您可能感兴趣的文档:

--结束END--

本文标题: Oracle数据库启动和关闭

本文链接: https://www.lsjlt.com/news/43356.html(转载时请注明来源链接)

有问题或投稿请发送至: 邮箱/279061341@qq.com    QQ/279061341

本篇文章演示代码以及资料文档资料下载

下载Word文档到电脑,方便收藏和打印~

下载Word文档
猜你喜欢
  • Oracle数据库启动和关闭
    要了解Oracle数据库的启动和停止需要先了解“实例”(instance)和“数据库”(database)这两个名词的定义:数据库(database):物理操作系统文件或磁盘(disk)的集合。实例(ins...
    99+
    2022-10-18
  • Oracle 11g 数据库启动和关闭
    Oracles11数据库的启动状态Oracle11g在启动的时候必须经过三个状态:NOMOUNT,MOUNT,OPEN。NOMOUNT: 此状态下只打开数据库实例,读取参数文件。MOUNT: 根据参数文件信...
    99+
    2022-10-18
  • oracle中怎么启动和关闭数据库
    这篇文章将为大家详细讲解有关oracle中怎么启动和关闭数据库,文章内容质量较高,因此小编分享给大家做个参考,希望大家阅读完这篇文章后对相关知识有一定的了解。启动和关闭数据库:每个数据库至少包含一个例程,例...
    99+
    2022-10-18
  • Oracle数据库如何启动与关闭
    小编给大家分享一下Oracle数据库如何启动与关闭,相信大部分人都还不怎么了解,因此分享这篇文章给大家参考一下,希望大家阅读完这篇文章后大有收获,下面让我们一起去了解一下吧!C:\app\Administr...
    99+
    2022-10-19
  • db2数据库的启动和关闭
    在一个DB2 实例下,可以创建多个database(具体每个实例下可以创建多少个database,可以通过DB2 GET DBM CFG查看.一旦建立了数据库之后,就可以对其进行操作,然而,在向数据库中建立对象或访问数据库中的对象(数据)之...
    99+
    2023-06-06
  • oracle 11g的启动和关闭
    Oracle 11g 启动和关闭startup nomount:打开数据库实例,此时读取参数文件,同时启动必须的后台进程,DBWR(数据库写进程)LGWR(日志写进程)SMON(系统监控进程)PMON(进程...
    99+
    2022-10-18
  • oracle 启动与关闭
    Oracle数据库startup和shutdown方式要启动和关闭数据库,必须要以具有Oracle 管理员权限用户登陆,通常也就是以具有SYSDBA权限用户登陆。一般我们常用INTERNAL用户来启动和关闭...
    99+
    2022-10-18
  • Mysql 5.5 数据库启动关闭命令
    启动MySQL服务 ./bin/mysqld_safe --defaults-file=/etc/my.cnf & [1] 21698 [root@localhost bin]# 160402 0...
    99+
    2022-10-18
  • oracle的启动与关闭原理-数据路的分阶段关闭
    3.oracle数据库的分阶段关闭3.1 将数据库从open状态置于mount状态SQL> alter database close;Database altered.关闭掉所有的数据文件和日志文件3...
    99+
    2022-10-18
  • linux下oracle启动关闭
    启动oracle端口监听 lsnrctl start 启动数据库 sqlplus / as sysdba 回车 开启数据库:startup   关闭监听 lsnrctl stop   关闭数据库服务 shutdown  ...
    99+
    2015-06-07
    linux下oracle启动关闭
  • 启动/关闭数据库、实例及服务
    【关闭集群顺序】1.使用crs_stat 命令查询RAC节点的服务状态是否正常[grid@ora01sh ~]$ crs_stat -t -v2.使用srvctl (service control)命令依次关闭集群服务关闭顺序:关闭数据库(...
    99+
    2021-08-07
    启动/关闭数据库 实例及服务
  • Oracle 12.2 Heavy swapping 数据库自动关闭
    环境信息: [root@oralinux7p5 ~]# free               total  ...
    99+
    2022-10-18
  • Oracle DB 开机自启动和关闭
    参考http://docs.oracle.com/database/122/UNXAR/stopping-and-starting-oracle-software.htm#UNXAR417 ...
    99+
    2022-10-18
  • ORACLE RAC 的启动和关闭顺序
    之前关闭集群数据库的时候,直接执行OS命令shutdown -h now ,后来发现启动OS之后很多服务都是UNKNOW状态,想想自己那样关闭数据库太过于"暴力",决定还是按照"温和"的方式去关闭集群数据库...
    99+
    2022-10-18
  • Oracle 11g数据库随系统自动启动与关闭的设置方法
    备注:此文根据网上文章实践并修改所成。RHEL6.8 64bit+Oracle Database 11g Enterprise Edition Release 11.2.0.1.0Oracle 11g系统自...
    99+
    2022-10-18
  • windows 启动关闭Oracle监听和服务
    经常要用数据库,让他自己启动的话,开机太慢,所以用命令启动方便点。  1.开启:    在运行中输入cmd,进入控制台,lsnrctl start回车,提示...
    99+
    2022-10-18
  • Oracle DG主备启动和关闭流程
    环境: Oracle 11g RAC和DG 关闭操作流程: RAC节点: 关闭primary主机: SQL>shutdown immediate 无法...
    99+
    2022-10-18
  • rac 启动和关闭
    Oracle 10g时代,我们很羡慕那些懂得Oracle9i的DBA,而不知不觉中度过了Oracle11g并迎接了12c时代,但是还是有不少DBA习惯于Oracle 10g的管理思维,尤其是在管理...
    99+
    2022-10-18
  • oracle的启动与关闭原理-oracle的启动阶段
    案例1:如何知道当前数据库是处于哪个阶段SQL> select instance_name,status from v$instance;INSTANCE_NAME   ...
    99+
    2022-10-18
  • Linux下如何启动、关闭Oracle
    这篇文章主要介绍了Linux下如何启动、关闭Oracle,具有一定借鉴价值,感兴趣的朋友可以参考下,希望大家阅读完这篇文章之后大有收获,下面让小编带着大家一起了解一下。Oracle Database,又名Oracle RDBMS,或简称Or...
    99+
    2023-06-28
软考高级职称资格查询
编程网,编程工程师的家园,是目前国内优秀的开源技术社区之一,形成了由开源软件库、代码分享、资讯、协作翻译、讨论区和博客等几大频道内容,为IT开发者提供了一个发现、使用、并交流开源技术的平台。
  • 官方手机版

  • 微信公众号

  • 商务合作