SID与Oracle tnsnames.ora中的服务名称有何不同
时间:2020-03-05 18:47:38 来源:igfitidea点击:
我为什么需要其中两个?什么时候必须使用一个或者另一个?
解决方案
回答
请参阅: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.
简而言之:SID =数据库实例的唯一名称,ServiceName =连接时使用的别名
回答
@DAC
In short: SID = the unique name of your DB, ServiceName = the alias used when connecting
并非完全正确。SID = INSTANCE的唯一名称(例如,计算机上运行的oracle进程)。 Oracle将"数据库"视为文件。
服务名称=实例(或者许多实例)的别名。这样做的主要目的是,如果我们正在运行集群,则客户端可以说"将我连接到SALES.acme.com",DBA可以即时更改可用于SALES.acme.com请求的实例数,甚至将SALES.acme.com移至完全不同的数据库,而客户端无需更改任何设置。
回答
根据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.
我们应该在TNSNAMES.ORA中使用SID作为更好的方法。