oracle 监听服务配置

最近在red hat 6.6虚拟机上安装了Oracle 11gR2数据库,安装完毕,使用没有问题,通过主机也可以访问到虚拟机上的数据库。然而,在重新启动虚拟机后,主机无法访问到数据库,提示错误:

PS C:\Users\13842> sqlplus sys/Lijiaman3102700@orcl as sysdba

SQL*Plus: Release 11.2.0.1.0 Production on 星期六 2月 25 16:56:47 2017

Copyright (c) 1982, 2010, Oracle.  All rights reserved.

ERROR:
ORA-12541: TNS: 无监听程序


请输入用户名:

发现没有监听程序,于是到虚拟机上查看监听器状态,结果如下:

LSNRCTL> status
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1521)))
TNS-12541: TNS:no listener
 TNS-12560: TNS:protocol adapter error
  TNS-00511: No listener
   Linux Error: 2: No such file or directory
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost)(PORT=1521)))
TNS-12541: TNS:no listener
 TNS-12560: TNS:protocol adapter error
  TNS-00511: No listener
   Linux Error: 111: Connection refused

发现是监听器没有启动,启动即可:

[oracle@localhost Desktop]$ lsnrctl start

LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 25-FEB-2017 18:13:56

Copyright (c) 1991, 2009, Oracle.  All rights reserved.

Starting /home/app/oracle/product/11.2.0/dbhome_1/bin/tnslsnr: please wait...

TNSLSNR for Linux: Version 11.2.0.1.0 - Production
System parameter file is /home/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora
Log messages written to /home/app/oracle/diag/tnslsnr/localhost/listener/alert/log.xml
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost)(PORT=1521)))

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1521)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 11.2.0.1.0 - Production
Start Date                25-FEB-2017 18:13:56
Uptime                    0 days 0 hr. 0 min. 0 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /home/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora
Listener Log File         /home/app/oracle/diag/tnslsnr/localhost/listener/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost)(PORT=1521)))
The listener supports no services
The command completed successfully

启动之后,新的问题又出现了,在倒数第2行,提示:The listener support no services。说明Oracle的服务并没有注册到监听器,这时,使用主机上的客户端连接数据库,会提示错误:

ERROR:
ORA-12514: TNS: 监听程序当前无法识别连接描述符中请求的服务

 

接下来配置监听服务信息,在虚拟机上打开网络管理界面:

[oracle@localhost Desktop]$ netmgr

出现如下界面,点击Local->Listeners->Listener->Database Services->Add Database:

image

三个参数设置:

· Global Database Name:

SQL> select * from global_name;

GLOBAL_NAME
--------------------------------------------------------------------
ORCL

· Oracle Home Dictionary: Oracle安装路径,一般为:../app/oracle/product/11.2.0/dbhome_1

· SID:默认ORCL

点击File->Save network Configuration。

重启数据库,解决。

posted @ 2017-02-25 18:50  gegeman  阅读(5598)  评论(0编辑  收藏  举报