DBNEWIN工具使用一:更改DBID

wuweilong發表於2011-12-21
DBNEWID 工具的使用:
     DBNEWID 工具是用於更改資料庫SID和資料庫DBNAME;DBID是ORACLE用來標識這個資料庫的唯一內部ID號,DBNAME用於標識資料庫的唯一名稱;
通常情況下使用者使用者是不容易修改ORACLE的DBID和DBNAME的,但是有特殊情況的時候需要修改,ORACLE為我們提供了DBNEWID這個工具來輔助我們去
更改DBID和DBNAME。
一、更改DBID
    DBID是資料庫唯一內部識別符號,一旦更改後,該資料庫的原有日誌檔案和歸檔檔案均不能使用,同時也會修改所有的控制檔案資料檔案頭部的DBID,並
且在啟動的時候必須使用resetlogs選項重新建立資料庫的日誌組。本人建議在生產環境中不到萬不得已最好還是別改,如果一旦要修改DBID,一定要事先停
止當前資料庫的所有業務並用RMAN對資料庫進行一次全備,後再修改,備份過程再次就不論述了,在後期的RMAN文件中將會有詳細的論述。

1、檢查資料庫的當前DBID
SQL> select dbid,name from v$database;
      DBID NAME
---------- ---------
4284499451 WWL
2、關閉資料庫,並將資料庫啟動到MOUNT狀態
SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup mount;
ORACLE instance started.
Total System Global Area  285212672 bytes
Fixed Size                  1218992 bytes
Variable Size              62916176 bytes
Database Buffers          218103808 bytes
Redo Buffers                2973696 bytes
Database mounted.
SQL> host
3、透過使用NID命令來修改資料庫的DBID
[oracle@ora10g dbs]$ nid target=sys/oracle
DBNEWID: Release 10.2.0.1.0 - Production on Wed Dec 7 00:18:52 2011
Copyright (c) 1982, 2005, Oracle.  All rights reserved.
Connected to database WWL (DBID=4284499451)
Connected to server version 10.2.0
Control Files in database:
    /oradata/wwl/control01.ctl
    /oradata/wwl/control02.ctl
    /oradata/wwl/control03.ctl
Change database ID of database WWL? (Y/[N]) => Y 
Proceeding with operation
Changing database ID from 4284499451 to 4286252909
    Control File /oradata/wwl/control01.ctl - modified
    Control File /oradata/wwl/control02.ctl - modified
    Control File /oradata/wwl/control03.ctl - modified
    Datafile /oradata/wwl/system01.dbf - dbid changed
    Datafile /data2/test_local_01.dbf - dbid changed
    Datafile /oradata/wwl/sysaux01.dbf - dbid changed
    Datafile /oradata/wwl/users01.dbf - dbid changed
    Datafile /oradata/wwl/test01_01.dbf - dbid changed
    Datafile /data2/test001_01.dbf - dbid changed
    Datafile /data2/test001_02.dbf - dbid changed
    Datafile /data2/test002_01.dbf - dbid changed
    Datafile /data2/bigfile001.dbf - dbid changed
    Datafile /data2/undotbs2_01.dbf - dbid changed
    Datafile /oradata/wwl/temp01.dbf - dbid changed
    Datafile /data2/temp01_01.dbf - dbid changed
    Control File /oradata/wwl/control01.ctl - dbid changed
    Control File /oradata/wwl/control02.ctl - dbid changed
    Control File /oradata/wwl/control03.ctl - dbid changed
    Instance shut down
Database ID for database WWL changed to 4286252909.
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.
4、成功修改完DBID後登陸到資料庫
[oracle@ora10g dbs]$ sqlplus / as sysdba
SQL*Plus: Release 10.2.0.1.0 - Production on Wed Dec 7 00:19:41 2011
Copyright (c) 1982, 2005, Oracle.  All rights reserved.
Connected to an idle instance.
5、首先啟動到mount狀態
SQL> startup mount;
ORACLE instance started.
Total System Global Area  285212672 bytes
Fixed Size                  1218992 bytes
Variable Size              62916176 bytes
Database Buffers          218103808 bytes
Redo Buffers                2973696 bytes
Database mounted.
6、將資料庫啟動到open resetlogs狀態,這個時候將會清空原有的redo log組中的資訊
SQL> alter database open resetlogs;
Database altered.
7、我們看到DBID已由原來的4284499451改變為4286252909,當然這個改變的值不是我們自己可以控制的。
SQL> select dbid,name from v$database;
      DBID NAME
---------- ---------
4286252909 WWL
SQL> select * from v$log;
8、檢查redo log 資訊已經清空。
SQL> set line 200
SQL> select * from v$log;
    GROUP#    THREAD#  SEQUENCE#      BYTES    MEMBERS ARC STATUS           FIRST_CHANGE# FIRST_TIME
---------- ---------- ---------- ---------- ---------- --- ---------------- ------------- ----------
         1          1          1   52428800          1 NO  CURRENT                 670390 07-12?-11
         2          1          0   52428800          1 YES UNUSED                       0
         3          1          0   52428800          1 YES UNUSED                       0
SQL> select * from v$logfile;
    GROUP# STATUS  TYPE    MEMBER                                   IS_
---------- ------- ------- ---------------------------------------- ---
         3         ONLINE  /oradata/wwl/redo03.log                  NO
         2         ONLINE  /oradata/wwl/redo02.log                  NO
         1         ONLINE  /oradata/wwl/redo01.log                  NO
SQL> alter system switch logfile;
System altered.
SQL> alter system switch logfile;
System altered.
SQL> alter system switch logfile;
System altered.
SQL> alter system switch logfile;
System altered.
SQL> select * from v$log;
    GROUP#    THREAD#  SEQUENCE#      BYTES    MEMBERS ARC STATUS           FIRST_CHANGE# FIRST_TIME
---------- ---------- ---------- ---------- ---------- --- ---------------- ------------- ----------
         1          1          4   52428800          1 YES INACTIVE                671378 07-12?-11
         2          1          5   52428800          1 NO  CURRENT                 671389 07-12?-11
         3          1          3   52428800          1 YES INACTIVE                671375 07-12?-11
SQL>
SQL>
SQL>
SQL>
SQL>
SQL>
SQL>
 
 

 

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

相關文章