DBID SID DB_NAME DB_DOMAIN DB_UNIQUE_NAME INSTANCE_NAME GLOBAL_NAME

一、DB相关的参数
1.1、DBID(DataBase IDentifier):

Oracle官网对DBID的解释:
       An internal, uniquely generated number that differentiates databases. Oracle creates this number automatically when you create the database.
查看DBID:

SQL> select dbid from v$database;

DBID
----------
1346107797
使用DBNEWID Utility去修改DBID(可以使用DBNEWID去修改DBNAME和DBID):
http://docs.oracle.com/cd/E11882_01/server.112/e16536/dbnewid.htm#SUTIL014

Changing the DBID of a database is a serious procedure. When the DBID of a database is changed, all previous backups and archived logs of the database become unusable. This is similar to creating a database except that the data is already in the data files. After you change the DBID, backups and archive logs that were created before the change can no longer be used because they still have the original DBID, which does not match the current DBID. You must open the database with the RESETLOGS option, which re-creates the online redo logs and resets their sequence to 1 (see Oracle Database Administrator's Guide). Consequently, you should make a backup of the whole database immediately after changing the DBID.
Changing the DBNAME without changing the DBID does not require you to open with the RESETLOGS option, so database backups and archived logs are not invalidated. However, changing the DBNAME does have consequences. You must change the DB_NAME initialization parameter after a database name change to reflect the new name. Also, you may have to re-create the Oracle password file. If you restore an old backup of the control file (before the name change), then you should use the initialization parameter file and password file from before the database name change.
Do not change the DBID or DBNAME of a database if you are using a capture process to capture changes to the database. See Oracle Streams Concepts and Administration for more information about capture processes.


1.2、SID(System Identifier):
Oracle官网对SID的解释:

http://docs.oracle.com/cd/E11882_01/server.112/e40540/startup.htm#CNCPT89037

The system identifier (SID) is a unique name for an Oracle database instance on a specific host. On UNIX and Linux, Oracle Database uses the SID and Oracle home values to create a key to shared memory. Also, the SID is used by default to locate the parameter file, which is used to locate relevant files such as the database control files.
On most platforms, the ORACLE_SID environment variable sets the SID, whereas the ORACLE_HOME variable sets the Oracle home. When connecting to an instance, clients can specify the SID in an Oracle Net connection or use a net service name. Oracle Database converts a service name into an ORACLE_HOME and ORACLE_SID.

查看SID:
SQL> select instance_name from v$instance;

INSTANCE_NAME
----------------

orcl

1.3数据库名称(DBNAME)

在初始化参数文件中数据库名称用DB_NAME来指定。

SQL> startup nomount;
ORACLE instance started.
Total System Global Area  535662592 bytes
Fixed Size                  1337720 bytes
Variable Size             390071944 bytes
Database Buffers          138412032 bytes
Redo Buffers                5840896 bytes

SQL> show parameter db_name;

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
db_name                              string      PANDA

在控制文件总也保存着数据库名称,可以使用V$DATABASE查看(V$DATABASE displays information about the database from the control file.)。当启动时初始化参数文件中的数据库名称与控制文件中的数据库名称不同时会报ORA-01103(例如:ORA-01103: database name 'PANDA' in control file is not 'ORCL')

SQL> select name from v$database;
NAME
---------
PANDA

使用DBNEWID Utility去修改DBNAME(可以使用DBNEWID去修改DBNAME和DBID):
http://docs.oracle.com/cd/E11882_01/server.112/e16536/dbnewid.htm#SUTIL014

也可以重建控制文件来修改DBNAME.

二、Pfile 中的参数
2.1、DB_NAME

Oracle官网对DB_NAME的解释:

http://docs.oracle.com/cd/E11882_01/server.112/e40402/initparams064.htm#REFRN10041

DB_NAME specifies a database identifier of up to 8 characters. This parameter must be specified and must correspond to the name specified in the CREATE DATABASE statement.
If you have multiple databases, the value of this parameter should match the Oracle instance identifier of each one to avoid confusion with other databases running on the system. The value of DB_NAME should be the same in both the standby and production initialization parameter files.
The database name specified in either the STARTUP command or the ALTER DATABASE ... MOUNT statement for each instance of the cluster database must correspond to the DB_NAME initialization parameter setting.
The following characters are valid in a database name: alphanumeric characters, underscore (_), number sign (#), and dollar sign ($). No other characters are valid. Oracle removes double quotation marks before processing the database name. Therefore you cannot use double quotation marks to embed other characters in the name. The database name is case insensitive.


DB_NAME是数据库名,它的长度不能超过8个字节,超过8个会被截断。对于RAC环境,各个节点之间的DB_NAME都是相同的,INSTANCE_NAME 不同。 对于Data Guard环境,DB_NAME相同,DB_UNIQUE_NAME 不同。

查看DBNAME:
SQL> show parameter db_name

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
db_name                              string      orcl

修改DB_NAME:
使用DBNEWID Utility去修改DBNAME(可以使用DBNEWID去修改DBNAME和DBID):
http://docs.oracle.com/cd/E11882_01/server.112/e16536/dbnewid.htm#SUTIL014

2.2、DB_DOMAIN
Oracle官网对DB_DOMAIN的解释:
http://docs.oracle.com/cd/E11882_01/server.112/e40402/initparams055.htm#REFRN10036

Property Description
Parameter type String
Syntax DB_DOMAIN = domain_name
Default value There is no default value.
Modifiable No
Range of values Any legal string of name components, separated by periods and up to 128 characters long (including the periods).
Basic Yes
Oracle RAC You must set this parameter for every instance, and multiple instances must have the same value.

In a distributed database system, DB_DOMAIN specifies the logical location of the database within the network structure. You should set this parameter if this database is or ever will be part of a distributed system. The value consists of the extension components of a global database name, consisting of valid identifiers (any alphanumeric ASCII characters), separated by periods.


Note:
Oracle recommends that you specify DB_DOMAIN as a unique string for all databases in a domain.
This parameter allows one department to create a database without worrying that it might have the same name as a database created by another department. If one sales department's DB_DOMAIN is JAPAN.ACME.COM, then their SALES database (SALES.JAPAN.ACME.COM) is uniquely distinguished from another database with DB_NAME = SALES but with DB_DOMAIN = US.ACME.COM.
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 (#).


2.3、DB_UNIQUE_NAME
Oracle官网对DB_UNIQUE_NAME的解释:

http://docs.oracle.com/cd/E11882_01/server.112/e40402/initparams070.htm#REFRN10242

Property Description
Parameter type String
Syntax DB_UNIQUE_NAME = database_unique_name
Default value Database instances: the value of DB_NAME
Automatic Storage Management instances: +ASM
Modifiable No
Basic Yes
Oracle RAC Multiple instances must have the same value.
DB_UNIQUE_NAME specifies a globally unique name for the database. Databases with the same DB_NAME within the same DB_DOMAIN (for example, copies of a database created for reporting or a physical standby) must have a unique DB_UNIQUE_NAME. Every database's DB_UNIQUE_NAME must be unique within the enterprise.
The value of DB_UNIQUE_NAME can be up to 30 characters and is case insensitive. The following characters are valid in a database name: alphanumeric characters, underscore (_), number sign (#), and dollar sign ($).

Note:
As part of their operations, some database tools or utilities create a string that uniquely identifies a database. The string may include the DB_UNIQUE_NAME for a database, and other identifying information for the database, such as the database SID. Oracle Database restricts some identifiers to 30 characters, so using a short DB_UNIQUE_NAME can help prevent ORA-00972 "identifier is too long" messages from database tools and utilities that create a string that includes the DB_UNIQUE_NAME.
See Al


查看db_unique_name:
SQL> show parameter db_unique_name

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
db_unique_name                       string      orcl

2.4、INSTANCE_NAME
Oracle官网对INSTANCE_NAME的解释:

http://docs.oracle.com/cd/E11882_01/server.112/e40402/initparams105.htm#REFRN10072

Property Description
Parameter type String
Syntax INSTANCE_NAME = instance_id
Default value The instance's SID
Note: The SID identifies the instance's shared memory on a host, but may not uniquely distinguish this instance from other instances.
Modifiable No
Range of values Any alphanumeric characters and the underscore (_) character
Basic No
In a Real Application Clusters environment, multiple instances can be associated with a single database service. Clients can override Oracle's connection load balancing by specifying a particular instance by which to connect to the database. INSTANCE_NAME specifies the unique name of this instance.
In a single-instance database system, the instance name is usually the same as the database name.

如果在初始化参数文件中指定了instance_name的值,则instance_name为初始化参数文件中的设定值,否则instance_name取默认值(操作系统的环境变量ORACLE_SID).

2.5、SERVICE_NAME:
Oracle官网对SID的解释:

http://docs.oracle.com/cd/E11882_01/server.112/e40540/dist_pro.htm#CNCPT9855

In the context of net services, a service is a set of one or more database instances. A service name is a logical representation of a service used for client connections.
When a client connects to a listener, it requests a connection to a service. When a database instance starts, it registers itself with a listener as providing one or more services by name. Thus, the listener acts as a mediator between the client and instances and routes the connection request to the right place.
A single service, as known by a listener, can identify one or more database instances. Also, a single database instance can register one or more services with a listener. Clients connecting to a service need not specify which instance they require.


2.6、GLOBAL_NAME

oracle官方解释:

http://docs.oracle.com/cd/E11882_01/server.112/e16536/dbnewid.htm#SUTIL1542

If you are dealing with a database in a distributed database system, then each database should have a unique global database nameThe DBNEWID utility does not change global database names. This can only be done with the SQL ALTER DATABASE statement, for which the syntax is as follows:

ALTER DATABASE RENAME GLOBAL_NAME TO newname.domain;

The global database name is made up of a database name and a domain, which are determined by the DB_NAME and DB_DOMAIN initialization parameters when the database is first created.

The following example changes the database name to sales in the domain us.example.com:

ALTER DATABASE RENAME GLOBAL_NAME TO sales.us.example.com

You would do this after you finished using DBNEWID to change the database name.

global_name是由db_name.db_domain组成
查看global_name:
SQL> select * from global_name;

GLOBAL_NAME
-------------------------------------------
ORCL

2.7、GLOBAL_NAMES
Oracle官网对GLOBAL_NAMES的解释:
http://docs.oracle.com/cd/E11882_01/server.112/e40402/initparams098.htm#REFRN10065

Property Description
Parameter type Boolean
Default value false
Modifiable ALTER SESSION, ALTER SYSTEM
Range of values true | false
Basic No

GLOBAL_NAMES specifies whether a database link is required to have the same name as the database to which it connects.

If the value of GLOBAL_NAMES is false, then no check is performed. If you use or plan to use distributed processing, then Oracle recommends that you set this parameter to true to ensure the use of consistent naming conventions for databases and links in a networked environment.

Global_names 是一个布尔值,global_names的作用是创建db link时是否强制使用远程数据库的global_name,如果global_names=true,则db link name必须要求是remote database的global_name,否则创建之后db link 不能连同,缺省值是false。多用于分布式系统。

查看global_names:
SQL> show parameter global_names
NAME                  TYPE        VALUE
------------------------------------ ----------- -------
global_names             boolean     FALSE

三.  Listener.ora 文件中的参数
先看一个listener.ora 文件:
[oracle@dg2 admin]$ cat listener.ora
SID_LIST_LISTENER =
  (SID_LIST =
    (SID_DESC =
      (SID_NAME = PLSExtProc)
      (ORACLE_HOME = /u01/app/oracle/product/10.2.0/db_1)
      (PROGRAM = extproc)
    )
    (SID_DESC =
      (SID_NAME = orcl)
      (ORACLE_HOME = /u01/app/oracle/product/10.2.0/db_1)
      (GLOBAL_DBNAME = orcl)
    ) 
)
 
3.1 SID_NAME
       SID_NAME指数据库的运行的实例名,和instance_name保持一致。
 
3.2 GLOBAL_DBNAME
       配置静态监听注册时,需要输入SID和GLOBAL_NAME。 我上面贴出来的内容,就是静态监听配置的内容。 SID 已经说过,和Instance_name 保持一致就可以了。
       GLOBAL_DBNAME 是listener配置的对外网络连接名称,我们可以写成任意值。 在客户端配置监听的tnsnames.ora 文件中的service_name 与这个GLOBAL_DBNAME 保持一致就可以了。因为客户端访问数据库是通过监听来实现的。
 
       如果采用动态注册的话,PMON进程会根据初始化参数initSID.ora中的instance_name,service_names两个参数将实例和服务动态注册到listener中,这时自动注册的对外网络连接名称就是initSID.ora文件中service_names.
     因为service_names可以有多个值,如果有多个值,就会注册多个。 但是他们对应都是同一个instance_name。 这样,我们在客户端配置tnsnames.ora 时,在service_name 写其中任意一个都可以正常连上数据库。
 
四. Tnsnames.ora 文件
 
先看一个tnsnames.ora 文件:
ORCL_PD =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.3.2)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SERVICE_NAME = orcl)
    )
  )
 
4.1  SERVICE_NAME
       如果服务器采监听采用了静态注册,那么这个参数就等于Listener.ora 文件中的GLOBAL_DBNAME的值。
       如果是动态注册,那么这个值就是initSID.ora 文件中service_names中的值。
 
4.2  SID
       在tnsnames.ora文件中还可以使用SID。 如果使用该参数,只需要把该参数指定为instance_name就可以了。


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值