sqlplus登录缓慢的解决 您所在的位置:网站首页 tim登录很慢 sqlplus登录缓慢的解决

sqlplus登录缓慢的解决

2024-07-01 03:41| 来源: 网络整理| 查看: 265

sqlplus登录Oracle数据库出现缓慢或者错误的原因可能很多,例如曾经碰到的,《登录缓慢的诡异问题》、《sqlplus登录报ORA-06502错误的问题排查和解决》,最近碰到了另外一种可能。

一台测试数据库,sqlplus登陆的时候,总是非常慢,按说这种sqlplus / as sysdba本地操作系统认证登录,应该很快才对,

[oracle@bisal ~]$ sqlplus / as sysdba 开始卡顿,大约等待5秒 SQL*Plus: 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 - Production Version 19.3.0.0.0

登陆其他的库,都很快,几乎秒出,这就怪了,但是事出必有因,网上学习了下,通过strace看下能给我们什么信息,strace会记录进程的系统调用和这个进程接收的信号值,每次系统调用的名称、参数、返回值,都会打印到标准输出或者-o选项指定的文件,

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可以看到具体可用的参数,打印出调用时间,

执行如下指令,

[oracle@bisal ~]$ strace -T -t -o sqlplus.trc sqlplus / as sysdba

打开sqlplus.trc,一堆内容,眼花缭乱,至少对我来说,确实不太能看懂,但是我们能看懂每行记录的时间,这两步操作之间,间隔了5秒,和实际操作等待很像,

就是这条,等待了5秒,出现超时,

21:17:21 poll([{fd=9, events=POLLIN}], 1, 4991) = 0 (Timeout)

从上下文看,这段内容是建立了一个socket,看到有个IP,

sin_addr=inet_addr("192.168.15.2")}, 16)

这个IP是DNS服务器的,

[root@bisal ~]# vi /etc/resolv.conf # Generated by NetworkManager search localdomain nameserver 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 NetworkManager search localdomain nameserver 192.168.15.2

同时配置/etc/hosts,

[root@bisal ~]# vi /etc/hosts 127.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过程中碰到的坑》

《Oracle 11g的examples静默安装》

《同名的同义词和视图解惑》

《v$和v_$的一些玄机》

历史文章分类和索引:

《公众号700篇文章分类和索引》



【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

    专题文章
      CopyRight 2018-2019 实验室设备网 版权所有