1. %ORACLE_HOME%/NETWORK/ADMIN/sqlnet.ora
# sqlnet.ora Network Configuration File: D:\Oracle\product\11.1.0\db_1\NETWORK\ADMIN\sqlnet.ora # Generated by Oracle configuration tools. # This file is actually generated by netca. But if customers choose to # install "Software Only", this file wont exist and without the native # authentication, they will not be able to connect to the database on NT. SQLNET.AUTHENTICATION_SERVICES = (BEQ, NONE) NAMES.DIRECTORY_PATH = (TNSNAMES, HOSTNAME) # TCP.INVITED_NODES = (127.0.0.1,192.168.1.1) # TCP.EXCLUDED_NODES = (192.168.1.2) # TCP.VALIDNODE_CHECKING = yes
# NAMES.DIRECTORY_PATH = (TNSNAMES, HOSTNAME)
这个参数用来决定oracle如何解析连接字符串,其中 TNSNAMES 表示优先在 tnsnames.ora 查找相应的字符串信息;如果未找到相应记录,那么再通过 HOSTNAME 的方式进行解析。例如:
sqlplus scott/tiger@local # TNSNAMES 的方式
sqlplus scott/tiger@//ip:port/serviceName # HOSTNAME 的方式
# TCP.INVITED_NODES = (127.0.0.1,192.168.1.1)
这个参数表示允许进行访问的客户端ip
# TCP.EXCLUDED_NODES = (192.168.1.2)
这个参数表示不允许进行访问的客户端ip
# TCP.VALIDNODE_CHECKING = yes
这个参数表示启用上面两个参数
2. %ORACLE_HOME%/NETWORK/ADMIN/tnsnames.ora
# tnsnames.ora Network Configuration File: D:\Oracle\product\11.1.0\db_1\network\admin\tnsnames.ora # Generated by Oracle configuration tools. local = ( DESCRIPTION = ( ADDRESS_LIST = ( ADDRESS = (PROTOCOL = TCP)(HOST = 127.0.0.1)(PORT = 1521) ) ) ( CONNECT_DATA = (SERVER = DEDICATED)(SERVICE_NAME = ORCL1) ) )
# 这个文件只在本地使用,其作用类似于windows中的hosts文件,相当于一个字符串替换。
sqlplus scott/tiger@local
等同于
sqlplus scott/tiger@(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=127.0.0.1)(PORT=1521)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=ORCL1)))
# local 表示一个别名,用户可以自定义
3. %ORACLE_HOME%/NETWORK/ADMIN/listener.ora
# listener.ora Network Configuration File: D:\Oracle\product\11.1.0\db_1\network\admin\listener.ora # Generated by Oracle configuration tools. SID_LIST_LISTENER = ( SID_LIST = ( SID_DESC = (GLOBAL_DBNAME = ORCL1) (SID_NAME = ORCL) (ORACLE_HOME = D:\Oracle\product\11.1.0\db_1) ) ) listener1 = ( DESCRIPTION_LIST = ( DESCRIPTION = ( ADDRESS = (PROTOCOL = TCP)(HOST = 127.0.0.1)(PORT = 1521) ) ) )
# GLOBAL_DBNAME = ORCL1
这个参数表示数据库的服务名,用户可以自定义,客户端连接时需要用到,一共有哪些服务名可以通过 lsnrctl status 查看,其中 db_name.db_domain 这个服务名是数据库启动时自动添加的
# SID_NAME = ORCL
这个参数表示数据库的实例名(大小写要一致),可以通过 select instance_name from v$instance 查看
# listener1 表示监听的名称,用户可以自定义