DB_NAME DB_UNIQUE_NAME 和 SID 的理解

kisslfcr發表於2016-02-15
1. DB_NAME 表示資料庫名稱,DB_NAME 會保持在資料檔案頭、控制檔案、REDO檔案裡,所以更改DB_NAME不能僅僅修改spfile ,還需要用nid 來進行更改,並且更改後還需要手工做些工作,使其生效。
DB_NAME 最長 8 個字元。


2. 在 DG下,主庫和物理從庫的 DB_NAME 是一致的,主庫和物理從庫的DB_UNIQUE_NAME 不同,DB_UNIQUE_NAME 用於標識主從庫。


修改 DB_UNIQUE_NAME 需要修改 spfile 並重啟資料庫;
由於 DB_NAME 記錄在資料檔案頭、控制檔案、REDO檔案裡,所以修改 DB_NAME 一般有兩種方式:
(1)備份控制檔案到trace,修改 spfile,重啟資料庫,resetlogs 開啟資料庫
(2)或者透過 nid 命令修改


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


doc上把sid解釋為在host上用sid來標示例項的共享記憶體的,可見sid主要是和os打交道的。


sid可以透過如下語句在庫中查詢: select instance_name from v$instance;


(I):如果你只想更改資料庫的id(dbid),那麼你只需要指定target引數就可以了,具體的操作過程,請參考如下:
1. Backup the database
2. SHUTDOWN IMMEDIATE of the database
3. STARTUP MOUNT
4. Open one session and run NID with sysdba privileges
% nid TARGET=SYS/password@test_db
5. Shutdown IMMEDIATE of the database
6. Set the DB_NAME initialization parameter in the initialization parameter
file to the new database name
7. Create a new password file
8. Startup of the database with open resetlogs
(II):如果你想只更改資料庫名(db_name),那麼你需要設定SETNAME引數為Y,同時指定DBNAME引數,具體的操作過程,請參考如下:
1. Backup the database
2. SHUTDOWN IMMEDIATE of the database
3. STARTUP MOUNT
4. Open one session and run NID with sysdba privileges
% nid TARGET=SYS/password@test_db DBNAME=test_db2 SETNAME=Y
- the value of DBNAME is the new dbname of the database
- SETNAME must be set to Y. The default is N and causes the
DBID to be changed also.
5. shutdown IMMEDIATE of the database
6. Set the DB_NAME initialization parameter in the initialization parameter
file to the new database name
7. Create a new password file
8. Startup of the database(without resetlogs)
(III):如果你想同時更改資料庫名(db_name)和資料庫ID(dbid),那麼你要指定DBNAME引數,同時設定SETNAME為N(其值預設也為N),具體操作過程,請參考如下:
1. Backup of the database.
2. Shutdown IMMEDIATE of the database
3. STARTUP MOUNT
4. Open one session and run NID with sysdba privileges
% nid TARGET=SYS/password@test_db DBNAME=test_db2
- the value of DBNAME is the new dbname of the database
5. After DBNEWID successfully changes the DBID,Shutdown IMMEDIATE of the database
6. Set the DB_NAME initialization parameter in the initialization parameter file to the new database name.
7. Create a new password file.
8. Startup of the database with open resetlogs
(IV):如果你只更改了資料庫名,而沒有更改資料庫id,那麼你開啟資料庫就不需要open resetlogs了。
在構建DG的時候,從庫上提示:


ORA-16047: DGID mismatch between destination setting and standby


其實就是主從庫上配置的 db_unique_name, log_archive_config 引數是否匹配導致的。

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/29135257/viewspace-1989004/,如需轉載,請註明出處,否則將追究法律責任。

相關文章