RMAN Duplicate Database to Same SID

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
welcome back guys and in this video we will be looking at how can you perform harmon cloning from a live database you know guys armin has a lot of capabilities armen is the most powerful tool a dba can have but do you know that by just following six steps you can perform an active database cloning like you have a live database running and for this live database you have no backup at all like no backup taken so this live database live running database we will be performing cloning of a live running database using our men also one thing you guys need to note is in this video we will be looking at the same sid cloning so on the source server the database sid will be prog and after cloning the clone database sid will still be proud let us move on to my system and look at this armament cloning all right guys so we are back onto my system and over here i have two servers on the left hand side i'm in the first window the first tab is my prod server this is where one production or the prod database is up and running let's check the pmon ps siphon ef crap beam on you can see prod pmon is up and running and also guys i'll show you something env crap for rna so these are the environment variables you can see the oracle home over here is this one that is user one app oracle product 1201 i also have a test server where no pmon is running you can check this one and if you check the environment variables you can see oracle is already installed on the exact same oracle home our goal right now is to perform an active database cloning of this broad database from this prod server to the test server where the oracle home remains exactly same all right so the oracle home locations are same the database s id after cloning will also remain exactly same so once we clone the prod database onto the test server still the name of the database will remain exactly same that is prawn it is one of the simplest active armament database cloning so what you can do is guys go to our support website support.dbagenesis.com and if you search for arm and duplicate from active database you will get this article i have two scenarios covered over here right now we are looking at the first scenario that is armand duplicate database 2 same sid this is we are duplicating from a live database that means no backup has been taken on the prod database there is no backup no harm and backup zero it is the fresh installation so no backup taken off for the prod database and we are going to perform the cloning from the active that is like the running database the database is already up and running and we will be performing the active cloning and yes we'll be using our man to perform the active database cloning and after cloning the database sid remains exactly same as the source database so we will be using the first scenario in this video so arm and duplicate database two same sid the first thing we need to do is we need to configure the listener on the clone server to accept the incoming connections in our case our clone server is the test server so we need to create a listener over here so i will get into oracle underscore home slash network slash admin and vi listener dot aura this is the listener entry or the listener file i'll copy these contents and just put it over here so what all things we need to change first thing that we need to change is the host so i'll put the ip address of the test server where this listener will be accepting the connections 172.20.10.12. the port is 1521 and we need to change the oracle home so i think i'll copy and paste the oracle home i'll copy it from the prod because oracle home is exactly same on both the servers so we'll just paste it and the sid name remains fraud so that is same let us save now we'll start this listener lsnrctl start listener and this listener should be up and running in some time all right our listener is up and running now on the prod server or the source server we need to configure a tns entry so that our prod server can connect to the test server where this listener is up and running so we will go to the prod server we will get inside oracle underscore home network admin and vi tns names dot aura this is the file which will contain the dns entries to connect to the clone server so the name that i'm giving to this dns entry is prod underscore clone because this will be our test server give the ip address of the test server where we are going to clone this database so i'll put the ip address as 172.20.10.12. i think that's the correct ip address and the service name will still remain prod because we are cloning from prod to prod also if you see the listener is accepting connection for the fraud service right save and close the dns entries on fraud and let us perform a dns ping so prod underscore clone this should ping our test server it's working perfectly fine you can see all right let's move on so tns ping is fine now we are performing the actual cloning steps our first step on prod server create p file from sp file and copy to clone server let us connect to sql plus we'll create this p file from sp file slash sus tba so createp file from sp file will exit and we need to copy this to the test server so where do we find our p file oracle home dbs location right lsiphon lrt init prod dot aura this is the p file init fraud dot aura and i need to copy to oracle at 172 dot 20.10 dot this is the server and i want to copy it into the same location oracle underscore home slash dbs because oracle home is exactly same on both the servers hit enter give the password for the other server and let us see all right so this is copied init product aura is copied so we have the p file which is copied onto the clone server now the next step is also copy the password file from the prod to clone server you can see under the dbs location we are already in the dbs location there is a file or a pw this is the password file so i'll copy this file scp or pw and i'll copy it to oracle at i mean the same location where we copied the p file all right so give the password of this server and then so we copied the p file from the prod to clone and we copied the password file from pro to clone this is done and on the clone server open the p file that you copied from prod server and create the directory locations see guys on the prod server we have the locations where we have the control file the data files the log files these same locations might not exist on the server where you're cloning so the first thing we have to do is we have to create those directory locations so that when you clone from the active database using our men are men can create those files inside the right locations perfect so let us go to oracle underscore home slash dbs so guys this step i'm doing on the clone i mean the test server okay so ls iphone lrt this is the p file so i'll open this p file sorry guys oh you need prod dot aura so i have this parameter file open now mkdir hyphen p i will create all the directory locations that i see i'll start with the a dump location then i'll create the location for the prod and then i'll create the location for the control files i think this one is already created but i'll just copy and paste it and and i don't see any other location over here so just hit enter and all these directory locations are created perfect so guys one more step that you guys need to add up over here is you need to create all the locations where your like the source database data files reside so let us connect to the sql plus this is a test so we are ignoring it but in real time you need to make sure you're creating all the locations of select name from the dollar data file so you have to create all the locations of the data files also in case if the data file locations are different in our test scenario we have only one location where we have everything the data file the control file and also the log file so we are ignoring it but just one more step you need to add in real time make sure you are looking at the locations of the data files and also select member from vdollar log file and you have to create these locations also once you are done with all the locations creation on the clone server next take the clone server database to no amount stage because we have the parameter file on the clone server we can definitely take it to the no mount stage make sure you export the oracle underscore sid to prod because the sid we are cloning from the source is also prod right now connect to sql plus slash says dba and then perform startup no mount you can only take it to no more stage over here because we only have the parameter file the control files the data files will automatically come via the armand cloning from the source server one thing you guys need to remember over here and this is something i have told people thousand times but they always miss it okay read this notice it says cloning will fail if you do not exit from sql plus many dbas they keep the clone server at the stage they do not exit the sql plus and they will go to the prod server and they will try to fire the cloning the arm and cloning command and the command fails the reason why the armament cloning command fails is over here oracle thinks that a user is connected to the database and there is one live user session so rmn will not disturb the live user session and that's why cloning fails it is must and you've got to exit from the sql plus on the clone server so what all we have done guys very simple steps if you look at the article again we created a listener on the clone we created a tns entry from the prod server which connects to the clone server we created the p file from sp file we copied the password file from prod to the test server and then we created all the directory locations which are required to hold all the data files control files and all and then we took the target or the clone database to no mount mode all right simple steps right now here is the beauty with just one command i mean this is the command duplicate target database to prod from active database no file name check this one command will clone your production database live running database active from the active running database where even if you don't have any backup of the prod database rmn will automatically clone from the live database the one that is already running so the first thing that you need to do is connect to the rmn target says and then you have to connect to the auxiliary database what is auxiliary auxiliary is the clone server if you don't connect to it you won't be able to perform this cloning so from where you will connect on this rmn you need to connect to armin from the main prod server because from the prod database i mean this is the database from where armament cloning has to be initiated i'll exit from sql plus so rmn target says this is connecting to the fraud so when i say r target this is connecting to the prod and i need to connect to the auxiliary auxiliary and then you have to give the username at so what is the dns entry name you have given for the connection to the clone server in our case we have given it as prod underscore clone hit enter this will ask you password for the target database give the sys user password so i will type the cis user password over here all right so it is connected to the target database also this is where the dbas get confused armin will ask you the cis user password for the auxiliary database and many dbas think that okay so we are about to clone the database right what is the auxiliary database it is the clone database right so the clone database does not exist so what password to give over here to keep it simple guys just give the same target sys user password once again why we do it because you copied the same prod server password file onto the clone server right so the password that you give over here will be authenticated via the password file that we copied onto the clone server so i'll give the exactly same password let us type it and see can you see it says connected to auxiliary database not mounted over here i have also mentioned a node gives same sis password for both target and auxiliary to keep things simple and the most important command this one command will start the duplicate of your production database from the active live running database where even if you don't have any backups that's perfectly okay let me fire this command but before firing this command always go to your clone server make sure you are out of the sql prompt otherwise the cloning will fail let us go back to the prod server i will fire this command duplicate target database 2 what is the name that you want to clone i want to clone to the same sid that is prod from active database right i want to like perform the cloning from the live running database and no file name check that means i want to keep all the files in the same location and guys this no file name check parameter is a pretty old one i mean there's no actual significance of it but the only condition is you have to keep it there if you don't keep it the cloning will fail let me hit enter and we will wait for our men to perform the cloning you will see how simple it is to perform the active database arm and cloning over here at this stage if you see guys what armin is doing is it restored the clone primary control file so control files are copied onto the target server that is the clone server and now rmn will start restoring the data file so it is copying the system data file onto the clone server but before even copying this one if you see this one the target database is put into mount mode if you remember we only put the target database into no mount mode and armand copied the control file and put the target database in mount mode for us now it is proceeding further to copy the data files you can see the system data file is copied already now it is proceeding to copy the csox data file onto the clone server awesome all the data files are copied you can see now rmin is proceeding to recover the target or the clone database using the existing archive logs it is copying the archive logs on the target server and then it is performing the recovery and once the recovery is completed then it will start the instance again and it will open can you see alt clone database open reset logs it is opening the target clone database and it will be ready in a minute for us to use so meanwhile this comes up guys let us count the number of steps are involved in order to perform the armament cloning we can see we set up the listener step one set up the tns entries step two then we copied the p file and the password file step three then we created the directory locations on the clone server step four and then we put the target or the clone database into no amount mode this is step five and step six we issued the duplicate target database command that means you can perform the arm and cloning from fraud to a test server by just following six steps very simple straightforward steps and guys we did not take any backup of the broad database it is from a live running database cloning and over here you can see finish duplicate database at this point of time awesome let us go to the clone server so guys the first thing that we need to check i will clear the screen meanwhile so i'll connect to the database or let us do this ps hyphen ef correct pmon we can see broad database is up and running let us connect to the database slash asus dba now select name comma open underscore mode from v dollar database guys if you remember we only put this database in no mount mode before cloning let me hit enter and can you see this database is currently in read write more awesome let us also check whether this database is running from p file or sp file because earlier we only copied the p file right so show parameter sp file can you see this instance is currently running with sp file so you should have a question like from where sp file came if you go back and read through the armin cloning output you will see that this creates the sp file for the database instance let us look at can you see create sp file from memory so the rmn script is creating sp file for you and after creating the sp file it shuts down the instance and then starts it in no mount mode so the rmn is smart enough it knows that it has to create the sp file so it created the sp file now show parameter control this will show us all the control files so there are two control files again you can also check select name from the dollar data file you can see all the data files are available and also select name from sorry select member from v dollar log file perfect that is how simple armament cloning is using the active database so you can use rmin to perform the duplicate from the active database awesome guys i think you enjoyed this activity very simple straightforward six steps you can perform cloning of any database but guys one of my personal recommendation is use this method of arm and cloning only when your database size is small if your database size is in terabytes you cannot use arm and active database cloning because it will take i think ages for you not for you actually for our men to perform the cloning from prod to the test or the dev server don't use this method for multi-terabyte databases this method is sweet and simple method for very small databases that's all for today guys and we will catch up in our next video bye
Info
Channel: DBA Genesis
Views: 8,395
Rating: undefined out of 5
Keywords: dba genesis, oracle, database, cloud
Id: NQDycSXcEeY
Channel Id: undefined
Length: 23min 20sec (1400 seconds)
Published: Wed Mar 24 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.