使用作業系統命令來trace監聽,trace監聽
strace tnsping prod
strace tnsping prod 2>&1 | less
strace -eopen tnsping prod 2>&1 | grep '= -1'
strace tnsping prod 2>&1 >/dev/null | grep -E '^stat|^open'
strace -e trace=access,open,stat tnsping no-such-sid 2>&1 >/dev/null | grep '\.ora' | cut -f2 -d\" | sort |uniq -c
strace -e trace=access,open,stat tnsping no-such-sid prod 2>&1 >/dev/null | grep '\.ora' | cut -f2 -d\" | sort |uniq -c
[oracle@rh64 ~]$ strace -eopen tnsping prod 2>&1 | grep '= -1'
open("/u01/app/oracle/product/11.2.0/dbhome_1/lib/tls/x86_64/libclntsh.so.11.1", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/u01/app/oracle/product/11.2.0/dbhome_1/lib/tls/libclntsh.so.11.1", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/u01/app/oracle/product/11.2.0/dbhome_1/lib/x86_64/libclntsh.so.11.1", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/u01/app/oracle/product/11.2.0/dbhome_1/lib/libdl.so.2", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/u01/app/oracle/product/11.2.0/dbhome_1/lib/libdl.so.2", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/u01/app/oracle/product/11.2.0/dbhome_1/lib32/tls/x86_64/libdl.so.2", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/u01/app/oracle/product/11.2.0/dbhome_1/lib32/tls/libdl.so.2", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/u01/app/oracle/product/11.2.0/dbhome_1/lib32/x86_64/libdl.so.2", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/u01/app/oracle/product/11.2.0/dbhome_1/lib32/libdl.so.2", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/u01/app/oracle/product/11.2.0/dbhome_1/lib/libm.so.6", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/u01/app/oracle/product/11.2.0/dbhome_1/lib/libm.so.6", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/u01/app/oracle/product/11.2.0/dbhome_1/lib/libpthread.so.0", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/u01/app/oracle/product/11.2.0/dbhome_1/lib/libpthread.so.0", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/u01/app/oracle/product/11.2.0/dbhome_1/lib/libnsl.so.1", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/u01/app/oracle/product/11.2.0/dbhome_1/lib/libnsl.so.1", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/u01/app/oracle/product/11.2.0/dbhome_1/lib/libc.so.6", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/u01/app/oracle/product/11.2.0/dbhome_1/lib/libc.so.6", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/u01/app/oracle/product/11.2.0/dbhome_1/lib/libaio.so.1", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/u01/app/oracle/product/11.2.0/dbhome_1/lib/libaio.so.1", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/u01/app/oracle/product/11.2.0/dbhome_1/lib/libaio.so.1", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/u01/app/oracle/product/11.2.0/dbhome_1/lib/libociei.so", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/u01/app/oracle/product/11.2.0/dbhome_1/lib/libociicus.so", O_RDONLY) = -1 ENOENT (No such file or directory)
[oracle@rh64 ~]$ strace tnsping prod 2>&1 >/dev/null | grep -E '^stat|^open'
open("/u01/app/oracle/product/11.2.0/dbhome_1/lib/tls/x86_64/libclntsh.so.11.1", O_RDONLY) = -1 ENOENT (No such file or directory)
stat("/u01/app/oracle/product/11.2.0/dbhome_1/lib/tls/x86_64", 0x7ffff9beb660) = -1 ENOENT (No such file or directory)
open("/u01/app/oracle/product/11.2.0/dbhome_1/lib/tls/libclntsh.so.11.1", O_RDONLY) = -1 ENOENT (No such file or directory)
stat("/u01/app/oracle/product/11.2.0/dbhome_1/lib/tls", 0x7ffff9beb660) = -1 ENOENT (No such file or directory)
open("/u01/app/oracle/product/11.2.0/dbhome_1/lib/x86_64/libclntsh.so.11.1", O_RDONLY) = -1 ENOENT (No such file or directory)
stat("/u01/app/oracle/product/11.2.0/dbhome_1/lib/x86_64", 0x7ffff9beb660) = -1 ENOENT (No such file or directory)
open("/u01/app/oracle/product/11.2.0/dbhome_1/lib/libclntsh.so.11.1", O_RDONLY) = 3
open("/u01/app/oracle/product/11.2.0/dbhome_1/lib/libnnz11.so", O_RDONLY) = 3
open("/u01/app/oracle/product/11.2.0/dbhome_1/lib/libdl.so.2", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/u01/app/oracle/product/11.2.0/dbhome_1/lib/libdl.so.2", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/u01/app/oracle/product/11.2.0/dbhome_1/lib32/tls/x86_64/libdl.so.2", O_RDONLY) = -1 ENOENT (No such file or directory)
stat("/u01/app/oracle/product/11.2.0/dbhome_1/lib32/tls/x86_64", 0x7ffff9beb600) = -1 ENOENT (No such file or directory)
open("/u01/app/oracle/product/11.2.0/dbhome_1/lib32/tls/libdl.so.2", O_RDONLY) = -1 ENOENT (No such file or directory)
stat("/u01/app/oracle/product/11.2.0/dbhome_1/lib32/tls", 0x7ffff9beb600) = -1 ENOENT (No such file or directory)
open("/u01/app/oracle/product/11.2.0/dbhome_1/lib32/x86_64/libdl.so.2", O_RDONLY) = -1 ENOENT (No such file or directory)
stat("/u01/app/oracle/product/11.2.0/dbhome_1/lib32/x86_64", 0x7ffff9beb600) = -1 ENOENT (No such file or directory)
open("/u01/app/oracle/product/11.2.0/dbhome_1/lib32/libdl.so.2", O_RDONLY) = -1 ENOENT (No such file or directory)
stat("/u01/app/oracle/product/11.2.0/dbhome_1/lib32", 0x7ffff9beb600) = -1 ENOENT (No such file or directory)
open("/etc/ld.so.cache", O_RDONLY) = 3
open("/lib64/libdl.so.2", O_RDONLY) = 3
open("/u01/app/oracle/product/11.2.0/dbhome_1/lib/libm.so.6", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/u01/app/oracle/product/11.2.0/dbhome_1/lib/libm.so.6", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/lib64/libm.so.6", O_RDONLY) = 3
open("/u01/app/oracle/product/11.2.0/dbhome_1/lib/libpthread.so.0", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/u01/app/oracle/product/11.2.0/dbhome_1/lib/libpthread.so.0", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/lib64/libpthread.so.0", O_RDONLY) = 3
open("/u01/app/oracle/product/11.2.0/dbhome_1/lib/libnsl.so.1", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/u01/app/oracle/product/11.2.0/dbhome_1/lib/libnsl.so.1", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/lib64/libnsl.so.1", O_RDONLY) = 3
open("/u01/app/oracle/product/11.2.0/dbhome_1/lib/libc.so.6", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/u01/app/oracle/product/11.2.0/dbhome_1/lib/libc.so.6", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/lib64/libc.so.6", O_RDONLY) = 3
open("/u01/app/oracle/product/11.2.0/dbhome_1/lib/libaio.so.1", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/u01/app/oracle/product/11.2.0/dbhome_1/lib/libaio.so.1", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/u01/app/oracle/product/11.2.0/dbhome_1/lib/libaio.so.1", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/lib64/libaio.so.1", O_RDONLY) = 3
open("/u01/app/oracle/product/11.2.0/dbhome_1/lib/libociei.so", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/u01/app/oracle/product/11.2.0/dbhome_1/lib/libociicus.so", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/u01/app/oracle/product/11.2.0/dbhome_1/nls/data/lx1boot.nlb", O_RDONLY) = 3
open("/u01/app/oracle/product/11.2.0/dbhome_1/nls/data/lx00001.nlb", O_RDONLY) = 3
open("/u01/app/oracle/product/11.2.0/dbhome_1/nls/data/lx20001.nlb", O_RDONLY) = 3
open("/u01/app/oracle/product/11.2.0/dbhome_1/nls/data/lx10001.nlb", O_RDONLY) = 3
open("/u01/app/oracle/product/11.2.0/dbhome_1/nls/data/lx40011.nlb", O_RDONLY) = 3
open("/etc/localtime", O_RDONLY) = 3
stat("/u01/app/oracle/product/11.2.0/dbhome_1/network/admin/tnsnames.ora", {st_mode=S_IFREG|0644, st_size=166, ...}) = 0
open("/u01/app/oracle/product/11.2.0/dbhome_1/network/admin/tnsnames.ora", O_RDONLY) = 3
open("/u01/app/oracle/product/11.2.0/dbhome_1/network/mesg/tnsus.msb", O_RDONLY) = 3
open("/u01/app/oracle/product/11.2.0/dbhome_1/lib/libnque11.so", O_RDONLY) = 4
[oracle@rh64 ~]$
[oracle@rh64 ~]$ strace -e trace=access,open,stat tnsping no-such-sid prod 2>&1 >/dev/null | grep '\.ora' | cut -f2 -d\" | sort |uniq -c
1 /etc/tnsnames.ora
1 /home/oracle/.tnsnames.ora
1 /u01/app/oracle/product/11.2.0/dbhome_1/ldap/admin/fips.ora
1 /u01/app/oracle/product/11.2.0/dbhome_1/ldap/admin/ldap.ora
1 /u01/app/oracle/product/11.2.0/dbhome_1/network/admin/ldap.ora
2 /u01/app/oracle/product/11.2.0/dbhome_1/network/admin/sqlnet.ora
3 /u01/app/oracle/product/11.2.0/dbhome_1/network/admin/tnsnames.ora
著作權聲明:本文為博主原創文章,未經博主允許不得轉載。