[20141229]配置tnsnames.ora使用rsp文件.txt
--大部分配置tnsnames.ora,特别是服务器都是直接编辑,使用copy & paste.
--我个人特别讨厌copy & paste 使用vim出现阶梯显示的情况,特别讨厌,我多次跟我同事在copy & paste设置:set paste来避免这种情况.
--但是就是不改,按照他们的道理这样做是能正常访问的.
--如果能看看我以前写的
http://blog.itpub.net/267265/viewspace-762224/
--下面讲解如何编写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
Default local naming configuration complete.
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 =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.101.115)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = test.com)
)
)
--说明:我故意把TESTDG的d小写,配置后是大写.
$ cat sqlnet.ora
# sqlnet.ora Network Configuration File: /u01/app/oracle11g/product/11.2.0/db_2/network/admin/sqlnet.ora
# Generated by Oracle configuration tools.
NAMES.DIRECTORY_PATH= (TNSNAMES, HOSTNAME, EZCONNECT)
ADR_BASE = /u01/app/oracle11g
--测试也可以通过.
--如果你增加,修改配置都可以重复执行.留给大家测试了.