ITPub博客

首页 > IT职业 > IT职场 > strace解决sqlplus登陆缓慢的问题一例

strace解决sqlplus登陆缓慢的问题一例

IT职场 作者:shenmingmingDBA 时间:2020-03-23 16:58:32 1 删除 编辑

 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/,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2015-03-17

  • 博文量
    42
  • 访问量
    121052