[20141229]配置tnsnames.ora使用rsp檔案.txt
--大部配置設定置tnsnames.ora,特别是伺服器都是直接編輯,使用copy & paste.
--我個人特别讨厭copy & paste 使用vim出現階梯顯示的情況,特别讨厭,我多次跟我同僚在copy & paste設定:set paste來避免這種情況.
--但是就是不改,按照他們的道理這樣做是能正常通路的.
--如果能看看我以前寫的
<a href="http://blog.itpub.net/267265/viewspace-762224/">http://blog.itpub.net/267265/viewspace-762224/</a>
--下面講解如何編寫rsp檔案,實際上很簡單,參考netca.rsp的寫法就知道如何配置了.自己做一個測試:
SYS@test> @ver1
PORT_STRING VERSION BANNER
------------------------------ -------------- --------------------------------------------------------------------------------
x86_64/Linux 2.4.xx 11.2.0.3.0 Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
--測試先備份一下原來的tnsnames.ora配置.
$ cd /u01/app/oracle11g/product/11.2.0/db_2/network/admin
$ mv tnsnames.ora tnsnames.ora_20141229
$ mv sqlnet.ora sqlnet.ora_20141229
--建立rsp檔案netcatest.rsp,主要是後面部分:
##################### netca.rsp ######################
[GENERAL]
RESPONSEFILE_VERSION="11.2"
CREATE_TYPE="CUSTOM"
[oracle.net.ca]
INSTALL_TYPE=""custom""
NAMING_METHODS={"TNSNAMES","HOSTNAME","EZCONNECT"}
#--------------- Modify settings in this section ---------------
NSN_NUMBER=2
NSN_NAMES={"40","TESTdG"}
NSN_SERVICE={"test.com","test.com"}
NSN_PROTOCOLS={"TCP;192.168.100.40;1521","TCP;192.168.101.115;1521"}
#---------------------------------------------------------------
#######################################################
--執行如下:
$ netca -silent -responseFile /home/oracle11g/teste/netcatest.rsp
Parsing command line arguments:
Parameter "silent" = true
Parameter "responsefile" = /home/oracle11g/teste/netcatest.rsp
Done parsing command line arguments.
Oracle Net Services Configuration:
Default local naming configuration complete.
Created net service name: 40
Created net service name: TESTdG
Profile configuration complete.
Oracle Net Services configuration successful. The exit code is 0
--注意rsp檔案必須要使用全路徑.檢查結果.
$ cat tnsnames.ora
# tnsnames.ora Network Configuration File: /u01/app/oracle11g/product/11.2.0/db_2/network/admin/tnsnames.ora
# Generated by Oracle configuration tools.
40 =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.100.40)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = test.com)
)
TESTDG =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.101.115)(PORT = 1521))
--說明:我故意把TESTDG的d小寫,配置後是大寫.
$ cat sqlnet.ora
# sqlnet.ora Network Configuration File: /u01/app/oracle11g/product/11.2.0/db_2/network/admin/sqlnet.ora
NAMES.DIRECTORY_PATH= (TNSNAMES, HOSTNAME, EZCONNECT)
ADR_BASE = /u01/app/oracle11g
--測試也可以通過.
--如果你增加,修改配置都可以重複執行.留給大家測試了.