DBNEWID 使用一:更改DBID

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>

 

 


 

上一篇:微软发布Win8补丁 修复IE10漏洞


下一篇:浅谈BFC