码迷,mamicode.com
首页 > 数据库 > 详细

RMAN迁移数据库(不改变文件目录)

时间:2018-11-06 11:58:38      阅读:161      评论:0      收藏:0      [点我收藏+]

标签:创建目录   11.2   dump   sysdba   checked   1.2   down   dmi   init   


1、目标库创建相应目录
mkdir -p /u01/app/oracle/oradata/orcl
mkdir -p /u01/app/oracle/fast_recovery_area/ORCL
mkdir -p /u01/app/oracle/admin/orcl/{a,dp}dump

2、目标库创建密码文件
orapwd file=orapworcl password=oracle

3、原库备份
RMAN> backup as compressed backupset database plus archivelog;

4、将原库备份传输到目标库
在目标库创建目录存放原库传输过来的原库备份
mkdir –p /home/oracle/bak
mkdir –p /home/oracle/autobak
利用scp工具传输,具体不详细介绍。

5、[oracle@orcl ~]$ rman target /
Recovery Manager: Release 11.2.0.3.0 - Production on Mon Nov 5 11:19:38 2018

Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.

connected to target database: (not started)
RMAN> set dbid 238796283
executing command: SET DBID

6、
RMAN> startup nomount

startup failed: ORA-01078: failure in processing system parameters
LRM-00109: could not open parameter file ‘/u01/app/oracle/product/11.2.0/db_1/dbs/initorcl.ora‘

starting Oracle instance without parameter file for retrieval of spfile
Oracle instance started

Total System Global Area 159019008 bytes

Fixed Size 1343612 bytes
Variable Size 75501444 bytes
Database Buffers 79691776 bytes
Redo Buffers 2482176 bytes

RMAN> restore spfile to pfile ‘/u01/app/oracle/product/11.2.0/db_1/dbs/initorcl.ora‘ from ‘/home/oracle/autobak/o1_mf_s_991416863_fy03o039_.bkp‘;

Starting restore at 05-NOV-18
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=19 device type=DISK

channel ORA_DISK_1: restoring spfile from AUTOBACKUP /home/oracle/autobak/o1_mf_s_991416863_fy03o039_.bkp
channel ORA_DISK_1: SPFILE restore from AUTOBACKUP complete
Finished restore at 05-NOV-18

RMAN> exit


Recovery Manager complete.
[oracle@fz-orcl autobak]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.3.0 Production on Mon Nov 5 18:28:15 2018

Copyright (c) 1982, 2011, Oracle. All rights reserved.


Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SYS@orcl>select status from v$instance;

STATUS
------------
STARTED

SYS@orcl>create spfile from pfile;

File created.

SYS@orcl>shutdown immediate
ORA-01507: database not mounted


ORACLE instance shut down.
SYS@orcl>startup nomount
ORACLE instance started.

Total System Global Area 472887296 bytes
Fixed Size 1345716 bytes
Variable Size 289408844 bytes
Database Buffers 176160768 bytes
Redo Buffers 5971968 bytes
SYS@orcl>show parameter spfile

NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
spfile string /u01/app/oracle/product/11.2.0
/db_1/dbs/spfileorcl.ora
SYS@orcl>exit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
[oracle@fz-orcl autobak]$ rman target /

Recovery Manager: Release 11.2.0.3.0 - Production on Mon Nov 5 18:29:57 2018

Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.

connected to target database: ORCL (not mounted)

RMAN> restore controlfile from ‘/home/oracle/autobak/o1_mf_s_991416863_fy03o039_.bkp‘;

Starting restore at 05-NOV-18
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=19 device type=DISK

channel ORA_DISK_1: restoring control file
channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
output file name=/u01/app/oracle/oradata/orcl/control01.ctl
output file name=/u01/app/oracle/fast_recovery_area/orcl/control02.ctl
Finished restore at 05-NOV-18

RMAN> alter database mount;

database mounted
released channel: ORA_DISK_1

RMAN> catalog start with ‘/home/oracle/bak‘;

Starting implicit crosscheck backup at 05-NOV-18
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=19 device type=DISK
allocated channel: ORA_DISK_2
channel ORA_DISK_2: SID=20 device type=DISK
Crosschecked 6 objects
Finished implicit crosscheck backup at 05-NOV-18

Starting implicit crosscheck copy at 05-NOV-18
using channel ORA_DISK_1
using channel ORA_DISK_2
Crosschecked 2 objects
Finished implicit crosscheck copy at 05-NOV-18

searching for all files in the recovery area
cataloging files...
no files cataloged

searching for all files that match the pattern /home/oracle/bak

List of Files Unknown to the Database
=====================================
File Name: /home/oracle/bak/o1_mf_annnn_TAG20181105T173422_fy03nylc_.bkp
File Name: /home/oracle/bak/o1_mf_annnn_TAG20181105T173202_fy03jlmo_.bkp
File Name: /home/oracle/bak/o1_mf_nnndf_TAG20181105T173205_fy03jolp_.bkp
File Name: /home/oracle/bak/o1_mf_annnn_TAG20181105T173202_fy03jllk_.bkp
File Name: /home/oracle/bak/o1_mf_nnndf_TAG20181105T173205_fy03joyn_.bkp
File Name: /home/oracle/bak/o1_mf_s_991416863_fy03o039_.bkp
File Name: /home/oracle/bak/o1_mf_annnn_TAG20181105T173202_fy03jms6_.bkp

Do you really want to catalog the above files (enter YES or NO)? yes
cataloging files...
cataloging done

List of Cataloged Files
=======================
File Name: /home/oracle/bak/o1_mf_annnn_TAG20181105T173422_fy03nylc_.bkp
File Name: /home/oracle/bak/o1_mf_annnn_TAG20181105T173202_fy03jlmo_.bkp
File Name: /home/oracle/bak/o1_mf_nnndf_TAG20181105T173205_fy03jolp_.bkp
File Name: /home/oracle/bak/o1_mf_annnn_TAG20181105T173202_fy03jllk_.bkp
File Name: /home/oracle/bak/o1_mf_nnndf_TAG20181105T173205_fy03joyn_.bkp
File Name: /home/oracle/bak/o1_mf_s_991416863_fy03o039_.bkp
File Name: /home/oracle/bak/o1_mf_annnn_TAG20181105T173202_fy03jms6_.bkp
RMAN> restore database;

Starting restore at 05-NOV-18
using channel ORA_DISK_1
using channel ORA_DISK_2

channel ORA_DISK_1: starting datafile backup set restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_DISK_1: restoring datafile 00001 to /u01/app/oracle/oradata/orcl/system01.dbf
channel ORA_DISK_1: restoring datafile 00004 to /u01/app/oracle/oradata/orcl/users01.dbf
channel ORA_DISK_1: restoring datafile 00006 to /u01/app/oracle/oradata/orcl/rc_data.dbf
channel ORA_DISK_1: reading from backup piece /home/oracle/bak/o1_mf_nnndf_TAG20181105T173205_fy03joyn_.bkp
channel ORA_DISK_2: starting datafile backup set restore
channel ORA_DISK_2: specifying datafile(s) to restore from backup set
channel ORA_DISK_2: restoring datafile 00002 to /u01/app/oracle/oradata/orcl/sysaux01.dbf
channel ORA_DISK_2: restoring datafile 00003 to /u01/app/oracle/oradata/orcl/undotbs01.dbf
channel ORA_DISK_2: restoring datafile 00005 to /u01/app/oracle/oradata/orcl/example01.dbf
channel ORA_DISK_2: reading from backup piece /home/oracle/bak/o1_mf_nnndf_TAG20181105T173205_fy03jolp_.bkp
channel ORA_DISK_2: piece handle=/home/oracle/bak/o1_mf_nnndf_TAG20181105T173205_fy03jolp_.bkp tag=TAG20181105T173205
channel ORA_DISK_2: restored backup piece 1
channel ORA_DISK_2: restore complete, elapsed time: 00:01:57
channel ORA_DISK_1: piece handle=/home/oracle/bak/o1_mf_nnndf_TAG20181105T173205_fy03joyn_.bkp tag=TAG20181105T173205
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:02:27
Finished restore at 05-NOV-18
RMAN> alter database open resetlogs;

database opened

RMAN> exit

RMAN迁移数据库(不改变文件目录)

标签:创建目录   11.2   dump   sysdba   checked   1.2   down   dmi   init   

原文地址:https://www.cnblogs.com/orcl-2018/p/9914321.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!