* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
Download RMAN Database Cloning Process
Microsoft Access wikipedia , lookup
Extensible Storage Engine wikipedia , lookup
Ingres (database) wikipedia , lookup
Open Database Connectivity wikipedia , lookup
Concurrency control wikipedia , lookup
Microsoft Jet Database Engine wikipedia , lookup
Microsoft SQL Server wikipedia , lookup
Relational model wikipedia , lookup
Oracle Database wikipedia , lookup
Versant Object Database wikipedia , lookup
Database model wikipedia , lookup
RMAN Database Cloning Process For the sake of clarity, this document will refer to the database being cloned as the target (source), and the cloning target will be referred to as the auxiliary (target). Same Server Ensure that there is enough space in the database filesystems for a cloned copy of the database. 1. Create new locations for the target datafiles to ensure that the current datafiles are not overwritten. 2. Create a new init.ora file for the cloned database. Use a copy of the current init.ora parameter file and change DB_NAME. CONTROL_FILES, and other destinations for the cloned database. Ensure that the database’s initialization parameter remote_login_passwordfile is set to EXCLUSIVE or SHARED. 3. Create an Oracle password file for the auxiliary database with the orapwd command and modify the listener.ora and tnsnames.ora files to create a new listener and connect string for the cloned database. 4. Connect to the target database and execute “alter database backup controlfile to trace resetlogs;”. 5. Execute the following query: select 'set newname for datafile '||file_id||' to '||''''||file_name||''''||';' from dba_data_files order by file_id; The results: set newname for datafile 1 to '/u04/oradata/oemtest/system01.dbf'; set newname for datafile 2 to '/u02/oradata/oemtest/undotbs01.dbf'; set newname for datafile 3 to '/u04/oradata/oemtest/sysaux01.dbf'; set newname for datafile 4 to '/u01/oradata/oemtest/undotbs01.dbf'; set newname for datafile 5 to '/u01/oradata/oemtest/data01.dbf'; set newname for datafile 6 to '/u02/oradata/oemtest/data02.dbf'; set newname for datafile 7 to '/u03/oradata/oemtest/data03.dbf'; set newname for datafile 8 to '/u04/oradata/oemtest/data04.dbf'; set newname for datafile 9 to '/u01/oradata/oemtest/index01.dbf'; set newname for datafile 10 to '/u02/oradata/oemtest/index02.dbf'; set newname for datafile 11 to '/u03/oradata/oemtest/index03.dbf'; set newname for datafile 12 to '/u04/oradata/oemtest/index04.dbf'; Copy these results to a text editor session. 6. Go to the udump location and open the latest trace file. Copy the entire logfile clause to the same text editor session where you put the query results from the last step. The logfile section will look like this: LOGFILE GROUP 1 ( '/u01/oradata/oemclone/redo01.log', '/u04/oradata/oemclone/redo02.log' ) SIZE 100M, GROUP 2 ( '/u02/oradata/oemclone/redo03.log', '/u03/oradata/oemclone/redo04.log' ) SIZE 100M, GROUP 3 ( '/u03/oradata/oemclone/redo05.log', '/u02/oradata/oemclone/redo06.log' ) SIZE 100M, GROUP 4 ( '/u04/oradata/oemclone/redo07.log', '/u01/oradata/oemclone/redo08.log' ) SIZE 100M 7. Edit the information in the text editor session so that the paths for the new data and logfiles are correct and the result looks like this (pay attention to the areas in bold text): run { set newname for datafile 1 to '/u04/oradata/oemclone/system01.dbf'; set newname for datafile 2 to '/u02/oradata/oemclone/undotbs01.dbf'; set newname for datafile 3 to '/u04/oradata/oemclone/sysaux01.dbf'; set newname for datafile 4 to '/u01/oradata/oemclone/undotbs01.dbf'; set newname for datafile 5 to '/u01/oradata/oemclone/data01.dbf'; set newname for datafile 6 to '/u02/oradata/oemclone/data02.dbf'; set newname for datafile 7 to '/u03/oradata/oemclone/data03.dbf'; set newname for datafile 8 to '/u04/oradata/oemclone/data04.dbf'; set newname for datafile 9 to '/u01/oradata/oemclone/index01.dbf'; set newname for datafile 10 to '/u02/oradata/oemclone/index02.dbf'; set newname for datafile 11 to '/u03/oradata/oemclone/index03.dbf'; set newname for datafile 12 to '/u04/oradata/oemclone/index04.dbf'; duplicate target database to <cloned DB sid> LOGFILE GROUP 1 ( '/u01/oradata/oemclone/redo01.log', '/u04/oradata/oemclone/redo02.log' ) SIZE 100M, GROUP 2 ( '/u02/oradata/oemclone/redo03.log', '/u03/oradata/oemclone/redo04.log' ) SIZE 100M, GROUP 3 ( '/u03/oradata/oemclone/redo05.log', '/u02/oradata/oemclone/redo06.log' ) SIZE 100M, GROUP 4 ( '/u04/oradata/oemclone/redo07.log', '/u01/oradata/oemclone/redo08.log' ) SIZE 100M; } 8. Set the ORACLE_SID environment variable to the cloned database SID and start an SQL*Plus session. 9. Start the cloned instance in nomount mode. startup nomount pfile=$ORACLE_HOME/dbs/init<sid>.ora 10. Start an RMAN session and execute the following commands: a. Connect target sys/<password>@<current DB> b. Connect rcvcat rcvcat/rcvcat@OEMPROD c. Connect auxiliary / 11. Copy and paste the duplicate command from the text editor into the RMAN session. If there are too many lines (datafiles), you can create a Unix shell script with the following format: #!/bin/ksh #rman_archivelog_backup.ksh . $HOME/.profile rman <<! connect target /; sys/<password>@<auxiliary> <put cloning commands here> ! 13. Once the process is complete, the new cloned database is ready to use. Different Servers (Refresh) 1. The Tivoli backup software and IBM Data Protection for Oracle needs to be installed and configured on the auxiliary server. See the “RMAN – Tivoli configuration.doc” document for the steps to accomplish this. Perform steps 1 through 6 only. 2. 3. 4. 5. On the auxiliary server, edit the /usr/tivoli/tsm/client/oracle/bin64/tdpo.opt file and change the value of TDPO_NODE to the name of the server where the target database will be cloned from. Ask the Tivoli admin to create a password file on the auxiliary server based on the change to the tdpo.opt file in the last step. Create the necessary link on the auxiliary server by performing step 9 of the “RMAN – Tivoli configuration.doc” document. Ensure that the auxiliary server has enough space in the database filesystems for a copy of the target database. You can run the following query to find out how much space is allocated in the source database: select to_char(sum(a.bytes + b.bytes + nvl(c.bytes,0)), '999,999,999,999,999,990') "DB Total Size (Bytes)" from (select sum(bytes) bytes from dba_data_files) a, (select (sum(bytes*members)) bytes from v$log) b, (select sum(bytes) bytes from v$tempfile) c; 6. 7. 8. 9. 10. 11. On the auxiliary server, create locations for the target datafiles if they do not already exist. Note – If the datafile names and locations are to be identical between the two servers, you MUST use the NOFILENAMECHECK option of the database duplicate command. See the command is step 12 for details. On the auxiliary server, create a new init.ora file for the cloned database. Use a copy of the target init.ora parameter file and change the CONTROL_FILES location (if necessary), and other destinations for the new database. LEAVE THE DB_NAME PARAMETER UNCHANGED. Ensure that the parameter remote_login_passwordfile is set to EXCLUSIVE. On the auxiliary server, create an Oracle password file for the new database with the orapwd command (i.e orapwd file=orapw<SID> password=<password> ) On the auxiliary server, modify the listener.ora and tnsnames.ora files to create a new listener and connect string for the new database. On the target server, connect to the current database and execute “alter database backup controlfile to trace resetlogs;”. Execute the following query: select 'set newname for datafile '||file_id||' to '||''''||file_name||''''||';' from dba_data_files order by file_id; The results: set newname for datafile 1 to '/u04/oradata/oemtest/system01.dbf'; set newname for datafile 2 to '/u02/oradata/oemtest/undotbs01.dbf'; set newname for datafile 3 to '/u04/oradata/oemtest/sysaux01.dbf'; set newname for datafile 4 to '/u01/oradata/oemtest/undotbs01.dbf'; set newname for datafile 5 to '/u01/oradata/oemtest/data01.dbf'; set newname for datafile 6 to '/u02/oradata/oemtest/data02.dbf'; set newname for datafile 7 to '/u03/oradata/oemtest/data03.dbf'; set newname for datafile 8 to '/u04/oradata/oemtest/data04.dbf'; set newname for datafile 9 to '/u01/oradata/oemtest/index01.dbf'; set newname for datafile 10 to '/u02/oradata/oemtest/index02.dbf'; set newname for datafile 11 to '/u03/oradata/oemtest/index03.dbf'; set newname for datafile 12 to '/u04/oradata/oemtest/index04.dbf'; Copy these results to a text editor session. 12. Go to the udump location and open the latest trace file (the last file after an ‘ls –lart’ command). Copy the entire logfile clause to the same text editor session where you put the query results from the last step. The logfile section will look like this: LOGFILE GROUP 1 ( '/u01/oradata/oemclone/redo01.log', '/u04/oradata/oemclone/redo02.log' ) SIZE 100M, GROUP 2 ( '/u02/oradata/oemclone/redo03.log', '/u03/oradata/oemclone/redo04.log' ) SIZE 100M, GROUP 3 ( '/u03/oradata/oemclone/redo05.log', '/u02/oradata/oemclone/redo06.log' ) SIZE 100M, GROUP 4 ( '/u04/oradata/oemclone/redo07.log', '/u01/oradata/oemclone/redo08.log' ) SIZE 100M 13. Edit the information in a text editor session so that the paths for the new data and logfiles are correct and the result looks like this (pay attention to the areas in bold text): run { set newname for datafile 1 to '/u04/oradata/oemclone/system01.dbf'; set newname for datafile 2 to '/u02/oradata/oemclone/undotbs01.dbf'; set newname for datafile 3 to '/u04/oradata/oemclone/sysaux01.dbf'; set newname for datafile 4 to '/u01/oradata/oemclone/undotbs01.dbf'; set newname for datafile 5 to '/u01/oradata/oemclone/data01.dbf'; set newname for datafile 6 to '/u02/oradata/oemclone/data02.dbf'; set newname for datafile 7 to '/u03/oradata/oemclone/data03.dbf'; set newname for datafile 8 to '/u04/oradata/oemclone/data04.dbf'; set newname for datafile 9 to '/u01/oradata/oemclone/index01.dbf'; set newname for datafile 10 to '/u02/oradata/oemclone/index02.dbf'; set newname for datafile 11 to '/u03/oradata/oemclone/index03.dbf'; set newname for datafile 12 to '/u04/oradata/oemclone/index04.dbf'; duplicate target database to <target DB sid> nofilenamecheck (Only necessary if datafile names &locations are identical between servers) LOGFILE GROUP 1 ( '/u01/oradata/oemclone/redo01.log', '/u04/oradata/oemclone/redo02.log' ) SIZE 100M, GROUP 2 ( '/u02/oradata/oemclone/redo03.log', '/u03/oradata/oemclone/redo04.log' ) SIZE 100M, GROUP 3 ( '/u03/oradata/oemclone/redo05.log', '/u02/oradata/oemclone/redo06.log' ) SIZE 100M, GROUP 4 ( '/u04/oradata/oemclone/redo07.log', '/u01/oradata/oemclone/redo08.log' ) SIZE 100M; } 14. 15. On the auxiliary server, set the ORACLE_SID environment variable to the new database SID and start an SQL*Plus session. On the auxiliary server, start the new instance in nomount mode with the following command: startup nomount pfile=$ORACLE_HOME/dbs/init<sid>.ora 16. 17. On the target server, add a connect string to the $ORACLE_HOME/network/admin/tnsnames.ora file to connect to the auxiliary instance. The name of the connect string can be anything you loke, but the name of the auxiliary SID will be the same name of the target SID. On the target server, start an RMAN session and execute the following commands: a. connect target / b. connect auxiliary sys/<password>@<connect_string> 18. Copy and paste the duplicate command from the text editor into the RMAN session. If there are too many lines (datafiles), you can create a Unix shell script with the following format: #!/bin/ksh #rman_archivelog_backup.ksh . $HOME/.profile rman <<! connect target /; sys/<password>@<auxiliary> <put cloning commands here> ! …Or you can save the duplicate commands in a .sql file and execute it from the RMAN> prompt as you would from an SQL*Plus session using the @ sign (i.e. @rman_clone_commands.sql) 19. Once the process is complete, the new cloned database is ready to use. However, if you want to change the name of the cloned database, you need to go through the process of creating a new control file with the following steps: a. Start an SQL*Plus session and execute the command “alter database backup controlfile to trace resetlogs;” b. Execute “show parameter user_dump_dest” to find the location of the trace file you just created. c. Shutdown the database and exit the SQL*Plus session. d. Modify the init.ora file to reflect the new name of the database. Examine the names and locations of the control, log, and dump files. You may need to create new locations. Create a new password file if necessary with the orapwd command. e. Go to the user_dump_dest location and open the latest trace file (the last file after an ‘ls –lart’ command). Edit the file so that it appears like this (pay special attention to the areas in bold text and ensure they are correct): STARTUP NOMOUNT PFILE=/oracle/product/9.2.0/dbs/initoemclone.ora CREATE CONTROLFILE SET DATABASE "OEMPROD" RESETLOGS NOARCHIVELOG MAXLOGFILES 16 MAXLOGMEMBERS 3 MAXDATAFILES 255 MAXINSTANCES 8 MAXLOGHISTORY 454 LOGFILE GROUP 1 ( '/u01/oradata/oemprod/redo01.log', '/u04/oradata/oemprod/redo02.log' ) SIZE 100M, GROUP 2 ( '/u02/oradata/oemprod/redo03.log', '/u03/oradata/oemprod/redo04.log' ) SIZE 100M, GROUP 3 ( '/u03/oradata/oemprod/redo05.log', '/u02/oradata/oemprod/redo06.log' ) SIZE 100M, GROUP 4 ( '/u04/oradata/oemprod/redo07.log', '/u01/oradata/oemprod/redo08.log' ) SIZE 100M -- STANDBY LOGFILE DATAFILE '/u04/oradata/oemprod/system01.dbf', '/u01/oradata/oemprod/undotbs01.dbf', '/u03/oradata/oemprod/sysaux01.dbf', '/u01/oradata/oemprod/data01.dbf', '/u02/oradata/oemprod/data02.dbf', '/u03/oradata/oemprod/data03.dbf', '/u04/oradata/oemprod/data04.dbf', '/u01/oradata/oemprod/index01.dbf', '/u02/oradata/oemprod/index02.dbf', '/u03/oradata/oemprod/index03.dbf', '/u04/oradata/oemprod/index04.dbf', '/u02/oradata/oemprod/undotbs02.dbf', '/u02/oradata/oemprod/tools01.dbf' CHARACTER SET AL32UTF8 ; --RECOVER DATABASE USING BACKUP CONTROLFILE --ALTER DATABASE OPEN RESETLOGS; Save the file as an SQL script. f. Change the ORACLE_SID environment variable to reflect the name change. g. Start an SQL*Plus session h. Execute the SQL script create in step e. i. When the message “Controlfile created” appears, execute “alter database open resetlogs;”. When the message “Database altered” appears, the change is complete. j. If this is a new production database, go through the steps to register and back it up with RMAN.