Chinaunix首页 | 论坛 | 博客
  • 博客访问: 506662
  • 博文数量: 161
  • 博客积分: 6010
  • 博客等级: 准将
  • 技术积分: 1947
  • 用 户 组: 普通用户
  • 注册时间: 2007-08-25 01:20
文章分类

全部博文(161)

文章存档

2011年(44)

2010年(47)

2009年(48)

2008年(22)

我的朋友

分类: Oracle

2011-01-24 16:18:50

How to Change the DBID | DBNAME by using NID 参考[ID 224266.1]

 

1>利用NIDNew Database ID)既可以改变DBID,DBNAME,或同时

注意

改变 the dbid 后,用resetlogs 打开数据库

如果仅仅是改变dbname,没有改变dbid,不需要用resetlogs选项打开数据库

2>仅改变DBID

  1. Backup 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

  5. Shutdown IMMEDIATE of the database

  6. Create a new password file

  7. Startup of the database with open resetlogs

     SQL>alter database open resetlogs

3>仅改变DBNAME

  1. Backup 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 SETNAME=Y

     - the value of DBNAME is the new dbname of the database

     - SETNAME must be set to Y. The default is N and causes the

       DBID to be changed also.

  5. 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(without resetlogs)

4>Change Both DBID and DBNAME 

  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

Example

1>备份略,检查

SQL>  select dbid,name,open_mode,activation#,created from v$database;

      DBID NAME      OPEN_MODE  ACTIVATION# CREATED

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

1348672851 DGT       READ WRITE  1348649811 16-JAN-11

--参数pfile

SQL> create pfile='/u01/new.ora' from spfile;

File created.

2>shutdown

SQL> shutdown immediate;

Database closed.

Database dismounted.

ORACLE instance shut down.

3>startup mount 

SQL> startup mount

ORACLE instance started.

Total System Global Area  167772160 bytes

Fixed Size                  1218316 bytes

Variable Size              67111156 bytes

Database Buffers           96468992 bytes

Redo Buffers                2973696 bytes

Database mounted.

SQL> !

4>nid TARGET=SYS/ank88ank@DGT DBNAME=DG2  | nid target=/ ndbame=DG2

[oracle@node1 admin]$ nid target=/ dbname=DG2

DBNEWID: Release 10.2.0.1.0 - Production on Mon Oct 24 00:22:17 2011

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

Connected to database DGT (DBID=1348672851)

Connected to server version 10.2.0

Control Files in database:

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

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

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

Change database ID and database name DGT to DG2? (Y/[N]) => Y

Proceeding with operation

Changing database ID from 1348672851 to 1542037561

Changing database name from DGT to DG2

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

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

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

    Datafile /u01/app/oracle/oradata/DGT/system01.dbf - dbid changed, wrote new name

    Datafile /u01/app/oracle/oradata/DGT/undotbs01.dbf - dbid changed, wrote new name

    Datafile /u01/app/oracle/oradata/DGT/sysaux01.dbf - dbid changed, wrote new name

    Datafile /u01/app/oracle/oradata/DGT/users01.dbf - dbid changed, wrote new name

    Datafile /u01/rundo2_01.dbf - dbid changed, wrote new name

    Datafile /u01/rundo3_01.dbf - dbid changed, wrote new name

    Datafile /u01/rundo4_01.dbf - dbid changed, wrote new name

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

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

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

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

    Instance shut down

Database name changed to DG2.

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

Database ID for database DG2 changed to 1542037561.

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.

5>oracle instance has been shutdown 

6>修改pfiledbname

7>创建口令文件

[oracle@node1 dbs]$ orapwd file=orapwDG2 password=ank88ank 

8>startup the database use pfile (with the option of resetlogs)

SQL> startup mount pfile='/u01/new.ora' ;

ORACLE instance started.

Total System Global Area  167772160 bytes

Fixed Size                  1218316 bytes

Variable Size              67111156 bytes

Database Buffers           96468992 bytes

Redo Buffers                2973696 bytes

Database mounted.

SQL> alter database open;

alter database open

*

ERROR at line 1:

ORA-01589: must use RESETLOGS or NORESETLOGS option for database open

SQL> alter database open resetlogs;

Database altered.

SQL> create spfile from pfile='/u01/new.ora' ;

File created.

验证

SQL>   select dbid,name,open_mode,activation#,created from v$database;

      DBID NAME      OPEN_MODE  ACTIVATION# CREATED

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

1542037561 DG2       READ WRITE  1542014436 16-JAN-11

补充:

修改export ORACLE_SID=DG2

阅读(674) | 评论(4) | 转发(0) |
0

上一篇:Red hat 下的LVM 下

下一篇:Oracle 碎片整理

给主人留下些什么吧!~~

chinaunix网友2011-06-05 01:40:44

大连法律咨询在线 http://www.fabowang.com 大连律师在线咨询 http://www.fabowang.com 大连法律顾问网 http://www.fabowang.com 大连律师咨询 http://www.fabowang.com

chinaunix网友2011-03-19 20:30:13

http://www.307liuyaosheng.com 股骨头坏死 http://www.kangbaili.com 雪蛤 http://www.307liuyaosheng.com 脊柱结核 http://www.307liuyaosheng.com 脊柱转移瘤 http://www.wuhua.sh 驱鼠器 http://www.famenb2b.com 阀门 http://www.txxwl.com 天津网站制作 http://www.okxiazai.com 软件下载网站 http://www.txxwl.com 天津网站建设 http://www.okxiazai.com 软件下载 http://www.okxiazai.com 软件下载网站 http://www.okxiazai.com 绿色软件 http://www.okxiazai.com 绿色下载

chinaunix网友2011-03-19 20:29:34

http://www.307liuyaosheng.com 股骨头坏死 http://www.kangbaili.com 雪蛤 http://www.307liuyaosheng.com 脊柱结核 http://www.307liuyaosheng.com 脊柱转移瘤 http://www.wuhua.sh 驱鼠器 http://www.famenb2b.com 阀门 http://www.txxwl.com 天津网站制作 http://www.okxiazai.com 软件下载网站 http://www.txxwl.com 天津网站建设 http://www.okxiazai.com 软件下载 http://www.okxiazai.com 软件下载网站 http://www.okxiazai.com 绿色软件 http://www.okxiazai.com 绿色下载