Using Rman for Oracle Database migration under the Linux platform

Source: Internet
Author: User
Tags sqlplus

Experimental purpose: Migrating an Oracle database from one machine to another (same as Linux platform), set to a different path, different instance name
SOURCE side:
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 side:
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: Two hosts are not one, but the hostname is the same model.rhel5

Step One: Get backup data on the source side

Check the MAI user's data, do the final check using
[Email protected] > select * from tab;
Tname Tabtype Clusterid
------------------------------ ------- ----------
BONUS TABLE
DEPT TABLE
EMP TABLE
Salgrade TABLE
TEST TABLE
TEST01 TABLE
Start Backup:
$ [email protected]/mnt/hgfs/software/backup> Rmantarget/
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:
$ [email protected]/mnt/hgfs/software/backup> LS-LH
Total 304M
-rwxrwxrwx 1 root root 594M 20:3120120829_02njsrtb_1_1*
-rwxrwxrwx 1 root root 6.9M 20:3120120829_03njss0b_1_1*
-rwxrwxrwx 1 root root 6.8M 20:3120120829_ctl_04njss0k_1_1*
-rwxrwxrwx 1 root root 96K 20:3120120829_spfile_05njss0m_1_1*

Step Two: Prepare for the standby
1, install the database software, the base location reference described above.
2. Create the relevant directory:
$ [email protected] ~> env | grep ORACLE
Oracle_base=/u02/app/oracle
Oracle_home=/u02/app/oracle/product/10.2.0/db_1
$ [Email protected] ~> CD $ORACLE _base
$ [email protected]/u02/app/oracle> Mkdirflash_recovery_area
$ [email protected]/u02/app/oracle> Mkdir-padmin/test2
$ [Email protected]/u02/app/oracle> CD Admin/test2
$ [email protected]/u02/app/oracle/admin/test2> Mkdir{a,b,c,d,u}dump

Step Three: Start recovery, at which point the recovered instance is named Test
$ [email protected] ~> export oracle_sid=test
$ [email protected] ~> 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 the new path
$ [email protected] ~> Sqlplus/as SYSDBA
[Email protected] > create Pfile from SPFile;
Edit the generated $oracle_home/dbs/inittest.ora file to change the path in the file to a new path, i.e.:
/oradata/test/modified to/oradata2/test2/
/u01/app/oracle/modified to/u02/app/oracle
/u01/app/oracle/admin/test modified to/u02/app/oracle/admin/test2
$ [email protected] ~> Sqlplus/as SYSDBA
[Email protected] > create SPFile from Pfile;
3. Recovery control File:
$ [email protected] ~> Rman target/
Rman> Startup Nomount
rman> restore Controlfile from '/mnt/hgfs/software/backup/20120829_ctl_04njss0k_1_1 ';
4. Recover 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, rebuild the control file, update the data file path in the control file
$ [email protected] ~> Sqlplus/as SYSDBA
[EMAIL protected] > ALTER DATABASE backup Controlfile totrace;
To $oracle_base/admin/udump, locate the trace file that you just generated, copy the fragment where you created the file set, modify the path information for the new path information, alternate
[email protected] > shutdown immediate;
[Email protected] > Startup Nomount
Use the control file you just modified to create a script to rebuild the control file:
[email protected] > 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 50M,
9 GROUP 2 '/oradata2/test2/redo02.log ' SIZE 50M,
Ten GROUP 3 '/oradata2/test2/redo03.log ' size50m
One--STANDBY LOGFILE
DataFile
'/oradata2/test2/system01.dbf ',
'/oradata2/test2/undotbs01.dbf ',
'/oradata2/test2/sysaux01.dbf ',
'/oradata2/test2/users01.dbf ',
+ '/oradata2/test2/example01.dbf '
CHARACTER SET ZHS16GBK
19;
[EMAIL protected] > ALTER DATABASE open resetlogs;
At this point, the database has started normally, but the instance name and database name are test, you need to change it to test2 and continue down.

Part IV: Modifying the instance name, and the database name

Related content can be found in previous articles: renaming of Oracle DB instances (http://blog.sina.com.cn/s/blog_67be3b4501016dgu.html)
[email protected] > shutdown immediate;
[Email protected] > Startup mount
Modify the database name in the data file, control file, and close the database after modification
[email protected] >!nid target=sys/oracle dbname=test2logfile=/tmp/change_name2test2.log
Start the database, this time will report the database name inconsistent error, do not care about him (ora-01103:database name ' MAI ' InControl file is not ' TEST ')
[Email protected] > Startup mount
Update the database name to the SPFile file
[EMAIL protected] > alter system set db_name= ' Test2 ' scope=spfile;
[Email protected] > create Pfile from SPFile;
[email protected] > shutdown immediate;
$ [email protected] ~> export ORACLE_SID=TEST2
$ [email protected] ~> Sqlplus/as SYSDBA
[email protected] > startuppfile= '/u02/app/oracle/product/10.2.0/db_1/dbs/inittest.ora '
[Email protected] > Create SPFile frompfile= '/u02/app/oracle/product/10.2.0/db_1/dbs/inittest.ora ';
[email protected] > shutdown immediate;
[Email protected] > startup mount;
[Email protected] > create Pfile from SPFile;
[EMAIL protected] > ALTER DATABASE open resetlogs;
Write Oracle_sid=test2 to the. bash_profile file for the Oracle User:
$ [email protected] ~> echo export oracle_sid=test2>>. bash_profile
At this point, the database migration is completely complete.

Part V: the final check
1, Mai user authentication:
[Email protected] > select * from tab;
Tname Tabtype Clusterid
------------------------------ ------- ----------
BONUS TABLE
DEPT TABLE
EMP TABLE
Salgrade TABLE
TEST TABLE
TEST01 TABLE
2, database name verification:
[Email protected] > select Name,open_mode fromv$database;
NAME Open_mode
--------- ----------
TEST2 READ WRITE
3. Instance Name verification:
[Email protected] > select Instance_name,status fromv$instance;
instance_name STATUS
---------------- ------------
Test2 OPEN
4. Process Validation:
$ [email protected] ~> PS aux | grep Ora_ | Grep-vgrep
Oracle 25592 0.0 1.2 261864 12756? Ss 00:23 0:00 Ora_pmon_test2
Oracle 25594 0.0 1.0 261252 11104? Ss 00:23 0:00 Ora_psp0_test2
Oracle 25596 0.0 1.3 261252 13848? Ss 00:23 0:00 Ora_mman_test2
Oracle 25598 0.0 1.3 263320 13708? Ss 00:23 0:00 Ora_dbw0_test2
Oracle 25600 0.0 2.9 276804 30644? Ss 00:23 0:00 Ora_lgwr_test2
Oracle 25602 0.0 1.6 261236 16956? Ss 00:23 0:00 Ora_ckpt_test2
Oracle 25604 0.0 3.4 261784 35812? Ss 00:23 0:00 Ora_smon_test2
Oracle 25606 0.0 1.6 261252 17224? Ss 00:23 0:00 Ora_reco_test2
Oracle 25608 0.0 2.2 262812 22948? Ss 00:23 0:00 Ora_cjq0_test2
Oracle 25610 0.1 4.2 262988 43768? Ss 00:23 0:00 Ora_mmon_test2
Oracle 25612 0.0 1.2 261252 12832? Ss 00:23 0:00 Ora_mmnl_test2
Oracle 25614 0.0 1.0 261248 10672? Ss 00:23 0:00 Ora_d000_test2
Oracle 25616 0.0 1.0 261248 10656? Ss 00:23 0:00 Ora_d001_test2
Oracle 25626 0.0 2.6 276804 27168? Ss 00:24 0:00 Ora_arc0_test2
Oracle 25628 0.0 2.6 276804 27040? Ss 00:24 0:00 Ora_arc1_test2
Oracle 25630 0.0 2.6 276804 26920? Ss 00:24 0:00 Ora_arc2_test2
Oracle 25632 0.0 1.5 261252 15660? Ss 00:24 0:00 Ora_qmnc_test2
Oracle 25638 0.0 1.1 261248 11656? Ss 00:24 0:00 Ora_q000_test2
Oracle 25640 0.0 1.3 261248 13912? Ss 00:24 0:00 Ora_q001_test2
5, the Oracle user's variable verification:
$ [email protected] ~> env | grep ORACLE
Oracle_sid=test2
Oracle_base=/u02/app/oracle
Oracle_home=/u02/app/oracle/product/10.2.0/db_1
Validation is done, and the results of the validation show that the migration has indeed been successful and has achieved the intended purpose.

Using Rman for Oracle Database migration under the Linux platform

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.