Listener — Linux Error: 2: No such file or directory

The other day I was working on a system and noticed an interesting thing — while the listener was stopped, if I ran “lsnrctl status” and I got the following errors:

TNS-12541: TNS:no listener
 TNS-12560: TNS:protocol adapter error
  TNS-00511: No listener
   Linux Error: 2: No such file or directory

It said “No listener” was expected, but I didn’t remember I had seen the error “No such file or directory” before. That made me wonder what lsnrctl command was looking for.

So I used the command strace to check what files were being opened.

[oracle@joetest dbinstall]$ strace -o /tmp/output.txt lsnrctl status

From the output file, I could see it complained quite some lib files:

openat(AT_FDCWD, "/opt/oracle/190000/lib/glibc-hwcaps/x86-64-v3/libclntsh.so.19.1", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/opt/oracle/190000/lib/glibc-hwcaps/x86-64-v3", 0x7ffc89a32a00) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/opt/oracle/190000/lib/glibc-hwcaps/x86-64-v2/libclntsh.so.19.1", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/opt/oracle/190000/lib/glibc-hwcaps/x86-64-v2", 0x7ffc89a32a00) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/opt/oracle/190000/lib/tls/haswell/x86_64/libclntsh.so.19.1", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/opt/oracle/190000/lib/tls/haswell/x86_64", 0x7ffc89a32a00) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/opt/oracle/190000/lib/tls/haswell/libclntsh.so.19.1", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/opt/oracle/190000/lib/tls/haswell", 0x7ffc89a32a00) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/opt/oracle/190000/lib/tls/x86_64/libclntsh.so.19.1", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/opt/oracle/190000/lib/tls/x86_64", 0x7ffc89a32a00) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/opt/oracle/190000/lib/tls/libclntsh.so.19.1", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/opt/oracle/190000/lib/tls", 0x7ffc89a32a00) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/opt/oracle/190000/lib/haswell/x86_64/libclntsh.so.19.1", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/opt/oracle/190000/lib/haswell/x86_64", 0x7ffc89a32a00) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/opt/oracle/190000/lib/haswell/libclntsh.so.19.1", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/opt/oracle/190000/lib/haswell", 0x7ffc89a32a00) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/opt/oracle/190000/lib/x86_64/libclntsh.so.19.1", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/opt/oracle/190000/lib/x86_64", 0x7ffc89a32a00) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/opt/oracle/190000/lib/libdl.so.2", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/opt/oracle/190000/lib/libm.so.6", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/opt/oracle/190000/lib/libpthread.so.0", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/opt/oracle/190000/lib/libnsl.so.1", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/opt/oracle/190000/lib/librt.so.1", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/opt/oracle/190000/lib/libaio.so.1", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/opt/oracle/190000/lib/libresolv.so.2", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/opt/oracle/190000/lib/libc.so.6", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/opt/oracle/190000/lib/libnss_files.so.2", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/opt/oracle/190000/lib/libociei.so", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/opt/oracle/190000/lib/libociicus.so", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)

Initially I thought that’s it, those lib files were missing. But another thought would be why it doesn’t complian when the listener is running. So I checked the output file again and focused on “No such file or directory” message after “No listener” message, it actually complained about the following files:

write(1, "TNS-12541: TNS:no listener\n TNS-"..., 131) = 131
write(1, "TNS-12541: TNS:no listener\n TNS-"..., 136) = 136

access("/var/tmp/.oracle/sREGISTER", F_OK) = -1 ENOENT (No such file or directory)
access("/var/tmp/o/sREGISTER", F_OK)    = -1 ENOENT (No such file or directory)

Now it makes sense. The error was about the file “sREGISTER” which is a socket file. When the listener is running, it creates the socket file, that’s why it doesn’t complain about it. If the listener is stopped, the socket file is removed, then “lsnrctl status” will complain it which should be ignored.

The following shows socket files created when a listener is running, noting files has permissions starting with “s” which means it’s a socket file.

[oracle@joetest tmp]$ ls -l /var/tmp/.oracle/
total 0
srwxrwxrwx. 1 oracle oinstall 0 Mar  9 05:38 s#3898952.1
srwxrwxrwx. 1 oracle oinstall 0 Mar  9 05:38 s#3898952.2
srwxrwxrwx. 1 oracle oinstall 0 Mar  9 05:38 sREGISTER

BTW, to create a socket file from bash, we can use python. For example:

[oracle@joetest tmp]$ python3.6 -c "import socket as s; sock = s.socket(s.AF_UNIX); sock.bind('/tmp/somesocket')"

[oracle@joetest tmp]$ ls -l /tmp/somesocket
srwxr-x---. 1 oracle oinstall 0 Mar 22 08:19 /tmp/somesocket


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s