目的:希望从本地SQLPLUS连接服务器的数据库。
从以往经验来看这是个很简单的事情,比如以前有TOAD工具新建连接,或者在OEM中添加。这次我希望直接修改TNSNAMES.ORA文件实现。
DEV=
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = DEVDEV)(PORT = 1527))
)
(CONNECT_DATA =
(SID = DEV)
(GLOBAL_NAME = DEV)
)
)
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = DEVDEV)(PORT = 1527))
)
(CONNECT_DATA =
(SID = DEV)
(GLOBAL_NAME = DEV)
)
)
TST=
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS =
(COMMUNITY = SAP.WORLD)
(PROTOCOL = TCP)
(HOST = MYNAME)
(PORT = 1521)
)
)
(CONNECT_DATA =
(SID = TST)
(GLOBAL_NAME = TST)
)
)
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS =
(COMMUNITY = SAP.WORLD)
(PROTOCOL = TCP)
(HOST = MYNAME)
(PORT = 1521)
)
)
(CONNECT_DATA =
(SID = TST)
(GLOBAL_NAME = TST)
)
)
DEV是服务器,TST是本地数据库。修改之后SQLPLUS连接DEV.
开始感觉无从下手,一会儿检查TNS文件一会儿检查SQLNET文件。
现在的体会是SQLNET文件是作为连接的规则,TNSNAME则是指定连接的位置。
SQLNET.ORA
#AUTOMATIC_IPC = ON
#TRACE_LEVEL_CLIENT = OFF
#NAMES.DEFAULT_DOMAIN = WORLD
# 05.01.06 unsorported parameter now
#NAME.DEFAULT_ZONE = WORLD
# 05.01.06 set the default to 10
#SQLNET.EXPIRE_TIME = 10
SQLNET.AUTHENTICATION_SERVICES = (NTS,NONE)
NAMES.DIRECTORY_PATH= (TNSNAMES,HOSTNAME,EZCONNECT)
# 05.01.06 set to default
#TCP.NODELAY=YES
# 05.01.06 set to 32768
#DEFAULT_SDU_SIZE=32768
#TRACE_LEVEL_CLIENT = OFF
#NAMES.DEFAULT_DOMAIN = WORLD
# 05.01.06 unsorported parameter now
#NAME.DEFAULT_ZONE = WORLD
# 05.01.06 set the default to 10
#SQLNET.EXPIRE_TIME = 10
SQLNET.AUTHENTICATION_SERVICES = (NTS,NONE)
NAMES.DIRECTORY_PATH= (TNSNAMES,HOSTNAME,EZCONNECT)
# 05.01.06 set to default
#TCP.NODELAY=YES
# 05.01.06 set to 32768
#DEFAULT_SDU_SIZE=32768
SQLNET.AUTHENTICATION_SERVICES = (NTS,NONE)表示认证方式是系统登陆认证还是密码认证。DEV是系统认证所以加一条NTS.
NAMES.DIRECTORY_PATH= (TNSNAMES,HOSTNAME,EZCONNECT)
这个表示连接方式,不加的话会自动选择,这2条都是可以不加的。
关键在TNSNAMES.ORA文件中指定的HOST = DEVDEV,没有IP对应关系,所以在C:\WINDOWS\DRIVER\ETC的HOSTS文件中加上IP地址与DEVDEV的对应关系,就正常了。
回过头想想,其实是挺简单的一件事,如果思路清晰,应该很快能够解决。
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/22078283/viewspace-626210/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/22078283/viewspace-626210/