我的编程空间,编程开发者的网络收藏夹
学习永远不晚

如何使用RMAN实现Oracle数据库迁移

短信预约 -IT技能 免费直播动态提醒
省份

北京

  • 北京
  • 上海
  • 天津
  • 重庆
  • 河北
  • 山东
  • 辽宁
  • 黑龙江
  • 吉林
  • 甘肃
  • 青海
  • 河南
  • 江苏
  • 湖北
  • 湖南
  • 江西
  • 浙江
  • 广东
  • 云南
  • 福建
  • 海南
  • 山西
  • 四川
  • 陕西
  • 贵州
  • 安徽
  • 广西
  • 内蒙
  • 西藏
  • 新疆
  • 宁夏
  • 兵团
手机号立即预约

请填写图片验证码后获取短信验证码

看不清楚,换张图片

免费获取短信验证码

如何使用RMAN实现Oracle数据库迁移

这篇文章主要介绍了如何使用RMAN实现Oracle数据库迁移,具有一定借鉴价值,感兴趣的朋友可以参考下,希望大家阅读完这篇文章之后大有收获,下面让小编带着大家一起了解一下。


1.打开RMAN
[oracle@ENMOEDU ~]$ rman target /
Recovery Manager: Release 11.2.0.3.0 - Production on Sun Apr 6 17:52:06 2014
Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.
connected to target database: ENMOEDU (DBID=87396644)
RMAN> 

2.查看当前的配置信息并修改配置信息
RMAN> show all;

RMAN configuration parameters for database with db_unique_name ENMOEDU are:
CONFIGURE RETENTION POLICY TO REDUNDANCY 1; # default
CONFIGURE BACKUP OPTIMIZATION OFF; # default
CONFIGURE DEFAULT DEVICE TYPE TO DISK; # default
CONFIGURE CONTROLFILE AUTOBACKUP OFF; # default
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '%F'; # default
CONFIGURE DEVICE TYPE DISK PARALLELISM 1 BACKUP TYPE TO BACKUPSET; # default
CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE MAXSETSIZE TO UNLIMITED; # default
CONFIGURE ENCRYPTION FOR DATABASE OFF; # default
CONFIGURE ENCRYPTION ALGORITHM 'AES128'; # default
CONFIGURE COMPRESSION ALGORITHM 'BASIC' AS OF RELEASE 'DEFAULT' OPTIMIZE FOR LOAD TRUE ; # default
CONFIGURE ARCHIVELOG DELETION POLICY TO NONE; # default
CONFIGURE SNAPSHOT CONTROLFILE NAME TO '/u01/app/oracle/product/11.2.0/dbhome_1/dbs/snapcf_ENMOEDU.f'; # default 

RMAN> CONFIGURE BACKUP OPTIMIZATION ON;

new RMAN configuration parameters:
CONFIGURE BACKUP OPTIMIZATION ON;
new RMAN configuration parameters are successfully stored

RMAN> CONFIGURE CONTROLFILE AUTOBACKUP ON;

new RMAN configuration parameters:
CONFIGURE CONTROLFILE AUTOBACKUP ON;
new RMAN configuration parameters are successfully stored

3.对数据库进行一次全备

RMAN> backup database include current controlfile plus archivelog;

Starting backup at 06-APR-14
current log archived
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1

                            .

                            . 

                            .
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 06-APR-14

4.查看备份情况,删除冗余备份
RMAN> list backup;
List of Backup Sets
===================

BS Key  Size       Device Type Elapsed Time Completion Time
------- ---------- ----------- ------------ ---------------
1       70.64M     DISK        00:00:00     06-APR-14      
        BP Key: 1   Status: AVAILABLE  Compressed: NO  Tag: TAG20140406T181504
        Piece Name: /u01/app/oracle/fast_recovery_area/ENMOEDU/backupset/2014_04_06/o1_mf_annnn_TAG20140406T181504_9n2b987h_.bkp

.

.

.

BS Key  Type LV Size       Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
11      Full    9.36M      DISK        00:00:00     06-APR-14      
        BP Key: 11   Status: AVAILABLE  Compressed: NO  Tag: TAG20140406T183542
        Piece Name: /u01/app/oracle/fast_recovery_area/ENMOEDU/autobackup/2014_04_06/o1_mf_s_844194942_9n2chyvw_.bkp
  SPFILE Included: Modification time: 04-APR-14
  SPFILE db_unique_name: ENMOEDU
  Control File Included: Ckp SCN: 1302814      Ckp time: 06-APR-14

RMAN> delete obsolete;

RMAN retention policy will be applied to the command
RMAN retention policy is set to redundancy 1
using channel ORA_DISK_1
Deleting the following obsolete backups and copies:
Type                 Key    Completion Time    Filename/Handle
-------------------- ------ ------------------ --------------------
Archive Log          1      06-APR-14          /u01/app/oracle/fast_recovery_area/ENMOEDU/archivelog/2014_04_06/o1_mf_1_91_9n27s6o2_.arc

.

.

.

Do you really want to delete the above objects (enter YES or NO)? yes

.

.

.

deleted backup piece
backup piece handle=/u01/app/oracle/fast_recovery_area/ENMOEDU/backupset/2014_04_06/o1_mf_ncnnf_TAG20140406T183529_9n2chwnm_.bkp RECID=9 STAMP=844194940
Deleted 11 objects

5.将快速恢复区下的备份发送到要建立数据库的主机上
[oracle@ENMOEDU ~]$ cd /u01/app/oracle/fast_recovery_area/
[oracle@ENMOEDU fast_recovery_area]$ scp -r ENMOEDU/ oracle@192.168.80.11:/u01/app/oracle/fast_recovery_area/
oracle@192.168.80.11's password: 
o1_mf_1_95_9n2chxov_.arc                                                               100% 3072     3.0KB/s   00:00    
o1_mf_nnndf_TAG20140406T183529_9n2chkgc_.bkp                                           100% 1059MB  53.0MB/s   00:20    
o1_mf_nnndf_TAG20140406T183529_9n2chrl2_.bkp                                           100%  224MB  55.9MB/s   00:04    
o1_mf_annnn_TAG20140406T183541_9n2chxs6_.bkp                                           100% 4608     4.5KB/s   00:00    
o1_mf_s_844194942_9n2chyvw_.bkp                                                        100% 9600KB   9.4MB/s   00:00    
control02.ctl                                                                          100% 9520KB   9.3MB/s   00:00

6.在建立数据库的主机上查看传输过来的备份
[oracle@FRANK ~]$ ls /u01/app/oracle/fast_recovery_area/
ENMOEDU  FRANK
此时,数据库的备份传输成功。

7.利用RMAN恢复数据库
[oracle@FRANK ENMOEDU]$ export ORACLE_SID=ENMOEDU
[oracle@FRANK ENMOEDU]$ echo $ORACLE_SID
ENMOEDU
[oracle@FRANK ENMOEDU]$ rman target /
Recovery Manager: Release 11.2.0.3.0 - Production on Sat Mar 1 15:10:16 2014
Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.
connected to target database (not started)
RMAN> startup nomount
Oracle instance started
Total System Global Area     171581440 bytes

Fixed Size                     1343668 bytes
Variable Size                117444428 bytes
Database Buffers              50331648 bytes
Redo Buffers                   2461696 bytes
1)恢复控制文件
RMAN> restore controlfile FROM AUTOBACKUP;

Starting restore at 01-MAR-14
using channel ORA_DISK_1

recovery area destination: /u01/app/oracle/fast_recovery_area
database name (or database unique name) used for search: ENMOEDU
channel ORA_DISK_1: AUTOBACKUP /u01/app/oracle/fast_recovery_area/ENMOEDU/autobackup/2014_03_01/o1_mf_s_841048138_9k2bgbo1_.bkp found in the recovery area
AUTOBACKUP search with format "%F" not attempted because DBID was not set
channel ORA_DISK_1: restoring control file from AUTOBACKUP /u01/app/oracle/fast_recovery_area/ENMOEDU/autobackup/2014_03_01/o1_mf_s_841048138_9k2bgbo1_.bkp
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of restore command at 03/01/2014 15:33:58
ORA-19870: error while restoring backup piece /u01/app/oracle/fast_recovery_area/ENMOEDU/autobackup/2014_03_01/o1_mf_s_841048138_9k2bgbo1_.bkp
ORA-19504: failed to create file "/u01/app/oracle/oradata/ENMOEDU/control01.ctl"
ORA-27040: file create error, unable to create file
Linux Error: 2: No such file or directory
Additional information: 1

根据提示我们创建文件夹:
[oracle@FRANK 2014_04_06]$ mkdir -p /u01/app/oracle/oradata/ENMOEDU

继续之前的恢复工作:
RMAN> restore controlfile FROM AUTOBACKUP;

Starting restore at 01-MAR-14
using channel ORA_DISK_1

recovery area destination: /u01/app/oracle/fast_recovery_area
database name (or database unique name) used for search: ENMOEDU
channel ORA_DISK_1: AUTOBACKUP /u01/app/oracle/fast_recovery_area/ENMOEDU/autobackup/2014_03_01/o1_mf_s_841048138_9k2bgbo1_.bkp found in the recovery area
AUTOBACKUP search with format "%F" not attempted because DBID was not set
channel ORA_DISK_1: restoring control file from AUTOBACKUP /u01/app/oracle/fast_recovery_area/ENMOEDU/autobackup/2014_03_01/o1_mf_s_841048138_9k2bgbo1_.bkp
channel ORA_DISK_1: control file restore from AUTOBACKUP complete
output file name=/u01/app/oracle/oradata/ENMOEDU/control01.ctl
output file name=/u01/app/oracle/fast_recovery_area/ENMOEDU/control02.ctl
Finished restore at 01-MAR-14

控制文件恢复成功。

2)将数据库启动到mount模式
RMAN> alter database mount;

database mounted
released channel: ORA_DISK_1

启动成功。

3)恢复数据库文件
RMAN> restore database;

Starting restore at 01-MAR-14
Starting implicit crosscheck backup at 01-MAR-14
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=19 device type=DISK
Crosschecked 9 objects
Finished implicit crosscheck backup at 01-MAR-14

                            .

                           . 

                           .
channel ORA_DISK_1: piece handle=/u01/app/oracle/fast_recovery_area/ENMOEDU/backupset/2014_03_04/o1_mf_nnndf_TAG20140304T114802_9kbm7lm8_.bkp tag=TAG20140304T114802
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:15
Finished restore at 01-MAR-14

RMAN> recover database;

Starting recover at 01-MAR-14
using channel ORA_DISK_1

starting media recovery

unable to find archived log
archived log thread=1 sequence=1
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of recover command at 03/01/2014 15:53:22
RMAN-06054: media recovery requesting unknown archived log for thread 1 with sequence 9 and starting SCN of 1459216

由提示可得,归档日志已经用完,要应用在线日志来恢复数据库。

4)传输在线日志并应用
[oracle@ENMOEDU ENMOEDU]$ cd /u01/app/oracle/oradata/ENMOEDU/
[oracle@ENMOEDU ENMOEDU]$ ls
control01.ctl  redo01.log  redo03.log    system01.dbf  test01.dbf  undotbs01.dbf
example01.dbf  redo02.log  sysaux01.dbf  temp01.dbf    test02.dbf  users01.dbf
[oracle@ENMOEDU ENMOEDU]$ scp *.log oracle@192.168.80.11:/u01/app/oracle/oradata/ENMOEDU/
oracle@192.168.80.11's password: 
redo01.log                                                                                 100%   50MB  50.0MB/s   00:01 
redo02.log                                                                                 100%   50MB  50.0MB/s   00:01 
redo03.log                                                                                 100%   50MB  50.0MB/s   00:01 
 

RMAN> recover database;

Starting recover at 01-MAR-14
using channel ORA_DISK_1

starting media recovery

archived log for thread 1 with sequence 9 is already on disk as file
/u01/app/oracle/oradata/ENMOEDU/redo01.log
archived log file name=/u01/app/oracle/oradata/ENMOEDU/redo01.log thread=1 sequence=9
media recovery complete, elapsed time: 00:00:00  
Finished recover at 01-MAR-14

感谢你能够认真阅读完这篇文章,希望小编分享的“如何使用RMAN实现Oracle数据库迁移”这篇文章对大家有帮助,同时也希望大家多多支持亿速云,关注亿速云行业资讯频道,更多相关知识等着你来学习!

免责声明:

① 本站未注明“稿件来源”的信息均来自网络整理。其文字、图片和音视频稿件的所属权归原作者所有。本站收集整理出于非商业性的教育和科研之目的,并不意味着本站赞同其观点或证实其内容的真实性。仅作为临时的测试数据,供内部测试之用。本站并未授权任何人以任何方式主动获取本站任何信息。

② 本站未注明“稿件来源”的临时测试数据将在测试完成后最终做删除处理。有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341

如何使用RMAN实现Oracle数据库迁移

下载Word文档到电脑,方便收藏和打印~

下载Word文档

猜你喜欢

如何在 Golang 中使用数据库迁移?

在 golang 中使用数据库迁移可确保数据库与代码同步。可以使用 ent 或 gormigrate 等库执行迁移:使用 ent:安装 ent。生成迁移文件。运行迁移。使用 gormigrate:安装 gormigrate。创建迁移文件(含
如何在 Golang 中使用数据库迁移?
2024-05-14

在Oracle数据库中如何实现跨平台数据迁移和升级

在Oracle数据库中,可以使用以下方法实现跨平台数据迁移和升级:使用Oracle Data Pump工具:Oracle Data Pump是Oracle提供的用于导入导出数据库对象和数据的工具。您可以使用Data Pump将数据从一个平台
在Oracle数据库中如何实现跨平台数据迁移和升级
2024-03-02

如何使用PHP数据库迁移工具Phinx

这篇文章给大家分享的是有关如何使用PHP数据库迁移工具Phinx的内容。小编觉得挺实用的,因此分享给大家做个参考,一起跟随小编过来看看吧。1.安装composer require nhzex/think-phinx2.执行php vendo
2023-06-29

如何使用 Phinx 在 PHP 中迁移数据库

构建现代 Web 应用程序通常涉及大量数据。 在开发和生产过程中管理这些数据(数据库)可能很多。如果有多个开发人员和多个必须手动实施更改的环境,则尤其如此。数据库迁移可帮助开发人员跨多个环境和开发人员轻松管理这些更改。在本篇文章中我们将介绍
如何使用 Phinx 在 PHP 中迁移数据库
2024-02-27

oracle两个数据库之间如何迁移表

在Oracle数据库中,迁移表可以通过以下几种方式实现:1. 使用Oracle Data Pump工具:Data Pump是Oracle提供的一个强大的导入导出工具,可以用于将表从一个数据库导出到另一个数据库。你可以使用expdp命令将表导
2023-09-17

编程热搜

目录