用rman进行数据迁移

来源:互联网 发布:淘宝上的劣质充气娃娃 编辑:程序博客网 时间:2024/06/06 13:16

                  RMAN数据迁移

原理:源数据库(A) rman备份。新数据库rmanB)恢复。

         (A)

1.新建RMAN恢复目录数据库(实例=rman).

    第一步,在目录数据库中创建恢复目录所用表空间:

     create tablespace rman_tar datafile '/oracle/oradata/rman/rman_tar.dbf' size 20M;

    第二步,在目录数据库中创建RMAN 用户并授权:

     create user rman identified by rman default tablespace rman_tar;

    grant recovery_catalog_owner to rman;

    grant connect to rman;

    grant resource to rman;

    第三步,在目录数据库中创建恢复目录

    $rman catalog rman/rman

    如果未安装恢复目录 (执行)

    create catalog tablespace rman_tar;

2.注册目标数据库

[oracle@SZSC ~]$ rman catalog rman/rman

RMAN> connect target /

RMAN> register database;

3.对目标数据库进行备份

    run{

  configure controlfile autobackup on;

configure controlfile autobackup format for device type disk to '/opt/backup/%F';

allocate channel d1 type disk format '/opt/backup/full_%U';

backup database tag 'full_ora10g_data' filesperset 10 plus archivelog filesperset 20  delete all input;

release channel d1;

}

4.将备份的backup目录传输到目标服务器对应的backup目录。并且将密码文件及pfile文件传到对应的目录。

       Scp -r /opt/backup/* 192.168.124.3:/opt/backup

       Scp -r /opt/oracle/dbs/* 192.168.124.3:/opt/oracle/dbs

     (B

5.到B数据库,进行恢复。

 先用传输过来的pfile启动数据库。

   Sqlplus / as sysdba

   Startup nomount pfile='/opt/oracle/dbs/initora10g.ora

6.连接rman 

   Rman target /

   Set dbid=XXXXX(DBID到控制文件自动备份里找)

   恢复控制文件。

   Restore controlfile from '/opt/backup/c-4106385437-20120723-01'

   Alter database mount

   恢复数据文件

   Restore databae from tag='full_ora10g_data';

   Recover database;

Alter databae open;

原创粉丝点击