重启Oracle监听器会中断已有连接吗

实验表明,当Oracle监听器被重启时,已存在的客户端连接不会中断,但无法建立新的连接。ORA-12516和ORA-12162错误提示分别表明无法找到匹配的协议栈和服务名配置问题。在数据库维护时,应先关闭监听器并结束会话。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

重启Oracle监听器会中断已有连接吗

问题背景

Oracle RAC架构中,重启两个数据库节点的监听器,是否会影响已经建立的客户端连接?🐒🐒

实验测试

现有两个数据库节点DB01、DB02,对应的SCAN-vipx.x.x.34,以及一个装有Oracle client的应用服务器AP01。假设数据库名为FLEXCOM,用户账号及密码为flex/xlef_101

建立一个从应用服务器到数据库的连接。登录AP01执行:

su - oracle
sqlplus flex/xlef_101@x.x.x.34:1521/FLEXCOM

登录成功。

依次停止两个数据库节点的监听器:

ssh $DB01_IP
su - grid
lsnrctl stop

ssh $DB02_IP
su - grid
lsnrctl stop

测试已有的连接是否断开。回到AP01起先建立的会话,尝试执行SQL语句:

show parameter session;
select grantee,privilege from dba_sys_privs where grantee='XXX';

SQL语句执行成功,可见停止监听器对已经建立的会话没有影响。

测试是否可以建立新的连接:

su - oracle
sqlplus flex/xlef_101@x.x.x.34:1521/FLEXCOM
ERROR: ORA-12516: TNS:listener could not find available handler with matching protocol stack
Enter user-name:
Enter password:
ERROR: ORA-12162: TNS:net service name is incorrectly specified

可见,停止监听器后,无法再建立新的客户端连接。

启动两个数据库节点的监听器:

ssh $DB01_IP
su - grid
lsnrctl start

ssh $DB02_IP
su - grid
lsnrctl start

检查监听器状态:

lsnrctl status

综上可知,当客户端成功连接到Oracle数据库后,重启监听器并不会中断已有的连接;只是无法建立新的连接。因此,在数据库升级、重启等过程中,需要先停掉监听器,然后杀掉已有的会话连接。

报错分析

在停止监听器后,尝试连接数据库时,我们收到了两个报错信息:ORA-12516ORA-12162

ORA-12516: TNS:listener could not find available handler with matching protocol stack
Cause: None of the known and available service handlers for the given SERVICE_NAME support the client’s protocol stack: transport, session, and presentation protocols.
Action: Check to make sure that the service handlers (e.g. dispatchers) for the given SERVICE_NAME are registered with the listener, are accepting connections, and that they are properly configured to support the desired protocols.

ORA-12516是由于我们停止了数据库的监听器造成的。

ORA-12162: TNS:net service name is incorrectly specified
Cause: The connect descriptor corresponding to the net service name in TNSNAMES.ORA or in the directory server (Oracle Internet Directory) is incorrectly specified.
Action: If using local naming make sure there are no syntax errors in the corresponding connect descriptor in the TNSNAMES.ORA file. If using directory naming check the information provided through the administration used for directory naming. If using ORACLE_SID, please check if ORACLE_SID is// set.

ORA-12612是因为我们没有在Oracle client服务器配置tnsnames.ora导致的。

References
【1】Database error maessages

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

GottdesKrieges

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值