sqlplus登陆Oracle数据库出现缓慢或者错误的缘由可能不少,例如曾经碰到的,《登陆缓慢的诡异问题》、《sqlplus登陆报ORA-06502错误的问题排查和解决》,最近碰到了另一种可能。css
一台测试数据库,sqlplus登录的时候,老是很是慢,按说这种sqlplus / as sysdba本地操做系统认证登陆,应该很快才对,web
~]$ sqlplus / as sysdba 开始卡顿,大约等待5秒
Release 19.0.0.0.0 - Production on Thu Dec 17 20:57:48 2020 : Version 19.3.0.0.0
Copyright (c) 1982, 2019, Oracle. All rights reserved.
Connected to:Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - ProductionVersion 19.3.0.0.0
登录其余的库,都很快,几乎秒出,这就怪了,可是事出必有因,网上学习了下,经过strace看下能给咱们什么信息,strace会记录进程的系统调用和这个进程接收的信号值,每次系统调用的名称、参数、返回值,都会打印到标准输出或者-o选项指定的文件,sql
It intercepts and records the system calls which are called by a process and the signals which are received by a process. The name of each system call, its arguments and its return value are printed on standard error or to the file specified with the -o option.数据库
strace is a useful diagnostic, instructional, and debugging tool. System administrators, diagnosticians and trouble-shooters will find it invaluable for solving problems with programs for which the source is not readily available since they do not need to be recompiled in order to trace them. Students, hackers and the overly-curious will find that a great deal can be learned about a system and its system calls by tracing even ordinary programs. And programmers will find that since system calls and signals are events that happen at the user/kernel interface, a close examination of this boundary is very useful for bug isolation, sanity checking and attempting to capture race conditions.服务器
man strace能够看到具体可用的参数,打印出调用时间,
微信
执行以下指令,
网络
[as sysdba ]$ strace -T -t -o sqlplus.trc sqlplus /
打开sqlplus.trc,一堆内容,眼花缭乱,至少对我来讲,确实不太能看懂,可是咱们能看懂每行记录的时间,这两步操做之间,间隔了5秒,和实际操做等待很像,oracle
就是这条,等待了5秒,出现超时,
app
21:17:21 poll([{fd=9, events=POLLIN}], 1, 4991) = 0 (Timeout) <4.991529>
从上下文看,这段内容是创建了一个socket,看到有个IP,
dom
sin_addr=inet_addr("192.168.15.2")}, 16)
这个IP是DNS服务器的,
[root@bisal ~]# vi /etc/resolv.conf# Generated by NetworkManagersearch localdomainnameserver 192.168.15.2
可是咱们这台机器上没配置/etc/hosts,光是要个DNS,好像没什么用?
尝试注释resolv.conf中的IP,再次登陆,此次秒出了,并且看strace的记录,socket请求的是127.0.0.1,直接访问本地了,
同理,咱们若是配置DNS,
[root@bisal ~]# vi /etc/resolv.conf# Generated by NetworkManagersearch localdomainnameserver 192.168.15.2
同时配置/etc/hosts,
[root@bisal ~]# vi /etc/hosts127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.15.128 bisal.com bisal
sqlplus仍是很快,可是strace记录中,没出现sin_addr=inet_addr调用的IP,网络这块不太懂,若是有内行朋友,敬请指教下。
sqlplus登陆慢的问题,此次咱们用到了工具strace,虽然用的很浅,并且trace文件未必能看懂多少,可是根据时间戳,一些IP信息,能给咱们些提示,可能这就是2-8原则,咱们平常掌握的一些知识,可能不是很全面和深刻,可是每每能解决平常碰到的大部分问题,这是基础,打好了基础,才能够逐渐深刻,须要按部就班,不可好高骛远。
近期更新的文章:
《VMWare 11安装RedHat Linux 7过程当中碰到的坑》
历史文章分类和索引:
本文分享自微信公众号 - bisal的我的杂货铺(gh_e8769c7350b1)。
若有侵权,请联系 support@oschina.cn 删除。
本文参与“OSC源创计划”,欢迎正在阅读的你也加入,一块儿分享。