Oracle Database Cloning via RMAN Restore Recover Method

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
Craig so here we have an activity where we'll be performing DB cloning why are men restore and then recover method so we have a prerequisite we need a separate wheel server with Oracle already installed only Oracle should be installed in case you have you have other databases you can just ignore them but make sure you have already Oracle installed okay so here we have two servers on the left hand side I have prod dB we can check the beam on should be up and running yes we have prod DBP Mon which is up and running on the right hand side we have a test server it is OG test dot oracle genesis comm on this test server we don't have any P Mon up and running so what we'll do is we'll try to clone prod DB on this test server and we also have the Oracle home and everything already set we see already Oracle is installed so we have already completed the prerequisite the activity flow very simple take the source backup move the parameter file control file backup pieces to target server start the instance in mount stage and restore from the backup pieces open the database as source s ID later we'll rename the database this is how the activity flow will happen first will trigger the backup on this source so backup database + archive log delete input so I'm triggering it on the left-hand window that is our prod ok I'm sorry our main target slash catalog Arman RC Ironman RC I did it our cat so let me maximize the window backup database + archive log delete input Craig the backup is completed now we can also check the backup completion list backup of database summary so we have this as the latest tag now we have to restore the control file to some location nothing but what we are doing is we are getting the copy of the control file from our backup you can even take the direct control file from the database but this is recommended because you should take the control file after your backup is done okay so make sure you don't take a control file before the backup because after the backup is done the backup information will be there in the control file so what I am doing is restoring the control file to some location /tmp and this is some dummy name we are giving to the file so restore control file to this location now control file is restored great next we have to move files to the target server first we'll start the movement of the parameter file because once we copy the parameter file we can at least take our database instance to know mount stage so I'll exit will go to Oracle underscore home slash DBS location LS - LRT we have a neat prod DB dot or on let us SCP this file to Oracle at the rate 192 168 0 or 2 not 3 that is the test server then same location Oracle home slash DBS give the password great the file is copied next edit the P file change s ID except for DB name parameter keep it as source now this is our target server let us go to Oracle underscore home location / DB s LS - LRT we have got the need prod DB dot or aam open this file just place percenters fraud DB with test DB / global but where you find this DB name put it still as fraud DB fraud DB because our instance will be started with proudly be named perfect and also don't change the parameter file because our instance should start with fraud DB now create directories as per the new file we have the parameter file and because we have changed the Prada be to test DB so these new locations do not reside on the server so what we need to do is we need to create these locations and don't create the control file just give the location whatever location you find you can just directly create it hit enter great next we need to SCP the control file to target control file location we have taken the pack up or we restored the control file to /tmp location with this command right so what I'll do is we'll go to /tmp LS - LRT then we'll SCP this control file - this is our target server and control file location so we have this control file parameter right I will just take the entire entire control file location with the name and we'll copy it over there Oracle one two three that's the password once again SCP this control file - the second control file name Oracle one two three perfect now on the target server we have the parameter file and let us check if we have the control file or not first control file and the second control file yes we see both the control files are available right now as we have the parameter file we have the control file so we can take the database at least ill mount stage perfect next we have to copy the backup pieces to the same location as the source on the target so first of all connect to our main target slash catalog Garmin RC Arman RC at the rate are cat list backup of database summary now this is the tag list backup tag okay here is the backup piece name I'll exit now SCP this backup piece to Oracle at the rate 492 168 0.2 not 3 : in the same location okay now this location might not exist on the target server so meanwhile create this location on on target also Oracle's 1 2 3 ok the file is being copied and also this backup will not help us to restore the database the problem is let me show you the backup output right in the backup output if you see this is these are the data files which are backed up in this backup piece but after this backup piece there is an archive log sequence number 6 which is backed up in this backup piece once we perform the restore we have to apply at least one archive log now this archive log backup we need onto the target server in order to perform the recovery if you don't have this backup piece then we cannot perform the recovery we can perform restore but when you try to perform recovery Armand will complain that it is not able to find out this backup piece so what we'll do is we'll copy this backup piece also on to the target server so SCP then Oracle at the rate this one and once again just copy to this location or I kill one two three perfect so we have copied the control file to control file location database backup pieces to the same location as source we have copied the archive backup pieces to the same location now we'll start the cloning on the target server export the environmental variables and connect to our men this is our target server let me clear so env aura the Oracle s ID is set to prod DB Oracle home is also correct and will connect to Arman Arman target slash we don't have a catalog over here so we are going with Arman now startup no ok we can actually mount the database because we have both parameter file and control files right the data files will be getting through the restore command so we can see the database has been mounted perfect next is get the latest SC n available in the archive log backup we need to get the latest Sen number because when we recover the database until SC n we have to give that SN number over here in in real-time people perform pointing time recovery then you need the time till where you want to perform the recovery and because this is test so what we are doing is we are performing an SC n based recovery so what we can do is list backup of archive log all and the last archive log that is sequence number 6 this is important one we have the next Sen so we need this Sen number for recovery purpose so I'll just make a note of this sa number recover database until Sen over here right and this is done next is rename the DB redo log files so they can be created in new location now see this is our production let me connect to the database now select member from V dollar log file now in this case see the location of the log file is under this location which contains the database s ID also as proudly be on the target server we will later renamed the database to test DB correct so if our redo log files reside under this location prod DB on the target it will be confusing so what we need to do is we need to rename these redo log files on the target server don't do it on the source so this is our target server I'll exit will connect to SQL plus slash assist EBA select instance name comma status from V dollar instance this is also brought DB han it is in mounted state right now what we need to do is we need to just rename these redo log files over here so that the redo log files reflect or gets created in the new location so what we do is alter database rename file whatever you're reading log file name is you just rename it to new location and if you see in this location we have SIDS test DB now in case if you want to keep the same location and same name of the database then you can continue you can just ignore this step so we are renaming the redo log file one then we'll also rename you log file too okay and then we'll rename the redo log file three perfect so renaming of the real log files is done now we need to perform the restore the data files to new location this is the run block what we need to do is we want to restore the data files to some new locations now what are these new locations this is our source server select name from V dollar data file in the data file locations also we can see that we have s ID as the directory name correct so if in the source of a directory location contains prod dB on the target it must contain test dB so what we need to do is we need to tell our man that ok boss we have the data file number 1 that is the system data file don't restore it to the location from where you have taken the backup restore it to a new location which I am providing so set new name command will tell our men to restore data files to a new location so all the data files that we have we want to restore them to this location and in this location we see prod DB change to test dB so how do we figure out you can just do select file name comma m file number name from V dollar data file set lines 9 and 9 okay so this is our data file 1 and this is system data file data file - this is the Sox data file 3 undo tablespace for users and fie example with this output you need to create these set new name parameters so once you have all those parameters next you need to restore the database from tag so let us get the tag number on target first we'll check PMON prod DBP Mon is running Carmen target slash list backup of database summary this is the backup tag with which we want to restore the database right so just replace this tag over here and later on we need to switch the data files why are we switching the data files because we have new data files locations so Oracle will update the control file with these new data file locations and finally we need to recover the database until the SCN number that we got from list backup of archive log wall and then we'll open the database so if you run this command or this run block the cloning should be started now we can see data files are being restored now reading from the backup piece this is the backup piece location so we can also see that starting media recovery so media recovery started and then it finished the media recovery and later on database is also open perfect now we'll exit and just perform our health check of the database prod deep is running SQL plus slash assess DBA select name comma open underscore mode from V dollar database it is in read write mode perfect this is our prod dB now this is the clone prod DB because we are on test server you can see we are on the test server so now we want to rename this Prada be to test TB only instance name has to be changed so how do we do that so first we connect to the database take control file backup to trace with reset locks option so let us do that sqlplus / as DBA altered database backup control file to trace as I'm taking it under temp mmm create control file dot SQL because this file will contain the SQL script of create control file okay I'll just exit next is we need to shut down the database kill + / DB shut immediate perfect exit now create P file for new database ID so right now if we go to DBS location we see that the P file is still for fraud DB will move this P file to test dB you need test DB dot Aram right also within this test DB there is one parameter that is DB name which is still proudly B so we need to change it to test DB now in the entire file we have testdb correct so the parameter file name is stress DB inside parameter file everything is testdb great start up the instance in no mount stage SQL plus okay before starting up we have to export oracle underscore s ID to new name that is test DB then SQL plus slash assist EBA startup no mount right now we can go only till gnome on stage because we have to recreate the control files okay so don't take it to mount stage and we have to edit the control file in trace location with newest ID so we had taken the control file backup in the /tmp location so what I would suggest is don't edit this file I always request you to cat the file and then copy the create control file statement into notepad take a new notepad and paste it over there so what all changes do we have to make in this control create control file statement is create control file we want to set the database name to s DB not rod DB ok test DB and then definitely we have to perform reset locks because we are recreating the control file and rest all if you see everything remains same all the log file locations are new location that is tells DB all the data file locations are now is DB right so we don't have to worry about all of them just make sure you change reuse to set and change the database s ID also also change reset logs if it is no reset lots now you have this create control file statement right what is the next step so remove reuse and put set we have already done that change no reset locks to reset locks in case if you find it over there then remove the old control files we had started the database with the control files of prod DB correct so what we need to do is we need to remove those files from the control file location so that our new control files will be created so we will cat the unit prod DB daughter sorry you need testdb datura and RM - RF delete the control files great done next now create the control file for new instance so what we can do is sqlplus / SS da select instance underscore name comma status from V dollar instance this is this DB and it is only in started state correct now we have the create control file statement so we'll copy this statement and directly run inside this test DB we can see that control files are created perfect so where the control files are created very simple it will read the control file parameter inside the P file and then it will create this control files fine now the control files are created so we can open the database order database open reset locks so control file recovery is always considered as incomplete recovery and you have to perform reset locks now let us perform a health check select name comma open under scope mode from V dollar database this is our test dB select name from V dollar control file our control file resides under is DB location and over here also we can see it resides under test DB location now select member from V dollar log file we see even our log files reside under test DB location so now where there is any trace of prod DB we have perfectly cloned our database with the newest ID into new locations using Armin restore and recover method also remember after cloning let's take this is first time you are doing you must always update the slash EDC slash or a tap file with the new database entry
Info
Channel: DBA Genesis
Views: 42,988
Rating: undefined out of 5
Keywords: oracle database, oracle recovery manager, database cloning, database cloning in oracle, rman backup and recovery, oracle clone database, what is cloning, cloning process, oracle 12c rman duplicate database from backup, restore controlfile from backup, rman restore controlfile, point-in-time recovery oracle, rman restore database from backup location, rman, oracle backup and recovery, rman backup commands, oracle backup database, cloning, Types of cloning, oracle database cloning
Id: 55Z5jzQ1Duk
Channel Id: undefined
Length: 23min 58sec (1438 seconds)
Published: Mon Jul 16 2018
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.