Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

The difference of several nouns of ORACLE_SID,INSTANCE_NAME,DB_NAME in Oracle

2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

Colleague project uses Oracle, ask me about these contents, although I listed OCP, but that was six years ago, the past few years of heavy work, basically cleared zero, was asked by colleagues to reorganize it.

The names involved include: DB_NAME,DB_DOMAIN,ORACLE_SID,INSTANCE_NAME, SERVICE_NAME and so on.

To mention these names, the first thing to understand is the logical architecture of ORACLE, which we usually refer to as accessible ORACLE DB. In fact, it consists of two parts: instance (including a set of processes, and SGA memory, etc.) + physical media. The media includes control files, data files, log files, parameter files and so on. An instance process is a bunch of processes that manipulate physical media. In addition, the instance process can not mount (mount) any physical media, and the instance is called idle instance.

The above name starts with a simple one: DB_NAME. These two things are specified when creating the database, and they are the most stable. DB_NAME is distributed in data files, log files, and parameter files. 99.9% of the cases do not and do not need to change it. (although the current version can also be modified).

It can be understood as a mark of physical media, which all belong to this DB. As for DB_DOMAIN is just a logo for distributed management, it doesn't make much sense, just know that there is such a thing.

ORACLE_SID: general ORACLE_SID is used as an environment variable. It is an operating system-level thing. The two most common uses are:

Determine the name of the Oracle instance process. If you look at it under linux, the corresponding process in Oracle will find that it is all suffixed with ORACLE_SID.

Locate the startup parameter file for Oracle, and Oracle looks for its configuration file at startup (currently look for spfile.ora-> spfile.ora-> init.ora in this order).

After Oracle starts, this parameter is of little use.

Note: the ORACLE_SID should be different under the same Oracle_HOME, but the same under different Oracle_HOME.

INSTANCE_NAME:DB_NAME is the identity of the physical media, and INSTANCE_NAME is the identity of the instance process.

For ORACLE databases, physical media can be mounted (mount) and opened (open) by any instance process without RAC.

But only one instance process can open him at a time. In the case of RAC, multiple instance processes are allowed to open the same physical media.

In the case of RAC, multiple instances correspond to the same physical medium.

JAVAEE students will remember that the connection string of JDBC is: jdbc:oracle:thin:@::

This SID is INSTANCE_NAME. A database connection is actually a connection to an instance process. Most of the time we think of it as ORACLE_SID, just because they are the same at that time. With regard to the default value of each parameter, there is no child here, the code word is tired.

It seems that there is an entity positioning problem that INSTANCE_NAME+DB_NAME has solved perfectly. Until the emergence of RAC, broke this serenity. There are cases where multiple instances open the same DB_NAME at the same time. The connection string of JDBC above doesn't work, and SERVICE_NAME comes out of nowhere.

To put it simply, SERVICE_NAME represents the entire database (process + DB), and there can be multiple instances under a SERVICE_NAME, so whether it is a RAC or a singleton database, jdbc:oracle:thin:@:: can connect normally.

How does SERVICE_NAME play? we know that Oracle listens on port 1521 because there is a listener. When the ORACLE instance starts, the PMON process registers the instance with the listener, which currently includes the service name of its attribute. This is called dynamic registration, which may not be easy to understand SERVICE_NAME (you can use the lsnrctl status command to check the existing service and instance). Look at a statically registered listener.ora:

SID_LIST_LISTENER = (SID_LIST = (SID_DESC = (SID_NAME = ORCL)-- here is INSTANCE_NAME (ORACLE_HOME = / mydatafile2/app/oracle/oracle/product/11.2.0/db_1) (GLOBAL_DBNAME=WOO.COM)-here is SERVICE_NAME. ))

Connect to this SERVICE and the listener will load the connection to the corresponding instance according to a certain algorithm.

To sum up: most of the people who visit the database are concerned about Instance_name and service_name.

ORACLE_SID and DB_NAME are used to manage the database.

Write so much first, and then fill in later.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report