修改DBID, DBNAME步骤 不是instance_name哦!

来源:互联网 发布:手机暗黑类游戏 知乎 编辑:程序博客网 时间:2024/05/20 11:33

修改DBID,  DBNAME步骤

       在这里,只演示一下修改DBID 和 DBNAME的操作。 并不修改INSTANE_NAME.

 

步骤如下:

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

 

 

在修改之前,先看一下数据库的参数:

SQL> select name,dbid,db_unique_name from v$database;

NAME  DBID DB_UNIQUE_NAME

--------- ---------- ------------------------------

ORCL  1264931370 orcl

SQL> select instance_name from v$instance;

INSTANCE_NAME

----------------

orcl

 

 

2.1 shutdown database

SQL> shutdown immediate

Database closed.

Database dismounted.

ORACLE instance shut down.

 

2.2  Startup mount

SQL> startup mount;

ORACLE instance started.

 

Total System Global Area  360710144 bytes

Fixed Size                  1219424 bytes

Variable Size             109053088 bytes

Database Buffers          247463936 bytes

Redo Buffers                2973696 bytes

Database mounted.

 

2.3 Run NID command

[oracle@singledb bdump]$ nid

DBNEWID: Release 10.2.0.1.0 - Production on Mon Dec 20 14:26:13 2010

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

 

[oracle@singledb bdump]$ nid target=/ dbname=dave

DBNEWID: Release 10.2.0.1.0 - Production on Mon Dec 20 14:27:13 2010

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

Connected to database ORCL (DBID=1264931370)

Connected to server version 10.2.0

Control Files in database:

    /u01/app/oracle/oradata/orcl/control01.ctl

    /u01/app/oracle/oradata/orcl/control02.ctl

    /u01/app/oracle/oradata/orcl/control03.ctl

 

Change database ID and database name ORCL to DAVE? (Y/[N]) => Y  --手工输入

 

Proceeding with operation

Changing database ID from 1264931370 to 801102850

Changing database name from ORCL to DAVE

    Control File /u01/app/oracle/oradata/orcl/control01.ctl - modified

    Control File /u01/app/oracle/oradata/orcl/control02.ctl - modified

    Control File /u01/app/oracle/oradata/orcl/control03.ctl - modified

    Datafile /u01/app/oracle/oradata/orcl/system.256.736598559 - dbid changed, wrote new name

    Datafile /u01/app/oracle/oradata/orcl/undotbs1.258.736598599 - dbid changed, wrote new name

    Datafile /u01/app/oracle/oradata/orcl/sysaux.257.736598563 - dbid changed, wrote new name

    Datafile /u01/app/oracle/oradata/orcl/users.259.736598641 - dbid changed, wrote new name

    Datafile /u01/app/oracle/oradata/orcl/temp.263.736599505 - dbid changed, wrote new name

    Datafile /u01/app/oracle/oradata/orcl/temp01.dbf - dbid changed, wrote new name

    Control File /u01/app/oracle/oradata/orcl/control01.ctl - dbid changed, wrote new name

    Control File /u01/app/oracle/oradata/orcl/control02.ctl - dbid changed, wrote new name

    Control File /u01/app/oracle/oradata/orcl/control03.ctl - dbid changed, wrote new name

    Instance shut down

 

Database name changed to DAVE.

Modify parameter file and generate a new password file before restarting.

Database ID for database DAVE changed to 801102850.

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 name and ID.

DBNEWID - Completed succesfully.

 

[oracle@singledb bdump]$

 

 

2.4 修改PFILE 里的DB_NAME参数

[oracle@singledb dbs]$ cat initorcl.ora

...

*.db_name='dave'

...

 

2.5 pfile启动数据库,并用resetlogs 打开

SQL> startup mount pfile='/u01/app/oracle/product/10.2.0/db_1/dbs/initorcl.ora';

ORACLE instance started.

Total System Global Area  360710144 bytes

Fixed Size                  1219424 bytes

Variable Size             109053088 bytes

Database Buffers          247463936 bytes

Redo Buffers                2973696 bytes

Database mounted.

SQL> alter database open resetlogs;

Database altered.

 

2.7 查看修改之后的信息

SQL>  select name,dbid,db_unique_name from v$database;

NAME   DBID DB_UNIQUE_NAME

--------- ---------- ------------------------------

DAVE   801102850 dave

 

SQL> select instance_name from v$instance;

INSTANCE_NAME

----------------

orcl

 

SQL>

 

       在这里看到, db_name 和DBID 都修改了,但是instance_name 没有修改。  在官网的文档里提到了重建密码文件,因为我的instance_name没有修改,所以我没有进行重建。

 

原创粉丝点击