DBNEWID 筆記

wmlm發表於2010-12-27

使用了ASM的資料庫,修改DBID DB NAME

參考資料

Oracle® Database Utilities

10g Release 2 (10.2)

Part Number B14215-01

16 DBNEWID Utility

[@more@]

$ sqlplus '/as sysdba'

SQL*Plus: Release 10.2.0.1.0 - Production on Mon Dec 27 10:04:05 2010

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

Connected to an idle instance.

SQL> startup mount;

ORACLE instance started.

Total System Global Area 2499805184 bytes

Fixed Size 2022928 bytes

Variable Size 620757488 bytes

Database Buffers 1862270976 bytes

Redo Buffers 14753792 bytes

Database mounted.

SQL>

SQL> exit

$ nid target=sys/system

DBNEWID: Release 10.2.0.1.0 - Production on Mon Dec 27 10:04:42 2010

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

Connected to database TEST (DBID=2028887164)

Connected to server version 10.2.0

Control Files in database:

+DATA/test/controlfile/current.256.730740741

+DATA/test/controlfile/current.257.730740743

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

Proceeding with operation

Changing database ID from 2028887164 to 2036943802

Control File +DATA/test/controlfile/current.256.730740741 - modified

Control File +DATA/test/controlfile/current.257.730740743 - modified

Datafile +DATA/test/datafile/system.264.730740755 - dbid changed

Datafile +DATA/test/datafile/undotbs1.265.730740767 - dbid changed

Datafile +DATA/test/datafile/sysaux.266.730740771 - dbid changed

Datafile +DATA/test/datafile/users.268.730740781 - dbid changed

Datafile /tmp/users01.ora - dbid changed

Datafile +DATA/test/tempfile/temp.267.730740775 - dbid changed

Control File +DATA/test/controlfile/current.256.730740741 - dbid changed

Control File +DATA/test/controlfile/current.257.730740743 - dbid changed

Instance shut down

Database ID for database TEST changed to 2036943802.

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.

$

$ sqlplus '/as sysdba'

SQL*Plus: Release 10.2.0.1.0 - Production on Mon Dec 27 10:09:39 2010

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

Connected to an idle instance.

SQL> startup mount

ORACLE instance started.

Total System Global Area 2499805184 bytes

Fixed Size 2022928 bytes

Variable Size 620757488 bytes

Database Buffers 1862270976 bytes

Redo Buffers 14753792 bytes

Database mounted.

SQL> show parameter db_name

NAME TYPE VALUE

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

db_name string test

SQL> exit

Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - 64bit Production

With the Partitioning, OLAP and Data Mining options

$ nid target=sys/system dbname=test_db setname=yes

DBNEWID: Release 10.2.0.1.0 - Production on Mon Dec 27 10:10:25 2010

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

Connected to database TEST (DBID=2036943802)

Connected to server version 10.2.0

Control Files in database:

+DATA/test/controlfile/current.256.730740741

+DATA/test/controlfile/current.257.730740743

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

Proceeding with operation

Changing database name from TEST to TEST_DB

Control File +DATA/test/controlfile/current.256.730740741 - modified

Control File +DATA/test/controlfile/current.257.730740743 - modified

Datafile +DATA/test/datafile/system.264.730740755 - wrote new name

Datafile +DATA/test/datafile/undotbs1.265.730740767 - wrote new name

Datafile +DATA/test/datafile/sysaux.266.730740771 - wrote new name

Datafile +DATA/test/datafile/users.268.730740781 - wrote new name

Datafile /tmp/users01.ora - wrote new name

Datafile +DATA/test/tempfile/temp.267.730740775 - wrote new name

Control File +DATA/test/controlfile/current.256.730740741 - wrote new name

Control File +DATA/test/controlfile/current.257.730740743 - wrote new name

Instance shut down

Database name changed to TEST_DB.

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

Succesfully changed database name.

DBNEWID - Completed succesfully.

$

接著要修改初始化引數檔案

$ sqlplus '/as sysdba'

SQL*Plus: Release 10.2.0.1.0 - Production on Mon Dec 27 10:13:29 2010

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

Connected to an idle instance.

SQL> create pfile from SPFILE='+DATA/test/spfiletest.ora';

File created.

SQL> host vi inittest.ora

"inittest.ora" 27 lines, 925 characters

test.__db_cache_size=1862270976

test.__java_pool_size=16777216

test.__large_pool_size=16777216

test.__shared_pool_size=587202560

test.__streams_pool_size=0

*.audit_file_dest='/oracle/admin/test/adump'

*.background_dump_dest='/oracle/admin/test/bdump'

*.compatible='10.2.0.1.0'

*.control_files='+DATA/test/controlfile/current.256.730740741','+DATA/test/controlf

ile/current.257.730740743'

*.core_dump_dest='/oracle/admin/test/cdump'

*.db_block_size=8192

*.db_create_file_dest='+DATA'

*.db_domain=''

*.db_file_multiblock_read_count=16

*.db_name='test_db'

*.db_recovery_file_dest='+DATA'

*.db_recovery_file_dest_size=8589934592

*.dispatchers='(PROTOCOL=TCP) (SERVICE=testXDB)'

*.job_queue_processes=10

*.open_cursors=300

*.pga_aggregate_target=828375040

*.processes=150

*.remote_login_passwordfile='EXCLUSIVE'

*.sga_target=2485125120

*.undo_management='AUTO'

*.undo_tablespace='UNDOTBS1'

*.user_dump_dest='/oracle/admin/test/udump'

SQL> createp SPFILE='+DATA/test/spfiletest.ora' from pfile;

SP2-0734: unknown command beginning "createp SP..." - rest of line ignored.

SQL> create SPFILE='+DATA/test/spfiletest.ora' from pfile;

File created.

SQL> host rm orapwtest

SQL> host orapwd file=orapwtest password=change_on_install

SQL> startup

ORACLE instance started.

Total System Global Area 2499805184 bytes

Fixed Size 2022928 bytes

Variable Size 620757488 bytes

Database Buffers 1862270976 bytes

Redo Buffers 14753792 bytes

Database mounted.

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

SQL> alter database open resetlogs;

Database altered.

SQL>

注意: 如果沒有修改DBID,不需要重置日誌;

SQL> select incarnation#,resetlogs_change#,resetlogs_time
2 from v$database_incarnation;

INCARNATION# RESETLOGS_CHANGE# RESETLOGS_TIME
------------ ----------------- --------------
1 1 20100926.15:32
2 8109854 20101227.10:18

SQL>

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/271063/viewspace-1043715/,如需轉載,請註明出處,否則將追究法律責任。