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

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

--安全等保的需求,需要在1台数据库打开2个监听端口,并且还不能是1521缺省端口.看了一些文档,做一些记录.
--参考连接:http://blog.itpub.net/267265/viewspace-2083455/

1.环境:
SCOTT@book> @ &r/ver1
PORT_STRING                    VERSION        BANNER
------------------------------ -------------- --------------------------------------------------------------------------------
x86_64/Linux 2.4.xx            11.2.0.4.0     Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production

--设置打开2个端口,15210,15211.

2.修改listener.ora如下:
--注:先stop监听,再修改.
$ cat listener.ora
# listener.ora Network Configuration File: /u01/app/oracle/product/11.2.0.4/dbhome_1/network/admin/listener.ora
# Generated by Oracle configuration tools.
#SUBSCRIBE_FOR_NODE_DOWN_EVENT_LISTENER=OFF

SID_LIST_LISTENER =
   (SID_LIST =
    (SID_DESC =
      (SDU=32767)
      (GLOBAL_DBNAME = book)
      (ORACLE_HOME = /u01/app/oracle/product/11.2.0.4/dbhome_1)
      (SID_NAME = book)
      )
    )

LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 127.0.0.1)(PORT = 15210))
      (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.100.78)(PORT = 15210))
      (ADDRESS = (PROTOCOL = TCP)(HOST = 127.0.0.1)(PORT = 15211))
      (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.100.78)(PORT = 15211))
    )
  )

ADR_BASE_LISTENER = /u01/app/oracle

--重启监听就ok了.

$ lsnrctl status
LSNRCTL for Linux: Version 11.2.0.4.0 - Production on 27-DEC-2016 08:31:36

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

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=127.0.0.1)(PORT=15210)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 11.2.0.4.0 - Production
Start Date                27-DEC-2016 08:29:33
Uptime                    0 days 0 hr. 2 min. 3 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /u01/app/oracle/product/11.2.0.4/dbhome_1/network/admin/listener.ora
Listener Log File         /u01/app/oracle/diag/tnslsnr/gxqyydg4/listener/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=127.0.0.1)(PORT=15210)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.100.78)(PORT=15210)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=127.0.0.1)(PORT=15211)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.100.78)(PORT=15211)))
Services Summary...
Service "book" has 1 instance(s).
  Instance "book", status UNKNOWN, has 1 handler(s) for this service...
  ~~~~~~~~~~~~~~~~~~~UNKBOWN 说明是静态监听.
The command completed successfully

--使用ezconnect连接测试: sqlplus scott/book@192.168.100.78:15211/book ,通过.

# lsof -i -P -n | grep 1521| grep LISTEN
tnslsnr    1997  oracle    8u  IPv4 21318788      0t0  TCP 127.0.0.1:15210 (LISTEN)
tnslsnr    1997  oracle   11u  IPv4 21318790      0t0  TCP 192.168.100.78:15210 (LISTEN)
tnslsnr    1997  oracle   12u  IPv4 21318791      0t0  TCP 127.0.0.1:15211 (LISTEN)
tnslsnr    1997  oracle   13u  IPv4 21318792      0t0  TCP 192.168.100.78:15211 (LISTEN)

--这样最简单的.但是需要配置静态监听.如果注解前面的静态监听呢?

3.无静态监听:
$ cat listener.ora
# listener.ora Network Configuration File: /u01/app/oracle/product/11.2.0.4/dbhome_1/network/admin/listener.ora
# Generated by Oracle configuration tools.
#SUBSCRIBE_FOR_NODE_DOWN_EVENT_LISTENER=OFF

# SID_LIST_LISTENER =
#    (SID_LIST =
#     (SID_DESC =
#       (SDU=32767)
#       (GLOBAL_DBNAME = book)
#       (ORACLE_HOME = /u01/app/oracle/product/11.2.0.4/dbhome_1)
#       (SID_NAME = book)
#       )
#     )

LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 127.0.0.1)(PORT = 15210))
      (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.100.78)(PORT = 15210))
      (ADDRESS = (PROTOCOL = TCP)(HOST = 127.0.0.1)(PORT = 15211))
      (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.100.78)(PORT = 15211))
    )
  )

ADR_BASE_LISTENER = /u01/app/oracle

--重启监听.

$ lsnrctl status

LSNRCTL for Linux: Version 11.2.0.4.0 - Production on 27-DEC-2016 08:44:48

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

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=127.0.0.1)(PORT=15210)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 11.2.0.4.0 - Production
Start Date                27-DEC-2016 08:43:16
Uptime                    0 days 0 hr. 1 min. 32 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /u01/app/oracle/product/11.2.0.4/dbhome_1/network/admin/listener.ora
Listener Log File         /u01/app/oracle/diag/tnslsnr/gxqyydg4/listener/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=127.0.0.1)(PORT=15210)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.100.78)(PORT=15210)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=127.0.0.1)(PORT=15211)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.100.78)(PORT=15211)))
The listener supports no services
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The command completed successfully

--注意后面2行,The listener supports no services.即使你执行alter system register ;也一样,因为缺省是注册1521端口.而服务端
--没有开放1521端口,无效.这个时候就需要修改参数local_listener.

4.修改参数local_listener:
--有2种方式:一种直接写入spfile中,这样写入内容稍微长一点:

alter system set local_listener="(DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 127.0.0.1)(PORT = 15210)) (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.100.78)(PORT = 15210)) (ADDRESS = (PROTOCOL = TCP)(HOST = 127.0.0.1)(PORT = 15211)) (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.100.78)(PORT = 15211)))" scope=memory;
--我遇到如下提示:
*
ERROR at line 1:
ORA-00972: identifier is too long

--先不注册127.0.0.1地址看看.

alter system set local_listener="(DESCRIPTION =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.100.78)(PORT = 15210))
      (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.100.78)(PORT = 15211))
    )" scope=memory;

$ oerr ora 972
00972, 00000, "identifier is too long"
// *Cause:  An identifier with more than 30 characters was specified.
// *Action:  Specify at most 30 characters.
--昏限制30个字符.我写成如下:

SYS@book> alter system set local_listener="(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.100.78)(PORT=15210))(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.100.78)(PORT=15211)))" scope=memory;
System altered.

--我的测试写成1行,里面没有空格就ok了.但是也超过30个字符限制啊,写成如下也报错.

alter system set local_listener="(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=127.0.0.1)(PORT=15210))(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.100.78)(PORT=15210))(ADDRESS=(PROTOCOL=TCP)(HOST=127.0.0.1)(PORT=15211))(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.100.78)(PORT=15211)))" scope=memory;

SYS@book> show parameter local_listener
NAME           TYPE   VALUE
-------------- ------ ----------------------------------------------------------------------------------------------------
local_listener string (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.100.78)(PORT=15210))(ADDRESS=(PROTOCOL=TCP)(HOST=1
                                                                              92.168.100.78)(PORT=15211)))

$ lsnrctl status
LSNRCTL for Linux: Version 11.2.0.4.0 - Production on 27-DEC-2016 09:03:06
Copyright (c) 1991, 2013, Oracle.  All rights reserved.

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=127.0.0.1)(PORT=15210)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 11.2.0.4.0 - Production
Start Date                27-DEC-2016 08:48:33
Uptime                    0 days 0 hr. 14 min. 33 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /u01/app/oracle/product/11.2.0.4/dbhome_1/network/admin/listener.ora
Listener Log File         /u01/app/oracle/diag/tnslsnr/gxqyydg4/listener/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=127.0.0.1)(PORT=15210)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.100.78)(PORT=15210)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=127.0.0.1)(PORT=15211)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.100.78)(PORT=15211)))
Services Summary...
Service "book" has 1 instance(s).
  Instance "book", status READY, has 2 handler(s) for this service...
  ~~~~~~~~~~~~~~=> READ 表示动态监听注册.
Service "bookXDB" has 1 instance(s).
  Instance "book", status READY, has 1 handler(s) for this service...
The command completed successfully

--可以发现现在动态注册ok.实际上还有另外的修改方式把以上内容写入tnsnames.ora文件中.看下面的测试.

5.修改参数local_listener:

--在tnsnames.ora文件加入如下内容:

LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 127.0.0.1)(PORT = 15210))
      (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.100.78)(PORT = 15210))
      (ADDRESS = (PROTOCOL = TCP)(HOST = 127.0.0.1)(PORT = 15211))
      (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.100.78)(PORT = 15211))
    )
  )

--LISTENER 可以换自己喜欢的名字.

SYS@book> alter system set local_listener="LISTENER" scope=memory;
System altered.

--使用ezconnect连接测试: sqlplus scott/book@192.168.100.78:15211/book ,通过.

时间: 2024-09-22 01:04:18

[20161227]打开多个监听端口.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       

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

[20130422]修改oracle监听端口.txt 昨天朋友想尝试修改oracle的缺省监听端口,测试没有通过,而我在我的测试机器通过,通过对比监听文件,我发现其中的差异,问题出在动态注册以及静态注册的问题,把一些测试记录下来,便于理解动态以及静态注册监听的问题. 1.测试环境: SQL> @verBANNER--------------------------------------------------------------------------------Oracle Databa

socket-ecplise Java中用ServerSocket监听端口问题

问题描述 ecplise Java中用ServerSocket监听端口问题 端口号为60012,java的PID为4036,只启用了一个ServerSocket.打开cmd并netstat -aon|findstr ""60012""后,发现有两个地址?这是为什么?谢谢各位大神了 解决方案 验证了的确会出现这两条信息.你的客户端代码和服务器端代码是在同一个局域网中吗?如果代码正确的话,不会连接不上的啊. 解决方案二: 不懂---------- 解决方案三: 或者能不

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

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

tcp连接-TCP连接时,服务端监听socket接收客户端连接后新创建的socket默认绑定的端口是监听端口吗?

问题描述 TCP连接时,服务端监听socket接收客户端连接后新创建的socket默认绑定的端口是监听端口吗? 比如用来监听连接的socket绑定23端口,服务端每接受一个连接都新开一个线程和客户端通信,并把新socket传递给新线程,是不是所有新创建的socket都是经过23端口和客户端通信? 解决方案 是的,都通过端口23进行通信 解决方案二: 都是监听端口,如果不是客户端就不能将数据发送到服务器 解决方案三: 23只是监听建立连接,后续数据交换走实际上端口

socket-负责监听端口的局部变量serverScoket在方法结束后,为什么还能继续监听端口?

问题描述 负责监听端口的局部变量serverScoket在方法结束后,为什么还能继续监听端口? 我在winform中的按钮点击事件中新建了一个局部变量serveScoket,开启监听,在方法结束后,我新建一个客户端连接仍然可以连接到服务器,这是为什么? private void btnStart_Click(object sender, EventArgs e) { Socket server = new Socket(AddressFamily.InterNetwork,SocketType.

求vb.net windows service监听端口源码!!

问题描述 求vb.netwindowsservice监听端口源码!!!!!!!!!!!!!!!!!!!! 解决方案 解决方案二:VB.NET端口监听实例ImportsSystem.ComponentModelImportsSystem.DrawingImportsSystem.WinFormsImportsSystem.ThreadingImportsSystem.Net.SocketsPublicClassForm1InheritsSystem.WinForms.FormPrivateoLis

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

Linux用netstat查看服务及监听端口

[root@localhost ~]# netstat -nlp netstat命令各个参数说明如下: -t : 指明显示TCP端口 -u : 指明显示UDP端口 -l : 仅显示监听套接字(所谓套接字就是使应用程序能够读写与收发通讯协议(protocol)与资料的程序) -p : 显示进程标识符和程序名称,每一个套接字/端口都属于一个程序. -n : 不进行DNS轮询(可以加速操作) 即可显示当前服务器上所有端口及进程服务,于grep结合可查看某个具体端口及服务情况 [root@localho