Db_name, instance_name, service_names, db_domain, global_name, global_names

Source: Internet
Author: User
Tags number sign time 0 alphanumeric characters in domain

1. db_name Database Name

SQL> connect xys/manager as sysdba
Connected.
SQL> show user
USER is "SYS"
SQL> show parameter db_name

NAME TYPE VALUE
-----------------------------------------------------------------------------
Db_name string test1

Db_name is the name of the database, and oracle itself may be useful. It is of little use to us. db_name is recorded in controlfile, datafile_header, and redo, there are two ways to modify db_name: 1. re-create controlfile, And then you must open the database in reseglogs mode; 2. Use nid. In addition, db_name is limited to a maximum of 8 characters when creating a database. Although there is no error prompt when creating a 10 Gb database, you can see at most a few characters in the database, even if the input exceeds 8 characters, no error is returned, but it is finally truncated. Previously, I handled some problems caused by the truncation of db_name for an enterprise.

SQL> desc v $ database;
Is the name empty? Type
-------------------------------------------------------------------------

DBID NUMBER
NAME VARCHAR2 (9)

SQL>
Therefore, it is very important to specify the appropriate db_name when creating a database. Db_name also plays an important role in dynamically registering a listener. No matter whether service_name or the value of service_name is specified, pmon uses db_name to dynamically register the listener.

SQL> host lsnrctl status

LSNRCTL for 32-bit Windows: Version 10.2.0.1.0-Production on-2007
9: 36

Copyright (c) 1991,200 5, Oracle. All rights reserved.

Connecting to (ADDRESS = (PROTOCOL = tcp) (HOST =) (PORT = 1521 ))
LISTENER STATUS
------------------------
Alias LISTENER
Version TNSLSNR for 32-bit Windows: Version 10.2.0.1.0-Produ
Ction
Start Date:-2007 09:29:47
Normal operation time 0 days 0 hours 49 minutes 50 seconds
Tracking level off
Security ON: Local OS Authentication
SNMP OFF
Listener log File e: oracleproduct10.2.0db _ 1networkloglistener. log

Listener endpoint overview...
(DESCRIPTION = (ADDRESS = (PROTOCOL = tcp) (HOST = xys) (PORT = 1521 )))
Service summary ..
The Service "TEST2.COM" contains one routine.
Routine "inst_test", status READY, contains 1 handler of this service...
The Service "TEST3.COM" contains one routine.
Routine "inst_test", status READY, contains 1 handler of this service...
The Service "test1.COM" contains one routine.
Routine "inst_test", status READY, contains 1 handler of this service...
The Service "test10000xpt.com" contains one routine.
Routine "inst_test", status READY, contains 1 handler of this service...
Command executed successfully

SQL> show parameter service_names

NAME TYPE VALUE
-----------------------------------------------------------------------------
Service_names string TEST2, TEST3

We found that the service_names value is TEST2 and TEST3, but the result displayed by lsnrctl status contains"

The Service "test1.COM" contains one routine.
Routine "inst_test", status READY, contains 1 handler of this service ..."

2. instnace_name

SQL> show parameter instance_name

NAME TYPE VALUE
-----------------------------------------------------------------------------
Instance_name string inst_test
Instance_name is used in addition to Dynamic Registration listening. So far, I have not found any other use. Maybe oracle uses it to differentiate instances? However, I believe that only instance_name cannot be fully differentiated. At least sid is also used. Let's take a look at the information displayed in the Dynamic Registration listener, where inst_test is instance_name.

3. SID: System Identifier

The SID identifies the instance's shared memory on a host, but may not uniquely distinguish this instance from other instances

In the doc, sid is interpreted as marking the shared memory of the instance with sid on the host. It can be seen that sid mainly deals with OS.

Sid can be queried in the database using the following statement:

SQL> select instance_name from v $ instance;

INSTANCE_NAME
----------------
Tsid

Although the instance_name field in v $ instance looks like the instance name, it actually stores the sid. In win, the sid cannot be repeated, no matter whether oracle_home is the same or not, the differences here are mainly for unix/linux, in unix/linux, As long as oracle of different versions is installed in different oracle_home, instances with the same sid can be created, but Windows cannot. This is not determined by oracle, it is mainly restricted by windows Services. There cannot be oracle services with the same service name in the service. The service name is in the following format: OracleServiceSID, because the service name includes sid, therefore, if the sid is the same, the service name is the same, which is not allowed by windows. Therefore, different instances with the same sid cannot be created under win.

4. service_names service name

The service name is a complex number. After reading it, it means that service_names can be multiple values. The service name here is not used in Dynamic Registration listening, but has no other usage, we recommend that you use the same service_names on primary and standby in dataguard, so that you can implement transparent switching as much as possible, provided that static listening is not configured, of course, if the listener with static registration is configured in primary, standby must also ensure that the input service name is the same in listener. In that case, implement transparent switching as much as possible. The following query shows service_names:

SQL> show parameter service_names

NAME TYPE VALUE
-----------------------------------------------------------------------------
Service_names string TEST2, TEST3

Here I have specified two values: test2 and test3. Let's take a look at how a dynamically registered listener uses the service name. Some status information of the listener is as follows:

The Service "TEST2.COM" contains one routine.
Routine "inst_test", status READY, contains 1 handler of this service...
The Service "TEST3.COM" contains one routine.
Routine "inst_test", status READY, contains 1 handler of this service...

Here, we can see that the service name is suffixed with com because I set db_domain

5. db_domain database Domain Name

SQL> show parameter db_domain

NAME TYPE VALUE
-----------------------------------------------------------------------------
Db_domain string COM

Doc says it is ". "segmentation, including a maximum of 128 characters at the time of the period, has not been changed so long, do not know, has not been verified, who wants to verify it, the role of db_domain is mainly used in distributed databases, each database of distributed transactions should have db_domain, but they are required to be the same. I didn't mention it in the doc, and I didn't know it. The previous Unit developed a distributed environment, but I didn't pay attention to it at the time, however, the database of the object to be synchronized in the Advanced Replication requires db_domain in any way. It is not clear whether the requirements are the same, I set db_domain to the same during configuration replication. Another purpose of introducing db_domain is to create a database with the same name db_name in the same OS domain. If you want to create a database with the same name db_name, we recommend that you set the database with the same db_name to a different db_domain, to ensure that global_name is unique in the same domain. This is also recommended on the doc: Oracle recommends that you specify DB_DOMAIN as a unique string for all databases in a domain

When db_domain is specified, db_domain (doc:

If you omit the domains from the name of a database link, Oracle expands the name by qualifying the database with the domain of your local database as it currently exists in the data dictionary, and then stores the link name in the data dictionary. the characters valid in a database domain name are: alphanumeric characters, underscore (_), and number sign (#).

), 9i seems to remember this, but 10g I verified that it is not:

SQL> create database link dbl_test using 'orcl ';

The database link has been created.

SQL> select db_link from dba_db_links;

DB_LINK
----------------------------------------------------------------------------

DBL
DBL_TEST
ORCL

Another important thing is: You must set this parameter for every instance, and multiple instances must have the same value in Real Application Clusters

6. global_name Global Database Name

Global_name is composed of db_name.db_domain. The doc is as follows:

Understanding How Global Database Names Are Formed
A global database name is formed from two components: a database name and a domain. The database name and the domain name are determined by the following initialization parameters at database creation:

Component Parameter Requirements Example
Database name DB_NAME Must be eight characters or less. sales
Domain containing the database DB_DOMAIN Must follow standard Internet conventions. Levels in domain names must be separated by dots and the order of domain names is from leaf to root, left to right. us.acme.com

However, after verification, we found that oracle didn't synchronize db_name.db_domain and global_name. Why? Global_name oracle provides a view, sys. global_name, Which is originated from props $. You can view the script for creating a view. Finally, we access a public synonym global_name:

SQL> select * from global_name;

GLOBAL_NAME
--------------------------------------------

Test1

According to the doc, the query result I saw above should be test1.com. This is my question. How long has it been?

However, we can also modify global_name:

SQL> alter database rename global_name to test1.com;

The database has been changed.

SQL> select * from global_name;

GLOBAL_NAME
--------------------------------------------------------------------------------

TEST1.COM

SQL> alter database rename global_name to test123.com;

The database has been changed.

SQL> select * from global_name;

GLOBAL_NAME
--------------------------------------------------------------------------------

TEST123.COM

SQL>

Note that once a domain is added, the preceding command cannot be removed, for example:

SQL> alter database rename global_name to test123.com;

The database has been changed.

SQL> select * from global_name;

GLOBAL_NAME
--------------------------------------------------------------------------------

TEST123.COM

SQL> alter database rename global_name to test1;

The database has been changed.

SQL> select * from global_name;

GLOBAL_NAME
--------------------------------------------------------------------------------

TEST1.COM

SQL> alter database rename global_name to test123;

The database has been changed.

SQL> select * from global_name;

GLOBAL_NAME
--------------------------------------------------------------------------------

TEST123.COM

SQL>

However, you can directly update global_name or props $ to remove the Suffix:

SQL> update global_name set global_name = 'test1 ';

1 row updated.

SQL> commit;

Submitted.

SQL> select * from global_name;

GLOBAL_NAME
---------------------------------------------------------------

Test1

SQL>

Global_name is mainly used in Distributed Database. I only used global_name in advanced replication.

For details, refer to the following connection:

Http://download.oracle.com/docs/cd/B19306_01/server.102/b14231/ds_admin.htm#sthref4096

7. global_names is a Boolean value. Why should we mention it? It should look like global_names and global_name. The role of global_names is to determine whether to force the use of global_name of the remote database when creating the db link, if global_names = true, the db link name must be global_name of the remote database. Otherwise, the db link cannot be used together after creation. The test is as follows. The default value is false.
SQL> show parameter global_names

NAME TYPE VALUE
-----------------------------------------------------------------------------
Global_names boolean TRUE
SQL> select count (*) from t_emp @ dbl;
Select count (*) from t_emp @ dbl
*
Row 3 has an error:
ORA-02085: database link DBL connect to ORCL

SQL> col db_link format a10
SQL> col host format a10
SQL> col owner format a10
SQL> col username format a10
SQL> select * from dba_db_links;

OWNER DB_LINK USERNAME HOST CREATED
------------------------------------------------------
Sys dbl test orcl month-07
Sys orcl test orcl 01-12-07

SQL> select count (*) from t_emp @ orcl;

COUNT (*)
----------
4

SQL>

8. What should I enter for the global database name (GLOBAL_DBNAME) When configuring static listening registration through netmanager?

? What is the service name (SERVICE_NAME) required to configure the network service name (tns) through netmanager?

The content of listener. ora is as follows:

SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME = test)
(ORACLE_HOME = E: oracleproduct10.2.0db _ 1)
(SID_NAME = tsid)
)
)

LISTENER =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP) (HOST = xys) (PORT = 1521 ))
)

-- ======================================

The content of tnsnames. ora is as follows:

TEST =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP) (HOST = xys) (PORT = 1521 ))
)
(CONNECT_DATA =
(SERVICE_NAME = test)
)
)

-- ======================================

It is clearly stated that the global database name (GLOBAL_DBNAME) that needs to be entered during static listener registration can be entered

Make sure that the GLOBAL_DBNAME in listerner. ora is consistent with the SERVICE_NAME in tnsnames. ora.

Test to see the effect:

It is worth noting that GLOBAL_DBNAME = test. In this case, db_name, global_name, and service_names of the database are as follows:

Shown below:

SQL> show parameter db_name

NAME TYPE VALUE
-----------------------------------------------------------------------------
Db_name string test1
SQL> select * from global_name;

GLOBAL_NAME
--------------------------------------------------------------------------------

Test1

SQL> alter database rename global_name to abcd. yu;

The database has been changed.

SQL> select * from global_name;

GLOBAL_NAME
--------------------------------------------------------------------------------

ABCD. YU

SQL>
SQL> show parameter service_names

NAME TYPE VALUE
-----------------------------------------------------------------------------
Service_names string TEST2, TEST3
SQL>

However, the test, db_name, globl_name, and service_name provided when I configure listener and tnsnames do not have any relationship. Then

Let's take a look at the effect of tnsping:

C:> tnsping test
Alias resolved using TNSNAMES Adapter
Attempting to contact (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)
(HOST = xys) (PORT = 1521) (CONNECT_DATA = (SERVICE_NAME = test )))
OK (30 ms)

C:>

9. db_unique_name

DB_UNIQUE_NAME is a 10G parameter. When configuring the dataguard environment, you must set a unique value for each database in the dg Environment. Before the DB_UNIQUE_NAME parameter is absent, when building dg on the same machine, the LOCK_NAME_SPACE parameter must be used. In the standby parameter file, 10 GB

Db_unique_name and LOCK_NAME_SPACE have been deprecated!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.