strace解決sqlplus登陸緩慢的問題一例

shenmingmingDBA發表於2020-03-23

 strace -T -t -o /tmp/nohost sqlplus / as sysdba

檢視/tmp/nohost內容,此處省略部分內容


  1. 10:05:39 munmap(0x7fb66c71c000, 404774) = 0 <0.000082>
  2. 10:05:39 socket(PF_INET, SOCK_DGRAM|SOCK_NONBLOCK, IPPROTO_IP) = 9 <0.000094>
  3. 10:05:39 connect(9, {sa_family=AF_INET, sin_port=htons(53), sin_addr=inet_addr("221.228.255.1")}, 16) = 0 <0.000076>
  4. 10:05:39 poll([{fd=9, events=POLLOUT}], 1, 0) = 1 ([{fd=9, revents=POLLOUT}]) <0.000061>
  5. 10:05:39 sendto(9, "\23\232\1\0\0\1\0\0\0\0\0\0\5test8\0\0\1\0\1", 23, MSG_NOSIGNAL, NULL, 0) = 23 <0.000201>
  6. 10:05:39 poll([{fd=9, events=POLLIN|POLLOUT}], 1, 5000) = 1 ([{fd=9, revents=POLLOUT}]) <0.000062>
  7. 10:05:39 sendto(9, "\3d\1\0\0\1\0\0\0\0\0\0\5test8\0\0\34\0\1", 23, MSG_NOSIGNAL, NULL, 0) = 23 <0.000098>
  8. 10:05:39 poll([{fd=9, events=POLLIN}], 1, 4998) = 1 ([{fd=9, revents=POLLIN}]) <0.006345>
  9. 10:05:39 ioctl(9, FIONREAD, [39]) = 0 <0.000063>
  10. 10:05:39 recvfrom(9, "\23\232\201\200\0\1\0\1\0\0\0\0\5test8\0\0\1\0\1\300\f\0\1\0\1\0\0\0"..., 2048, 0, {sa_family=AF_INET, sin_port=htons(53), sin_addr=inet_addr("221.228.255.1")}, [16]) = 39 <0.000096>
  11. 10:05:39 poll([{fd=9, events=POLLIN}], 1, 4991) = 0 (Timeout) <4.996143>
  12. 10:05:44 poll([{fd=9, events=POLLOUT}], 1, 0) = 1 ([{fd=9, revents=POLLOUT}]) <0.000100>
  13. 10:05:44 sendto(9, "\23\232\1\0\0\1\0\0\0\0\0\0\5test8\0\0\1\0\1", 23, MSG_NOSIGNAL, NULL, 0) = 23 <0.000198>
  14. 10:05:44 poll([{fd=9, events=POLLIN}], 1, 5000) = 1 ([{fd=9, revents=POLLIN}]) <0.006851>
  15. 10:05:44 ioctl(9, FIONREAD, [39]) = 0 <0.000151>
  16. 10:05:44 recvfrom(9, "\23\232\201\200\0\1\0\1\0\0\0\0\5test8\0\0\1\0\1\300\f\0\1\0\1\0\0\0"..., 2048, 0, {sa_family=AF_INET, sin_port=htons(53), sin_addr=inet_addr("221.228.255.1")}, [16]) = 39 <0.000107>
  17. 10:05:44 poll([{fd=9, events=POLLOUT}], 1, 4990) = 1 ([{fd=9, revents=POLLOUT}]) <0.000088>
  18. 10:05:44 sendto(9, "\3d\1\0\0\1\0\0\0\0\0\0\5test8\0\0\34\0\1", 23, MSG_NOSIGNAL, NULL, 0) = 23 <0.000120>
  19. 10:05:44 poll([{fd=9, events=POLLIN}], 1, 4990) = 1 ([{fd=9, revents=POLLIN}]) <0.008139>
  20. 10:05:44 ioctl(9, FIONREAD, [98]) = 0 <0.000074>
  21. 10:05:44 recvfrom(9, "\3d\201\203\0\1\0\0\0\1\0\0\5test8\0\0\34\0\1\0\0\6\0\1\0\0\35\17"..., 2009, 0, {sa_family=AF_INET, sin_port=htons(53), sin_addr=inet_addr("221.228.255.1")}, [16]) = 98 <0.000084>
  22. 10:05:44 close(9) = 0 <0.000143>
  23. 10:05:44 open("/etc/hostid", O_RDONLY) = -1 ENOENT (No such file or directory) <0.000095>
  24. 10:05:44 uname({sys="Linux", node="test8", ...}) = 0 <0.000061>

    問題已經浮出水面了,耗時最長的一步是


    而且卡在此處足足有5s,而且最終超時,根據上下文判斷,此處是一個socket連線,而且還涉及到dns伺服器的地址,由此推斷應該和解析有關

    檢視/etc/resolv.conf



    可見配置了dns,其實我將dns註釋掉之後sqlplus就恢復了正常,但dns不應該成為導致此問題的根本原因,此處明顯是去dns上解析本機了

    再來看/etc/hosts


    再重新查閱了hosts的正確配置之後發現我的hosts配置方法是錯誤的


    我的主機名是test8,在我測試郵件的時候,為了騙過郵件伺服器,我把hosts裡解析隨意加了個域名,卻從未正式瞭解過hosts的配置方法,現在正確配置一下



    再測試sqlplus,已經恢復正常

  25. 10:05:39 poll([{fd=9, events=POLLIN}], 1, 4991) = 0 (Timeout) <4.996143>
    1. [root@test8 etc]# cat /etc/resolv.conf
    2. # Generated by NetworkManager
    3. #nameserver 221.228.255.1
    4. nameserver 221.228.255.1
    5. nameserver 218.2.135.1
    1. [root@test8 etc]# cat /etc/hosts
    2. 127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
    3. ::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
    4. 192.168.1.8 test8.com
    5. 192.168.1.29 oem.oracle.com
    1. 格式:
    2.   一般情況下hosts的內容關於主機名(hostname)的定義,每行為一個主機,每行由三部份組成,每個部份由空格隔開。其中#號開頭的行做說明,不被系統解釋。
    3.   第一部份:網路IP地址;
    4.   第二部份:主機名.域名,注意主機名和域名之間有個半形的點,比如 localhost.localdomain
    5.   第二部份:主機名(主機名別名) ,其實就是主機名;
    1. [root@test8 etc]# cat /etc/hosts
    2. 127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
    3. ::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
    4. 192.168.1.8 test8.com test8
    5. 192.168.1.29 oem.oracle.com


來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/30166976/viewspace-2682096/,如需轉載,請註明出處,否則將追究法律責任。

相關文章