为编程爱好者分享易语言教程源码的资源网
好用的代理IP,游戏必备 ____广告位招租____ 服务器99/年 ____广告位招租____ ____广告位招租____ 挂机,建站服务器
好用的代理IP,游戏必备 ____广告位招租____ 服务器低至38/年 ____广告位招租____ ____广告位招租____ 挂机,建站服务器

网站首页 > 数据库 正文

Oracle 数据库启动阶段分析(oracle数据库的启动过程有哪几个过程(状态)?)

三叶资源网 2022-08-23 21:18:50 数据库 283 ℃ 0 评论

概述:

Oracle 数据库启动过程包括三个阶段nomount,mount,open,详情如下。


1. 启动数据库到nomount 状态

在启动的第一步骤,Oracle 首先寻找参数文件(pfile/spfile ),然后根据参数文件中的设置,创建实例,分配内存,启动后台进程。

more spfiledemo0310.ora

demo03102.__db_cache_size=3875536896
demo03101.__db_cache_size=4009754624
demo03102.__java_pool_size=83886080
demo03101.__java_pool_size=83886080
demo03102.__large_pool_size=100663296
demo03101.__large_pool_size=100663296
demo03101.__oracle_base='/u01/app/oracle'#ORACLE_BASE set from environment
demo03102.__oracle_base='/u01/app/oracle'#ORACLE_BASE set from environment
demo03102.__pga_aggregate_target=148092485632
demo03101.__pga_aggregate_target=148092485632
demo03102.__sga_target=5368709120
demo03101.__sga_target=5368709120
demo03102.__shared_io_pool_size=0
demo03101.__shared_io_pool_size=0
demo03102.__shared_pool_size=1241513984
demo03101.__shared_pool_size=1107296256
demo03102.__streams_pool_size=0
demo03101.__streams_pool_size=0
*.audit_file_dest='/u01/app/oracle/admin/demo0310/adump'
*.audit_trail='db'
*.cluster_database=true
*.compatible='11.2.0.4.0'
*.control_files='+DATA_DG/demo0310/controlfile/control01.ctl'#Restore Controlfile
*.db_block_size=8192
*.db_create_file_dest='+DATA_DG'
*.db_domain=''
*.db_name='ERPDB'
*.db_recovery_file_dest_size=107374182400
*.db_unique_name='DEMO0310'
*.diagnostic_dest='/u01/app/oracle'
*.dispatchers='(PROTOCOL=TCP) (SERVICE=demo0310XDB)'
demo03102.instance_number=2
demo03101.instance_number=1
*.open_cursors=300
*.pga_aggregate_target=148092485632
*.processes=2000
*.remote_listener='bidb-scan:1521'
*.remote_login_passwordfile='exclusive'
*.sessions=2205
*.sga_target=5368709120
demo03102.thread=2
demo03101.thread=1
demo03102.undo_tablespace='UNDOTBS2'
demo03101.undo_tablespace='UNDOTBS1'

只要拥有了一个参数文件,就可以启动实例(Instance), 这一步并不需要任何控制文件或数据文件的参与。

SQL> startup nomount
ORACLE instance started.
Total System Global Area 5344731136 bytes
Fixed Size 2262656 bytes
Variable Size 1996491136 bytes
Database Buffers 3305111552 bytes
Redo Buffers 40865792 bytes

Oracle 根据参数文件的内容,创建了 instance,分配相应的内存区域,启动相应的后台进程。 此时可观察警报日志文件(show parameter dump查看路径),可以看到这一阶段的启动过程,读取参数文件,应用参数启动实例,所有在参数文件中定义的非缺省参数都会记录在警报日志文件中:

tail -50f /u01/app/oracle/diag/rdbms/demo0310/demo03101/trace/alert_demo03101.log

Starting up:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, Real Application Clusters, OLAP, Data Mining
and Real Application Testing options.
ORACLE_HOME = /u01/app/oracle/product/11.2.0/dbhome_1
System name: Linux
Node name: bidb1
Release: 2.6.32-754.el6.x86_64
Version: #1 SMP Thu May 24 18:18:25 EDT 2018
Machine: x86_64
Using parameter settings in server-side pfile /u01/app/oracle/product/11.2.0/dbhome_1/dbs/initdemo03101.ora
System parameters with non-default values:
processes = 2000
sessions = 3072
spfile = "+DATA_DG/demo0310/spfiledemo0310.ora"
sga_target = 5G
control_files = "+DATA_DG/demo0310/controlfile/control01.ctl"
db_block_size = 8192
compatible = "11.2.0.4.0"
cluster_database = TRUE
db_create_file_dest = "+DATA_DG"
db_recovery_file_dest_size= 100G
thread = 1
undo_tablespace = "UNDOTBS1"
instance_number = 1
remote_login_passwordfile= "EXCLUSIVE"
db_domain = ""
dispatchers = "(PROTOCOL=TCP) (SERVICE=demo0310XDB)"
remote_listener = "bidb-scan:1521"
audit_file_dest = "/u01/app/oracle/admin/demo0310/adump"
audit_trail = "DB"
db_name = "ERPDB"
db_unique_name = "DEMO0310"
open_cursors = 300
pga_aggregate_target = 141232M
diagnostic_dest = "/u01/app/oracle"
Cluster communication is configured to use the following interface(s) for this instance

然后后台进程依次启动:

Cluster communication is configured to use the following interface(s) for this instance
169.254.75.95
169.254.197.13
cluster interconnect IPC version:Oracle UDP/IP (generic)
IPC Vendor 1 proto 2
Thu Apr 14 13:59:12 2022
PMON started with pid=2, OS id=43381
Thu Apr 14 13:59:12 2022
PSP0 started with pid=3, OS id=43383
Thu Apr 14 13:59:13 2022
VKTM started with pid=4, OS id=43385 at elevated priority
VKTM running at (1)millisec precision with DBRM quantum (100)ms
Thu Apr 14 13:59:13 2022
GEN0 started with pid=5, OS id=43389
Thu Apr 14 13:59:13 2022
DIAG started with pid=6, OS id=43391
Thu Apr 14 13:59:13 2022
DBRM started with pid=7, OS id=43393
Thu Apr 14 13:59:13 2022
PING started with pid=8, OS id=43395
Thu Apr 14 13:59:13 2022
ACMS started with pid=9, OS id=43397
Thu Apr 14 13:59:13 2022
DIA0 started with pid=10, OS id=43399
Thu Apr 14 13:59:13 2022
LMON started with pid=11, OS id=43401
Thu Apr 14 13:59:13 2022
LMD0 started with pid=12, OS id=43403
* Load Monitor used for high load check
* New Low - High Load Threshold Range = [61440 - 81920]
Thu Apr 14 13:59:13 2022
LMS0 started with pid=13, OS id=43405 at elevated priority
Thu Apr 14 13:59:13 2022
LMS1 started with pid=14, OS id=43409 at elevated priority
Thu Apr 14 13:59:13 2022
LMS2 started with pid=15, OS id=43413 at elevated priority
Thu Apr 14 13:59:13 2022
LMS3 started with pid=16, OS id=43417 at elevated priority
Thu Apr 14 13:59:13 2022
RMS0 started with pid=17, OS id=43421
Thu Apr 14 13:59:13 2022
LMHB started with pid=18, OS id=43423
Thu Apr 14 13:59:13 2022
MMAN started with pid=19, OS id=43425
Thu Apr 14 13:59:13 2022
DBW0 started with pid=20, OS id=43427
Thu Apr 14 13:59:13 2022
DBW1 started with pid=21, OS id=43429
Thu Apr 14 13:59:13 2022
DBW2 started with pid=22, OS id=43431
Thu Apr 14 13:59:13 2022
DBW3 started with pid=23, OS id=43433
Thu Apr 14 13:59:13 2022
DBW4 started with pid=24, OS id=43435
Thu Apr 14 13:59:13 2022
DBW5 started with pid=25, OS id=43437
Thu Apr 14 13:59:13 2022
DBW6 started with pid=26, OS id=43439
Thu Apr 14 13:59:13 2022
DBW7 started with pid=27, OS id=43441
Thu Apr 14 13:59:13 2022
LGWR started with pid=28, OS id=43443
Thu Apr 14 13:59:13 2022
CKPT started with pid=29, OS id=43445
Thu Apr 14 13:59:13 2022
SMON started with pid=30, OS id=43447
Thu Apr 14 13:59:13 2022
RECO started with pid=31, OS id=43449
Thu Apr 14 13:59:13 2022
RBAL started with pid=32, OS id=43451
Thu Apr 14 13:59:13 2022
ASMB started with pid=33, OS id=43453
Thu Apr 14 13:59:13 2022
MMON started with pid=34, OS id=43455
Thu Apr 14 13:59:13 2022
MMNL started with pid=35, OS id=43459
starting up 1 dispatcher(s) for network address '(ADDRESS=(PARTIAL=YES)(PROTOCOL=TCP))'...
NOTE: initiating MARK startup
starting up 1 shared server(s) ...
Starting background process MARK
Thu Apr 14 13:59:13 2022
MARK started with pid=37, OS id=43463
NOTE: MARK has subscribed
lmon registered with NM - instance number 1 (internal mem no 0)
Reconfiguration started (old inc 0, new inc 16)
List of instances:
1 2 (myinst: 1)
Global Resource Directory frozen
* allocate domain 0, invalid = TRUE
Communication channels reestablished
* domain 0 valid according to instance 2
* domain 0 valid = 1 according to instance 2
Master broadcasted resource hash value bitmaps
Non-local Process blocks cleaned out
LMS 1: 0 GCS shadows cancelled, 0 closed, 0 Xw survived
LMS 2: 0 GCS shadows cancelled, 0 closed, 0 Xw survived
LMS 3: 0 GCS shadows cancelled, 0 closed, 0 Xw survived
LMS 0: 0 GCS shadows cancelled, 0 closed, 0 Xw survived
Set master node info
Submitted all remote-enqueue requests
Dwn-cvts replayed, VALBLKs dubious
All grantable enqueues granted
Submitted all GCS remote-cache requests
Fix write in gcs resources
Reconfiguration complete
Thu Apr 14 13:59:14 2022
LCK0 started with pid=40, OS id=43471
Starting background process RSMN
Thu Apr 14 13:59:15 2022
RSMN started with pid=41, OS id=43473
Thu Apr 14 13:59:15 2022
ORACLE_BASE from environment = /u01/app/oracle
NOTE: Loaded library: /opt/oracle/extapi/64/asm/orcl/1/libasm.so
NOTE: Loaded library: System
SUCCESS: diskgroup DATA_DG was mounted
Thu Apr 14 13:59:16 2022
ALTER SYSTEM SET local_listener=' (ADDRESS=(PROTOCOL=TCP)(HOST=192.168.90.8)(PORT=1521))' SCOPE=MEMORY SID='demo03101';
NOTE: dependency between database DEMO0310 and diskgroup resource ora.DATA_DG.dg is established

Oracle选择参数文件的顺序:

Oracle 首选spfile<sid>.ora文件作为启动参数文件;如果该文件不存在,Oracle选择spfile.ora 文件;如果前两者都不存在,Oracle将会选择 init<sid>.ora文件;如果以上 3 个文件都不存在,Oracle 将无法创建和启动 instance ,Oracle将无法启动。

通过show parameter spfile 命令来检查数据库是否使用了 spfile文件,如果 value 不为Null,则数据库使用了 spfile文件:

SQL> show parameter spfile;
NAME TYPE                                   VALUE
------------------------------------ ---------------------------------
spfile string                                  +DATA_DG/demo0310/spfiledemo0310.ora

2. 启动数据库到mount 状态

启动到nomount 状态以后,Oracle就可以从参数文件中获得控制文件的位置信息。

在nomount 状态,可以查询v$parameter视图,获得控制文件信息,这部分信息来自启动的参数文件;当数据库 mount 之后,可以查询 v$controlfile视图获得关于控制文件信息,此时,这部分信息来自控制文件:

SQL> alter database mount;

tail -50f /u01/app/oracle/diag/rdbms/demo0310/demo03101/trace/alert_demo03101.log

在正常Mount 过程中,数据库的警报日志文件仅记录如下信息:

Thu Apr 14 14:12:14 2022
alter database mount
Thu Apr 14 14:12:18 2022
Successful mount of redo thread 1, with mount id 248043993
Database mounted in Shared Mode (CLUSTER_DATABASE=TRUE)
Lost write protection disabled
Completed: alter database mount
SQL> select NAME,IS_RECOVERY_DEST_FILE, BLOCK_SIZE,FILE_SIZE_BLKS from v$controlfile;
NAME                                                                    IS_RECOVE BLOCK_SIZE         BLOCK_SIZE     FILE_SIZE_BLKS                                                                            
---------------------                                                ---------------------                ---------            --------
 +DATA_DG/demo0310/controlfile/control01.ctl  NO                                        16384                10530  

在这一步骤中,数据库需要计算Mount id 并将其记录在控制文件中,然后开始启动 Heartbeat(心跳),每3 秒更新一次控制文件。

启动到Mount 状态,数据库必须具备的另外一个重要文件是口令文件,该文件位于 $ORACLE_HOME/dbs 目录下,缺省的名称为 orapw 。 口令文件中存放用户名及口令:

[oracle@bidb1 dbs]$ strings orapwdemo03101
]\[Z
ORACLE Remote Password file
INTERNAL
C0A0B7EC92EC3376
51DC5A5E8D00560E9F9B8B2
5638228DAF52805F

在数据库没有启动之前,数据库内建用户是无法通过数据库本身来验证身份的,通过口令文件,Oracle 可以实现对用户的身份认证,在数据库未启动之前登录,进而启动数据库。 对于口令文件,Oracle 缺省查找 orapw 文件,如果该文件不存在,则继续查找orapw 文件,如果两者都不存在,则数据库将会出现错误,可以通过orapwd命令进行重建,相关文档请自行查找。

在$ORACLE_HOME/dbs 目录下,还会存在另外一个文件,该文件命名规则为 lk<SID>,lk指lock ,该文件在数据库启动时创建,用于操作系统对数据库的锁定。当数据库启动时锁定,数据库关闭时释放。该文件内容通常只有一行,提示不要删除,该文件仅仅用于锁定.

3. 启动数据库open阶段

由于控制文件中记录了数据库中数据文件、日志文件的位置信息、检查点信息等重要信息,所以在数据库的 open阶段,Oracle可以根据控制文件中记录的这些信息找到这些文件, 然后进行检查点及完整性检查。

如果不存在问题就可以启动数据库,如果存在不一致或文件丢失则需要进行恢复。

进一步地说,实际上在数据库 open的过程中,Oracle 进行的检查中包括以下两项:

第一次检查数据文件头中的检查点计数(Checkpoint cnt )是否和控制文件中的检查点计数(Checkpoint cnt )一致。此步骤检查用以确认数据文件是来自同一版本,而不是从备份中恢复而来(因为 Checkpoint Cnt 不会被冻结,会一直被修改)。

如果检查点计数检查通过,则数据库进行第二次检查。第二次检查数据文件头的开始SCN 和控制文件中记录的该文件的结束 SCN 是否一致,如果控制文件中记录的结束 SCN 等于数据 文件头的开始 SCN,则不需要对那个文件进行恢复。

SQL> alter database open;

tail -50f /u01/app/oracle/diag/rdbms/demo0310/demo03101/trace/alert_demo03101.log

Thu Apr 14 14:53:53 2022
alter database open
Picked broadcast on commit scheme to generate SCNs
Thu Apr 14 14:53:53 2022
Thread 1 opened at log sequence 17
Current log# 9 seq# 17 mem# 0: +DATA_DG/demo0310/onlinelog/group_9.322.1098969395
Successful open of redo thread 1
MTTR advisory is disabled because FAST_START_MTTR_TARGET is not set
Thu Apr 14 14:53:53 2022
SMON: enabling cache recovery
Thu Apr 14 14:53:54 2022
minact-scn: Inst 1 is a slave inc#:16 mmon proc-id:43455 status:0x2
minact-scn status: grec-scn:0x0000.00000000 gmin-scn:0x0000.00000000 gcalc-scn:0x0000.00000000
[50263] Successfully onlined Undo Tablespace 2.
Undo initialization finished serial:0 start:1733327124 end:1733327444 diff:320 (3 seconds)
Verifying file header compatibility for 11g tablespace encryption..
Verifying 11g file header compatibility for tablespace encryption completed
SMON: enabling tx recovery
Database Characterset is ZHS16GBK
No Resource Manager plan active
Starting background process GTX0
Thu Apr 14 14:53:54 2022
GTX0 started with pid=45, OS id=50283
Starting background process RCBG
Thu Apr 14 14:53:54 2022
RCBG started with pid=46, OS id=50285
replication_dependency_tracking turned off (no async multimaster replication found)
Starting background process QMNC
Thu Apr 14 14:53:55 2022
QMNC started with pid=47, OS id=50289
Completed: alter database open
Starting background process EMNC
Thu Apr 14 14:53:55 2022
EMNC started with pid=50, OS id=50295
Thu Apr 14 14:54:16 2022
Starting background process CJQ0
Thu Apr 14 14:54:16 2022
CJQ0 started with pid=57, OS id=50376

结束:

以上就是本文关于oracle 数据库启动阶段分析的全部内容,多DBA相关技术文档请双击加关注,希望大家以后多多支持。

来源:三叶资源网,欢迎分享,公众号:iisanye,(三叶资源网⑤群:21414575

本文暂时没有评论,来添加一个吧(●'◡'●)

欢迎 发表评论:

百度站内搜索
关注微信公众号
三叶资源网⑤群:三叶资源网⑤群

网站分类
随机tag
拖放对象模块TCP服务器Tencent企点加好友qzonetoken取电脑硬件信息花椒直播工具对比两块内存树型框项目淘宝宝贝列表分页源码javascript面试题源码注释SMTP发信遇见漂流瓶APP取启动时间office2019激活易语言源码扒站工具QQ群发插件源码微信加人多线程操作例子
最新评论