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

简介: [20130422]修改oracle监听端口.txt昨天朋友想尝试修改oracle的缺省监听端口,测试没有通过,而我在我的测试机器通过,通过对比监听文件,我发现其中的差异,问题出在动态注册以及静态注册的问题,把一些测试记录下来,便于理解动态以及静态注册监听的问题。
[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端口。

目录
相关文章
|
网络协议 Linux
Linux查看端口监听情况,以及Linux查看某个端口对应的进程号和程序
Linux查看端口监听情况,以及Linux查看某个端口对应的进程号和程序
1914 2
|
网络协议 Unix 应用服务中间件
|
人工智能 Serverless API
函数计算产品使用问题之如何在一个Docker容器内运行一个持续监听特定端口的应用程序
函数计算产品作为一种事件驱动的全托管计算服务,让用户能够专注于业务逻辑的编写,而无需关心底层服务器的管理与运维。你可以有效地利用函数计算产品来支撑各类应用场景,从简单的数据处理到复杂的业务逻辑,实现快速、高效、低成本的云上部署与运维。以下是一些关于使用函数计算产品的合集和要点,帮助你更好地理解和应用这一服务。
370 1
|
Java Android开发
Java Socket编程示例:服务器开启在8080端口监听,接收客户端连接并打印消息。
【6月更文挑战第23天】 Java Socket编程示例:服务器开启在8080端口监听,接收客户端连接并打印消息。客户端连接服务器,发送"Hello, Server!"后关闭。注意Android中需避免主线程进行网络操作。
404 4
|
开发框架 .NET Linux
【Azure 应用服务】 部署到App Service for Linux 服务的Docker 镜像,如何配置监听端口呢?
【Azure 应用服务】 部署到App Service for Linux 服务的Docker 镜像,如何配置监听端口呢?
253 0
|
网络协议
【qt】TCP的监听 (设置服务器IP地址和端口号)
【qt】TCP的监听 (设置服务器IP地址和端口号)
1058 0
|
Linux Windows
Windows查找监听端口对应的进程及其路径
Windows查找监听端口对应的进程及其路径
472 0
|
SQL Oracle 网络协议
oracle默认监听端口更改
oracle默认监听端口更改 1. 更改oracle的默认监听端口号    修改端口号的整体步骤      1.1 。
1017 0
|
7月前
|
Oracle 关系型数据库 Linux
【赵渝强老师】Oracle数据库配置助手:DBCA
Oracle数据库配置助手(DBCA)是用于创建和配置Oracle数据库的工具,支持图形界面和静默执行模式。本文介绍了使用DBCA在Linux环境下创建数据库的完整步骤,包括选择数据库操作类型、配置存储与网络选项、设置管理密码等,并提供了界面截图与视频讲解,帮助用户快速掌握数据库创建流程。
634 93
|
6月前
|
Oracle 关系型数据库 Linux
【赵渝强老师】使用NetManager创建Oracle数据库的监听器
Oracle NetManager是数据库网络配置工具,用于创建监听器、配置服务命名与网络连接,支持多数据库共享监听,确保客户端与服务器通信顺畅。
344 0

热门文章

最新文章

推荐镜像

更多
下一篇
开通oss服务