Oracle technology using RMAN to clone Databases

Source: Internet
Author: User

Source database RHEL4.5: 192.168.137.199 GLOBAL_NAME = WENDING. LK Oracle_SID = WENDING

Clone database RHEL4.5: 192.168.137.200 GLOBAL_NAME = STRM. LK ORACLE_SID = STRM

1. Full backup source database

$ Sqlplus '/as sysdba'

Write down the SCN before the backup, and repeat the time to repeat 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 clone database parameter file by referring to the source database parameter file:

SQL> create pfile = '/orahome/backup/initSTRM. ora' from spfile;

The data file number and position information of the source database are obtained to prepare the setting of the set newname when the clone database parameter db_file_name_convert or rman is repeated:

$ 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 of the cloned Database Host to ensure that the cloned Database Host also has the directory/orahome/backup.

$ Cd/orahome/backup

$ Scp *. bak 192.168.137.200:/orahome/backup

$ Scp initSTRM. ora 192.168.137.200:/orahome/backup

2. Database cloning preparation

Set the environment variables of the stakeholders on the clone database:

$ Vi. bash_profile (think about copying a copy from the source database host, and then correcting the ORACLE_SID parameter value)

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. Correct the cloned database parameter file

$ Vi/orahome/backup/initSTRM. ora

: % S/WENDING/STRM/g

Modify 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.

Make sure the following parameters are met:

*. Remote_login_passwordfile = exclusive

*. DB_FILE_NAME_CONVERT = '/orahome/oradata/WENDING/', '/orahome/oradata/STRM /'

4. Follow the Steps 3 to correct the path information and create the required contents on the clone Database 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 cloned Database

(The password file Technique in unix/Linux must be orapw <SID>)

$ Orapwd file = $ ORACLE_HOME/dbs/orapw $ ORACLE_SID password = iamwangnc force = y

6. Clone database startup nomount

$ Sqlplus '/as sysdba'

SQL> create spfile from pfile = '/orahome/backup/initSTRM. ora ';

SQL> startup nomount;

SQL> exit

7. duplicate the cloned database using rman rules

$ Cd/orahome

$ Vi recover. rcv (because the source database may still have an archive file after full backup, so it is time to set the set until value, otherwise there will be a fault RMAN-06025)

Run {

Allocate auxiliary channel c1 type disk;

# Set until time '2017-11-2008: 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 50 M,

Group 2 ('/orahome/oradata/STRM/redo02.dbf') SIZE 50 M,

Group 3 ('/orahome/oradata/STRM/redo03.dbf') SIZE 50 M;

}

The job information of other files after set newname and LOGFILE can be set as needed.

Follow the preceding rules: (wending. lk is the name of the source database to ensure that the source Database Listener has been started)

$ 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 13:02:39

The following error occurs when you repeat the database: RMAN-06025: no backup of log thread 1 seq 21255 scn 4144283685 found to restore

Perform the backup multiple times and then clone it. Sometimes an error occurs and sometimes no error occurs. Very confusing. After careful observation, it was found that an archive diary file would go wrong at the end of the shortage. This log file is generated after backup.

The target data is not backed up. You can transfer this file to the target host. If the database is cloned within a short period of time after the backup is generated and there is no archive file in the original database, no error will occur. There are many

Not mentioned in the manipulation document.

8. Test the clone Database

$ Sqlplus '/as sysdba'

SQL> select status from v $ instance;

SQL> archive log list;

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.