ITPub博客

首页 > 数据库 > Oracle > 使用NID修改DBID和DBNAME实验(下)

使用NID修改DBID和DBNAME实验(下)

原创 Oracle 作者:realkid4 时间:2016-10-24 14:47:46 0 删除 编辑

 

3、单独修改DBID情况

 

如果是单独修改DBID的情况呢?需要修改的范围略小一些。

 

 

[oracle@MYTElife admin]$ env | grep ORA

ORACLE_SID=testdb

ORACLE_BASE=/u01/app/oracle

ORACLE_HOME=/u01/app/oracle/product/11.2.0/dbhome_1

 

 

启动数据库到mount状态,启动nid进行修改。

 

 

SQL> shutdown immediate;

Database closed.

Database dismounted.

ORACLE instance shut down.

SQL> startup mount

ORACLE instance started.

 

Total System Global Area 3540881408 bytes

Fixed Size                  2258320 bytes

Variable Size             872417904 bytes

Database Buffers         2650800128 bytes

Redo Buffers               15405056 bytes

Database mounted.

SQL> quit

Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production

With the Partitioning, OLAP, Data Mining and Real Application Testing options

[oracle@MYTElife dbs]$ cd $ORACLE_HOME/bin

 

 

调用nid命令进行设置。

 

 

[oracle@MYTElife bin]$ nid target=sys/oracle

 

DBNEWID: Release 11.2.0.4.0 - Production on Wed Oct 19 19:29:34 2016

 

Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.

 

Connected to database TESTDB (DBID=2708979596)

 

Connected to server version 11.2.0

 

Control Files in database:

    /u01/app/oracle/oradata/MYTEDB/controlfile/o1_mf_bw7762ov_.ctl

    /u01/app/oracle/fast_recovery_area/MYTEDB/controlfile/o1_mf_bw7762v3_.ctl

 

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

 

Proceeding with operation

Changing database ID from 2708979596 to 2708978718

    Control File /u01/app/oracle/oradata/MYTEDB/controlfile/o1_mf_bw7762ov_.ctl - modified

    Control File /u01/app/oracle/fast_recovery_area/MYTEDB/controlfile/o1_mf_bw7762v3_.ctl - modified

    Datafile /u01/app/oracle/oradata/MYTEDB/datafile/o1_mf_system_bw773xok_.db - dbid changed

    Datafile /u01/app/oracle/oradata/MYTEDB/datafile/o1_mf_sysaux_bw773xpr_.db - dbid changed

    Datafile /u01/app/oracle/oradata/MYTEDB/datafile/o1_mf_undotbs1_bw773xqo_.db - dbid changed

    Datafile /u01/app/oracle/oradata/MYTEDB/datafile/o1_mf_users_bw773xrv_.db - dbid changed

    Datafile /u01/app/oracle/oradata/MYTEDB/datafile/o1_mf_MYTEdev_bw8xbqrz_.db - dbid changed

    Datafile /u01/app/oracle/oradata/MYTEDB/datafile/o1_mf_inttestt_bw8xdnkt_.db - dbid changed

    Datafile /u01/app/oracle/oradata/MYTEDB/datafile/o1_mf_epssite_by19vtnh_.db - dbid changed

    Datafile /u01/app/oracle/oradata/MYTEDB/datafile/o1_mf_temp_bw776mow_.tm - dbid changed

    Control File /u01/app/oracle/oradata/MYTEDB/controlfile/o1_mf_bw7762ov_.ctl - dbid changed

    Control File /u01/app/oracle/fast_recovery_area/MYTEDB/controlfile/o1_mf_bw7762v3_.ctl - dbid changed

    Instance shut down

 

Database ID for database TESTDB changed to 2708978718.

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.

 

 

启动数据库,由于新的DBID出现,需要使用resetlogs命令启动。

 

 

[oracle@MYTElife bin]$ sqlplus /nolog

 

SQL*Plus: Release 11.2.0.4.0 Production on Wed Oct 19 19:30:08 2016

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

 

SQL> conn / as sysdba

Connected to an idle instance.

SQL> startup mount;

ORACLE instance started.

 

Total System Global Area 3540881408 bytes

Fixed Size                  2258320 bytes

Variable Size             872417904 bytes

Database Buffers         2650800128 bytes

Redo Buffers               15405056 bytes

Database mounted.

SQL> alter database open resetlogs;

 

Database altered.

 

SQL> select dbid, name from v$database;

 

      DBID NAME

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

2708978718 TESTDB

 

 

由于DBNAME没有修改,参数文件、密码文件和Oracle Net不需要进行修改。

 

4、修改DBNAME情况

 

如果单独修改DBNAME,需要修改的文本类型文件多一些。但是,启动数据库时候不需要resetlogs,并且归档日志、备份集合都可以使用。

 

操作同样,都是在mount状态上。

 

 

SQL> shutdown immediate;

Database closed.

Database dismounted.

ORACLE instance shut down.

SQL> startup mount

ORACLE instance started.

 

Total System Global Area 3540881408 bytes

Fixed Size                  2258320 bytes

Variable Size             872417904 bytes

Database Buffers         2650800128 bytes

Redo Buffers               15405056 bytes

Database mounted.

 

 

调用nid命令。

 

 

[oracle@MYTElife bin]$ nid target=sys/oracle dbname=MYTEdb setname=yes

 

DBNEWID: Release 11.2.0.4.0 - Production on Wed Oct 19 19:46:11 2016

 

Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.

 

Connected to database TESTDB (DBID=2708978718)

 

Connected to server version 11.2.0

 

Control Files in database:

    /u01/app/oracle/oradata/MYTEDB/controlfile/o1_mf_bw7762ov_.ctl

    /u01/app/oracle/fast_recovery_area/MYTEDB/controlfile/o1_mf_bw7762v3_.ctl

 

Change database name of database TESTDB to MYTEDB? (Y/[N]) => y

 

Proceeding with operation

Changing database name from TESTDB to MYTEDB

    Control File /u01/app/oracle/oradata/MYTEDB/controlfile/o1_mf_bw7762ov_.ctl - modified

    Control File /u01/app/oracle/fast_recovery_area/MYTEDB/controlfile/o1_mf_bw7762v3_.ctl - modified

    Datafile /u01/app/oracle/oradata/MYTEDB/datafile/o1_mf_system_bw773xok_.db - wrote new name

    Datafile /u01/app/oracle/oradata/MYTEDB/datafile/o1_mf_sysaux_bw773xpr_.db - wrote new name

    Datafile /u01/app/oracle/oradata/MYTEDB/datafile/o1_mf_undotbs1_bw773xqo_.db - wrote new name

    Datafile /u01/app/oracle/oradata/MYTEDB/datafile/o1_mf_users_bw773xrv_.db - wrote new name

    Datafile /u01/app/oracle/oradata/MYTEDB/datafile/o1_mf_MYTEdev_bw8xbqrz_.db - wrote new name

    Datafile /u01/app/oracle/oradata/MYTEDB/datafile/o1_mf_inttestt_bw8xdnkt_.db - wrote new name

    Datafile /u01/app/oracle/oradata/MYTEDB/datafile/o1_mf_epssite_by19vtnh_.db - wrote new name

    Datafile /u01/app/oracle/oradata/MYTEDB/datafile/o1_mf_temp_bw776mow_.tm - wrote new name

    Control File /u01/app/oracle/oradata/MYTEDB/controlfile/o1_mf_bw7762ov_.ctl - wrote new name

    Control File /u01/app/oracle/fast_recovery_area/MYTEDB/controlfile/o1_mf_bw7762v3_.ctl - wrote new name

    Instance shut down

 

Database name changed to MYTEDB.

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

Succesfully changed database name.

DBNEWID - Completed succesfully.

 

 

设置Oracle环境变量到新的ORACLE_SID上。

 

 

[oracle@MYTElife dbs]$ su - oracle

Password:

[oracle@MYTElife ~]$ cd $ORACLE_HOME/dbs

[oracle@MYTElife dbs]$ env | grep ORA

ORACLE_SID=MYTEdb

ORACLE_BASE=/u01/app/oracle

ORACLE_HOME=/u01/app/oracle/product/11.2.0/dbhome_1

 

 

使用修改过DBNAMEPFILE启动数据库。

 

 

SQL> startup mount pfile=initMYTEdb.ora

ORACLE instance started.

 

Total System Global Area 3540881408 bytes

Fixed Size                  2258320 bytes

Variable Size             855640688 bytes

Database Buffers         2667577344 bytes

Redo Buffers               15405056 bytes

Database mounted.

 

SQL> alter database open;

Database altered.

 

 

之后,使用create spfile from pfile可以创建出新的spfile。另外生成新的密码文件即可,具体操作详见上文。

 

5、结论

 

一般情况下,修改投产环境上DBIDDBNAME的场景不是很多。通过nid的系列测试,我们可以对这些关键信息分布在哪些文件中有一个比较清晰的认识和理解。记录下来,留待需要的朋友待查。


来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/17203031/viewspace-2127000/,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论
求道~

注册时间:2010-11-30

  • 博文量
    545
  • 访问量
    7630795