dbnewid修改dbid和庫名

lingsam發表於2014-02-18

dbnewid可用於修改dbid和dbname。
dbnewid是oracle提供的工具程式,通過執行命令nid完成。
[oracle@target ~]$ nid

DBNEWID: Release 10.2.0.1.0 - Production on Tue Feb 18 15:58:50 2014

Copyright (c) 1982, 2005, Oracle.  All rights reserved.

Keyword     Description                    (Default)
----------------------------------------------------
TARGET      Username/Password              (NONE)
DBNAME      New database name              (NONE)
LOGFILE     Output Log                     (NONE)
REVERT      Revert failed change           NO
SETNAME     Set a new database name only   NO
APPEND      Append to output log           NO
HELP        Displays these messages        NO

1.修改全域性資料庫名
   不能使用dbnewid,可使用sql語句執行
   sql>conn / as sysdba
   sql>alter database rename global_name to ling.com;
   sql>select * from global_name;
2.修改dbid
  dbid是資料庫內部的唯一識別符號。因為rman使用dbid區分不同資料庫,所以為了在同一恢復目錄中備份源資料庫和複製資料庫,就需要改變dbid。
步驟:
sql>conn / as sysdba
sql>shutdown immediate;
sql>startup mount;
sql>host nid target=sys/ling
BNEWID: Release 10.2.0.1.0 - Production on Tue Feb 18 15:19:11 2014
Copyright (c) 1982, 2005, Oracle.  All rights reserved.
Connected to database LING (DBID=606074752)
Connected to server version 10.2.0
Control Files in database:
    /u01/oradata/LING/controlfile/o1_mf_8qk320b3_.ctl
    /u01/flash_recovery_area/LING/controlfile/o1_mf_8qk320mq_.ctl

Change database ID of database LING? (Y/[N]) => y

Proceeding with operation
Changing database ID from 606074752 to 632280239
    Control File /u01/oradata/LING/controlfile/o1_mf_8qk320b3_.ctl - modified
    Control File /u01/flash_recovery_area/LING/controlfile/o1_mf_8qk320mq_.ctl - modified
    Datafile /u01/oradata/LING/datafile/o1_mf_system_8qk32cxo_.dbf - dbid changed
    Datafile /u01/oradata/LING/datafile/o1_mf_undotbs1_8qk332sy_.dbf - dbid changed
    Datafile /u01/oradata/LING/datafile/o1_mf_sysaux_8qk339fm_.dbf - dbid changed
    Datafile /u01/oradata/LING/datafile/o1_mf_users_8qk33vwp_.dbf - dbid changed
    Datafile /u01/oradata/LING/datafile/goldengate.dbf - dbid changed
    Datafile /u01/oradata/LING/datafile/o1_mf_temp_8qk33gop_.tmp - dbid changed
    Control File /u01/oradata/LING/controlfile/o1_mf_8qk320b3_.ctl - dbid changed
    Control File /u01/flash_recovery_area/LING/controlfile/o1_mf_8qk320mq_.ctl - dbid changed
    Instance shut down

Database ID for database LING changed to 632280239.
All previous backups and archived redo logs for this database are unusable.
Database is not aware of previous backups and archived logs in Recovery Area.
Database has been shutdown, open database with RESETLOGS option.
Succesfully changed database ID.
DBNEWID - Completed succesfully.

sql>exit;
sql>conn / as sysdba
sql>startup mount;
sql>alter database open resetlogs;

3.更改dbname
使用資料庫的高階複製特性時,需要兩個資料庫的庫名不一樣。修改資料庫名有兩種方式:1.重建控制檔案2.使用dbnewid工具
步驟:
sql>conn / as sysdba
sql>shutdown immediate;
sql>startup mount;
sql>host nid target=sys/ling dbname=ling setname=y

輸入y
sql>alter system set db_name=ling scope=both;  --修改初始化引數檔案中的庫名
sql>host  orapwd file=$ORACLE_HOME/dbs/pwding.ora password=admin

重啟資料庫:
sql>conn /as sysdba
sql>startup pfile=$ORACLE_HOME/dbs/initling.ora
sql>create spfile from pfile;


 

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

相關文章