sqlplus 连接数据库等待10-20s port 6200

The sqlplus slow login is because sqlplus trying to connect to db server ONS/6200,

sqldeveloper does not have this issue because sqldeveloper will not auto configure FAN.

a. open port 6200

b. In the db side, use srvctl to configure all _srv db services NOT to enable notification

e.g.

srvctl modify service -d <dbname> -s <service name> -notification FALSE

c. Add a config file ons_oraaccess.xml to disable notification

12c Client: Approximate 9 - 10 Second Delay in Connecting via Remote SQL*Plus (Doc ID 2218140.1)

Symptoms

An Oracle 12c client (SQL*Plus) takes approximately 10 seconds to connect to 12c database.

A review of the client traces shows the connection seemed to hang during the authentication phase.

It also revealed the client was reaching out to the ONS on port 6200:

(2724587008) 22-DEC-2016 17:58:03:577 nsbasic_brc: 0F 00 00 00 0F 41 55 54 |.....AUT|

(2724587008) 22-DEC-2016 17:58:03:577 nsbasic_brc: 48 5F 4F 4E 53 5F 43 4F |H_ONS_CO|

(2724587008) 22-DEC-2016 17:58:03:577 nsbasic_brc: 4E 46 49 47 47 00 00 00 |NFIGG...|

(2724587008) 22-DEC-2016 17:58:03:577 nsbasic_brc: 47 6D 61 78 63 6F 6E 6E |Gmaxconn|

(2724587008) 22-DEC-2016 17:58:03:577 nsbasic_brc: 65 63 74 69 6F 6E 73 2E |ections.|

(2724587008) 22-DEC-2016 17:58:03:577 nsbasic_brc: 30 30 30 31 3D 30 30 30 |0001=000|

(2724587008) 22-DEC-2016 17:58:03:577 nsbasic_brc: 33 0A 6E 6F 64 65 73 2E |3.nodes.|

(2724587008) 22-DEC-2016 17:58:03:577 nsbasic_brc: 30 30 30 31 3D 73 73 30 |0001=any|

(2724587008) 22-DEC-2016 17:58:03:577 nsbasic_brc: 30 37 31 31 31 2E 69 6E |host.here|

(2724587008) 22-DEC-2016 17:58:03:577 nsbasic_brc: 74 72 61 30 31 2E 73 61 |.domain.|

(2724587008) 22-DEC-2016 17:58:03:577 nsbasic_brc: 6E 69 74 61 73 2E 63 6F |world.co|

(2724587008) 22-DEC-2016 17:58:03:577 nsbasic_brc: 6D 3A 36 32 30 30 0A 00 |m:6200..|

10 seconds pass when the client abandons the connection to the ONS because:

A) it is not running or

B) it is not reachable through a firewall.

Connection does get established to the database around 10 seconds later:

Note that at 17:58:13 the banner is delivered to the client indicating the connection to the database

is successful:

(2724587008) 22-DEC-2016 17:58:13:005 nsprecv: 00 00 00 BE 06 00 00 00 |........|

(2724587008) 22-DEC-2016 17:58:13:005 nsprecv: 00 00 08 A5 00 A5 4F 72 |......Or|

(2724587008) 22-DEC-2016 17:58:13:005 nsprecv: 61 63 6C 65 20 44 61 74 |acle.Dat|

(2724587008) 22-DEC-2016 17:58:13:005 nsprecv: 61 62 61 73 65 20 31 32 |abase.12|

(2724587008) 22-DEC-2016 17:58:13:005 nsprecv: 63 20 45 6E 74 65 72 70 |c.Enterp|

(2724587008) 22-DEC-2016 17:58:13:005 nsprecv: 72 69 73 65 20 45 64 69 |rise.Edi|

(2724587008) 22-DEC-2016 17:58:13:005 nsprecv: 74 69 6F 6E 20 52 65 6C |tion.Rel|

(2724587008) 22-DEC-2016 17:58:13:005 nsprecv: 65 61 73 65 20 31 32 2E |ease.12.|

(2724587008) 22-DEC-2016 17:58:13:005 nsprecv: 31 2E 30 2E 32 2E 30 20 |1.0.2.0.|

(2724587008) 22-DEC-2016 17:58:13:005 nsprecv: 2D 20 36 34 62 69 74 20 |-.64bit.|

Changes

This is likely a new installation or an upgrade to the 12c client.

Cause

FAN or Fast Application Notification events are enabled by default in the 12c client.

The client will attempt to contact an Oracle Notification Server during the remote

connection process. The default port for the ONS is 6200.

See the following document:

http://www.oracle.com/technetwork/database/options/clustering/overview/fastapplicationnotification12c-2538999.pdf

Scroll to this section:

Database client 12c, FAN is auto-configured. This means that when the client starts, it queries the databases for the ONS

end-points automatically. The automatic configuration spans data centers. The client automatically receives an ONS

configuration from each database listed in the connection URL. No configuration of ONS is required at the client other

than enabling FAN.

The Oracle Notification Service on the database server was not running or not available.

Once the ONS was started, the TCP connections on the server itself are working normally.

The delay is corrected.

However, if a remote SQL*Plus connection continues (after confirming the ONS is up) to encounter a delay

of about 10 seconds, it may be necessary to open port 6200 on the firewall in order to allow the communication

from client to the ONS.

The problem is a 10 sec wait trying to get ONS on port 6200.

The firewall doesn't allow communication through port 6200.

Solution

  1. Configure the firewall to allow access from the client to the ONS on port 6200.

  2. Disable ONS event notifications as they are ON by default in 12c SQL*Plus client.

Oracle does not consider disabling events a "best practice" solution.

  1. Turn off notifications at the server using srvctl:

The service to which you're connecting can be modified with -notification =FALSE

srvctl modify service -d <dbname> -s <service name> -notification FALSE

See the srvctl documentation for assistance.

You can disable the ONS contact at the client using these instructions:

  1. Copy the ons_oraaccess.xml file from the database server at

$ORACLE_HOME/rdbms/demo

  1. Save the file to: ORACLE_HOME/network/admin or TNS_ADMIN

Rename the file to oraaccess.xml

The ons_oraaccess.xml file in its default state looks like this (header removed)

<oraaccess xmlns="http://xmlns.oracle.com/oci/oraaccess"

xmlns:oci="http://xmlns.oracle.com/oci/oraaccess"

schemaLocation="http://xmlns.oracle.com/oci/oraaccess

http://xmlns.oracle.com/oci/oraaccess.xsd">

<default_parameters>

<events>false</events>

</default_parameters>

</oraaccess>

  1. Make the following change to the file:
复制代码
  Go to the <default_parameters> section in the oraaccess.xml file.  You might see that you have more than 1 <default_parameters> section  but there
      is only 1 setting like:  <events>true<events>

      <default_parameters> - This element describes any default parameter settings shared across connections. These default parameters include:

       Change only this:

       FROM:

      <events>true<events>

       TO:

      <events>false<events>

3)   Check the connection again and confirm that there is no delay.  If the delay persists after this change, 
       this document may not apply to your situation and you should remove the oraaccess.xml file from the client.

So to be clear, obtain your oraaccess.xml from $ORACLE_HOME/rdbms/demo on the

server.

Copy it to your remote client's ORACLE_HOME/network/admin or TNS_ADMIN

directory.

Try the connection again after changing events from true to false:

FROM:

<events>true <events>

TO:

<events>false <events>

Once you confirm that the communication to the ONS or Oracle Notification Service is the problem, take

the necessary action.

It is an acceptable workaround to de-subscribe to the ONS using the method described here. However,

enabling events is a valuable enhancement to the Oracle client.

相关推荐
ZhengEnCi1 小时前
覆盖索引怎么设计:从回表代价到 MySQL 与 PostgreSQL 的落地写法
sql·mysql·postgresql
FungLeo4 小时前
FengCMS · PHP+MySQL 升级实录·模型导入从“加密 SQL 码“到.fengmodel.json
sql·mysql·php·工程实践·fengcms
正在走向自律5 小时前
MySQL兼容性深度实践:建表、增删改查与迁移避坑全记录
数据库·sql·mysql·信创·数据库迁移
Decay__6 小时前
PostgreSQL 体系架构全解 —— 进程模型、共享内存、MVCC 与 WAL 预写日志深入
运维·数据库·sql·mysql·架构
镰刀韭菜1 天前
用 AI 做数据分析时,怎么保住自己的思考力
sql·数据分析·学习方法·提示工程·ai应用
Databend1 天前
用 SQL 排查支付故障,OpenTelemetry 接入 Databend Cloud 实战
大数据·数据库·sql
杨凯凡1 天前
IT日报|2026-11-19:Oracle Java 紧急补丁、Optimizely 供应链攻击、GitHub 安全评估升级
java·oracle·github
Decay__2 天前
SQLServer 运维自动化平台 —— PowerShell + SQL Agent 作业:部署、监控、巡检、告警、工单闭环一体化
运维·数据库·sql·mysql·架构
星恒随风2 天前
MySQL 从零入门(十):MVCC、Undo Log 与 Read View 详解——InnoDB 如何实现事务隔离?
linux·数据库·笔记·sql·mysql
OxYGC2 天前
[Web3] 智能合约 13: 项目实战⑤ DappLink Oracle
oracle·web3·智能合约