-->Oracle 数据库实例启动关闭过程
--================================
[root@robinson ~]# su - oracle
--查看未启动实例前的进程情况
[oracle@robinson ~]$ ps -aef |grep oracle
root 3332 3300 0 12:20 pts/1 00:00:00 su - oracle
oracle 3333 3332 0 12:20 pts/1 00:00:00 -bash
oracle 3365 3333 0 12:20 pts/1 00:00:00 ps -aef
oracle 3366 3333 0 12:20 pts/1 00:00:00 grep oracle
--使用ipcs查看当前进程间通讯所用到的共享资源,内存段及信号量,
--可以看出当前无任何通信设备及共享资源
[oracle@robinson ~]$ ipcs -a
------ Shared Memory Segments --------
key shmid owner perms bytes nattch status
------ Semaphore Arrays --------
key semid owner perms nsems
------ Message Queues --------
key msqid owner perms used-bytes messages
--登陆到sqlplus
[oracle@robinson ~]$ sqlplus / as sysdba
SQL*Plus: Release 10.2.0.1.0 - Production on Thu Apr 29 13:07:29 2010
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Connected to an idle instance.
--再次查看进程情况,多出了进程
SQL> !ps -aef | grep oracle
root 3332 3300 0 12:20 pts/1 00:00:00 su - oracle
oracle 3333 3332 0 12:20 pts/1 00:00:00 -bash
oracle 3972 3333 0 13:07 pts/1 00:00:00 sqlplus as sysdba
oracle 3973 3972 0 13:07 ? 00:00:00 oracleorcl (DESCRIPTION=(LOCAL=YES)(ADDRESS=(PROTOCOL=beq)))
oracle 3974 3972 0 13:07 pts/1 00:00:00 /bin/bash -c ps -aef | grep oracle
oracle 3975 3974 0 13:07 pts/1 00:00:00 ps -aef
--再次查看进程间通讯资源,同样是没有任何分配
SQL> !ipcs -a
------ Shared Memory Segments --------
key shmid owner perms bytes nattch status
------ Semaphore Arrays --------
key semid owner perms nsems
------ Message Queues --------
key msqid owner perms used-bytes messages
--启动到nomount
SQL> startup nomount
ORACLE instance started.
Total System Global Area 398458880 bytes
Fixed Size 1219640 bytes
Variable Size 117441480 bytes
Database Buffers 276824064 bytes
Redo Buffers 2973696 bytes
--可以看到多出了一些后台进程,即为Oracle的后台进程。从开始。
SQL> !ps -aef | grep oracle
root 3332 3300 0 12:20 pts/1 00:00:00 su - oracle
oracle 3333 3332 0 12:20 pts/1 00:00:00 -bash
oracle 3972 3333 0 13:07 pts/1 00:00:00 sqlplus as sysdba
oracle 3981 1 0 13:09 ? 00:00:00 ora_pmon_orcl
oracle 3983 1 0 13:09 ? 00:00:00 ora_psp0_orcl
oracle 3985 1 0 13:09 ? 00:00:00 ora_mman_orcl
oracle 3987 1 0 13:09 ? 00:00:00 ora_dbw0_orcl
oracle 3989 1 0 13:09 ? 00:00:00 ora_lgwr_orcl
oracle 3991 1 0 13:09 ? 00:00:00 ora_ckpt_orcl
oracle 3993 1 0 13:09 ? 00:00:00 ora_smon_orcl
oracle 3995 1 0 13:09 ? 00:00:00 ora_reco_orcl
oracle 3997 1 0 13:09 ? 00:00:00 ora_cjq0_orcl
oracle 3999 1 0 13:09 ? 00:00:00 ora_mmon_orcl
oracle 4001 1 0 13:09 ? 00:00:00 ora_mmnl_orcl
oracle 4003 1 0 13:09 ? 00:00:00 ora_d000_orcl
oracle 4005 1 0 13:09 ? 00:00:00 ora_s000_orcl
oracle 4006 3972 0 13:09 ? 00:00:00 oracleorcl (DESCRIPTION=(LOCAL=YES)(ADDRESS=(PROTOCOL=beq)))
oracle 4009 3972 0 13:10 pts/1 00:00:00 /bin/bash -c ps -aef | grep oracle
oracle 4010 4009 0 13:10 pts/1 00:00:00 ps -aef
--可以看到已经分配了SGA
SQL> !ipcs -a
------ Shared Memory Segments --------
key shmid owner perms bytes nattch status
0x99eb282c 65537 oracle 640 402653184 14
------ Semaphore Arrays --------
key semid owner perms nsems
0x6df43ca0 98304 oracle 640 127
0x6df43ca1 131073 oracle 640 127
0x6df43ca2 163842 oracle 640 127
------ Message Queues --------
key msqid owner perms used-bytes messages
--查看控制文件,没有任何数据,因为此阶段控制文件并没有打开
SQL> select * from v$controlfile;
no rows selected
--查看数据文件和日志文件,提示database not mounted
SQL> select * from v$datafile;
select * from v$datafile
*
ERROR at line 1:
ORA-01507: database not mounted
SQL> select * from v$logfile;
select * from v$logfile
*
ERROR at line 1:
ORA-01507: database not mounted
--切换到mount阶段
SQL> alter database mount;
Database altered.
--可以查看控制文件的相关信息
SQL> select * from v$controlfile;
STATUS NAME IS_ BLOCK_SIZE FILE_SIZE_BLKS
------- -------------------------------------------------- --- ---------- --------------
/u01/app/oracle/oradata/orcl/control01.ctl NO 16384 430
/u01/app/oracle/oradata/orcl/control02.ctl NO 16384 430
/u01/app/oracle/oradata/orcl/control03.ctl NO 16384 430
--可以查看数据文件的相关信息
SQL> select FILE#,STATUS,ENABLED,CHECKPOINT_CHANGE#,CHECKPOINT_TIME,ONLINE_TIME,NAME fromv$datafile;
FILE# STATUS ENABLED CHECKPOINT_CHANGE# CHECKPOIN ONLINE_TI NAME
---------- ------- ---------- ------------------ --------- --------- --------------------------------------------------
1 SYSTEM READ WRITE 2027235 28-APR-10 06-APR-10/u01/app/oracle/oradata/orcl/system01.dbf
2 ONLINE READ WRITE 2027235 28-APR-10 06-APR-10/u01/app/oracle/oradata/orcl/undotbs01.dbf
3 ONLINE READ WRITE 2027235 28-APR-10 06-APR-10/u01/app/oracle/oradata/orcl/sysaux01.dbf
4 ONLINE READ WRITE 2027235 28-APR-10 06-APR-10/u01/app/oracle/oradata/orcl/users01.dbf
5 ONLINE READ WRITE 2027235 28-APR-10 /u01/app/oracle/oradata/orcl/example01.dbf
6 ONLINE READ WRITE 2027235 28-APR-10 /u01/app/oracle/oradata/orcl/Test.dbf
7 ONLINE READ WRITE 2027235 28-APR-10 /u01/app/oracle/oradata/orcl/ORCL/datafile/o1_mf_s
_5vrl1t7h_.dbf
--可以查看日志文件的相关信息
SQL> select * from v$logfile;
GROUP# STATUS TYPE MEMBER IS_
---------- ------- ------- ------------------------------------------------------------ ---
3 ONLINE /u01/app/oracle/oradata/orcl/redo03.log NO
2 ONLINE /u01/app/oracle/oradata/orcl/redo02.log NO
1 ONLINE /u01/app/oracle/oradata/orcl/redo01.log NO
--数据不可访问,因为在此阶段,数据文件,日志文件并没有打开
SQL> select * from scott.emp;
select * from scott.emp
*
ERROR at line 1:
ORA-01219: database not open: queries allowed on fixed tables/views only
--切换到open 阶段
SQL> alter database open;
Database altered.
--再次查看进程信息,多出了之后的相关进程
SQL> !ps -aef | grep oracle
oracle 3981 1 0 13:09 ? 00:00:00 ora_pmon_orcl
oracle 3983 1 0 13:09 ? 00:00:00 ora_psp0_orcl
oracle 3985 1 0 13:09 ? 00:00:00 ora_mman_orcl
oracle 3987 1 0 13:09 ? 00:00:00 ora_dbw0_orcl
oracle 3989 1 0 13:09 ? 00:00:00 ora_lgwr_orcl
oracle 3991 1 0 13:09 ? 00:00:00 ora_ckpt_orcl
oracle 3993 1 0 13:09 ? 00:00:00 ora_smon_orcl
oracle 3995 1 0 13:09 ? 00:00:00 ora_reco_orcl
oracle 3997 1 0 13:09 ? 00:00:00 ora_cjq0_orcl
oracle 3999 1 0 13:09 ? 00:00:00 ora_mmon_orcl
oracle 4001 1 0 13:09 ? 00:00:00 ora_mmnl_orcl
oracle 4003 1 0 13:09 ? 00:00:00 ora_d000_orcl
oracle 4005 1 0 13:09 ? 00:00:00 ora_s000_orcl
root 4068 4036 0 13:29 pts/1 00:00:00 su - oracle
oracle 4069 4068 0 13:29 pts/1 00:00:00 -bash
oracle 4101 4069 0 13:29 pts/1 00:00:00 sqlplus
oracle 4102 4101 0 13:29 ? 00:00:01 oracleorcl (DESCRIPTION=(LOCAL=YES)(ADDRESS=(PROTOCOL=beq)))
oracle 4137 1 0 13:54 ? 00:00:00 ora_qmnc_orcl
oracle 4139 1 0 13:54 ? 00:00:01 ora_j000_orcl
oracle 4141 1 0 13:54 ? 00:00:00 ora_j001_orcl
oracle 4143 1 0 13:54 ? 00:00:00 ora_j002_orcl
oracle 4145 1 0 13:54 ? 00:00:00 ora_j003_orcl
oracle 4147 1 0 13:54 ? 00:00:00 ora_j004_orcl
oracle 4149 1 0 13:54 ? 00:00:00 ora_j005_orcl
oracle 4159 1 0 13:54 ? 00:00:00 ora_q001_orcl
oracle 4167 1 0 13:56 ? 00:00:00 ora_q002_orcl
oracle 4169 1 0 13:57 ? 00:00:00 ora_q003_orcl
oracle 4172 4101 0 13:58 pts/1 00:00:00 /bin/bash -c ps -aef | grep oracle
oracle 4173 4172 0 13:58 pts/1 00:00:00 ps -aef
--数据已可正常访问
SQL> select * from scott.emp where ename = ‘SCOTT‘;
EMPNO ENAME JOB MGR HIREDATE SAL COMM
---------- ---------- --------- ---------- --------- ---------- ----------
DEPTNO
----------
7788 SCOTT ANALYST 7566 19-APR-87 3000
--查看告警日志文件路径
SQL> show parameter background_dump_dest
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
background_dump_dest string /u01/app/oracle/admin/orcl/bdu
mp
--查看动态性能视图
SQL> select sql_text,executions from v$sql where cpu_time >2000000;
SQL_TEXT
--------------------------------------------------------------------------------
EXECUTIONS
----------
select s.synonym_name object_name, o.object_type from all_synonyms s, sys.a
ll_objects o where s.owner in (‘PUBLIC‘, :schema) and o.owner = s.table_owner an
d o.object_name = s.table_name and o.object_type in (‘TABLE‘, ‘VIEW‘, ‘PACKAGE‘,
‘TYPE‘, ‘PROCEDURE‘, ‘FUNCTION‘, ‘SEQUENCE‘)
2
SQL> select username,status,server,state from v$session where program = ‘plsqldev.exe‘;
USERNAME STATUS SERVER STATE
------------------------------ -------- --------- -------------------
SYS INACTIVE DEDICATED WAITING
SYS INACTIVE DEDICATED WAITING
SQL> select sid,ctime from v$lock where sid = 275;
SID CTIME
-------
http://blog.sina.com.cn/s/blog_49d5466301016jw6.html