Oracle数据库启动过程

news/2024/11/23 2:51:34/

一、Oracle数据库的四种状态

Oracle数据库有四种状态:SHUTDOWN、NOMOUNT、MOUNT、OPEN.

二、Oracle数据库的启动过程详解

Oracle数据库启动主要包括三个过程:
(1) shutdown状态 ;= 数据库没有启动
(2)启动数据库到 NOMOUNT 状态;=(只是启动instance实例,尚未打开控制文件)= 启动后台进程+分配了内存
(3)启动数据库到 MOUNT 状态;=(加载控制文件)加载了 controlfile
(4)启动数据库到 OPEN 状态;=(执行控制文件,打开数据文件和redo日志文件)
在这里插入图片描述

三、执行 startup 命令,Oracle数据库会依次完成这三个过程;

另外,也可以通过手工命令依次进行:

1、数据库启动到NOMOUNT 状态

该状态查询不到控制文件和数据文件

SQL> startup nomount
ORACLE instance started.Total System Global Area 3774873224 bytes
Fixed Size		    9141896 bytes
Variable Size		  788529152 bytes
Database Buffers	 2969567232 bytes
Redo Buffers		    7634944 bytes
SQL> select status from  v$instance;STATUS
------------------------
STARTEDSQL> select status from  v$controlfile;no rows selectedSQL> select status from  v$datafile;
select status from  v$datafile*
ERROR at line 1:
ORA-01507: database not mountedSQL> select status from  v$log;
select status from  v$log*
ERROR at line 1:
ORA-01507: database not mounted

已启动实例进程

[oracle@rhel dbs]$ ps -ef |grep sanshi
oracle   126788      1  0 17:28 ?        00:00:00 ora_pmon_sanshi
oracle   126790      1  0 17:28 ?        00:00:00 ora_clmn_sanshi
oracle   126792      1  0 17:28 ?        00:00:00 ora_psp0_sanshi
oracle   126795      1  0 17:28 ?        00:00:01 ora_vktm_sanshi
oracle   126799      1  0 17:28 ?        00:00:00 ora_gen0_sanshi
oracle   126801      1  0 17:28 ?        00:00:00 ora_mman_sanshi
oracle   126805      1  0 17:28 ?        00:00:00 ora_gen1_sanshi
oracle   126808      1  0 17:28 ?        00:00:00 ora_diag_sanshi
oracle   126810      1  0 17:28 ?        00:00:00 ora_ofsd_sanshi
oracle   126813      1  0 17:28 ?        00:00:00 ora_dbrm_sanshi
oracle   126815      1  0 17:28 ?        00:00:00 ora_vkrm_sanshi
oracle   126817      1  0 17:28 ?        00:00:00 ora_svcb_sanshi
oracle   126819      1  0 17:28 ?        00:00:00 ora_pman_sanshi
oracle   126821      1  0 17:28 ?        00:00:00 ora_dia0_sanshi
oracle   126823      1  0 17:28 ?        00:00:00 ora_dbw0_sanshi
oracle   126825      1  0 17:28 ?        00:00:00 ora_lgwr_sanshi
oracle   126827      1  0 17:28 ?        00:00:00 ora_ckpt_sanshi
oracle   126829      1  0 17:28 ?        00:00:00 ora_lg00_sanshi
oracle   126831      1  0 17:28 ?        00:00:00 ora_smon_sanshi
oracle   126833      1  0 17:28 ?        00:00:00 ora_lg01_sanshi
oracle   126835      1  0 17:28 ?        00:00:00 ora_smco_sanshi
oracle   126837      1  0 17:28 ?        00:00:00 ora_reco_sanshi
oracle   126839      1  0 17:28 ?        00:00:00 ora_w000_sanshi
oracle   126841      1  0 17:28 ?        00:00:00 ora_lreg_sanshi
oracle   126843      1  0 17:28 ?        00:00:00 ora_w001_sanshi
oracle   126845      1  0 17:28 ?        00:00:00 ora_pxmn_sanshi
oracle   126849      1  0 17:28 ?        00:00:00 ora_mmon_sanshi
oracle   126851      1  0 17:28 ?        00:00:00 ora_mmnl_sanshi
oracle   126853      1  0 17:28 ?        00:00:00 ora_d000_sanshi
oracle   126855      1  0 17:28 ?        00:00:00 ora_s000_sanshi
oracle   126857      1  0 17:28 ?        00:00:00 ora_tmon_sanshi
oracle   126862      1  0 17:28 ?        00:00:00 ora_m000_sanshi
oracle   127023 121945  0 17:31 pts/0    00:00:00 grep --color=auto sanshi

2 、数据库启动到MOUNT 状态

[oracle@rhel dbs]$ sqlplus / as sysdbaSQL*Plus: Release 19.0.0.0.0 - Production on Wed Jul 5 17:32:25 2023
Version 19.3.0.0.0Copyright (c) 1982, 2019, Oracle.  All rights reserved.Connected to:
Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.3.0.0.0SQL> alter database mount;Database altered.

实例处于mount状态,控制文件、数据文件已加载可查询

在这里插入代码片SQL> select status from  v$controlfile;STATUS
--------------SQL> select status from  v$instance;STATUS
------------------------
MOUNTEDSQL> select name from  v$controlfile;NAME
--------------------------------------------------------------------------------
/u01/app/oracle/oradata/SANSHI/control01.ctl
/u01/app/oracle/fast_recovery_area/SANSHI/control02.ctlSQL> select name,status from  v$controlfile;NAME
--------------------------------------------------------------------------------
STATUS
--------------
/u01/app/oracle/oradata/SANSHI/control01.ctl/u01/app/oracle/fast_recovery_area/SANSHI/control02.ctlSQL> select name,status from  v$datafile;NAME
--------------------------------------------------------------------------------
STATUS
--------------
/u01/app/oracle/oradata/SANSHI/system01.dbf
SYSTEM/u01/app/oracle/oradata/SANSHI/sysaux01.dbf
ONLINE/u01/app/oracle/oradata/SANSHI/undotbs01.dbf
ONLINENAME
--------------------------------------------------------------------------------
STATUS
--------------
/u01/app/oracle/oradata/SANSHI/pdbseed/system01.dbf
SYSTEM/u01/app/oracle/oradata/SANSHI/pdbseed/sysaux01.dbf
ONLINE/u01/app/oracle/oradata/SANSHI/users01.dbf
ONLINENAME
--------------------------------------------------------------------------------
STATUS
--------------
/u01/app/oracle/oradata/SANSHI/pdbseed/undotbs01.dbf
ONLINE/u01/app/oracle/oradata/SANSHI/pdb1/system01.dbf
SYSTEM/u01/app/oracle/oradata/SANSHI/pdb1/sysaux01.dbf
ONLINENAME
--------------------------------------------------------------------------------
STATUS
--------------
/u01/app/oracle/oradata/SANSHI/pdb1/undotbs01.dbf
ONLINE/u01/app/oracle/oradata/SANSHI/pdb1/users01.dbf
ONLINE/u01/app/oracle/oradata/SANSHI/pdb2/system01.dbf
SYSTEMNAME
--------------------------------------------------------------------------------
STATUS
--------------
/u01/app/oracle/oradata/SANSHI/pdb2/sysaux01.dbf
ONLINE/u01/app/oracle/oradata/SANSHI/pdb2/undotbs01.dbf
ONLINE/u01/app/oracle/oradata/SANSHI/pdb2/users01.dbf
ONLINENAME
--------------------------------------------------------------------------------
STATUS
--------------
/u01/app/oracle/oradata/SANSHI/pdb3/system01.dbf
SYSTEM/u01/app/oracle/oradata/SANSHI/pdb3/sysaux01.dbf
ONLINE/u01/app/oracle/oradata/SANSHI/pdb3/undotbs01.dbf
ONLINENAME
--------------------------------------------------------------------------------
STATUS
--------------
/u01/app/oracle/oradata/SANSHI/pdb3/users01.dbf
ONLINE19 rows selected.SQL> 

查看参数文件,存放在oracle_home目录

SQL> exit
Disconnected from Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.3.0.0.0
[oracle@rhel dbs]$ cd $ORACLE_HOME/dbs
[oracle@rhel dbs]$ ls
hc_sanshi.dat  init.ora  lkSANSHI  orapwsanshi  snapcf_sanshi.f  spfilesanshi.ora
[oracle@rhel dbs]$ ll
total 18308
-rw-rw---- 1 oracle oinstall     1544 Jul  5 17:33 hc_sanshi.dat
-rwxr-xr-x 1 oracle oinstall     3079 May 14  2015 init.ora
-rw-r----- 1 oracle oinstall       24 Jul  4 12:18 lkSANSHI
-rw-r----- 1 oracle oinstall     2048 Jul  4 12:20 orapwsanshi
-rw-r----- 1 oracle oinstall 18726912 Jul  4 12:49 snapcf_sanshi.f
-rw-r----- 1 oracle oinstall     3584 Jul  5 17:33 spfilesanshi.ora
[oracle@rhel dbs]$ 

查看控制文件,存放在oracle_base下的数据文件目录中

[oracle@rhel dbs]$ cd $ORACLE_BASE
[oracle@rhel oracle]$ LS
bash: LS: command not found...
Similar command is: 'ls'
[oracle@rhel oracle]$ ls
admin  audit  cfgtoollogs  checkpoints  diag  fast_recovery_area  oradata  product
[oracle@rhel oracle]$ cd oradata/
[oracle@rhel oradata]$ ls
SANSHI
[oracle@rhel oradata]$ cd SANSHI/
[oracle@rhel SANSHI]$ kls
bash: kls: command not found...
[oracle@rhel SANSHI]$ ls
control01.ctl  pdb2  pdbseed     redo02.log  sysaux01.dbf  temp01.dbf     users01.dbf
pdb1           pdb3  redo01.log  redo03.log  system01.dbf  undotbs01.dbf
[oracle@rhel SANSHI]$ pwd
/u01/app/oracle/oradata/SANSHI
[oracle@rhel SANSHI]$ ll
total 2649240
-rw-r----- 1 oracle oinstall  18726912 Jul  5 17:39 control01.ctl
drwxr-x--- 2 oracle oinstall       104 Jul  4 12:40 pdb1
drwxr-x--- 2 oracle oinstall       104 Jul  4 12:40 pdb2
drwxr-x--- 2 oracle oinstall       104 Jul  4 12:40 pdb3
drwxr-x--- 2 oracle oinstall       111 Jul  4 12:25 pdbseed
-rw-r----- 1 oracle oinstall 209715712 Jul  5 16:43 redo01.log
-rw-r----- 1 oracle oinstall 209715712 Jul  5 16:20 redo02.log
-rw-r----- 1 oracle oinstall 209715712 Jul  5 16:20 redo03.log
-rw-r----- 1 oracle oinstall 629153792 Jul  5 16:43 sysaux01.dbf
-rw-r----- 1 oracle oinstall 954212352 Jul  5 16:43 system01.dbf
-rw-r----- 1 oracle oinstall 138420224 Jul  4 22:01 temp01.dbf
-rw-r----- 1 oracle oinstall 351281152 Jul  5 16:43 undotbs01.dbf
-rw-r----- 1 oracle oinstall   5251072 Jul  5 16:43 users01.dbf
[oracle@rhel SANSHI]$ 

打开数据库

在状态mount下,无法查看表,数据库open状态可以查看表。

SQL> select status from  v$instance;STATUS
------------------------
MOUNTEDSQL> desc tab;
ERROR:
ORA-01219: database or pluggable database not open: queries allowed on fixed
tables or views onlySQL> alter database open2  ;Database altered.SQL> desc tab;Name					   Null?    Type----------------------------------------- -------- ----------------------------TNAME					   NOT NULL VARCHAR2(128)TABTYPE					    VARCHAR2(13)CLUSTERID					    NUMBERSQL> 

shutdown关闭数据库

1、利用“shutdown immediate”命令执行某些清除工作后才关闭数据库;

SQL> shutdown immediate
ORA-01109: database not openDatabase dismounted.
ORACLE instance shut down.

2、利用“shutdown abort”命令直接关闭数据库,会话会被终止。

SQL> shutdown abort
ORACLE instance shut down.
SQL> 

3、利用“shutdown normal”命令正常关闭数据库;

SQL> shutdown normal

4、shutdown transaction

在这里插入图片描述


http://www.ppmy.cn/news/741366.html

相关文章

Android 手机听筒Earpiece和扬声器speaker切换

AudioManager audioManager (AudioManager)getSystemService(Context.AUDIO_SERVICE);private void setSpeakerphoneOn(boolean on) {if(on) {audioManager.setSpeakerphoneOn(true);} else {audioManager.setSpeakerphoneOn(false);//关闭扬声器audioManager.setRouting(Audi…

spring整合logBack日志框架:

1. SLF4J简介 SLF4J(Simple Logging Facade for Java)是一种日志规范,类似于JDBC,我们常用的日志log4j、logback等都实现了这个规范,所以我们可以直接使用SLF4J的规范来使用日志。 2. logback和log4j 它们是同一个作…

axios的post请求的几种传参方式

this.$axios.post(url,data) 直接这样传参后端是获取到不到的!!! 方式一: 利用js原生内置对象 let params new URLSearchParams(); //添加键值对 params.append("id",id); 方式二: 利用qs模块 cn…

来北京五年了

偶然进入了自己五年前刚来北京的博客,那时的我也是正在准备离职,处于找工作的间隙,而现在的我也即将再次离职,下周到新单位上班。 总结这五年,自己的提高并不多。离自己的预期目标差距很多,期间有迷茫&…

北京, 北京

周六下午到的北京。一出机场,顿时感觉北京真是和杭州不一样,天灰蒙蒙的,相比之下,杭州的天空算得上”蓝天”了。与几年前相比,交通还是那个老样子。12 点的飞机,大约 4 点半才赶到预定的汉庭安顿下来。晕机…

北京68个好吃不贵的地方

1.新街口的稻香春门脸,有个小小小小小极了的四川小吃店里的热干面一绝,好像只要两元五哟。。。。。 2.从地百北边的胡同串向后海,中途会有个小店,里面的锅贴一绝,也很便宜哟,两个MM吃,连汤不超过…

我在北京已经几年了

正文 2015年4月6日,我买了一张硬座来北京面试实习。我提前预约了。在我来之前,我采访了智联海头的四个人。当我预约时,我直接来了。下车后,我的高中同学来到火车站,提前为我订了一个旅馆。非常感谢他。面试结束后&…

北京,北京。

虽然我发誓再也不来北京了,可是命运还是莫名的让我来了北京。 那个冷得让我刻骨铭心的冬天,还有那段何必当初的恋情。 这次我来了,没有任何的牵绊,只为了一个目标,就是成功。 毕业这么久了,经历了很多风风…