Oracle 数据库启动过程的三阶段、停库四种模式详解
作者:梦想家DBA 时间:2024-01-16 04:05:25
数据库的启动过程(3个台阶)
1.nomount
shutdown --> nomount
startup nomount
select status from v$instance;
SQL>
SQL> conn / as sysdba
Connected to an idle instance.
SQL>
SQL> startup nomount
ORACLE instance started.
Total System Global Area 629145392 bytes
Fixed Size 9137968 bytes
Variable Size 197132288 bytes
Database Buffers 415236096 bytes
Redo Buffers 7639040 bytes
SQL>
SQL>
SQL>
SQL>
SQL> select status from v$instance;
STATUS
------------
STARTED
SQL>
数据库启动到nomount做了什么?
分配实例(ipcs -sm, ps -ef | grep ora_)
写审计文件和警报日志
数据库启动到nomount需要什么?
参数文件
需要审计目录和诊断目录
nomount状态可以做什么?
可以修改参数
可以查看内存和后台进程的信息
可以创建数据库
可以重建控制文件
SQL>
SQL> select * from v$sgainfo;
NAME BYTES RES CON_ID
-------------------------------- ---------- --- ----------
Fixed SGA Size 9137968 No 0
Redo Buffers 7639040 No 0
Buffer Cache Size 411041792 Yes 0
In-Memory Area Size 0 No 0
Shared Pool Size 197132288 Yes 0
Large Pool Size 4194304 Yes 0
Java Pool Size 0 Yes 0
Streams Pool Size 0 Yes 0
Shared IO Pool Size 0 Yes 0
Data Transfer Cache Size 0 Yes 0
Granule Size 4194304 No 0
NAME BYTES RES CON_ID
-------------------------------- ---------- --- ----------
Maximum SGA Size 629145392 No 0
Startup overhead in Shared Pool 193465328 No 0
Free SGA Memory Available 0 0
14 rows selected.
SQL> select name from v$bgprocess where paddr<>'00';
NAME
-----
PMON
CLMN
PSP0
VKTM
GEN0
MMAN
M000
GEN1
SCMN
DIAG
OFSD
NAME
-----
SCMN
DBRM
VKRM
SVCB
PMAN
DIA0
DBW0
LGWR
CKPT
LG00
SMON
NAME
-----
LG01
SMCO
RECO
W000
LREG
W001
PXMN
FENC
D000
MMON
MMNL
NAME
-----
S000
TMON
35 rows selected.
SQL>
2.mount
shutdown --> mount
startup mount
nomount --> mount
alter database mount;
SQL>
SQL> select status from v$instance;
STATUS
------------
STARTED
SQL> alter database mount;
Database altered.
SQL> select status from v$instance;
STATUS
------------
MOUNTED
SQL>
数据库启动到mount做了什么?
加载控制文件的信息到内存
数据库启动到mount状态需要做什么?
控制文件
mount状态可以做什么?
可以备份、还原、恢复
可以移动数据库文件
可以进行数据文件的offline
可以打开和关闭归档模式
可以打开和关闭闪回数据库的功能
SQL>
SQL> select name from v$datafile;
NAME
--------------------------------------------------------------------------------
/u02/oradata/CDB1/system01.dbf
/u02/oradata/CDB1/sysaux01.dbf
/u02/oradata/CDB1/undotbs01.dbf
/u02/oradata/CDB1/pdbseed/system01.dbf
/u02/oradata/CDB1/pdbseed/sysaux01.dbf
/u02/oradata/CDB1/users01.dbf
/u02/oradata/CDB1/pdbseed/undotbs01.dbf
/u02/oradata/CDB1/pdb1/system01.dbf
/u02/oradata/CDB1/pdb1/sysaux01.dbf
/u02/oradata/CDB1/pdb1/undotbs01.dbf
/u02/oradata/CDB1/pdb1/users01.dbf
11 rows selected.
SQL> select name from v$tempfile;
NAME
--------------------------------------------------------------------------------
/u02/oradata/CDB1/temp01.dbf
/u02/oradata/CDB1/pdbseed/temp012022-11-02_15-16-24-663-PM.dbf
/u02/oradata/CDB1/pdb1/temp01.dbf
SQL>
SQL> select member from v$logfile;
MEMBER
--------------------------------------------------------------------------------
/u02/oradata/CDB1/redo03.log
/u02/oradata/CDB1/redo02.log
/u02/oradata/CDB1/redo01.log
SQL>
3.open
shutdown --> open
startup
nomount ----> open
alter database mount;
alter datbase open;
只读方式去打开数据库
SQL>
SQL> startup mount
ORACLE instance started.
Total System Global Area 629145392 bytes
Fixed Size 9137968 bytes
Variable Size 197132288 bytes
Database Buffers 415236096 bytes
Redo Buffers 7639040 bytes
Database mounted.
SQL>
SQL>
SQL> select status from v$instance;
STATUS
------------
MOUNTED
SQL>
SQL> alter database open read only;
Database altered.
SQL>
SQL> select status from v$instance;
STATUS
------------
OPEN
SQL>
SQL>
SQL>
SQL> select open_mode from v$database;
OPEN_MODE
--------------------
READ ONLY
SQL>
SQL>
SQL> startup
ORACLE instance started.
Total System Global Area 629145392 bytes
Fixed Size 9137968 bytes
Variable Size 197132288 bytes
Database Buffers 415236096 bytes
Redo Buffers 7639040 bytes
Database mounted.
Database opened.
SQL>
数据库启动到open做了什么?
加载联机日志和数据文件
数据库启动到open需要什么?
联机日志和数据文件
open状态可以做什么?
数据库的停止(四种模式)
1.正常停库: shutdown normal = shutdown
普通用户的连接不允许建立
等待查询结束
等待事务结束
产生检查点(数据同步)
关闭联机日志和数据文件
关闭控制文件
关闭实例
2.事务级停库: shutdown transactional
普通用户的连接不允许建立
查询被终止
等待事务结束
产生检查点(数据同步)
关闭联机日志和数据文件
关闭控制文件
关闭实例
3.立即停库 : shutdown immediate (生产库最常用的停库方式)
普通用户的连接不允许建立
查询被终止
事务被回退
产生检查点(数据同步)
关闭联机日志和数据文件
关闭控制文件
关闭实例
4.强制停库 : shutdown abort
相当于拔电源
(停止之后的数据库是脏库)
注意:这些命令需要慎用
startup force = shutdown abort + startup
startup force nomount = shutdown abort + startup nomount
startup force mount = shutdown abort + startup mount
来源:https://blog.csdn.net/u011868279/article/details/127950584