18 Şubat 2015 Çarşamba

RMAN Simulation for tape:

You can test RMAN tape utility without any media manager

CONFIGURE CHANNEL DEVICE TYPE sbt PARMS 'SBT_LIBRARY=oracle.disksbt, ENV=(BACKUP_DIR=/u01/app/oracle/backup/)' format '%U.bck';
CONFIGURE DEFAULT DEVICE TYPE TO 'sbt';
CONFIGURE DEVICE TYPE SBT_TAPE PARALLELISM 2 BACKUP TYPE TO BACKUPSET;
CONFIGURE CONTROLFILE AUTOBACKUP ON;
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE SBT to 'control_file_%F.bck';

***without tape manager or storage, you can make rman sbt tests on local disk with this parameter

##################################################
Clone RAC Prod DB for RAC Test DB while Prod DB is all alive(with RMAN BACKUP/RESTORE, no Duplicate Database).

##################################################
RMAN Simulation for tape:
CONFIGURE CHANNEL DEVICE TYPE sbt PARMS 'SBT_LIBRARY=oracle.disksbt, ENV=(BACKUP_DIR=/u01/app/oracle/backup/)' format '%U.bck';
CONFIGURE DEFAULT DEVICE TYPE TO 'sbt';
CONFIGURE DEVICE TYPE SBT_TAPE PARALLELISM 2 BACKUP TYPE TO BACKUPSET;
CONFIGURE CONTROLFILE AUTOBACKUP ON;
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE SBT to 'control_file_%F.bck';

***without tape manager or storage, you can make rman sbt tests on local disk with this parameter
##################################################

We will clone the Prod Database for Test DB on same host while production is alive

Prod Rac Database: source
Test Database: target

1-backup the prod database

run{
backup database plus archivelog;
}

2-create pfile for test database

create pfile='/tmp/pf_Target.ora' from spfile;


3-edit pfile parameters

--change all "source1" with "target1"

--change to *.cluster_database=false

--create directory for audit;
mkdir -p /u01/app/oracle/admin/target/adump

--change controlfile path: 
*.control_files='+DATA/TARGET/CONTROLFILE/controlfile.ctl'

--comment redo log parameters
#*.db_create_online_log_dest_1='+REDO1'
#*.db_create_online_log_dest_2='+REDO2'


--do not change db_name='source'

#################################
the most important part is add the following line, otherwise you can not mount the database cos another "source" instance is running
*.db_unique_name='target'
#################################

--comment the following line:
#source1.instance_number=1


4-create spfile from pfile

export ORACLE_SID=target1
sqlplus / as sysdba
SQL> create spfile from pfile='/tmp/pf_Target.ora ';


5-start database mount nomount mode

SQL> startup nomount;
ORACLE instance started.

Total System Global Area  994050048 bytes
Fixed Size                  2931712 bytes
Variable Size             356516864 bytes
Database Buffers          629145600 bytes
Redo Buffers


6-restore controlfile from last auto backup

run {
allocate channel ch00 device type 'SBT_TAPE' PARMS="SBT_LIBRARY=oracle.disksbt,ENV=(BACKUP_DIR=/u01/app/oracle/backup)";
restore controlfile from 'control_file_c-2990360168-20150218-00.bck';
release channel ch00;
}


7-alter database mount;

SQL> alter database mount;



8-restore database different location;

run
  {
  set newname for database to '+DATA/TARGET/%b' ;
  SQL "alter database rename file''+REDO1/SOURCE/ONLINELOG/group_3.258.871999547'' to ''+REDO1'' ";
  SQL "alter database rename file''+REDO2/SOURCE/ONLINELOG/group_3.258.871999549'' to ''+REDO2'' ";
  SQL "alter database rename file''+REDO1/SOURCE/ONLINELOG/group_2.257.871999543'' to ''+REDO1'' ";
  SQL "alter database rename file''+REDO2/SOURCE/ONLINELOG/group_2.257.871999545'' to ''+REDO2'' ";
  SQL "alter database rename file''+REDO1/SOURCE/ONLINELOG/group_1.259.871999535'' to ''+REDO1'' ";
  SQL "alter database rename file''+REDO2/SOURCE/ONLINELOG/group_1.259.871999537'' to ''+REDO2'' ";
  restore database ;
  switch datafile all;
  switch tempfile all;
 }


9- recover database;

RMAN> recover database;

10- open with resetlogs

after this command, you must see the new redolog are created to the new path
RMAN> alter database open resetlogs;

SQL> shu immediate;

SQL> startup;


#####change DB name with NID utility#####

11- change the db_name parameter on pfile


*.db_name='target'

12- shutdown and startup mount

SQL> shu immediate;
SQL> startup mount;


13- issue nid utility (db will be autiomatically shut down)

nid target=sys/20300251 dbname=target setname=yes


14- create spfile from latest pfile with new db_name parameter

SQL> create spfile from pfile='/tmp/pf_Target.ora';


15- startup database and you will see this line in the alert log

SQL> startup;
Global Name changed to TARGET


#####add database to the RAC system##############
16- change parameter on pfile for RAC database

*.cluster_database=true
target1.instance_number=1


17- shutdown database, create spfile and open 

SQL> shu immediate;
SQL> create spfile from pfile='/tmp/pf_Target.ora';


18- startup and add database to cluster

srvctl add database -d target -o /u01/app/oracle/product/12.1.0/dbhome_1

srvctl add instance -d target -i target1 -n node1

19- shutdown database

SQL> shu immediate;

20- open and control database with srvctl

srvctl start database -d target
srvctl stop database -d target

srvctl start database -d target