|
一、Oracle的启动和关闭原理
1、oracle启动的步骤分析
SQL> startup --这是启动数据库的命令
ORACLE instance started. --第一个阶段,启动实例,nomount的状态
Total System Global Area 608174080 bytes
Fixed Size 1268920 bytes
Variable Size 230687560 bytes
Database Buffers 373293056 bytes
Redo Buffers 2924544 bytes
Database mounted. --第二个阶段,装载数据库,mount状态
Database opened. --第三个阶段,打开数据库,open状态
2、oracle数据库的分阶段启动
2.1 将数据库启动到nomount状态,只是启动实例
SQL> startup nomount
ORACLE instance started.
Total System Global Area 608174080 bytes
Fixed Size 1268920 bytes
Variable Size 230687560 bytes
Database Buffers 373293056 bytes
Redo Buffers 2924544 bytes
原理:读取参数文件spfile文件
参数文件路径:$ORACLE_HOME/dbs
[oracle@oracle3 dbs]$ ll
总计 48
-rw-r----- 1 oracle oinstall 1544 06-05 15:47 hc_LAW.dat
-rw-rw---- 1 oracle oinstall 1544 06-09 09:25 hc_ORCL.dat
-rw-r--r-- 1 oracle oinstall 12920 2001-05-03 initdw.ora
-rw-r----- 1 oracle oinstall 8385 1998-09-11 init.ora
-rw-r----- 1 oracle oinstall 24 06-04 16:20 lkORCL
-rw-r----- 1 oracle oinstall 1536 06-04 16:23 orapwORCL
-rw-r----- 1 oracle oinstall 2560 06-09 09:23 spfileORCL.ora
spfileORCL.ora:就是oracle启动所要读取的参数文件
反解spfile文件
SQL> create pfile from spfile;
File created.
在$ORACLE_HOME/dbs下多了这个文件
-rw-r--r-- 1 oracle oinstall 987 06-09 09:28 initORCL.ora --默认是没有这个文件的
在initORCL.ora文件中,关于内存组件的参数:
*.sga_target=605028352
*.pga_aggregate_target=201326592
ORCL.__db_cache_size=373293056
ORCL.__java_pool_size=33554432
ORCL.__large_pool_size=4194304
ORCL.__shared_pool_size=192937984
ORCL.__streams_pool_size=0
oracle的后台进程:
[oracle@oracle3 ~]$ ps aux | grep ora_
oracle 3473 0.0 0.6 694896 13096 ? Ss 09:25 0:00 ora_pmon_ORCL
oracle 3475 0.0 0.5 694312 11372 ? Ss 09:25 0:00 ora_psp0_ORCL
oracle 3477 0.0 1.0 694312 21756 ? Ss 09:25 0:00 ora_mman_ORCL
oracle 3479 0.0 0.6 695992 13200 ? Ss 09:25 0:00 ora_dbw0_ORCL
oracle 3481 0.0 0.5 694312 11420 ? Ss 09:25 0:00 ora_lgwr_ORCL
oracle 3483 0.0 0.5 694312 12248 ? Ss 09:25 0:00 ora_ckpt_ORCL
oracle 3485 0.0 0.5 694312 11436 ? Ss 09:25 0:00 ora_smon_ORCL
oracle 3487 0.0 0.5 694312 11376 ? Ss 09:25 0:00 ora_reco_ORCL
oracle 3489 0.0 0.5 694312 11396 ? Ss 09:25 0:00 ora_cjq0_ORCL
oracle 3491 0.0 0.5 694312 11548 ? Ss 09:25 0:00 ora_mmon_ORCL
oracle 3493 0.0 0.5 694312 11392 ? Ss 09:25 0:00 ora_mmnl_ORCL
oracle 3495 0.0 0.5 694820 11460 ? Ss 09:25 0:00 ora_d000_ORCL
oracle 3497 0.0 0.5 694308 10836 ? Ss 09:25 0:00 ora_s000_ORCL
查看监听器的状态
Service "ORCL" has 1 instance(s).
Instance "ORCL", status BLOCKED, has 1 handler(s) for this service...
nomount阶段使用场合:作数据库的维护操作,最经常做的就是控制文件的重建。
2.2 将数据库启动到mount状态,装载数据库
SQL> alter database mount; --这是只有在nomount状态下才能够使用这条命令
Database altered.
SQL> startup mount; --直接将数据库启动到mount状态,直接跳到第二阶段
ORACLE instance started.
Total System Global Area 608174080 bytes
Fixed Size 1268920 bytes
Variable Size 230687560 bytes
Database Buffers 373293056 bytes
Redo Buffers 2924544 bytes
Database mounted.
原理:读取控制文件
在参数文件中有关于控制文件的路径:
*.control_files='/u01/oracle/oradata/ORCL/control01.ctl','/u01/oracle/oradata/ORCL/control02.ctl','/u01/oracle/oradata/ORCL/control03.ctl'
[oracle@oracle3 ~]$ cd /u01/oracle/oradata/ORCL/
[oracle@oracle3 ORCL]$ ll *.ctl
-rw-r----- 1 oracle oinstall 7061504 06-09 09:53 control01.ctl
-rw-r----- 1 oracle oinstall 7061504 06-09 09:53 control02.ctl
-rw-r----- 1 oracle oinstall 7061504 06-09 09:53 control03.ctl
控制文件是一个二进制文件,想要读取的话需要将之trace出来,trace出来的文件放在/u01/oracle/admin/ORCL/udump
LOGFILE
GROUP 1 '/u01/oracle/oradata/ORCL/redo01.log' SIZE 50M,
GROUP 2 '/u01/oracle/oradata/ORCL/redo02.log' SIZE 50M,
GROUP 3 '/u01/oracle/oradata/ORCL/redo03.log' SIZE 50M
-- STANDBY LOGFILE
DATAFILE
'/u01/oracle/oradata/ORCL/system01.dbf',
'/u01/oracle/oradata/ORCL/undotbs01.dbf',
'/u01/oracle/oradata/ORCL/sysaux01.dbf',
'/u01/oracle/oradata/ORCL/users01.dbf',
'/u01/oracle/oradata/ORCL/example01.dbf'
CHARACTER SET ZHS16GBK
;
日志文件和数据文件的路径是存储在控制文件中的
注意:
实例跟数据库已经关联起来
SYS用户能够访问数据库
其他非SYS用户是无法访问数据库的
SQL> conn system/orcl
ERROR:
ORA-01033: ORACLE initialization or shutdown in progress
Warning: You are no longer connected to ORACLE.
mount状态的使用场合:
做数据库的恢复和数据的迁移
2.3 打开数据库
SQL> alter database open; --这里是在mount状态下才能使用这条命令
Database altered.
SQL> startup --直接将数据库打开,直接三级跳
ORACLE instance started.
Total System Global Area 608174080 bytes
Fixed Size 1268920 bytes
Variable Size 230687560 bytes
Database Buffers 373293056 bytes
Redo Buffers 2924544 bytes
Database mounted.
Database opened.
|
|