‘lsnrctl status’ could not display the status of running listener correctly

NeilZhang
NeilZhang
管理员
140
文章
106.8千
浏览
Linux Oracle1 1,101字数 699阅读2分19秒阅读模式

My friend got this issue and wanted to know the reason, so I built a test VM to verify it.

The dbss scirpt was used to start their instances and he found if he run 'dbss start' then he could get the correct information about listener:

  1. oracle@linux-ryjt:~> lsnrctl status
  2.  
  3. LSNRCTL for Linux: Version 12.1.0.2.0 - Production on 10-JUN-2018 22:47:47
  4.  
  5. Copyright (c) 1991, 2014, Oracle. All rights reserved.
  6.  
  7. Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=linux-ryjt)(PORT=1521)))
  8. STATUS of the LISTENER
  9. ------------------------
  10. Alias LISTENER
  11. Version TNSLSNR for Linux: Version 12.1.0.2.0 - Production
  12. Start Date 10-JUN-2018 22:08:46
  13. Uptime 0 days 0 hr. 39 min. 0 sec
  14. Trace Level off
  15. Security ON: Local OS Authentication
  16. SNMP OFF
  17. Listener Parameter File /u01/app/oracle/product/12.1.0/dbhome_1/network/admin/listener.ora
  18. Listener Log File /u01/app/oracle/diag/tnslsnr/linux-ryjt/listener/alert/log.xml
  19. Listening Endpoints Summary...
  20. (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=linux-ryjt)(PORT=1521)))
  21. (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
  22. (DESCRIPTION=(ADDRESS=(PROTOCOL=tcps)(HOST=linux-ryjt)(PORT=5500))(Security=(my_wallet_directory=/u01/app/oracle/admin/orcl/xdb_wallet))(Presentation=HTTP)(Session=RAW))
  23. Services Summary...
  24. Service "orcl" has 1 instance(s).
  25. Instance "orcl", status READY, has 1 handler(s) for this service...
  26. Service "orclXDB" has 1 instance(s).
  27. Instance "orcl", status READY, has 1 handler(s) for this service...
  28. Service "pdborcl" has 1 instance(s).
  29. Instance "orcl", status READY, has 1 handler(s) for this service...
  30. The command completed successfully

While if he run 'systemctl start dbss' then would get below error:

  1. oracle@linux-ryjt:~> lsnrctl status
  2.  
  3. LSNRCTL for Linux: Version 12.1.0.2.0 - Production on 10-JUN-2018 20:26:07
  4.  
  5. Copyright (c) 1991, 2014, Oracle. All rights reserved.
  6.  
  7. Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=linux-ryjt)(PORT=1521)))
  8. TNS-12541: TNS:no listener
  9. TNS-12560: TNS:protocol adapter error
  10. TNS-00511: No listener
  11. Linux Error: 2: No such file or directory
  12. Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1521)))
  13. TNS-12541: TNS:no listener
  14. TNS-12560: TNS:protocol adapter error
  15. TNS-00511: No listener
  16. Linux Error: 2: No such file or directory

And below was the config file of systemd service:

  1. cat /usr/lib/systemd/system/dbss.service
  2. [Unit]
  3. Description=Oracle
  4. After=network.target
  5.  
  6. [Service]
  7. Type=oneshot
  8. #PIDFile=/users/oracle/dbss.pid
  9. ExecStart=/usr/bin/dbss.sh start
  10. ExecReload=
  11. ExecStop=/usr/bin/dbss.sh stop
  12. PrivateTmp=true
  13. RemainAfterExit=true
  14.  
  15. [Install]
  16. WantedBy=multi-user.target

At the beginning I did not use his config file as the dbss script would generate one automatically, and I could not reproduce this issue, so I knew this issue was caused by his config file.

At the same time, I found below information from the strace file:

  1. 11323 read(7, "\0>\0\0\5\0\0\0\0004(DESCRIPTION=(ADDRESS="..., 8208) = 62
  2. 11323 setsockopt(7, SOL_SOCKET, SO_SNDTIMEO, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0", 16) = 0
  3. 11323 setsockopt(7, SOL_SOCKET, SO_RCVTIMEO, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0", 16) = 0
  4. 11323 close(7) = 0
  5. 11323 access("/var/tmp/.oracle", F_OK) = 0
  6. 11323 chmod("/var/tmp/.oracle", 01777) = -1 EPERM (Operation not permitted)
  7. 11323 socket(PF_LOCAL, SOCK_STREAM, 0) = 7
  8. 11323 access("/var/tmp/.oracle/s#10374.2", F_OK) = -1 ENOENT (No such file or directory)
  9. 11323 access("/var/tmp/o/s#10374.2", F_OK) = -1 ENOENT (No such file or directory)
  10. 11323 close(7) = 0
  11. 11323 lseek(6, 40448, SEEK_SET) = 40448
  12. 11323 read(6, "\16\0\3610\0\0\\\0\3630\0\0\231\0\3640\0\0\263\0\3650\0\0\307\0\3660\0\0\345\0"..., 512) = 512
  13. 11323 lseek(6, 41472, SEEK_SET) = 41472
  14. 11323 read(6, "\21\0\0201\0\0n\0\0211\0\0\210\0\0221\0\0\231\0\0241\0\0\256\0\0261\0\0\304\0"..., 512) = 512
  15. 11323 lseek(6, 14336, SEEK_SET) = 14336
  16. 11323 read(6, "\17\0;\1\0\0b\0<\1\0\0\250\0=\1\0\0\314\0\365\1\0\0\360\0\366\1\0\0\6\1"..., 512) = 512
  17. 11323 write(1, "TNS-12541: TNS:no listener\n TNS-"..., 136) = 136
  18. 11323 lseek(6, 18944, SEEK_SET) = 18944
  19. 11323 read(6, "\17\0\23\4\0\0b\0\24\4\0\0z\0\25\4\0\0\243\0\26\4\0\0\320\0\27\4\0\0\363\0"..., 512) = 512
  20. 11323 write(1, "Connecting to (DESCRIPTION=(ADDR"..., 70) = 70
  21. 11323 socket(PF_LOCAL, SOCK_STREAM, 0) = 7
  22. 11323 access("/var/tmp/.oracle/sEXTPROC1521", F_OK) = -1 ENOENT (No such file or directory)
  23. 11323 access("/var/tmp/o/sEXTPROC1521", F_OK) = -1 ENOENT (No such file or directory)
  24. 11323 close(7) = 0
  25. 11323 lseek(6, 40448, SEEK_SET) = 40448
  26. 11323 read(6, "\16\0\3610\0\0\\\0\3630\0\0\231\0\3640\0\0\263\0\3650\0\0\307\0\3660\0\0\345\0"..., 512) = 512
  27. 11323 lseek(6, 41472, SEEK_SET) = 41472
  28. 11323 read(6, "\21\0\0201\0\0n\0\0211\0\0\210\0\0221\0\0\231\0\0241\0\0\256\0\0261\0\0\304\0"..., 512) = 512
  29. 11323 lseek(6, 14336, SEEK_SET) = 14336
  30. 11323 read(6, "\17\0;\1\0\0b\0<\1\0\0\250\0=\1\0\0\314\0\365\1\0\0\360\0\366\1\0\0\6\1"..., 512) = 512
  31. 11323 write(1, "TNS-12541: TNS:no listener\n TNS-"..., 136) = 136

And also I found I could access the database using ezconnect.

I remembered listener should create some socket files under /tmp/.oracle or /var/tmp/.oracle, but from the strace file we could not find such files and got the 'TNS-12541: TNS:no listener' error.

I rechecked his config file and found there was one option 'PrivateTmp=true' and I seldom used it, so Google helped me:

  1. PrivateTmp=
  2. Takes a boolean argument. If true sets up a new file system
  3. namespace for the executed processes and mounts a private /tmp
  4. directory inside it, that is not shared by processes outside of
  5. the namespace. This is useful to secure access to temporary files
  6. of the process, but makes sharing between processes via /tmp
  7. impossible. Defaults to false.

So I removed it and tested all the things again, now the listener worked well. ‘lsnrctl status’ could not display the status of running listener correctly

 
  • 本文由 NeilZhang 发表于11/06/2018 04:55:36
  • Repost please keep this link: https://www.dbcloudsvc.com/blogs/linux/lsnrctl-status-could-not-display-the-status-of-running-listener-correctly/
    • Rainny
      Rainny 0

      Very appreciate for this test and I will deploy it as soon as possible, thank you my good friend!

    匿名

    发表评论

    匿名网友
    :?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:
    确定