Oracle 数据库修复一例
Oracle 数据库修复一例:
(系统装有两个实例,分别是:bhorcl,orcl)
今天一台生产服务器的Oracle不能正常登录,用plSql登录,提示:TNS:listernet does noet curently know of sid given in connect descriptor.
初步判断是监听不能启动。
第一步,查监听程序。
C:\Users\Administrator>lsnrctl status
LSNRCTL for 64-bit Windows: Version 11.2.0.1.0 - Production on 22-OCT-2019 20:29
:39
Copyright (c) 1991, 2010, Oracle. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=WIN-HQE6MJ8PJ5O)(PORT=15
21)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for 64-bit Windows: Version 11.2.0.1.0 - Produ
ction
Start Date 22-OCT-2019 18:12:37
Uptime 0 days 2 hr. 17 min. 2 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File E:\app\Administrator\product\11.2.0\dbhome_1\network\a
dmin\listener.ora
Listener Log File e:\app\administrator\diag\tnslsnr\WIN-HQE6MJ8PJ5O\list
ener\alert\log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=WIN-HQE6MJ8PJ5O)(PORT=1521)))
Services Summary...
Service "orcl" has 1 instance(s).
Instance "orcl", status READY, has 1 handler(s) for this service...
Service "orclXDB" has 1 instance(s).
Instance "orcl", status READY, has 1 handler(s) for this service...
The command completed successfully
C:\Users\Administrator>
少了BHORCL实例的监听,但另一个实现是正常的。(正常的监听状态应该是这样的:
C:\Users\Administrator>lsnrctl status
LSNRCTL for 64-bit Windows: Version 11.2.0.1.0 - Production on 22-OCT-2019 20:29
:39
Copyright (c) 1991, 2010, Oracle. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=WIN-HQE6MJ8PJ5O)(PORT=15
21)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for 64-bit Windows: Version 11.2.0.1.0 - Produ
ction
Start Date 22-OCT-2019 18:12:37
Uptime 0 days 2 hr. 17 min. 2 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File E:\app\Administrator\product\11.2.0\dbhome_1\network\a
dmin\listener.ora
Listener Log File e:\app\administrator\diag\tnslsnr\WIN-HQE6MJ8PJ5O\list
ener\alert\log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=WIN-HQE6MJ8PJ5O)(PORT=1521)))
Services Summary...
Service "BHORCLXDB" has 1 instance(s).
Instance "bhorcl", status READY, has 1 handler(s) for this service...
Service "CLRExtProc" has 1 instance(s).
Instance "CLRExtProc", status UNKNOWN, has 1 handler(s) for this service...
Service "bhorcl" has 1 instance(s).
Instance "bhorcl", status READY, has 1 handler(s) for this service...
Service "orcl" has 1 instance(s).
Instance "orcl", status READY, has 1 handler(s) for this service...
Service "orclXDB" has 1 instance(s).
Instance "orcl", status READY, has 1 handler(s) for this service...
The command completed successfully
C:\Users\Administrator>
测试一下,果然没错,orcl是能正常使用的。
第二步:查看数据库日志:
找到安装目录下的:\app\Administrator\diag文件夹,顺便说一下,这个文件夹很重要,很多日志都在里面。
这个文件夹下的:rdbms\bhorcl\bhorcl\trace\alert_bhorcl.log就是数据库日志。我不是很专业,分析不出原因,
(顺便提一下:大牛看了我发给他的这个日志,可以分析出很多问题,大牛就是大牛,与众不同)。
还有其它的文件也可以分析一下。但我看了所有的日志,没看出问题。只能再找其它原因。
第三步:进去命令行,运行sqlplus看看启动错误。
于是进入命令行,输入:sqlplus / as sysdba ,
无论无保也都报错:ORA-12560: TNS:protocol adapter error
以为是没有配置sid.于是:set ORACLE_SID=bhorcl
还是报错。
最后,大牛一看就知道原因:因为这台服务器不但安装了oracle服务端,同时也安装了客户端,在命令行输入sqlplus定位到了客户端文件夹执行了,所以找不到相关的配置
文件,所以会报错。解决方法,在命令前加上全路径。
Oracle 安装路径:E:\app\Administrator\product\11.2.0下有两个文件夹:
client_开头的是客户端(我这里是:client_2)
dbhome_开头的是服务端(我这里是:dbhome_1)
于是:再次进入命令行输入:
set ORACLE_SID=bhorcl
E:\app\Administrator\product\11.2.0\dbhome_1\BIN\sqlplus / as sysdba
可以进行了,但报错。不是正常的connected.
试一下能不能mount数据库:
命令:
startup mount;
提示:specified value of memory_target is too small,needs to ba at least 365344M.
终于找到真正的原因了:memeory_target配置太小。
怎么修改呢?
三步:一从spfile生成可修改的pfile,二,修改配置,测试正常,用pfile生成spfile.
以下命令在用sqlplus连接到数据库后执行:
create pfile='e:\spfile_bhorcl.ora' from spfile //一、生成e:\spfile_bhorcl.ora,二,用文本编编辑器打开,修改相关的值。
startup pfile='e:\spfile_bhorcl.ora' //二、测试,如果能正常启动,就说明修改成功。我的就是一修改就成功。
//停止数据库。
shutdown immediate ;
//生成spfile
create spfile from pfile='e:\spfile_bhorcl.ora';
退出sqlplus ,重启oralce服务,一切正常。终于又可以正常打开系统了。