Tuesday 25 February 2014

Oracle RAC RMAN Backup and Restore

Tried to prepare full documents to restore DB from PROD TO DEV


Make Copy of PROD DB in DEV == DB In RAC+ASM+RMAN


USING RMAN COLD BACK


Take a cold backup of RMAN as Under (we made a copy of DB with Netsnap to second location to use the cold backup and reduce network)


RMAN> connect target *
2> run
3> {
4> shutdown immediate;
5> startup mount;
6> allocate channel d01 type disk;
7> allocate channel d02 type disk;
8> allocate channel d03 type disk;
9> allocate channel d04 type disk;
10> allocate channel d05 type disk;
11> allocate channel d06 type disk;
12> backup database format '/d2/orabackup/RMAN/XXXPRD_%U'
13> include current controlfile;
14> }


ISSUE MORE CHANNELS TO COMPPLETE FAST AS ITS ON LOCAL DISK AND MAKE SURE WE HAVE SPACE AVAILABLE BEFORE FIRE


After its completion, ASK SA or you can do the FTP TO DEV DB Server all the RMAN backup Piece and start the PROD DB


Some IMPORTANT Point== Make sure you keep the RMAN backup Piece under same location where we took the back, or create same directory structure in DEV box


Shutdown the DEV Instances in RAC as under and before shutdown take backup of controlfile and also create a init file as you might be using spfile under ASM


srvctl stop instance -d xxxdev -i xxxdev01


srvctl stop instance -d xxxdev -i xxxdev02


Or


USE the Normal shutdown commands for both instances.


ASM Commands to removed the directory structure and also add the DISkGROUPS in ASM INSTANCE as UNDER


CHECK THE CURRENT structure in ASM sqlplus


SELECT name, type, total_mb, free_mb, required_mirror_free_mb,
usable_file_mb FROM V$ASM_DISKGROUP;



SELECT
name group_name
, sector_size sector_size
, block_size block_size
, allocation_unit_size allocation_unit_size
, state state
, type type
, total_mb total_mb
, (total_mb - free_mb) used_mb
,free_mb free_mb
, ROUND((1- (free_mb / total_mb))*100, 2) pct_used
FROM
v$asm_diskgroup
ORDER BY
name
/


===


Then CREATE THE DISKGROUP AS PER REQUIREMENT, under is the example


SQL> CREATE DISKGROUP xxxCTRL External REDUNDANCY DISK
'/orcl_san_links/asm/orcl_asm_rdw_ctrl1' size 10200M; 2


Diskgroup created.


SQL> CREATE DISKGROUP xxxREDO External REDUNDANCY DISK
'/orcl_san_links/asm/orcl_asm_rdw_redo1' size 10200M,
'/orcl_san_links/asm/orcl_asm_rdw_redo2' size 10200M; 2 3


Diskgroup created.


SQL> SELECT name from V$ASM_DISKgroup;


NAME
----------------------------------------
AAAADATA
xxxDATA
xxxARCH
xxxCTRL
xxxREDO



YOU CAN ADD THE DISK TO EXISTING GROUP AS UNDER


SQL> ALTER DISKGROUP xxxDATA ADD DISK '/dev/rdsk/c6t60A98000486E5850564A597964434473d0s0' NAME xxxDATA_0003;


Diskgroup altered.


OR
If you want to remove anything existing or created wrong then removed it as under


SQL> drop diskgroup xxxARCH including contents;


Diskgroup dropped.
---------------------------------------


CREATE DISKGROUP xxxARCH External REDUNDANCY DISK
'/orcl_san_links/asm/orcl_asm_rdw_arlogs1' SIZE 51100M,
'/orcl_san_links/asm/orcl_asm_rdw_arlogs2' SIZE 51100M,
'/orcl_san_links/asm/orcl_asm_rdw_arlogs3' SIZE 51100M,
'/orcl_san_links/asm/orcl_asm_rdw_arlogs4' SIZE 51100M;



Check the structure under ASM now, and remove the other physical files under ASM or create new Directories


mandy:/export/home/oracle $ asmcmd
ASMCMD> ls -lrt
State Type Rebal Name
cMOUNTED EXTERN N xxxREDO/
d MOUNTED EXTERN N xxxDATA/
MOUNTED EXTERN N xxxCTRL/
MOUNTED EXTERN N xxxARCH/
MOUNTED EXTERN N XXXDATA/


go the the Particular directory to remove the files under ASM


just use the simple unix command rm


create the new directory structure under ASM, like mkdir and sub directory (this is what you are keeping in initfile)



Also make the necessary changes under ASM initfile, if you are not using the spfile for ASM instance.


SHUTDOWN THE ASM instance and make necessary changes in init file on BOTH NODES (pointing to parameter diskgroups)
RESTART the ASM instance on both nodes and check the new file diskgroups mounted or not, if not then investigate more.





CURRENT SITUATION


1. YOU have RMAN COLD BACKUP PIECE ON DEV BOX
2. YOU HAD ADDED THE NEW DISKGROUPS UNDER ASM
3. TOOK BACKUP OF CONTROLFILE AND CREATED INIT FILE FROM EXISTING DEV DB
4. SHUTDOWN BOTH THE INSTANCES under RAC
5. REMOVED THE EXISTING PHYSICAL FILES UNDER ASM to CLEAR THE DB.


HERE IS THE NEW INIT FILE NOW to RESTORE THE DB, PLEASE NOTE WE ARE NOT CHANGING THE DB NAME AT THIS POINT, KEEPING PROD NAME in INIT, ALSO COMMENTING CLUSTER P*



***///


xxxdev02.__db_cache_size=872415232
xxxdev01.__db_cache_size=570425344
xxxdev01.__java_pool_size=16777216
xxxdev02.__java_pool_size=16777216
xxxdev01.__large_pool_size=33554432
xxxdev02.__large_pool_size=33554432
xxxdev01.__oracle_base='/opt/oracle/base'#ORACLE_BASE set from environment
xxxdev02.__oracle_base='/opt/oracle/base'#ORACLE_BASE set from environment
xxxdev01.__pga_aggregate_target=3875536896
xxxdev02.__pga_aggregate_target=3875536896
xxxdev01.__sga_target=1610612736
xxxdev02.__sga_target=1610612736
xxxdev01.__shared_io_pool_size=0
xxxdev02.__shared_io_pool_size=0
xxxdev02.__shared_pool_size=654311424
xxxdev01.__shared_pool_size=956301312
xxxdev02.__streams_pool_size=16777216
xxxdev01.__streams_pool_size=16777216
*.audit_file_dest='/opt/oracle/base/admin/xxxdev/adump'
*.audit_trail='db'
#*.cluster_database_instances=2
#*.cluster_database=true
*.compatible='11.1.0.0.0'
*.control_files='+xxxCTRL/xxxDEV/CONTROLFILE/current.256.713444083','+xxxCTRL/xxxDEV/CONTROLFILE/current.257.713444083','+xxxCTRL/xxxDEV/CON
TROLFILE/current.258.713444083'
*.db_block_size=8192
*.db_create_file_dest='+xxxDATA'
*.db_domain='citco.com'
*.db_name='xxxprd'
*.db_recovery_file_dest_size=104857600
*.db_recovery_file_dest='+xxxDATA'
*.diagnostic_dest='/opt/oracle/base'
*.dispatchers='(PROTOCOL=TCP) (SERVICE=xxxdev0XDB)'
#xxxprd02.instance_number=2
#xxxprd01.instance_number=1
#xxxdev02.local_listener='LISTENER_xxxDEV02'
#xxxdev01.local_listener='LISTENER_xxxDEV01'
*.log_archive_dest_1='location=+xxxARCH/xxxDEV/ARCHIVELOG'
*.log_archive_format='xxxprd_%t_%s_%r.arc'
*.open_cursors=300
*.pga_aggregate_target=3865051136
*.processes=400
*.remote_listener=''
*.remote_login_passwordfile='exclusive'
*.sessions=445
*.sga_target=1610612736
xxxdev02.thread=2
xxxdev01.thread=1
*.undo_management='AUTO'
*.undo_retention=600
xxxprd02.undo_tablespace='UNDOTBS2'
xxxprd01.undo_tablespace='UNDOTBS1'



***///


TIME TO KICK RESTORE NOW


PLEASE NOTE, WE DON"T HAVE EVEN THE CONTROLFILE AT THIS POINT, we are DOING FIRST CONTROLFILE RESTORE


TRY TO START THE INSTANCE ON ONE NODE WITH NEW PFILE AS ABOVE in nomount stage, as we are restoring controlfile now as under then go to RMAN NOW


mandy:/d2/oraback/RDW/RMAN $ rman


Recovery Manager: Release 11.1.0.6.0 - Production on Thu Jan 13 13:20:40 2011


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


RMAN> connect target /


connected to target database: xxxDEV (not mounted)


RMAN> restore controlfile from '/d2/oraback/RDW/RMAN/control_qtluhq83_1_1';


Starting restore at 13-JAN-11
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=418 instance=xxxdev01 device type=DISK


channel ORA_DISK_1: restoring control file
channel ORA_DISK_1: restore complete, elapsed time: 00:00:08
output file name=+xxxCTRL/xxxdev/controlfile/current.256.740323291
output file name=+xxxCTRL/xxxdev/controlfile/current.257.740323291
output file name=+xxxCTRL/xxxdev/controlfile/current.258.740323291
Finished restore at 13-JAN-11


RMAN> exit



SQL> alter database mount;


Database altered.



NOW WE CAN LIST THE BACKUP in RMAN EVEN, to see the last backup, if you want to use until SCN, but in hour case not required as we have COLD BACKUP.


NOW KICK THE RMAN RESTORE OF DATABASE, MAKE SURE you HAVE THE RMAN PIECE UNDER SAME DIRECTORY STRUCTURE at time of backup, AS CONTROLFILE IS LOOKING SAME LOCATION


RMAN>run
{
allocated channel d01 type disk;
allocated channel d02 type disk;
allocated channel d03 type disk;
allocated channel d04 type disk;
allocated channel d05 type disk;
allocated channel d06 type disk;
allocated channel d07 type disk;
allocated channel d08 type disk;
allocated channel d09 type disk;
restore database;
}


RESTORE COMPLETED IN almost 5 hours, without any issue


NOW TIME TO OPEN THE DATABASE NOW.


SQL> select open_mode from v$database;


OPEN_MODE
----------
MOUNTED


SQL> Alter database open resetlogs;



Database altered.


SQL> SQL>
SQL>
SQL> select open_mode from v$database;


OPEN_MODE
----------
READ WRITE


SQL> select name from v$database;


NAME
----------------------------------------
xxxPRD


SQL>
SQL> archive log list
Database log mode Archive Mode
Automatic archival Enabled
Archive destination +xxxARCH/xxxdev/archivelog
Oldest online log sequence 3
Next log sequence to archive 6
Current log sequence 6

1 comment:

  1. Thanks but the restored database is still in NON RAC mode !

    ReplyDelete