Thursday, January 3, 2013

Restore RAC database to new name ASM


1.====Create temporary parameter file
$ vi /u01/app/oracle/product/11.2.0.3/dbhome_1/dbs/initNEWDB.ora
--------------------------------------------------
*.audit_file_dest='/u01/app/oracle/admin/NEWDB/adump'
*.audit_trail='db'
*.compatible='11.2.0.2.0'
*.control_files='+DATA_DM02/NEWDB/control.ctl'
*.db_block_size=8192
*.db_domain=''
*.db_name='OLDDB'
*.db_unique_name='NEWDB'
*.lock_name_space='NEWDB'
*.diagnostic_dest='/u01/app/oracle'
*.dispatchers='(PROTOCOL=TCP) (SERVICE=NEWDBXDB)'
*.log_archive_dest_1='LOCATION=+RECO_DM02'
*.log_archive_format='%t_%s_%r.arc'
*.open_cursors=300
*.pga_aggregate_target=500M
*.processes=1500
*.remote_login_passwordfile='exclusive'
*.sessions=1655
*.sga_target=2G
*.undo_tablespace='UNDOTBS1'
--------------------------------------------------

2.====Create audit file destination

$ mkdir -p /u01/app/oracle/admin/NEWDB/adump

3.====Startup restoring DB to one instance first: You have to be under db home, not grid home

export ORACLE_SID=NEWDB
SQL>startup nomount pfile='/u01/app/oracle/product/11.2.0.3/dbhome_1/dbs/initNEWDB.ora';

RMAN>restore controlfile from '/backup1_110/OLDDB/c-49054504-20130102-01';
RMAN>alter database mount;
RMAN>catalog start with '/backup1_110/OLDDB/';

--change name online logfile
--if OLDDB is shutdown we should start it up to avoid loss online redo log.
SQL>
set pagesize 1000
set linesize 1000
select 'alter database rename file ''' || member  || ''' to ''+RECO_DM02'';' from v$logfile;

SQL>
alter database rename file '+RECO_DM02/olddb/onlinelog/group_2.28113.803468823' to '+RECO_DM02';
alter database rename file '+RECO_DM02/olddb/onlinelog/group_1.9205.803468821' to '+RECO_DM02';
alter database rename file '+RECO_DM02/olddb/onlinelog/group_7.9206.803468883' to '+RECO_DM02';
alter database rename file '+RECO_DM02/olddb/onlinelog/group_8.28112.803468883' to '+RECO_DM02';
alter database rename file '+RECO_DM02/olddb/onlinelog/group_5.9186.803468883' to '+RECO_DM02';
alter database rename file '+RECO_DM02/olddb/onlinelog/group_6.9187.803468885' to '+RECO_DM02';
alter database rename file '+RECO_DM02/olddb/onlinelog/group_3.9189.803468885' to '+RECO_DM02';
alter database rename file '+RECO_DM02/olddb/onlinelog/group_4.9190.803468885' to '+RECO_DM02';

--Shutdown database OLDDB to prevent user login

--Get datafile and tempfile to set new name
SQL>
set pagesize 1000
set linesize 1000
select 'set newname for datafile ' || File# || ' to ''+DATA_DM02'';'from v$datafile
Union All
select 'set newname for tempfile ' || File# || ' to ''+DATA_DM02'';'from v$tempfile;

RMAN>
run {
set newname for datafile 1 to '+DATA_DM02';
set newname for datafile 2 to '+DATA_DM02';
set newname for datafile 3 to '+DATA_DM02';
set newname for datafile 4 to '+DATA_DM02';
set newname for datafile 5 to '+DATA_DM02';
set newname for datafile 6 to '+DATA_DM02';
set newname for datafile 7 to '+DATA_DM02';
set newname for tempfile 1 to '+DATA_DM02';
restore database;
switch datafile all;
switch tempfile all;
recover database;
}
SQL> alter database open resetlogs;

*****
RMAN-03002: failure of alter db command at 11/19/2012 12:41:23
ORA-19751: could not create the change tracking file
ORA-19750: change tracking file: '+DATA_DM02/OLDDB/changetracking/ctf.952.798216451'
ORA-17502: ksfdcre:4 Failed to create file +DATA_DM02/OLDDB/changetracking/ctf.952.798216451
ORA-15046: ASM file name '+DATA_DM02/OLDDB/changetracking/ctf.952.798216451' is not in single-file creation form
ORA-17503: ksfdopn:2 Failed to open file +DATA_DM02/OLDDB/changetracking/ctf.952.798216451
ORA-15012: ASM file '+DATA_DM02/OLDDB/changetracking/ctf.952.798216
solution:
SQL> alter database disable block change tracking;
SQL> alter database open;
*****

4.====Change database name:

SQL> shutdown immediate;
SQL>startup nomount pfile='/u01/app/oracle/product/11.2.0.3/dbhome_1/dbs/initNEWDB.ora';
SQL>alter database mount;

$ nid target=sys dbname=NEWDB

***Note: database will shutdown after change its name:

5.====RAC configuration:
vi /u01/app/oracle/product/11.2.0.3/dbhome_1/dbs/initNEWDB.ora
===================pfile

*.audit_file_dest='/u01/app/oracle/admin/NEWDB/adump'
*.audit_trail='NONE'
*.cluster_database=false
*.compatible='11.2.0.2.0'
*.control_files='+DATA_DM02/NEWDB/control.ctl'
*.db_block_size=8192
*.db_create_file_dest='+DATA_DM02'
*.db_create_online_log_dest_1='+RECO_DM02'
*.db_domain=''
*.db_name='NEWDB'
*.diagnostic_dest='/u01/app/oracle'
*.dispatchers='(PROTOCOL=TCP) (SERVICE=NEWDBXDB)'
NEWDB3.instance_number=3
NEWDB2.instance_number=2
NEWDB1.instance_number=1
NEWDB4.instance_number=4
*.log_archive_dest_1='LOCATION=+RECO_DM02'
*.log_archive_format='%t_%s_%r.arc'
*.pga_aggregate_target=500M
*.processes=2000
*.remote_listener='dm02-scan:1521'
*.remote_login_passwordfile='exclusive'
*.sessions=1655
*.sga_max_size=2G
*.sga_target=2G
*.shared_servers=0
NEWDB3.thread=3
NEWDB4.thread=4
NEWDB2.thread=2
NEWDB1.thread=1
NEWDB1.undo_tablespace='UNDOTBS1'
NEWDB2.undo_tablespace='UNDOTBS2'
NEWDB3.undo_tablespace='UNDOTBS3'
NEWDB4.undo_tablespace='UNDOTBS4'

==================

SQL>startup nomount pfile='/u01/app/oracle/product/11.2.0.3/dbhome_1/dbs/initNEWDB.ora';

SQL>create spfile='+DATA_DM02/NEWDB/spfileNEWDB.ora' from pfile='/u01/app/oracle/product/11.2.0.3/dbhome_1/dbs/initNEWDB.ora';
SQL>alter database mount;
SQL>alter database open resetlogs;
SQL>shut immediate;


$ echo spfile=\'+DATA_DM02/NEWDB/spfileNEWDB.ora\' > /u01/app/oracle/product/11.2.0.3/dbhome_1/dbs/initNEWDB.ora

SQL>startup nomount pfile='/u01/app/oracle/product/11.2.0.3/dbhome_1/dbs/initNEWDB.ora';
SQL>alter database mount;
SQL>alter database open;
SQL>alter system set cluster_database=true scope=spfile sid='*';
alter system set cluster_database_instances=4 scope=spfile sid='*';
SQL>shut immediate;


Add 4 nodes:
vi $ORACLE_HOME/network/admin/tnsnames.ora
NEWDB=
  (DESCRIPTION =
    (SDU=32767)
    (TDU=32767)
      (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = dm02-scan)(PORT = 1521))
      (SEND_BUF_SIZE=32767)
      (RECV_BUF_SIZE=32767)
      (TCP.NODELAY = YES)
    )
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME=NEWDB)
    )
  )

4 nodes:
mkdir -p /u01/app/oracle/admin/NEWDB/adump

orapwd file=/u01/app/oracle/product/11.2.0.3/dbhome_1/dbs/orapwNEWDB1 password=oracle FORCE=Y
orapwd file=/u01/app/oracle/product/11.2.0.3/dbhome_1/dbs/orapwNEWDB2 password=oracle FORCE=Y
orapwd file=/u01/app/oracle/product/11.2.0.3/dbhome_1/dbs/orapwNEWDB3 password=oracle FORCE=Y
orapwd file=/u01/app/oracle/product/11.2.0.3/dbhome_1/dbs/orapwNEWDB4 password=oracle FORCE=Y


Create 4 init: initNEWDB1,initNEWDB2,initNEWDB3,initNEWDB4

$ echo spfile=\'+DATA_DM02/NEWDB/spfileNEWDB.ora\' > /u01/app/oracle/product/11.2.0.3/dbhome_1/dbs/initNEWDB1.ora
$ echo spfile=\'+DATA_DM02/NEWDB/spfileNEWDB.ora\' > /u01/app/oracle/product/11.2.0.3/dbhome_1/dbs/initNEWDB2.ora
$ echo spfile=\'+DATA_DM02/NEWDB/spfileNEWDB.ora\' > /u01/app/oracle/product/11.2.0.3/dbhome_1/dbs/initNEWDB3.ora
$ echo spfile=\'+DATA_DM02/NEWDB/spfileNEWDB.ora\' > /u01/app/oracle/product/11.2.0.3/dbhome_1/dbs/initNEWDB4.ora

$ srvctl add database -d NEWDB -o /u01/app/oracle/product/11.2.0.3/dbhome_1
srvctl add instance -d NEWDB -i NEWDB1 -n dm02db01
srvctl add instance -d NEWDB -i NEWDB2 -n dm02db02
srvctl add instance -d NEWDB -i NEWDB3 -n dm02db03
srvctl add instance -d NEWDB -i NEWDB4 -n dm02db04
srvctl start database -d NEWDB








No comments:

Post a Comment

Followers