
查看Oracle数据库监听是否启动应使用lsnrctl命令,命令如下
$ lsnrctl statusConnecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=ocm1.oracle.domain)(PORT=1521)))
STATUS of the LISTENER
————————
Alias LISTENER
Version TNSLSNR for Linux: Version 10.2.0.1.0 – Production
Start Date 17-MAY-2011 21:03:40
Uptime 0 days 0 hr. 2 min. 49 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /u01/app/oracle/product/10.2.1/db/network/admin/listener.ora
Listener Log File /u01/app/oracle/product/10.2.1/db/network/log/listener.log
Listening Endpoints Summary…
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=ocm1.oracle.domain)(PORT=1521)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=ocm1.oracle.domain)(PORT=1522)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=ocm1.oracle.domain)(PORT=1600)))
Services Summary…
Service “POD” has 1 instance(s).
Instance “POD”, status READY, has 1 handler(s) for this service…
Service “POD1″ has 1 instance(s).
Instance “POD”, status UNKNOWN, has 1 handler(s) for this service…
Service “PODS” has 1 instance(s).
Instance “POD”, status READY, has 2 handler(s) for this service…
Service “pod_XPT” has 1 instance(s).
Instance “POD”, status READY, has 1 handler(s) for this service…
Service “repos” has 2 instance(s).
Instance “repos”, status UNKNOWN, has 1 handler(s) for this service…
Instance “repos”, status READY, has 1 handler(s) for this service…
Service “repos_XPT” has 1 instance(s).
Instance “repos”, status READY, has 1 handler(s) for this service…
The command completed successfully
lsnrctl命令常用参数:
$ lsnrctl status:检查当前监听器的状态$ lsnrctl start [listener-name] 启动所有的监听器,可以指定名字来启动特定的监听器
$ lsnrctl stop [listener-name] 关闭所有的监听器,可以指定名字来关闭特定的监听器
$ lsnrctl reload 重启监听器,此命令可以代替lsnrctl stop,lsnrctl start
$ lsnrctl help 可以显示所有可用的监听器命令
Oracle数据库实例启动时,分成nomount、mount和open的三个阶段,下面的实例分析来展示不同阶段时,系统到底做了哪些工作1、nomout阶段,该阶段启动的前提是有参数文件,若没有参数文件,系统无法启动,在该过程中,系统分配内存、开启后台进程,同时更新alter日志文件
实例nomount之前的状态:
--无实例进程
[oracle@secdb1 admin]$ echo $ORACLE_SID
PROD
[oracle@secdb1 admin]$ ps -ef|grep PROD
oracle 14890 6310 0 21:12 pts/100:00:00 grep PROD
--alter日志信息
[oracle@secdb1 bdump]$ ls -lrt
total 48
-rw-r----- 1 oracle oinstall 1113 Mar 4 23:15 prod_lgwr_7319.trc
-rw-r----- 1 oracle oinstall 779 Mar 5 19:42 prod_mmnl_7329.trc
-rw-r--r-- 1 oracle oinstall 40910 Mar 5 21:08 alert_PROD.log
此时启动实例到nomount状态
[oracle@secdb1 admin]$ sqlplus / as sysdba
SQL*Plus: Release 10.2.0.1.0 - Production on Wed Mar 5 21:15:50 2014
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Connected to an idle instance.
SQL>startup nomount
ORACLE instance started.
Total System Global Area 314572800 bytes
Fixed Size 1219184 bytes
Variable Size 100664720 bytes
Database Buffers 209715200 bytes
Redo Buffers2973696 bytes
SQL>
此时查看进程和日志信息
[oracle@secdb1 bdump]$ ls -lrt
total 52
-rw-r----- 1 oracle oinstall 1113 Mar 4 23:15 prod_lgwr_7319.trc
-rw-r----- 1 oracle oinstall 779 Mar 5 19:42 prod_mmnl_7329.trc
-rw-r--r-- 1 oracle oinstall 42513 Mar 5 21:15 alert_PROD.log ----------------日志文件已经更新
[oracle@secdb1 bdump]$ ps -ef|grep PROD ----------------------------系统中出现后台进程
oracle 14946 1 0 21:15 ?00:00:00 ora_pmon_PROD
oracle 14948 1 0 21:15 ?00:00:00 ora_psp0_PROD
oracle 14950 1 0 21:15 ?00:00:00 ora_mman_PROD
oracle 14952 1 0 21:15 ?00:00:00 ora_dbw0_PROD
oracle 14954 1 0 21:15 ?00:00:00 ora_lgwr_PROD
oracle 14956 1 0 21:15 ?00:00:00 ora_ckpt_PROD
oracle 14958 1 0 21:15 ?00:00:00 ora_smon_PROD
oracle 14960 1 0 21:15 ?00:00:00 ora_reco_PROD
oracle 14962 1 0 21:15 ?00:00:00 ora_mmon_PROD
oracle 14964 1 0 21:15 ?00:00:00 ora_mmnl_PROD
oracle 14965 14942 0 21:15 ?00:00:00 oraclePROD (DESCRIPTION=(LOCAL=YES)(ADDRESS=(PROTOCOL=beq)))
oracle 14988 5989 0 21:17 pts/300:00:00 grep PROD
如果在$ORACLE_HOME/dbs目录下无参数文件,启动实例是现象如下:
[oracle@secdb1 dbs]$ sqlplus / as sysdba
SQL*Plus: Release 10.2.0.1.0 - Production on Wed Mar 5 21:21:19 2014
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Connected to an idle instance.
SQL>startup nomount
ORA-01078: failure in processing system parameters
LRM-00109: could not open parameter file '/u01/app/oracle/product/10.2.0/db_1/dbs/initPROD.ora'
SQL>quit
参数寻找的优先级 spfileSID.ora----initSID.ora
在该阶段,可以进行数据库的创建、控制文件的创建
2、mount,在该阶段,启动条件是需要有控制文件,如果控制文件丢失或者损坏,启动将会报错。此时系统会打开控制文件、检查数据文件、日志文件的名称和位置,
但此时不检查文件到底是否存在不存在
mount之前:
SQL>select * from v$controlfile
no rows selected
SQL>select * from v$datafile
select * from v$datafile
*
ERROR at line 1:
ORA-01507: database not mounted
mount之后
SQL>alter database mount
Database altered.
SQL>select name from v$controlfile
NAME
--------------------------------------------------------------------------------
/u01/app/oracle/oradata/PROD/disk1/control01.ctl
/u01/app/oracle/oradata/PROD/disk2/control02.ctl
SQL>select file#,name from v$datafile
FILE# name
--------------------------------------------------------------------------------
1 /u01/app/oracle/oradata/PROD/disk1/system01.dbf
2 /u01/app/oracle/oradata/PROD/disk1/undotbs01.dbf
3 /u01/app/oracle/oradata/PROD/disk1/sysaux01.dbf
在该阶段,可以进行数据库的完全恢复、修改数据库的归档模式、移动和重命令数据文件
SQL>archive log list ---查看数据库归档模式
Database log mode No Archive Mode
Automatic archival Disabled
Archive destination/u01/app/oracle/product/10.2.0/db_1/dbs/arch
Oldest online log sequence 3
Current log sequence 5
SQL>alter database archivelog---修改成归档模式
SQL>alter database noarchivelog---修改成非归档模式
如果控制文件丢失,系统报错,现象如下:
SQL>startup mount
ORACLE instance started.
Total System Global Area 314572800 bytes
Fixed Size 1219184 bytes
Variable Size 100664720 bytes
Database Buffers 209715200 bytes
Redo Buffers2973696 bytes
ORA-00205: error in identifying control file, check alert log for more info
3、open阶段,该阶段主要是打开数据文件、日志文件,在打开的过程中对数据文件和日志文件进行一致性检查,如果不一致,则SMON进程继续实例恢复,如果文件丢失,打开失败。
SQL>alter database open
Database altered.
--如何数据文件丢下,打开失败
SQL>startup mount
ORACLE instance started.
Total System Global Area 314572800 bytes
Fixed Size 1219184 bytes
Variable Size 79693200 bytes
Database Buffers 230686720 bytes
Redo Buffers2973696 bytes
Database mounted.
SQL>alter database open
alter database open
*
ERROR at line 1:
ORA-01157: cannot identify/lock data file 1 - see DBWR trace file
ORA-01110: data file 1: '/u01/app/oracle/oradata/PROD/disk1/system01.dbf'
4、小结
启动时分成三个步骤,1、nomount阶段,该阶段是实例启动,根据参数文件进行系统分配内存,启动后台进程。mount阶段,根据控制文件来进行数据文件和日志文件的名称和位置检查,把实例和数据库连接起来。open阶段,就是数据库打开阶段,打开是就需要检查文件是否正常,有没有发生文件丢失或者不一致的情况,丢失则报错,不一致则进行实例恢复。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)