ITPub博客

首页 > 数据库 > Oracle > 无监听文件listener.ora的动态监听小例试验

无监听文件listener.ora的动态监听小例试验

原创 Oracle 作者:next_junction 时间:2014-01-23 01:12:30 0 删除 编辑

    在数据库服务器上,监听文件的位置是:$ORACLE_HOME/network/admin/listener.ora

试验如下: 

移动db服务器上的监听文件,如下命令:

[oracle@ENMOEDU admin]$ ls
listener13101011AM2225.bak  listener13101011AM2741.bak  samples     tnsnames13101011AM2646.bak
listener13101011AM2646.bak  listener.ora                shrept.lst  tnsnames.ora
[oracle@ENMOEDU admin]$ mkdir test
[oracle@ENMOEDU admin]$ mv listener.ora ./test
[oracle@ENMOEDU admin]$ ls
listener13101011AM2225.bak  listener13101011AM2741.bak  shrept.lst  tnsnames13101011AM2646.bak
listener13101011AM2646.bak  samples                     test        tnsnames.ora

先在db服务器上启动监听:

[oracle@ENMOEDU admin]$ lsnrctl

LSNRCTL for Linux: Version 11.2.0.3.0 - Production on 22-JAN-2014 23:48:10

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

Welcome to LSNRCTL, type "help" for information.
LSNRCTL> start
Starting /u01/app/oracle/product/11.2.0/dbhome_1/bin/tnslsnr: please wait...

TNSLSNR for Linux: Version 11.2.0.3.0 - Production
Log messages written to /u01/app/oracle/diag/tnslsnr/ENMOEDU/listener/alert/log.xml
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=ENMOEDU)(PORT=1521)))

Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 11.2.0.3.0 - Production
Start Date                22-JAN-2014 23:48:20
Uptime                    0 days 0 hr. 0 min. 0 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Log File         /u01/app/oracle/diag/tnslsnr/ENMOEDU/listener/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=ENMOEDU)(PORT=1521)))
The listener supports no services
The command completed successfully

查看监听状态,此时没有注册任何服务:

LSNRCTL> status
Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 11.2.0.3.0 - Production
Start Date                22-JAN-2014 23:48:20
Uptime                    0 days 0 hr. 14 min. 20 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Log File         /u01/app/oracle/diag/tnslsnr/ENMOEDU/listener/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=ENMOEDU)(PORT=1521)))
The listener supports no services
The command completed successfully

启动数据库:

#sqlplus / as sydba
#startup

再次查看监听状态:

LSNRCTL> status
Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 11.2.0.3.0 - Production
Start Date                22-JAN-2014 23:48:20
Uptime                    0 days 0 hr. 18 min. 8 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Log File         /u01/app/oracle/diag/tnslsnr/ENMOEDU/listener/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=ENMOEDU)(PORT=1521)))
Services Summary...
Service "ENMOEDU" has 1 instance(s).
  Instance "ENMOEDU", status READY, has 1 handler(s) for this service...
Service "ENMOEDUXDB" has 1 instance(s).
  Instance "ENMOEDU", status READY, has 1 handler(s) for this service...
The command completed successfully

到此时可以发现服务已经注册到监听器了,可以进行远程cmd下sqlplus(或其他客户端)连接服务器数据库,客户端有两种连接方式如下:

    cmd下:
        sqlplus sys/oracle@192.168.80.10:1521/ENMOEDU as sysdba --这样就可以远程连接到数据库了。

也可以在客户端的tnsnames文件中配置如下(ORCL是我windows本机配置,ORCL1连接符的配置是为了远程连接服务器数据库):

LISTENER_ORCL =
  (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))

ORACLR_CONNECTION_DATA =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
    )
    (CONNECT_DATA =
      (SID = CLRExtProc)
      (PRESENTATION = RO)
    )
  )

ORCL =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = orcl.168.3.2)
    )
  )
ORCL1=
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.80.10)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = ENMOEDU)
    )
  )

这时就可以通过连接符ORCL1进行远程数据库连接。

    cmd下:sqlplus sys/oracle@ORCL1 as sysdba ---通过连接符远程连接到数据库

如上为没有listener.ora文件时候的动态监听试验,总结待续......

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/29117696/viewspace-1074332/,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2013-08-21

  • 博文量
    19
  • 访问量
    166947