[20111220]tnsnames.ora的定位.txt

lfree發表於2011-12-20
[20111220]tnsnames.ora的定位.txt

1.跟蹤在linux下sqlplus的執行過程,可以很容易定位tnsnames.ora的定位過程。

$ export TNS_ADMIN=/tmp
$ strace -o  findtnsnames.txt sqlplus scott/xxxx@noexist

$ grep -i tnsname findtnsnames.txt
access("/home/oracle/.tnsnames.ora", F_OK) = -1 ENOENT (No such file or directory)
access("/tmp/tnsnames.ora", F_OK)       = -1 ENOENT (No such file or directory)
access("/etc/tnsnames.ora", F_OK)       = -1 ENOENT (No such file or directory)
access("/u01/app/oracle/product/11.2.0/db_1/network/admin/tnsnames.ora", F_OK) = 0
stat("/u01/app/oracle/product/11.2.0/db_1/network/admin/tnsnames.ora", {st_mode=S_IFREG|0644, st_size=423, ...}) = 0
open("/u01/app/oracle/product/11.2.0/db_1/network/admin/tnsnames.ora", O_RDONLY) = 9
stat("/u01/app/oracle/product/11.2.0/db_1/network/admin/tnsnames.ora", {st_mode=S_IFREG|0644, st_size=423, ...}) = 0
stat("/u01/app/oracle/product/11.2.0/db_1/network/admin/tnsnames.ora", {st_mode=S_IFREG|0644, st_size=423, ...}) = 0
stat("/u01/app/oracle/product/11.2.0/db_1/network/admin/tnsnames.ora", {st_mode=S_IFREG|0644, st_size=423, ...}) = 0

可以確定在linux下,查詢路徑按照這個順序:
/home/oracle/.tnsnames.ora => /tmp/tnsnames.ora(TNS_ADMIN) => /etc/tnsnames.ora => $ORACLE_HOME/network/admin/tnsnames.ora

2.windows下我們可以使用sysinternal自帶的procmon.exe 工具:
set TNS_ADMIN=D:\tmp
sqlplus scott/btbtms@noexist

查詢tnsnames.ora,發現如下:

首先開啟c:\tnsnames.ora=>d:\tmp\tnsnames.ora(TNS_ADMIN) => D:\oracle\product\10.2.0\db_1\NETWORK\ADMIN\tnsnames.ora

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

相關文章