database SID 与 Oracle tnsnames.ora 中的服务名称有何不同

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/43866/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-08 06:54:20  来源:igfitidea点击:

How SID is different from Service name in Oracle tnsnames.ora

databaseoracleserviceadministrationsid

提问by Georgy Bolyuba

Why do I need two of them? When I have to use one or another?

为什么我需要其中两个?什么时候我必须使用一种或另一种?

采纳答案by Matthew Watson

Quote by @DAC

引用@DAC

In short: SID = the unique name of your DB, ServiceName = the alias used when connecting

简而言之:SID = 您的数据库的唯一名称,ServiceName = 连接时使用的别名

Not strictly true. SID = unique name of the INSTANCE (eg the oracle process running on the machine). Oracle considers the "Database" to be the files.

不完全正确。SID = INSTANCE 的唯一名称(例如在机器上运行的 oracle 进程)。Oracle 将“数据库”视为文件。

Service Name = alias to an INSTANCE (or many instances). The main purpose of this is if you are running a cluster, the client can say "connect me to SALES.acme.com", the DBA can on the fly change the number of instances which are available to SALES.acme.com requests, or even move SALES.acme.com to a completely different database without the client needing to change any settings.

服务名称 = 实例(或多个实例)的别名。这样做的主要目的是,如果您正在运行一个集群,客户端可以说“将我连接到 SALES.acme.com”,DBA 可以即时更改 SALES.acme.com 请求可用的实例数量,甚至将 SALES.acme.com 移动到一个完全不同的数据库,而无需客户端更改任何设置。

回答by DAC

Please see: http://www.sap-img.com/oracle-database/finding-oracle-sid-of-a-database.htm

请参阅:http: //www.sap-img.com/oracle-database/finding-oracle-sid-of-a-database.htm

What is the difference between Oracle SIDs and Oracle SERVICE NAMES. One config tool looks for SERVICE NAME and then the next looks for SIDs! What's going on?!

Oracle SID is the unique name that uniquely identifies your instance/database where as Service name is the TNS alias that you give when you remotely connect to your database and this Service name is recorded in Tnsnames.ora file on your clients and it can be the same as SID and you can also give it any other name you want.

SERVICE_NAME is the new feature from oracle 8i onwards in which database can register itself with listener. If database is registered with listener in this way then you can use SERVICE_NAME parameter in tnsnames.ora otherwise - use SID in tnsnames.ora.

Also if you have OPS (RAC) you will have different SERVICE_NAME for each instance.

SERVICE_NAMES specifies one or more names for the database service to which this instance connects. You can specify multiple services names in order to distinguish among different uses of the same database. For example:

SERVICE_NAMES = sales.acme.com, widgetsales.acme.com

You can also use service names to identify a single service that is available from two different databases through the use of replication.

In an Oracle Parallel Server environment, you must set this parameter for every instance.

Oracle SID 和 Oracle SERVICE NAMES 之间有什么区别。一个配置工具查找 SERVICE NAME,然后下一个查找 SID!这是怎么回事?!

Oracle SID 是唯一标识您的实例/数据库的唯一名称,其中服务名称是您远程连接到数据库时提供的 TNS 别名,该服务名称记录在客户端的 Tnsnames.ora 文件中,它可以是与 SID 相同,您也可以为其指定任何其他名称。

SERVICE_NAME 是 oracle 8i 以后的新特性,数据库可以在监听器中注册自己。如果数据库以这种方式注册到侦听器,那么您可以在 tnsnames.ora 中使用 SERVICE_NAME 参数,否则 - 在 tnsnames.ora 中使用 SID。

此外,如果您有 OPS (RAC),则每个实例都有不同的 SERVICE_NAME。

SERVICE_NAMES 为该实例连接的数据库服务指定一个或多个名称。您可以指定多个服务名称以区分同一数据库的不同用途。例如:

SERVICE_NAMES = sales.acme.com、widgetsales.acme.com

您还可以使用服务名称来标识通过使用复制可从两个不同数据库中获得的单个服务。

在 Oracle Parallel Server 环境中,您必须为每个实例设置此参数。

In short: SID = the unique name of your DB instance, ServiceName = the alias used when connecting

简而言之:SID = 数据库实例的唯一名称,ServiceName = 连接时使用的别名

回答by seorphates

I know this is ancient however when dealing with finicky tools, uses, users or symptoms re: sid & service naming one can add a little flex to your tnsnames entries as like:

我知道这很古老,但是在处理挑剔的工具、用途、用户或症状时: sid 和服务命名可以为您的 tnsnames 条目添加一点弹性,如下所示:

mySID, mySID.whereever.com =
(DESCRIPTION =
  (ADDRESS_LIST =
    (ADDRESS = (PROTOCOL = TCP)(HOST = myHostname)(PORT = 1521))
  )
  (CONNECT_DATA =
    (SERVICE_NAME = mySID.whereever.com)
    (SID = mySID)
    (SERVER = DEDICATED)
  )
)

I just thought I'd leave this here as it's mildly relevant to the question and can be helpful when attempting to weave around some less than clear idiosyncrasies of oracle networking.

我只是想我会把它留在这里,因为它与问题略有相关,并且在尝试编织一些不太清楚的 oracle 网络特性时可能会有所帮助。

回答by swaroop

what is a SID and Service name

什么是 SID 和服务名称

please look into oracle's documentation at https://docs.oracle.com/cd/B19306_01/network.102/b14212/concepts.htm

请在https://docs.oracle.com/cd/B19306_01/network.102/b14212/concepts.htm查看 oracle 的文档

In case if the above link is not accessable in future, At the time time of writing this answer, the above link will direct you to, "Database Service and Database Instance Identification" topic in Connectivity Concepts chapter of "Database Net Services Administrator's Guide". This guide is published by oracle as part of "Oracle Database Online Documentation, 10g Release 2 (10.2)"

如果以后无法访问上述链接,在撰写此答案时,上述链接将引导您转到“数据库网络服务管理员指南”的连接概念章节中的“数据库服务和数据库实例标识”主题. 本指南由 oracle 作为“Oracle 数据库在线文档,10g 第 2 版 (10.2)”的一部分发布

When I have to use one or another? Why do I need two of them?

什么时候我必须使用一种或另一种?为什么我需要其中两个?

Consider below mapping in a RAC Environment,

考虑以下 RAC 环境中的映射,

SID      SERVICE_NAME
bob1    bob
bob2    bob
bob3    bob
bob4    bob

SID SERVICE_NAME
bob1 bob
bob2 bob
bob3 bob
bob4 bob

if load balancing is configured, the listener will 'balance' the workload across all four SIDs. Even if load balancing is configured, you can connect to bob1 all the time if you want to by using the SID instead of SERVICE_NAME.

如果配置了负载平衡,则侦听器将在所有四个 SID 之间“平衡”工作负载。即使配置了负载平衡,您也可以通过使用 SID 而不是 SERVICE_NAME 始终连接到 bob1。

Please refer, https://community.oracle.com/thread/4049517

请参考,https://community.oracle.com/thread/4049517

回答by Ashish

As per Oracle Glossary :

根据 Oracle 术语表:

SID is a unique name for an Oracle database instance. ---> To switch between Oracle databases, users must specify the desired SID <---. The SID is included in the CONNECT DATA parts of the connect descriptors in a TNSNAMES.ORA file, and in the definition of the network listener in the LISTENER.ORA file. Also known as System ID. Oracle Service Name may be anything descriptive like "MyOracleServiceORCL". In Windows, You can your Service Name running as a service under Windows Services.

SID 是 Oracle 数据库实例的唯一名称。---> 要在 Oracle 数据库之间切换,用户必须指定所需的 SID <---。SID 包含在 TNSNAMES.ORA 文件中连接描述符的 CONNECT DATA 部分中,以及 LISTENER.ORA 文件中网络侦听器的定义中。也称为系统 ID。Oracle 服务名称可以是诸如“MyOracleServiceORCL”之类的任何描述性内容。在 Windows 中,您可以将您的服务名称作为 Windows 服务下的服务运行。

You should use SID in TNSNAMES.ORA as a better approach.

您应该在 TNSNAMES.ORA 中使用 SID 作为更好的方法。