Oracle tnsname.ora中service_name的理解

Oracle tnsnames.ora中global_dbname,service_name,SID等配置项易混淆。下面我们通过实验来看看service_name配置。

[grid@nodedg admin]$ lsnrctl status nodedg

LSNRCTL for Linux: Version 18.0.0.0.0 - Production on 06-MAR-2019 14:23:08

Copyright (c) 1991, 2018, Oracle.  All rights reserved.

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=nodedg)(PORT=1522)))
STATUS of the LISTENER
------------------------
Alias                     nodedg
Version                   TNSLSNR for Linux: Version 18.0.0.0.0 - Production
Start Date                06-MAR-2019 09:17:21
Uptime                    0 days 5 hr. 5 min. 46 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /app/grid/product/18.3.0/crs/network/admin/listener.ora
Listener Log File         /app/grid/diag/tnslsnr/nodedg/nodedg/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=nodedg)(PORT=1522)))
Services Summary...
Service "eighteen" has 1 instance(s).
  Instance "dg", status UNKNOWN, has 1 handler(s) for this service...
The command completed successfully

nodedg监听在1522端口注册了一个service:eighteen,那么如果想通过TNS协议链接实例需要配置tnsnames.ora

[oracle@node admin]$ more tnsnames.ora

nodedg =
 (DESCRIPTION =
   (ADDRESS_LIST =
     (ADDRESS = (PROTOCOL = TCP)(HOST = 10.6.0.138)(PORT = 1522))
   )
   (CONNECT_DATA =
     (SERVICE_NAME = eighteen)
     (RU=A)
   )
 )

service_name配置的是eighteen,正是nodedg监听中的service

[oracle@node admin]$ tnsping nodedg

TNS Ping Utility for Linux: Version 18.0.0.0.0 - Production on 06-MAR-2019 14:38:00

Copyright (c) 1997, 2018, Oracle.  All rights reserved.

Used parameter files:


Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 10.6.0.138)(PORT = 1522))) (CONNECT_DATA = (SERVICE_NAME = eighteen) (RU=A)))
OK (0 msec)
[oracle@node admin]$ sqlplus system/oracle@nodedg

SQL*Plus: Release 18.0.0.0.0 - Production on Wed Mar 6 14:38:10 2019
Version 18.5.0.0.0

Copyright (c) 1982, 2018, Oracle.  All rights reserved.

Last Successful login time: Thu Feb 28 2019 10:36:41 +08:00

Connected to:
Oracle Database 18c Enterprise Edition Release 18.0.0.0.0 - Production
Version 18.3.0.0.0

col name for a15
col open_mode for a10
col database_role for a18
col db_unique_name for a15
col cdb for a10
SQL> select name,open_mode,database_role,db_unique_name,cdb from v$database;

NAME		OPEN_MODE  DATABASE_ROLE      DB_UNIQUE_NAME  CDB
--------------- ---------- ------------------ --------------- ----------
EIGHTEEN	READ ONLY  PHYSICAL STANDBY   dg	      YES
		WITH APPLY

tnsnames.ora中的service_name是监听程序监听到的service_name

  • 2
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值