环境:
windows 2003 ,Oracle 10.2.0.5 升级
windows 2012 , Oracle 11.2.0.4 PSU 201020
现象: 版本升级后,本地/远程登录验证3-6秒
> loging / as sysdba
14:10:01 SQL> conn user/pass@orcl
已连接。
14:10:09 SQL> conn user/pass@orcl
已连接。
14:10:16 SQL> conn user/pass@orcl
已连接。
14:10:24 SQL>
排查过程记录:
第一天:
1) alert.log, listener.log , sqlnet.log, AWR/ASH 等无明显错误
2) listener.log 内有一应用,频繁连接 断开 连接的现象
3) 关闭11G下密码验证延迟, 无明显效果.
参考在MOS 上有说明:High 'library cache lock' Wait Time Due to Invalid Login Attempts(1309738.1)
第二天:
trace clent和Server的连接,发现有明显的3秒用时
ora_17040_19828.trc
----------------------------------------------------------
Description
--------------
Trace file E:\oracle\product\11.2.0\dbhome_1\log\oradiag_1111\diag\clients\user_l1284\host_3610829506_80\trace\ora_17040_19828.trc
2021-04-08 14:58:23.457326 : --- TRACE CONFIGURATION INFORMATION FOLLOWS ---
2021-04-08 14:58:23.502755 : New trace stream is E:\oracle\product\11.2.0\dbhome_1\log\oradiag_l1111\diag\clients\user_l1284\host_3610829506_80\trace\ora_17040_19828.trc
2021-04-08 14:58:23.502789 : New trace level is 16
2021-04-08 14:58:23.502811 : --- TRACE CONFIGURATION INFORMATION ENDS ---
2021-04-08 14:58:23.502841 : --- PARAMETER SOURCE INFORMATION FOLLOWS ---
2021-04-08 14:58:23.502868 : Attempted load of system pfile source E:\oracle\product\11.2.0\dbhome_1\network\admin\sqlnet.ora <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
2021-04-08 14:58:23.502889 : Parameter source loaded successfully
2021-04-08 14:58:23.503010 :
2021-04-08 14:58:23.503027 : Attempted load of local pfile source D:\sqlnet.ora
2021-04-08 14:58:23.503042 : Parameter source was not loaded
2021-04-08 14:58:23.503056 :
2021-04-08 14:58:23.503070 : -> PARAMETER TABLE LOAD RESULTS FOLLOW <-
.........
2021-04-08 14:58:23.639322 : nsbasic_brc:entry: oln/tot=0,prd=0
2021-04-08 14:58:23.639330 : nttfprd:entry <<<<<<<<<<<<<<<<<<<<<<<<<<
2021-04-08 14:58:27.362358 : nttfprd:socket 792 had bytes read=369 <<<<<<<<<<<<<<<<<<<<<<<<<<<<
2021-04-08 14:58:27.362416 : nttfprd:exit
2021-04-08 14:58:27.362427 : nsbasic_brc:type=6, plen=369
19828.txt
-------------------------------------------------------------
---> Send 256 bytes - Data packet timestamp=021-04-08 14:58:23.639016
Start of user function (TTIFUN)
Get the session key (OSESSKEY)
<--- Received 369 bytes - Data packet timestamp=021-04-08 14:58:27.362456
Return opi parameter (TTIRPA)
发现以上,找到慢所消耗时长,引起慢的原因未知....
第三天:
1) 发现oracle Service启动服务,本地系统帐号管理,现象如下
a)本地系统帐户方式
SQLNET.AUTHENTICATION_SERVICES = (NTS)
/as sysdbas可以登录 ,无法通过PLSQL工具远程连接上去。
b)此帐户指定了帐户和密码后
SQLNET.AUTHENTICATION_SERVICES = (NONE,NTS)
/as sysdbas可以登录,PLSQL工具远程连接上去。
--研究了多半天, 没有PSU补丁正常. 用了补丁本地服务就需指定帐号,之间是什么关系. 暂忽略.
--准备删除补丁来使用, 因库需要一致性的原则, 暂不考虑执行.
2) 确认审计关闭状态
--检查关闭审计(oracle 11g 默认打开审计)
alter system set audit_trail=none sid='*' scope=spfile;--说明:11g 默认打开数据库审计,
为了避免审计带来的 SYSTEM 表空间的过多占用,可以关闭审计。
--最近一年审计记录select * from aud$ where substr(sysdate-NTIMESTAMP#,2,9)<360;
--清理数据库审计truncate table sys.aud$ reuse storage;
3) TCP调度进程, 验证无效后进行了回退,对参数作用没深入理解,避免引起其它问题.
ALTER SYSTEM SET dispatchers='(PROTOCOL=TCP) (dispatchers=5)(SERVICE=initXDB)';
ALTER SYSTEM SET MAX_DISPATCHERS=5 ;
第四天
-- 使用端的压力及几天一直在折腾找原因,感觉什么什么参数都有问题.静下来...
-- 找专业人员,各种查问题....
---shared 设置
1)windows服务上的oracle是采用SHARED_SERVERS共享模式, 目前SHARED_SERVERS设置为1,
即同时1个连接,在多用户连接的场景,可能会出现连接性能问题。
2)分析连接日志,每秒连接数一般在7~10个连接。
建议:修改SHARED_SERVERS和MAX_SHARED_SERVERS次数,如下:
ALTER SYSTEM SET SHARED_SERVERS 5 ;
ALTER SYSTEM SET MAX_SHARED_SERVERS 10 ;
修改完成后,重起数据库。 性能无明显变化...
第五天:
发现大量的TIME_WAIT 连接, 占用端口超多, 猜测和TCP连接机制有关.
查询连接等待:
SELECT NAME,requests,
To_Char(busy*100/(busy+idle),'09D99') "Busy %",
status
FROM v$shared_server
WHERE status != 'QUIT'
ORDER BY 3 desc;
NAME, REQUESTS, Busy %, STATUS
S000 0 00.00 WAIT(COMMON)
Win下:
netsh int ipv4 show dynamicport tcp
netsh int ipv4 show dynamicport udp
netsh int ipv6 show dynamicport tcp
netsh int ipv6 show dynamicport udp
TCP Statistics for IPv4
Active Opens = 23047
Passive Opens = 1674397
Failed Connection Attempts = 3236
Reset Connections = 14778
Current Connections = 4400
Segments Received = 243800142
Segments Sent = 1170174053
Segments Retransmitted = 328009
参考文档: Microsoft doc , Adjust the MaxUserPort and TcpTimedWaitDelay settings
| Key: | HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters |
| Value: | TcpTimedWaitDelay |
| Data Type: | REG_DWORD |
| Range: | Windows Server 2012 and earlier: 30-300 (decimal)
Windows 8 and earlier: 30-300 (decimal) Windows Server 2012 R2 and later: 2-300 (decimal) Windows 8.1 and later: 2-300 (decimal) |
| Default value: | 0x78 (120 decimal) |
| Recommended value: | 30 |
| Value exists by default? | No, needs to |
回顾: 在整个过程中,
1) 在TRACE工具使用,给出来明确提示,在连接上明显3秒耗时,在这上面耗了较多的时间.在找资料.
2) 在服务启动上面,本地帐户管理服务的问题, 为验证正常,反复找环境多次测试.实际上只要指定权限就完全可跳过.
3) 跨版本升级, 连接数量多, 在测试验证时无明显预知,致升级后被动处理.
4) 考虑整个资源的平衡, 在DB层检测后 , 及时向外围展开来检查. 某一领域要专再综合提升.