上面的sqlnet.ora文件说明:
sqlnet.authentication_services= (nts)——这个表示采用os认证,在数据库服务器上,可以利用sqlplus “/ as sysdba”。一般这个配置在windows上是ok的,在unix环境下可能会有问题,一般在unix下可以去掉这个配置。
names.directory_path= (tnsnames, hostname, onames)——表示将首先利用tnsnames进行解析;如果tnsnames解析不到,将使用hostname解析;如果hostname解析不 到,将采用onames进行解析。
被注释掉的names.default_domain = us.oracle.com——表示采用默认的domain name为us.oracle.com,在tnsnames.ora中如果配置对应的解析,如果原来的别名oralocal,那么,当启用这个参数后,在 tnsnames中的配置要改成oralocal.us.oracle.com。在使用tnsping时或者sqlplus登录时,只需写前面的别名,系 统会自动加上后面的domain name来进行解析。
检查完毕sqlnet.ora,一般都会发现是使用tnsname来解析别名的,那么,tnsnames.ora中可以有哪些配置种类呢?
# tnsnames.ora network configuration file: $oracle_home/network/admin/tnsnames.ora
# generated by oracle configuration tools.
###### 一般的配置 ##################################
oralocal =
(description =
(address_list =
(address = (protocol = tcp)(host = 127.0.0.1)(port = 1521))
)
(connect_data =
(server = dedicated)
(service_name = oralocal)
)
)
###### 这样也行,用sid=oralocal ###########################
oralocal_2 =
(description =
(address_list =
(address = (protocol = tcp)(host = 127.0.0.1)(port = 1521))
)
(connect_data =
(server = dedicated)
(sid = oralocal)
)
###### rac的配置(3节点rac) ###############################
oralocal =
(description =
(load_balance = yes)
(failover = on)
(address_list =
(address = (protocol = tcp)(host = 192.168.1.1)(port = 1521))
(address = (protocol = tcp)(host = 192.168.1.2)(port = 1521))
(address = (protocol = tcp)(host = 192.168.1.3)(port = 1521))
)
(connect_data =
(service_name = oralocal)
(server = dedicated)
(failover_mode=(type=select)(method=basic)(retries=20)(delay=20))
)
)
oralocal_node1 =
(description =
(address_list =
(address = (protocol = tcp)(host = 192.168.1.1)(port = 1521))
)
(connect_data =
(service_name = oralocal)
(instance_name = oralocal_node1)
)
)
oralocal_node2=
(description =
(address_list =
(address = (protocol = tcp)(host = 192.168.1.2)(port = 1521))
)
(connect_data =
(service_name = oralocal)
(instance_name = oralocal_node2)
)
)
oralocal_node3 =
(description =
(address_list =
(address = (protocol = tcp)(host = 192.168.1.3)(port = 1521))
)
(connect_data =
(service_name = oralocal)
(instance_name = oralocal_node3)
)
)
)
###### data guard配置(primary库和standby库都需要配置)##############
standby =
(description =
(address_list =
(address = (protocol = tcp)(host = 192.168.2.2)(port = 1521))
)
(connect_data =
(server=dedicated)
(service_name = oralocal)
)
)
primary =
(description =
(address_list =
(address = (protocol = tcp)(host = 192.168.2.1)(port = 1521))
)
(connect_data =
(server=dedicated)
(service_name = oralocal)
)
)
另外需要注意的2点情况:
(1)如果tnsnames中的service_name配置错误,配置成了instance_name了,这个时候会发生tnsping能通,但是 sqlplus连接不上的奇怪情况。报错ora-12514: tns:listener could not resolve service_name given in connect descriptor。这个时候查错的时候,需要检查对应的service_name。
(2)如果远程数据库是rac,而且本地客户端端远程数据库处于不同的网段,通过公网链接,rac对外的ip映射只有一个,即只映射到一个节点。请注意在 客户端配置tnsnames的时候按照单机的情况来配置。呵呵,dba不仅仅要学习oracle,了解一些网络的知识,特别是自己系统的网络架构,也是需 要的。