oracle监听配置

   

服务器端配置Listener

[oracle@localhost admin]$ cat listener.ora
LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.0.129)(PORT = 1521))
    )
  )
ADR_BASE_LISTENER = /u01/app/oracle
SID_LIST_LISTENER=
  (SID_LIST=
    (SID_DESC=#BEQUEATH CONFIG
      (GLOBAL_DBNAME=test)
      (SID_NAME=test)
      (ORACLE_HOME=/u01/app/oracle/product/11.2.0/dbhome_1)
      #PRESPAWN CONFIG
      (PRESPAWN_MAX=20)
      (PRESPAWN_LIST=
      (PRESPAWN_DESC=(PROTOCOL=tcp)(POOL_SIZE=2)(TIMEOUT=1))
      )
     )
    )

GLOBAL_DBNAME=test Service 名称,在客户端一定配置和他相同
SID_NAME=test 实例名称,这个要和SID相同
GLOBAL_DBNAME可以不等于SID_NAME
客户端根据tnsname.ora中的SERVICE_NAME和地址(ADDRESS = (PROTOCOL = TCP)(HOST =racdb1)(PORT = 1521)),到这个地址去访问监听器。然后监听器根据文件lisnter.ora文件中的GLOBAL_NAME来判断是否有一个 GLOBAL_DBNAME 和 SERVICE_NAME 相等。如果相等,则建立客户端到SID标识的服务端实例的连接,在客户端上我们可以使用tnsping 命令来测试

客户端tnsnames

test =
 (description =
   (address_list =
     (address = (protocol = tcp)(host = 192.168.0.129)(port = 1521))
   )
   (connect_data =
     (service_name =test)(ur=a)
   )
 )

这里的service_name =test 就是在服务器端的GLOBAL_DBNAME=test

[oracle@localhost admin]$ tnsping test
TNS Ping Utility for Linux: Version 11.2.0.1.0 - Production on 06-SEP-2020 13:01:41
Copyright (c) 1997, 2009, Oracle.  All rights reserved.
Used parameter files:
Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.0.129)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = test)))
OK (0 msec)

Oracle Listener

lsnrctl stop
lsnrctl start
lsnrctl status
lsnrctl service

发表评论