Use RMAN for Oracle database migration in Linux

Source: Internet
Author: User

Objective: To migrate an Oracle database from one machine to another machine (the same as a linux platform) and set it to a different path and Instance name
Source end:
ORACLE_BASE =/u01/app/oracle
ORACLE_HOME =/u01/app/oracle/product/10.2.0/db_1
ORACLE_SID = test
Data File Location:/oradata/test
Target end:
ORACLE_BASE =/u02/app/oracle
ORACLE_HOME =/u02/app/oracle/product/10.2.0/db_1
ORALCE_SID = test2
Data File Location:/oradata2/test2
Note: The two hosts are not one, but the host names are both model. rhel5.

Step 1: Obtain backup data at the source end
Query the data of the MAI user for final verification.
MAI @ test> select * from tab;
TNAME TABTYPE CLUSTERID
-----------------------------------------------
BONUS TABLE
DEPT TABLE
EMP TABLE
SALGRADE TABLE
TEST TABLE
TEST01 TABLE
Start backup:
$ Oracle @ model/mnt/hgfs/software/backup> rman target/
RMAN> run {
2> allocate channel c1 device type disk format'/mnt/hgfs/software/backup/% T _ % U ';
3> backup database;
4> backup current controlfile format '/mnt/hgfs/software/backup/% T_CTL _ % U ';
5> backup spfile format '/mnt/hgfs/software/backup/% T_SPFILE _ % U ';
6> release channel c1;
7>}
Backup set information:
$ Oracle @ model/mnt/hgfs/software/backup> ls-lh
Total 304 M
-Rwxrwxrwx 1 root 594 M Aug 29 20:31 20120829_02njsrtb_1_1 *
-Rwxrwxrwx 1 root 6.9 M Aug 29 20:31 20120829_03njss0b_1_1 *
-Rwxrwxrwx 1 root 6.8 M Aug 29 20:31 20120829_CTL_04njss0k_1_1 *
-Rwxrwxrwx 1 root 96 K Aug 29 20:31 20120829_SPFILE_05njss0m_1_1 *

Step 2: Prepare the slave
1. Install the database software. For the base location, refer to the above description.
2. Create related directories:
$ Oracle @ model ~> Env | grep ORACLE
ORACLE_BASE =/u02/app/oracle
ORACLE_HOME =/u02/app/oracle/product/10.2.0/db_1
$ Oracle @ model ~> Cd $ ORACLE_BASE
$ Oracle @ model/u02/app/oracle> mkdir flash_recovery_area
$ Oracle @ model/u02/app/oracle> mkdir-p admin/test2
$ Oracle @ model/u02/app/oracle> cd admin/test2
$ Oracle @ model/u02/app/oracle/admin/test2> mkdir {a, B, c, d, u} dump

Step 3: start recovery. The recovered Instance name is test.
$ Oracle @ model ~> Export ORACLE_SID = test
$ Oracle @ model ~> Rman target/
RMAN> startup nomount
1. Restore spfile:
RMAN> restore spfile from '/mnt/hgfs/software/backup/20120829_SPFILE_05njss0m_1_1 ';
RMAN> shutdown immediate;
2. Edit the parameter file to change the relevant path in the parameter to a new path.
$ Oracle @ model ~> Sqlplus/as sysdba
SYS @ test> create pfile from spfile;
Edit the generated $ ORACLE_HOME/dbs/inittest. ora file and change the path in the file to a new path, that is:
/Oradata/test/to/oradata2/test2/
/U01/app/oracle/change to/u02/app/oracle
/U01/app/oracle/admin/test to/u02/app/oracle/admin/test2
$ Oracle @ model ~> Sqlplus/as sysdba
SYS @ test> create spfile from pfile;
3. Restore control file:
$ Oracle @ model ~> Rman target/
RMAN> startup nomount
RMAN> restore controlfile from '/mnt/hgfs/software/backup/20120829_CTL_04njss0k_1_1 ';
4. Restore data files:
RMAN> alter database mount;
RMAN> run {
2> set newname for datafile 1 to '/oradata2/test2/system01.dbf ';
3> set newname for datafile 2 to '/oradata2/test2/undotbs01.dbf ';
4> set newname for datafile 3 to '/oradata2/test2/sysaux01.dbf ';
5> set newname for datafile 4 to '/oradata2/test2/users01.dbf ';
6> set newname for datafile 5 to '/oradata2/test2/example01.dbf ';
7> restore database;
8>}
5. Recreate the control file and update the data file path in the control file.
$ Oracle @ model ~> Sqlplus/as sysdba
SYS @ test> alter database backup controlfile to trace;
Find the generated TRACE file in $ ORACLE_BASE/admin/udump, copy the part of the file set to be created, and modify the path information to the new path information.
SYS @ test> shutdown immediate;
SYS @ test> startup nomount
Use the modified control file to create a script to recreate the control file:
SYS @ test> create controlfile reuse database "TEST" RESETLOGS ARCHIVELOG
2 MAXLOGFILES 16
3 MAXLOGMEMBERS 3
4 MAXDATAFILES 100
5 MAXINSTANCES 8
6 MAXLOGHISTORY 292
7. LOGFILE
8 GROUP 1'/oradata2/test2/redo01.log' SIZE 50 M,
9 GROUP 2'/oradata2/test2/redo02.log 'SIZE 50 M,
10 GROUP 3 '/oradata2/test2/redo03.log' SIZE 50 M
11 -- STANDBY LOGFILE
12 DATAFILE
13 '/oradata2/test2/system01.dbf ',
14'/oradata2/test2/undotbs01.dbf ',
15'/oradata2/test2/sysaux01.dbf ',
16 '/oradata2/test2/users01.dbf ',
17 '/oradata2/test2/example01.dbf'
18 character set ZHS16GBK
19;
SYS @ test> alter database open resetlogs;
So far, the database can be started normally, but the Instance name and database name are both test, you need to change it to test2, continue to go down

For more details, please continue to read the highlights on the next page:

Basic Oracle tutorial-copying a database through RMAN

Reference for RMAN backup policy formulation

RMAN backup learning notes

Oracle Database Backup encryption RMAN Encryption

  • 1
  • 2
  • Next Page

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.