[20130422]修改oracle监听端口.txt

[20130422]修改oracle监听端口.txt

昨天朋友想尝试修改oracle的缺省监听端口,测试没有通过,而我在我的测试机器通过,通过对比监听文件,我发现其中的差异,问题出
在动态注册以及静态注册的问题,把一些测试记录下来,便于理解动态以及静态注册监听的问题。

1.测试环境:

SQL> @ver
BANNER
--------------------------------------------------------------------------------
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production

$ cd /u01/app/oracle11g/product/11.2.0/db_2/network/admin
$ cat listener.ora
# listener.ora Network Configuration File: /u01/app/oracle11g/product/11.2.0/db_2/network/admin/listener.ora
# Generated by Oracle configuration tools.

LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = TCP)(HOST = testtest)(PORT = 1521)(RATE_LIMIT=YES))
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
    )
  )

ADR_BASE_LISTENER = /u01/app/oracle11g

$ lsnrctl status

LSNRCTL for Linux: Version 11.2.0.3.0 - Production on 21-APR-2013 10:09:11

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

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=testtest)(PORT=1521)(RATE_LIMIT=YES)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 11.2.0.3.0 - Production
Start Date                21-APR-2013 09:59:56
Uptime                    0 days 0 hr. 9 min. 15 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      ON
Listener Parameter File   /u01/app/oracle11g/product/11.2.0/db_2/network/admin/listener.ora
Listener Log File         /u01/app/oracle11g/diag/tnslsnr/testtest/listener/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=testtest)(PORT=1521)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
Services Summary...
Service "test.com" has 1 instance(s).
  Instance "test", status READY, has 1 handler(s) for this service...
Service "testXDB.com" has 1 instance(s).
  Instance "test", status READY, has 1 handler(s) for this service...
The command completed successfully

--动态注册,状态是 READY。

2.停止监听,修改端口为1529.在启动监听看看。

$ lsnrctl start

LSNRCTL for Linux: Version 11.2.0.3.0 - Production on 21-APR-2013 10:10:38

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

Starting /u01/app/oracle11g/product/11.2.0/db_2/bin/tnslsnr: please wait...

TNSLSNR for Linux: Version 11.2.0.3.0 - Production
System parameter file is /u01/app/oracle11g/product/11.2.0/db_2/network/admin/listener.ora
Log messages written to /u01/app/oracle11g/diag/tnslsnr/testtest/listener/alert/log.xml
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=testtest)(PORT=1529)))
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1529)))

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=testtest)(PORT=1529)(RATE_LIMIT=YES)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 11.2.0.3.0 - Production
Start Date                21-APR-2013 10:10:38
Uptime                    0 days 0 hr. 0 min. 0 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      ON
Listener Parameter File   /u01/app/oracle11g/product/11.2.0/db_2/network/admin/listener.ora
Listener Log File         /u01/app/oracle11g/diag/tnslsnr/testtest/listener/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=testtest)(PORT=1529)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1529)))
The listener supports no services
The command completed successfully

SQL> alter system register;
System altered.

--执行lsnrctl status,发现显示还是

Listener Parameter File   /u01/app/oracle11g/product/11.2.0/db_2/network/admin/listener.ora
Listener Log File         /u01/app/oracle11g/diag/tnslsnr/testtest/listener/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=testtest)(PORT=1529)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1529)))
The listener supports no services
The command completed successfully

--如果这个时候远程登录,会出现:

sqlplus scott/xxxxxx@192.168.100.XXX:1529/test.com

ERROR:
ORA-12514: TNS:listener does not currently know of service requested in connect
descriptor

而执行sqlplus scott/xxxxxx@192.168.100.XXX:1521/test.com,是可以连接数据库的。为什么呢?
原来数据库动态注册仅仅连接的是1521端口,而不是监听需要的1529端口。

3.修改为静态监听看看。
$ lsnrctl stop
...

$ cat listener.ora
# listener.ora Network Configuration File: /u01/app/oracle11g/product/11.2.0/db_2/network/admin/listener.ora
# Generated by Oracle configuration tools.

SID_LIST_LISTENER =
   (SID_LIST =
    (SID_DESC =
      (GLOBAL_DBNAME = test.com)
      (ORACLE_HOME = /u01/app/oracle11g/product/11.2.0/db_2)
      (SID_NAME = test)
      )
   )

LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = TCP)(HOST = testtest)(PORT = 1529))
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1529))
    )
  )

ADR_BASE_LISTENER = /u01/app/oracle11g

$ lsnrctl start

LSNRCTL for Linux: Version 11.2.0.3.0 - Production on 21-APR-2013 10:21:07

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

Starting /u01/app/oracle11g/product/11.2.0/db_2/bin/tnslsnr: please wait...

TNSLSNR for Linux: Version 11.2.0.3.0 - Production
System parameter file is /u01/app/oracle11g/product/11.2.0/db_2/network/admin/listener.ora
Log messages written to /u01/app/oracle11g/diag/tnslsnr/testtest/listener/alert/log.xml
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=testtest)(PORT=1529)))
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1529)))

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=testtest)(PORT=1529)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 11.2.0.3.0 - Production
Start Date                21-APR-2013 10:21:07
Uptime                    0 days 0 hr. 0 min. 0 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      ON
Listener Parameter File   /u01/app/oracle11g/product/11.2.0/db_2/network/admin/listener.ora
Listener Log File         /u01/app/oracle11g/diag/tnslsnr/testtest/listener/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=testtest)(PORT=1529)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1529)))
Services Summary...
Service "test.com" has 1 instance(s).
  Instance "test", status UNKNOWN, has 1 handler(s) for this service...
The command completed successfully

--可以发现的监听状态是 UNKNOWN,是静态注册。
--这样使用端口1521,以及1529都可以连上。
sqlplus scott/xxxxxx@192.168.100.XXX:1529/test.com
sqlplus scott/xxxxxx@192.168.100.XXX:1521/test.com

--也就是讲如果使用非标准端口,要配置静态注册,这样远端机器才能使用该端口。但是这样并不能屏蔽1521端口来连接数据库。

4.如何屏蔽1521端口,也就是不让用户使用1521端口呢?

--这样必须告诉数据库注册监听时使用非1521端口。
SQL> show parameter local_listener
NAME             TYPE     VALUE
---------------- -------- ---------------
local_listener   string

SQL> alter system set local_listener='(ADDRESS=(PROTOCOL=tcp)(HOST=testtest)(PORT=1529))' scope=memory ;
System altered.

sqlplus scott/xxxxxx@192.168.100.XXX:1529/test.com =>通过
sqlplus scott/xxxxxx@192.168.100.XXX:1521/test.com =>ORA-12514: TNS:listener does not currently know of service requested in connect

5.再关闭静态注册看看,先关闭监听。
$ lsnrctl stop
...
$ cat listener.ora
# listener.ora Network Configuration File: /u01/app/oracle11g/product/11.2.0/db_2/network/admin/listener.ora
# Generated by Oracle configuration tools.

# SID_LIST_LISTENER =
#    (SID_LIST =
#     (SID_DESC =
#       (GLOBAL_DBNAME = test.com)
#       (ORACLE_HOME = /u01/app/oracle11g/product/11.2.0/db_2)
#       (SID_NAME = test)
#       )
#    )

LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = TCP)(HOST = testtest)(PORT = 1529))
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1529))
    )
  )

ADR_BASE_LISTENER = /u01/app/oracle11g

$ lsnrctl start

LSNRCTL for Linux: Version 11.2.0.3.0 - Production on 21-APR-2013 10:44:34

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

Starting /u01/app/oracle11g/product/11.2.0/db_2/bin/tnslsnr: please wait...

TNSLSNR for Linux: Version 11.2.0.3.0 - Production
System parameter file is /u01/app/oracle11g/product/11.2.0/db_2/network/admin/listener.ora
Log messages written to /u01/app/oracle11g/diag/tnslsnr/testtest/listener/alert/log.xml
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=testtest)(PORT=1529)))
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1529)))

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=testtest)(PORT=1529)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 11.2.0.3.0 - Production
Start Date                21-APR-2013 10:44:34
Uptime                    0 days 0 hr. 0 min. 0 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      ON
Listener Parameter File   /u01/app/oracle11g/product/11.2.0/db_2/network/admin/listener.ora
Listener Log File         /u01/app/oracle11g/diag/tnslsnr/testtest/listener/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=testtest)(PORT=1529)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1529)))
The listener supports no services
The command completed successfully

SQL> alter system register;
System altered.

$ lsnrctl status

LSNRCTL for Linux: Version 11.2.0.3.0 - Production on 21-APR-2013 10:44:48

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

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=testtest)(PORT=1529)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 11.2.0.3.0 - Production
Start Date                21-APR-2013 10:44:34
Uptime                    0 days 0 hr. 0 min. 14 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      ON
Listener Parameter File   /u01/app/oracle11g/product/11.2.0/db_2/network/admin/listener.ora
Listener Log File         /u01/app/oracle11g/diag/tnslsnr/testtest/listener/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=testtest)(PORT=1529)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1529)))
Services Summary...
Service "test.com" has 1 instance(s).
  Instance "test", status READY, has 1 handler(s) for this service...
Service "testXDB.com" has 1 instance(s).
  Instance "test", status READY, has 1 handler(s) for this service...
The command completed successfully

--动态注册,状态是 READY。

sqlplus scott/xxxxxx@192.168.100.XXX:1529/test.com =>通过。
sqlplus scott/xxxxxx@192.168.100.XXX:1521/test.com =>ORA-12514: TNS:listener does not currently know of service requested in connect

5.总结:
1.要使用非标准端口,可以使用静态注册。这样不要修改参数local_listener.但是动态注册依旧是1521,也就是通过1521端口也能连接
数据库。

2.也可以修改local_listener参数,让动态注册使用非标准的端口来实现。这样就无法使用1521端口。

时间: 2024-09-23 18:15:35

[20130422]修改oracle监听端口.txt的相关文章

[20160418]修改oracle监听端口.txt

[20160418]修改oracle监听端口.txt --上午开发提出要修改oracle的监听端口,我以前测试遇到过一些问题: --链接: http://blog.itpub.net/267265/viewspace-758983/ -- 但是在11.2.0.4下遇到以前不一样的情况,时间太久了,测试在2013年做的,也许现在存在一些变化. 1.无静态注册监听: SYS@book> @ &r/ver1 PORT_STRING                    VERSION       

【Oracle】修改oracle监听端口

修改oracle 监听端口号,过程相对比较简单: 1 修改 listener.ora ,tnsnames.ora 文件中的端口号 2 重启监听 lsnrctl stop ,lsnrctl start 上面的过程是对于 监听名为默认的LISTENER 而言的,如果listener.oar文件中的监听名不是默认的,就重启时必须指定监听名.比如将端口号由1521改为1523 oracle@rac3:/opt/oracle/11.2.0/alifpre/network/admin>vi listener

[20161227]打开多个监听端口.txt

[20161227]打开多个监听端口.txt --安全等保的需求,需要在1台数据库打开2个监听端口,并且还不能是1521缺省端口.看了一些文档,做一些记录. --参考连接:http://blog.itpub.net/267265/viewspace-2083455/ 1.环境: SCOTT@book> @ &r/ver1 PORT_STRING                    VERSION        BANNER ------------------------------ --

Linux下修改Oracle监听地址

如果你的服务器换了ip怎么办? 如果你的服务器换了名字怎么办? 以前的小伙伴怎么办? 以前的老客户怎么办? 没关系,简单教你修改监听地址,老朋友随便找! 想要修改监听地址首先要找到两个文件,确定两样东西! 第一 你的主机名字? 第二 你的IP地址? 第三 你的listener.ora在哪里? 第四 你的tnsnames.ora在哪里? 原来的文件监听的是localhost,这个名字在/etc/hosts中会被映射成Ip地址127.0.0.1 lisenter.ora 目录在 /opt/oracl

端口-oracle监听启动后停止

问题描述 oracle监听启动后停止 如图所示,之前好好的,昨天突然发现监听启动不了了,试过网上很多方法,包括修改listener.ora的IP,主机名:把监听改为手动后启动:命令启动监听弹出图二的错误:删除监听的时候会提示1521端口被占,但是换了其他端口全都提示被占.而且cmd命令显示1521没有被占.求高手帮忙! 解决方案 http://jingyan.baidu.com/article/d8072ac45d9860ec95cefdff.html

服务器-对外网端口做了映射,需要修改Apache的监听端口吗?

问题描述 对外网端口做了映射,需要修改Apache的监听端口吗? 我用apache做服务器,负责网络的人说把端口做了映射,80端口映射为10018,我应该把apache的监听端口改成10018吗? 现在局域网访问服务器好使,通过外网IP访问不好使,但是能ping到对外网服务的IP. 如果不是端口的问题,那会是什么原因呢? 我初学,求指教. 解决方案 你需要把端口改成10018,这样服务器会转到你apache的端口上.

ebs rac 数据库更改监听端口

背景: 新克隆出来一套ebs  rac数据库,但是监听端口使用的是1521,考虑到测试环境,不想用这个端口,打算改成1531. 1.修改context file,把对应的端口改掉(两个节点). 这三个端口都改成1531 2.分别在两个节点运行autocfg 会报错,不过可以忽略,查看db 层tns_admin 下面的tnsnames.ora配置文件都被改成1531,就可以了. 3.重新修改,注册local_listener,重启监听: db用户停止当前监听: srvctl stop listen

ORACLE监听程序打开后自动关闭,一个很常见却很棘手的问题

问题描述 ORACLE监听程序打开后自动关闭,一个很常见却很棘手的问题 这个是打开监听时候报的错误. 命令行启动报错 现在主机名 listener.ora tnsnames.ora 问题出在哪里了? 我自己也在找办法解决,c币有限,只是希望遇到过类似问题的朋友分享下自己的经验.问题解决之后希望可以给大家带来便利

AIX 日志清理 监听日志清理--过大的Oracle监听日志文件处理

AIX 日志清理 监听日志清理--过大的Oracle监听日志文件处理 Oracle监听器日志文件(通常叫做listener.log)是一个纯文本文件,它的大小是一直不断增长的,在一个生产Oracle服务器上,DBA会每日查看该文件,如检查监听器是否有异常停止,是否有恶意攻击连接等,当这个文件特别大的时候,打开和浏览文件内容时可能比较慢.这时可能会想到将当前的日志文件备份一下,然后重新创建一个新的日志文件,但Oracle的监听器在运行时是不允许对其日志文件做删除,重命名操作,于是只有停止监听器.重