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源創計劃」,歡迎正在閱讀的你也加入,一塊兒分享。