This article brings you relevant knowledge about Oracle, which mainly sorts out the issues related to the startup process, including NOMOUNT status, MOUNT status, OPEN status, etc., as follows: Let's take a look, hope it helps everyone.
Oracle Video Tutorial"
In-depth understanding of the ORACLE startup processORACLE SERVER byInstance (Instance, Application) and Database (database, Database file) are composed of a set of background processes and a It consists of a shared memory area (sga), and the background process is the channel for interaction between the database and the operating system. The name of the background process is determined by ORACLE_SID. ORACLE looks for the parameter file to start the instance based on ORACLE_SID. A database refers to a set of physical files stored on disk.
ORACLE startup is divided into 3 processes:NOMOUNT state: start the instance MOUNT state: open the control file OPEN state: open the control The file described in the file
NOMOUNT status:
ORACLE needs to find SPFILE(System Parameter File)(oracle 10g default, pfile (Parameter File)Also) file to create instances and allocate memory.
MOUNT state:
In this state, the control file needs to be opened, andthe control file contains the location information of log files, data files, and checkpoint information and other important information.
In ORACLE9i, an error will be reported if the password file is lost, and it can be rebuilt through the orapw tool. No error will be reported in Oracle 10g, query through v$pwfile_users view.lk_The file is created when the database is started and is used to lock the database by the operating system. (lock)
The password file exists in $ORACLE_HOME/dbsalter system set controlfile='控制文件路径' scope=spfile; alter system set lock_name_space=orcl scope=spfile;
Rebuild the control file:
SQL>startup nomount; SQL>create controlfile reuse database "orcl" noresetlogs archivelog maxlogfiles 5 maxlogmembers 3 maxdatafiles 100 maxinstances 1 maxloghistory 1134 logfile group 3 '/data/app/oracle/oradata/orcl/redo03.log' size 10m, group 4 '/data/app/oracle/oradata/orcl/redo04.log' size 10m, group 5 '/data/app/oracle/oradata/orcl/redo05.log' size 10m datafile '/data/app/oracle/oradata/orcl/system01.dbf', '/data/app/oracle/oradata/orcl/undotbs01.dbf', '/data/app/oracle/oradata/orcl/sysaux01.dbf' character set zhs16gbk;
OPEN status
First, check whether the checkpoint count in the data file header is consistent with the checkpoint count in the control file. Secondly, check whether the starting SCN of the data file header and the ending SCN of the file recorded in the control file are consistent. If the ending SCN in the control file is equal to the starting SCN in the data file header, it means no recovery is required. SQL>show parameter backgroud_dump_dest;If a file in the database is lost, the alarm log will not be displayed in the foreground during the MOUNT stage, but will be recorded in alter_.log. Oracle startup and shutdown1. sql*plus method:
Use sql*plus to connect to Oracle Sqlplus /nolog starts sql*plus without connecting to the databaseConnect /as sysdba connects to oracle as DBA . StartStartup to start . However, there are three Oracle startup modes: l Startup nomount (nomount mode) starts the instance without loading the database. l Startup mount (mount mode) starts the instance to load the database but does not open the database l Startup (open mode) starts the instance to load and open the database, which is the command we used aboveIn Nomount mode, Oracle only creates various memory structures and service processes for the instance, and does not open any database files.So:
1) Create a new database
2) Rebuild the control file
Both operations must be performed in this mode.
In Mount mode, Oracle only loads the database but does not open the database, so: 1) Rename the data file 2) Add and delete and rename redo log files 3) Perform a full database recovery operation 4) Change the database archive mode These four operations must be performed in this mode Open mode (that is, our startup above does not take any parameters) starts normally. Of course, these three modes can be converted: Alter database mount (nomount mode) —> alter database open (mount mode) —> (open mode) Of course, there are other situations. In our open mode, the database can be set to unrestricted state and restricted stateIn the restricted state, only the DBA can access the database, so:1) 执行数据导入导出
2) 使用sql*loader提取外部数据
3) 需要暂时拒绝普通用户访问数据库
4) 进行数据库移植或者升级操作
这4种操作都必须在这个状态下进行
在打开数据库时使用startup restrict命令即进入受限状态。
使用alter system disable restricted session命令即可以将受限状态改变为非受限状态。
使用alter system enable restricted session命令可以将非受限状态变为受限状态
使用alter database open read only可以使数据库进入只读状态。
使用alter database open read write 可以使数据库进入读写状态。
当然在某些情况下可能是用上述各种启动方式都无法成功启动数据库,这个时候就要使用startup force命令来强行启动数据库。当然谁都不想碰到这种情况:)
c.关闭数据库
1)正常关闭 shutdown
2) 立即关闭 shutdown immediate
3) 关闭事务 shutdown transactional
4) 强行关闭 shutdown abort,当然谁都不想碰到这种情况。
二、OEM为例
Oracle Enterprise Management(OEM),
跟第一小节讲的Sqlplus /nolog ,Connect /as sysdba 这2个命令差不多的操作如图:
按照上面的一步步操作就能够连接到数据库。
下面是如何启动和关闭数据库:
点击我们前几章创建的ORADB01这个数据库树中的配置选项,这个里面的:
1)已启动 对应 Nomount模式
2)已转载 对应 mount模式
3)打开 对应 open模式
当你点击应有按钮之后就会进入如下对话框
1)正常 对应 正常关闭 shutdown
2) 立即 对应 立即关闭 shutdown immediate
3) 事务处理 对应 关闭事务 shutdown transactional
4) 中止 对应 强行关闭 shutdown abort
确定之后出现如下对话框
限制对数据库访问 对应 alter system disable restricted session
alter system enable restricted session
只读模式 对应 alter database open read only
alter database open read write
简单吧,sql*plus的一大堆命令到OEM中变成了几个按钮罢了。
3.windows控制台
这个熟悉吧:
oracle ***********Agent 用于OEM管理结构
oracle************HTTPSERVER oracle Web服务器
oracle ***********ManagementServer 用于OEM管理结构
oracle ***********TNSListener oracle网络结构的服务器端进程
oracle ***********OEMREP 资料档案库文件
oracle ***********ORADB001 用户创建的数据库
我一般都把所有的服务全部选成手动启动,如果全开,内存要用掉700M..............
提示:建议关闭数据库服务前先shutdown,否则可能会丢失数据。
如果是windows系统,关系不大,会自动提交未提交的DML。但是在unix或者linux系统的话,最好先shutdown immediate,在检查一下是否还有oracle进程,最后在关闭服务器。
Oracle启动的整个过程
1.启动选项
在发出startup命令启动数据库时,oracle将在默认位置$ORACLE_HOME/dbs(UNIX/Linux)中查找初始化参数文件。Oracle将以下面的顺序在其中寻找合适的初始化文件:
Spfile$ORACLE_SID.ora
Spfile.ora
Init$ORACLE_SID.ora
可以用几种方式启动oracle数据库。不同方式启动将影响启动数据库的程度。启动状态由nomount(数据库未装载)——>mount(数据库完成装载)——>open(数据库打开)
1.1 STARTUP NOMOUNT命令
SQL> startup nomount;ORACLE instance started. Total System Global Area 167387136 bytes Fixed Size 1343668 bytes Variable Size 150998860 bytes Database Buffers 12582912 bytes Redo Buffers 2461696 bytes
--Oracle读参数文件(里面有控制文件目录),打开实例,启动Oracle后台进程,给Oracle分配SGA。此时数据库状态为未装载。
可以在SQL*Plus会话中使用STARTUP NOMOUNT命令启动实例,这样启动仅有实例运行。如果以这种方式启动,将不读控制文件,而且数据文件也不打开。操作系统启动Oracle后台进程,并且给oracle分配SGA。事实上,只有实例本身在运行。
1.2 STARTUP MOUNT命令
SQL> startup mount;ORACLE instance started. Total System Global Area 167387136 bytes Fixed Size 1343668 bytes Variable Size 150998860 bytes Database Buffers 12582912 bytes Redo Buffers 2461696 bytesDatabase mounted.
--Oracle 打开并读取控制文件(里面有数据文件和日志文件的目录),获取数据文件和重做日志文件的名称和位置。此时数据库完成装载。
在启动过程中,oracle把实例与数据库关联。Oracle打开并读取控制文件,获取数据文件和重做日志文件的名称和位置。在进行诸如全数据库恢复、更改数据库的归档日志模式或重命名数据文件这一类的活动时,通常需要以安装模式启动数据库。请注意,这三种操作都要求oracle访问数据文件,但不提供对文件的用户操作。
1.3 STARTUP [OPEN]命令
SQL> startup openORACLE instance started. Total System Global Area 167387136 bytes Fixed Size 1343668 bytes Variable Size 150998860 bytes Database Buffers 12582912 bytes Redo Buffers 2461696 bytesDatabase mounted. Database opened.
--Oracle打开数据文件和重做日志文件,才能对外(所有有效用户)提供数据库服务。
启动过程的最后一步是打开数据库。当数据库以打开模式启动时,所有有效用户可以连接到数据库,执行数据库操作。在此步骤之前,一般用户根本就不能连接到数据库。通过发布下面的命令让数据库出于打开模式。
Oracle 的启动需要经历四个状态,SHUTDOWN 、NOMOUNT 、MOUNT 、OPEN。
SHUTDOWN状态
第一状态没什么好解释的,oracle的所有文件都静静的躺在磁盘里,一切都还未开始,属于关机状态
NOMOUNT状态
Starting the instance (nomount) * Reading the initialization file from $ORACLE_HOME/dbs in the following order: -first spfileSID.ora -if not found then, spfile.ora -if not found then, initSID.ora Specifying the PFILE parameter with STARTUP overrides the default behavior. * Allocating the SGA * Starting the background processes * Opening the alertSID.log file and the trace files The database must be named with the DB_NAME parameter either in the initialization Parameter file or in the STARTUP command. ----------------------------------------------------------------------- * 读取环境变量下dbs目录下的参数文件(spfile/pfile) [ora10@localhost dbs]$ pwd /ora10/product/10.2.0/db_1/dbs [ora10@localhost dbs]$ ll -rw-r----- 1 ora10 dba 3584 07-19 22:07 spfilechongshi.ora -rw-r----- 1 ora10 dba 3584 07-23 22:00 spfile.ora -rw-r--r-- 1 ora10 dba 1106 07-19 21:47 initchongshi.ora
查找参数文件的顺序如上面列表的,读取优先级
spfilechongshi.ora > spfile.ora>initchongshi.ora
如果三个文件都找不到的话,那么将启动失败。
* 启动算法,分配内存
* 启动后台进程
* 开放alertSID.log文件和跟踪文件
[ora10@localhost dbs]$ sqlplus SQL*Plus: Release 10.2.0.1.0 - Production on Tue Jul 24 22:33:54 2012 Copyright (c) 1982, 2005, Oracle. All rights reserved. Enter user-name: /as sysdba Connected to an idle instance. SQL> startup nomount; ORACLE instance started. Total System Global Area 205520896 bytes Fixed Size 1218532 bytes Variable Size 79693852 bytes Database Buffers 121634816 bytes Redo Buffers 2973696 bytes
现在就处在一个nomount状态。
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. ---------------------------------------------------------------------------------
* 把一个数据库和启动的实例关联起来
* 在参数文件(spfile/pfile)中找到控制文件进行读取
查看参数文件:
[ora10@localhost dbs]$ strings spfileora10.ora | more ...... *.control_files='/ora10/product/oradata/ora10/control01.ctl','/ora10/product/ora data/ora10/control02.ctl','/ora10/product/oradata/ora10/control03.ctl' .......
控制文件:
[ora10@localhost ~]$ cd /ora10/product/oradata/ora10/ [ora10@localhost ora10]$ ll 总计 954196 -rw-r----- 1 ora10 dba 7061504 07-23 23:01 control01.ctl -rw-r----- 1 ora10 dba 7061504 07-23 23:01 control02.ctl -rw-r----- 1 ora10 dba 7061504 07-23 23:01 control03.ctl
* 读取控制文件,获得的数据文件和联机重做日志文件,然而,在这个时候没有进行检查以验证存在的数据文件和联机重做日志文件
[ora10@localhost dbs]$ sqlplus SQL*Plus: Release 10.2.0.1.0 - Production on Tue Jul 24 23:02:28 2012 Copyright (c) 1982, 2005, Oracle. All rights reserved. Enter user-name: /as sysdba Connected to an idle instance. SQL> startup mount; ORACLE instance started. Total System Global Area 205520896 bytes Fixed Size 1218532 bytes Variable Size 79693852 bytes Database Buffers 121634816 bytes Redo Buffers 2973696 bytes Database mounted.
现在进入了数据库的mount状态,我们通过mount启动的时候,下面会多一句提示“Database mounted.” 数据库准备就绪。
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. 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. -----------------------------------------------------------------------------------------
打开数据库包括下列任务:
打开在线数据日志文件
打开联机重做日志文件
如果任何数据文件或非线性重做日志文件不存在,当您试图打开的数据库,服务器返回错误。
在这最后阶段,该服务器验证所有数据文件和联机重做日志文件可以打开并检查数据库的一致性。如果需要,该系统监控进程开始实例恢复。
[ora10@localhost dbs]$ sqlplus /nolog SQL*Plus: Release 10.2.0.1.0 - Production on Wed Jul 25 21:50:55 2012 Copyright (c) 1982, 2005, Oracle. All rights reserved. SQL> conn /as sysdba Connected to an idle instance. SQL> startup ORACLE instance started. Total System Global Area 205520896 bytes Fixed Size 1218532 bytes Variable Size 79693852 bytes Database Buffers 121634816 bytes Redo Buffers 2973696 bytes Database mounted. Database opened.
在上面的命令中,startup后面不加其它信息的话,系统会为我们直接启动到第4个状态。
数据库关闭的三种方式
1、shutdown normal
正常方式关闭数据库。
发出该命令后,任何新的连接都将再不允许连接到数据库。在数据库关闭之前,Oracle将等待目前连接的所有用户都从数据库中退出后才开始关闭数据库。采 用这种方式关闭数据库,在下一次启动时不需要进行任何的实例恢复。但需要注意一点的是,采用这种方式,也许关闭一个数据库需要几天时间,也许更长。
2. shutdown immediate
Close the database immediately.
When shutdown immediate is executed in SVRMGRL, the database is not closed immediately.
Instead, it is closed after Oracle performs certain cleanup work (terminating the session and releasing session resources).
When shutdown cannot be used to close the database , shutdown immediate can complete the database shutdown operation.
This is a commonly used way to close the database. If you want to close the database quickly, but also want the database to be closed cleanly, this method is often used.
The SQL statement currently being processed by Oracle is immediately interrupted, and any uncommitted transactions in the system are rolled back. If there is a long uncommitted transaction in the system, shutting down the database in this way will also take some time (the transaction rollback time). The system does not wait for all users connected to the database to exit the system, forcibly rolls back all currently active transactions, and then disconnects all connected users.
3. shutdown abort
Close the database directly, and the session accessing the database will be terminated suddenly (equivalent to directly closing the background instance service process)
If there are a large number of operations being executed in the database, execute shutdown at this time After abort, restarting the database takes a long time.
4. After shutdown in Windows, you need to restart the background instance service process, otherwise the ora-12514 error will be reported. After restarting the instance service, the database automatically executed startup to the open state.
Recommended tutorial: "Oracle Video Tutorial"
The above is the detailed content of Master the Oracle startup process in one article. For more information, please follow other related articles on the PHP Chinese website!

oracle asm指的是“自动存储管理”,是一种卷管理器,可自动管理磁盘组并提供有效的数据冗余功能;它是做为单独的Oracle实例实施和部署。asm的优势:1、配置简单、可最大化推动数据库合并的存储资源利用;2、支持BIGFILE文件等。

方法:1、利用“select*from user_indexes where table_name=表名”语句查询表中索引;2、利用“select*from all_indexes where table_name=表名”语句查询所有索引。

在Oracle中,可利用lsnrctl命令查询端口号,该命令是Oracle的监听命令;在启动、关闭或重启oracle监听器之前可使用该命令检查oracle监听器的状态,语法为“lsnrctl status”,结果PORT后的内容就是端口号。

在oracle中,可以利用“TO_SINGLE_BYTE(String)”将全角转换为半角;“TO_SINGLE_BYTE”函数可以将参数中所有多字节字符都替换为等价的单字节字符,只有当数据库字符集同时包含多字节和单字节字符的时候有效。

在oracle中,可以利用“drop sequence sequence名”来删除sequence;sequence是自动增加数字序列的意思,也就是序列号,序列号自动增加不能重置,因此需要利用drop sequence语句来删除序列。

在oracle中,可以利用“select ... From all_tab_columns where table_name=upper('表名') AND owner=upper('数据库登录用户名');”语句查询数据库表的数据类型。

方法:1、利用“LOWER(字段值)”将字段转为小写,或者利用“UPPER(字段值)”将字段转为大写;2、利用“REGEXP_LIKE(字符串,正则表达式,'i')”,当参数设置为“i”时,说明进行匹配不区分大小写。

方法:1、利用“alter system set sessions=修改后的数值 scope=spfile”语句修改session参数;2、修改参数之后利用“shutdown immediate – startup”语句重启服务器即可生效。


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

SublimeText3 Linux new version
SublimeText3 Linux latest version

SublimeText3 Chinese version
Chinese version, very easy to use

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Mac version
God-level code editing software (SublimeText3)
