Oracle 监听的配置文件是:listener.ora
[dave@Dave admin]$ pwd
/u02/app/oracle/product/11.2.0/db_1/network/admin
[dave@Dave admin]$ ls
listener.ora samples shrept.lst sqlnet.ora tnsnames.ora
[dave@Dave admin]$ cat listener.ora
# listener.ora Network Configuration File: /u02/app/oracle/product/11.2.0/db_1/network/admin/listener.ora
# Generated by Oracle configuration tools.
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.56.2)(PORT = 1522))
)
)
ADR_BASE_LISTENER = /u02/app/oracle
但如果我们只修改这个配置文件,那么监听后的监听无法正常使用,连接时会报如下错误:https://www.cndba.cn/dave/article/2744
https://www.cndba.cn/dave/article/2744
C:/Users/Dave>sqlplus system/oracle@dave_562
SQL*Plus: Release 11.2.0.4.0 Production on Sun Apr 22 11:52:03 2018
Copyright (c) 1982, 2013, Oracle. All rights reserved.
ERROR:
ORA-12514: TNS:listener does not currently know of service requested in connect descriptor
所以要想修改默认的监听端口,除了修改监听的配置文件外,还需要需改LOCAL_LISTENER 参数。
因为 Oracle实例动态注册动作是在1521端口的监听程序上进行的,其他端口不会自动进行动态注册,需要通过修改LOCAL_LISTENER参数来实现非默认端口的动态注册。默认情况下,该参数为空。
将listener.ora中监听配置的内容复制一份到tnsnames.ora文件:https://www.cndba.cn/dave/article/2744https://www.cndba.cn/dave/article/2744
[dave@Dave admin]$ cat listener.ora
# listener.ora Network Configuration File: /u02/app/oracle/product/11.2.0/db_1/network/admin/listener.ora
# Generated by Oracle configuration tools.
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.56.2)(PORT = 1522))
)
)
ADR_BASE_LISTENER = /u02/app/oracle
[dave@Dave admin]$ cat tnsnames.ora
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.56.2)(PORT = 1522))
)
)
[dave@Dave admin]$
SQL> alter system set local_listener=listener;
System altered.
SQL> set lines 120
SQL> show parameter local_listener
NAME TYPE VALUE
------------------------------------ ---------------------- ------------------------------
local_listener string LISTENER
SQL>
配置后在客户端就可以使用非默认端口进行连接了:https://www.cndba.cn/dave/article/2744https://www.cndba.cn/dave/article/2744
C:/Users/Dave>sqlplus system/oracle@dave_562
SQL*Plus: Release 11.2.0.4.0 Production on Sun Apr 22 12:06:09 2018
Copyright (c) 1982, 2013, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL>
版权声明:本文为博主原创文章,未经博主允许不得转载。