你好,游客 登录 注册 搜索
背景:
阅读新闻

使用NID修改DBID和DBNAME实验

[日期:2016-10-31] 来源:Linux社区  作者:realkid4 [字体:大 中 小]

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

使用修改过DBNAME的PFILE启动数据库。

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、结论

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

更多Oracle相关信息见Oracle 专题页面 http://www.linuxidc.com/topicnews.aspx?tid=12

本文永久更新链接地址:http://www.linuxidc.com/Linux/2016-10/136568.htm

linux
相关资讯       NID修改DBID  NID修改DBNAME 
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款