How to clone a database using Rman in Oracle

Source: Internet
Author: User
Tags exit mkdir thread sqlplus backup

Source Library rhel4.5:192.168.137.199 Global_name=wending. LK oracle_sid=wending

Clone Library rhel4.5:192.168.137.200 GLOBAL_NAME=STRM. LK ORACLE_SID=STRM

1. Full Backup Source Library

$ Sqlplus '/as sysdba '

Note the SCN before the backup, and the time of the regulation is back to this point.

Sql> Select Dbms_flashback. Get_system_change_number from dual;

Get_system_change_number

------------------------

181557

Sql> exit

$ mkdir-p/orahome/backup

$ cd/orahome

$ VI BACKUP.RCV

run{

Allocate channel C1 type disk;

Backup full database format '/orahome/backup/db_t%t_s%s_p%p.bak ';

Backup Archivelog all format '/orahome/backup/arch_u%u.bak ';

Backup current controlfile format '/orahome/backup/cf_u%u.bak ';

Release channel C1;

}

$ nohup Rman target/@backup. RCV Log Backup.log &

$ tail-50f Backup.log

Create a new clone library parameter file with reference to the source library parameter file:

sql> Create pfile = '/orahome/backup/initstrm.ora ' from SPFile;

The Source Library data file number and the position information are obtained for the purpose of preparing the clone library parameter Db_file_name_convert or the set newname setting when the Rman regulation is complex:

$ Sqlplus '/as sysdba '

sql> Col name format A60

Sql> Set Lines 1024

Sql> Select File#,name from v$datafile UNION ALL select File#,name from V$tempfile;

file# NAME

---------- ------------------------------------------------------------

1/orahome/oradata/wending/system.dbf

2/orahome/oradata/wending/undotbs1.dbf

3/orahome/oradata/wending/sysaux.dbf

4/orahome/oradata/wending/users01.dbf

1/orahome/oradata/wending/temp01.dbf

Sql> exit

Copy the backup file to the same position as the Clone Library host, ensuring that the clone library host also has a catalog/orahome/backup.

$ cd/orahome/backup

$ SCP *.bak 192.168.137.200:/orahome/backup

$ SCP Initstrm.ora 192.168.137.200:/orahome/backup

2. Preparation of the Cloning library

To set up an environment variable on the clone library:

$ vi. Bash_profile (consider copying a copy from the source library and correcting the ORACLE_SID parameter values)

Export oracle_base=/u01/app/oracle;

Export Oracle_home= $ORACLE _base/product/10.2.0/db_1;

Export ORACLE_SID=STRM;

Export nls_lang= "American_america. ZHS16GBK "

Export nls_date_format= "Yyyy-mm-dd HH24:MI:SS"

$ . . bash_profile

3. Correcting the Clone library parameter file

$ vi/orahome/backup/initstrm.ora

:%s/wending/strm/g

As usual, correct the following parameters:

Audit_file_dest,background_dump_dest,core_dump_dest,user_dump_dest,db_name,db_unique_name,log_archive_dest_1, Control_files.

and ensure the following parameters:

*.remote_login_passwordfile = Exclusive

More Wonderful content: http://www.bianceng.cnhttp://www.bianceng.cn/database/Oracle/

*. Db_file_name_convert = '/orahome/oradata/wending/', '/orahome/oradata/strm/'

4. Path information as per step 3 new required catalog in clone library host

$ mkdir-p/orahome/flash_recovery_area

$ mkdir-p/ORAHOME/ARCH/STRM

$ mkdir-p/orahome/oradata/strm/

$ mkdir-p/u01/app/oracle/admin/strm/adump

Mkdir-p/u01/app/oracle/admin/strm/bdump

Mkdir-p/u01/app/oracle/admin/strm/cdump

Mkdir-p/u01/app/oracle/admin/strm/dpdump

Mkdir-p/u01/app/oracle/admin/strm/udump

5. Create a new password file in the Clone library

(Unix/linux under the password of the two must be orapw<sid>)

$ orapwd file= $ORACLE _home/dbs/orapw$oracle_sid password=iamwangnc force=y

6. Clone Library Startup Nomount

$ Sqlplus '/as sysdba '

Sql> create SPFile from pfile= '/orahome/backup/initstrm.ora ';

sql> startup Nomount;

Sql> exit

7. The clone storehouse uses the Rman regulation to reply

$ cd/orahome

$ VI RECOVER.RCV (due to the source library in full standby may also occur after the archive file, to be the time to set the reset set until value, otherwise the fault will occur RMAN-06025)

run{

Allocate auxiliary channel C1 type disk;

# Set until time ' 2008-11-21.11:33:31 ';

# set until sequence 21254 thread 1;

Set until SCN 181557;

Duplicate target database to STRM

LOGFILE

Group 1 ('/orahome/oradata/strm/redo01. DBF ') SIZE 50M,

Group 2 ('/orahome/oradata/strm/redo02. DBF ') SIZE 50M,

Group 3 ('/orahome/oradata/strm/redo03. DBF ') SIZE 50M;

}

Other file post information for set newname and logfile can be set as necessary.

Start Regulation Complex: (Wending.lk is the source of the name of the library, to ensure that the source library has been started listening)

$ nohup rman target sys/iamwangnc@192.168.137.199:1521/wending.lk auxiliary/@recover. RCV Log Recover.log &

$ tail-50f Recover.log

...

Database opened

Finished Duplicate Db at 2008-11-21 13:02:39

The following error occurred while regulating the database: Rman-06025:no backup of log thread 1 seq 21255 SCN 4144283685 found to restore

Perform a backup multiple times, then clone, and find that there are sometimes errors, sometimes without errors. Very puzzling. After careful observation, it was found that an archived journal file could be faulted at the end of the shortage. And this journal file is produced after the backup

Raw, there is no backup of the target data. It's OK to pass this file to the target host. If the backup, after a short period of time cloning, the original database does not have an archive file, there will be no errors. This in a lot

Manipulating the document, not mentioned.

8. Test the Clone Library

$ Sqlplus '/as sysdba '

Sql> select status from V$instance;

sql> archive log list;

Author: 51cto Blog Oracle Little Bastard

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.