1 平台环境概述
利用rman的duplicate命令测试过很多功能,但都是从linux到linux的,跨平台还没有测试过,今天群上有人问起我就特意做了测试,记录如下。
注意:源平台与目标平台的字节顺序(endian format)需要相同。
源平台:RHEL6.5 系统(64位) + oracle 11.2.0.1.0
目标平台:Windows xp 系统(32bit) + oracle11.2.0.1.0
注意: 本章节采用rman备份+duplicate的形式来实现linux到windows平台的数据库复制
2 本次实验简介
本次实验就是基于备份,但是不连接到目标数据库,也不连接到恢复目录。
When you duplicate a database without a target database connection and without a recovery catalog, RMAN uses a BACKUP LOCATION where all necessary backups and copies reside.
The diagram illustrates backup-based duplication without connections to the target or to the recovery catalog database instance. A disk backup location containing all the backups or copies for duplication must be available to the destination host.
3 本次实验原理图
4 查看字节序
SELECT d.NAME, i.VERSION, d.PLATFORM_NAME, ENDIAN_FORMAT
FROM V$TRANSPORTABLE_PLATFORM tp, V$DATABASE d, V$INSTANCE i
WHERE tp.PLATFORM_NAME = d.PLATFORM_NAME
and d.DB_UNIQUE_NAME = i.INSTANCE_NAME;
(一)------ windows平台下查看,windows下之前安装过一个orcl的库
C:\Users\华荣>sqlplus lhr/lhr@orclxp
SQL*Plus: Release 11.2.0.1.0 Production on 星期六 11月 29 12:49:15 2014
Copyright (c) 1982, 2010, Oracle. All rights reserved.
连接到:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> set line 9999 pages 9999
SQL> SELECT d.NAME, i.VERSION, d.PLATFORM_NAME, ENDIAN_FORMAT
2 FROM V$TRANSPORTABLE_PLATFORM tp, V$DATABASE d, V$INSTANCE i
3 WHERE tp.PLATFORM_NAME = d.PLATFORM_NAME
4 and d.DB_UNIQUE_NAME = i.INSTANCE_NAME;
NAME VERSION PLATFORM_NAME ENDIAN_FORMAT
--------- ----------------- ----------------------------------------------------------------------------------------------------- --------------
ORCL 11.2.0.1.0 Microsoft Windows IA (32-bit) Little
SQL>
(二)---------- linux 平台下查看
C:\Users\华荣>sqlplus lhr/lhr@rman
SQL*Plus: Release 11.2.0.1.0 Production on 星期六 11月 29 12:52:49 2014
Copyright (c) 1982, 2010, Oracle. All rights reserved.
连接到:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> set line 9999 pages 9999
SQL> SELECT d.NAME, i.VERSION, d.PLATFORM_NAME, ENDIAN_FORMAT
2 FROM V$TRANSPORTABLE_PLATFORM tp, V$DATABASE d, V$INSTANCE i
3 WHERE tp.PLATFORM_NAME = d.PLATFORM_NAME
4 and d.DB_UNIQUE_NAME = i.INSTANCE_NAME;
NAME VERSION PLATFORM_NAME ENDIAN_FORMAT
--------- ----------------- ----------------------------------------------------------------------------------------------------- --------------
RMAN 11.2.0.1.0 Linux x86 64-bit Little
SQL>
结论: 可知windows 是32位系统,linux是64位系统,都是Little字节序。
5 source database 归档模式
[oracle@rhel6 dbs]$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.1.0 Production on Sat Nov 29 15:46:11 2014
Copyright (c) 1982, 2009, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> archive log list;
Database log mode Archive Mode
Automatic archival Enabled
Archive destination /u01/app/oracle/product/11.2.0/dbhome_1/dbs/arch
Oldest online log sequence 13
Next log sequence to archive 15
Current log sequence 15
SQL>
6 linux 下操作
6.1 建表
--登录源数据库并创建一个新的表
create table test_duplicate(id number,text varchar2(20));
insert into test_duplicate values(1,'a');
insert into test_duplicate values(2,'b');
commit;
[oracle@rhel6 dbs]$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.1.0 Production on Sat Nov 29 17:46:55 2014
Copyright (c) 1982, 2009, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> create table test_duplicate(id number,text varchar2(20));
Table created.
SQL> insert into test_duplicate values(1,'a');
1 row created.
SQL> insert into test_duplicate values(2,'b');
1 row created.
SQL> commit;
Commit complete.
SQL>
6.2 rman备份
显示参数信息,确认自动备份spfile 和 controlfile
[oracle@rhel6 dbs]$ rman target /
Recovery Manager: Release 11.2.0.1.0 - Production on Sat Nov 29 16:12:57 2014
Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.
connected to target database: RMAN (DBID=1738582916)
RMAN> show all;
using target database control file instead of recovery catalog
RMAN configuration parameters for database with db_unique_name RMAN are:
CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 7 DAYS;
CONFIGURE BACKUP OPTIMIZATION ON;
CONFIGURE DEFAULT DEVICE TYPE TO DISK; # default
CONFIGURE CONTROLFILE AUTOBACKUP ON;
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '/home/oracle/oracle_bk/rman/control_%F.bak';
CONFIGURE DEVICE TYPE DISK PARALLELISM 2 BACKUP TYPE TO COMPRESSED BACKUPSET;
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_rman.f'; # default
RMAN>
如果不是的话配置自动备份:CONFIGURE CONTROLFILE AUTOBACKUP ON;
[oracle@rhel6 backup]$ rman target /
Recovery Manager: Release 11.2.0.1.0 - Production on Sat Nov 29 17:46:20 2014
Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.
connected to target database: RMAN (DBID=1738582916)
RMAN> backup as compressed backupset format '/home/oracle/oracle_bk/rman/full_%n_%T_%t_%s.bak' database plus archivelog delete input;
Starting backup at 29-NOV-14
current log archived
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=771 device type=DISK
allocated channel: ORA_DISK_2
channel ORA_DISK_2: SID=22 device type=DISK
channel ORA_DISK_1: starting compressed archived log backup set
channel ORA_DISK_1: specifying archived log(s) in backup set
input archived log thread=1 sequence=15 RECID=1 STAMP=864922325
channel ORA_DISK_1: starting piece 1 at 29-NOV-14
channel ORA_DISK_2: starting compressed archived log backup set
channel ORA_DISK_2: specifying archived log(s) in backup set
input archived log thread=1 sequence=16 RECID=2 STAMP=864928262
channel ORA_DISK_2: starting piece 1 at 29-NOV-14
channel ORA_DISK_2: finished piece 1 at 29-NOV-14
piece handle=/home/oracle/oracle_bk/rman/full_RMANxxxx_20141129_864928263_14.bak tag=TAG20141129T175102 comment=NONE
channel ORA_DISK_2: backup set complete, elapsed time: 00:00:01
channel ORA_DISK_2: deleting archived log(s)
archived log file name=/u01/app/oracle/product/11.2.0/dbhome_1/dbs/arch1_16_852155780.dbf RECID=2 STAMP=864928262
channel ORA_DISK_1: finished piece 1 at 29-NOV-14
piece handle=/home/oracle/oracle_bk/rman/full_RMANxxxx_20141129_864928263_13.bak tag=TAG20141129T175102 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
channel ORA_DISK_1: deleting archived log(s)
archived log file name=/u01/app/oracle/product/11.2.0/dbhome_1/dbs/arch1_15_852155780.dbf RECID=1 STAMP=864922325
Finished backup at 29-NOV-14
Starting backup at 29-NOV-14
using channel ORA_DISK_1
using channel ORA_DISK_2
channel ORA_DISK_1: starting compressed full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00001 name=/u01/app/oracle/oradata/rman/system01.dbf
input datafile file number=00004 name=/u01/app/oracle/oradata/rman/users01.dbf
channel ORA_DISK_1: starting piece 1 at 29-NOV-14
channel ORA_DISK_2: starting compressed full datafile backup set
channel ORA_DISK_2: specifying datafile(s) in backup set
input datafile file number=00002 name=/u01/app/oracle/oradata/rman/sysaux01.dbf
input datafile file number=00005 name=/u01/app/oracle/oradata/rman/rman.dbf
input datafile file number=00003 name=/u01/app/oracle/oradata/rman/undotbs01.dbf
channel ORA_DISK_2: starting piece 1 at 29-NOV-14
channel ORA_DISK_2: finished piece 1 at 29-NOV-14
piece handle=/home/oracle/oracle_bk/rman/full_RMANxxxx_20141129_864928264_16.bak tag=TAG20141129T175104 comment=NONE
channel ORA_DISK_2: backup set complete, elapsed time: 00:00:45
channel ORA_DISK_1: finished piece 1 at 29-NOV-14
piece handle=/home/oracle/oracle_bk/rman/full_RMANxxxx_20141129_864928264_15.bak tag=TAG20141129T175104 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:55
Finished backup at 29-NOV-14
Starting backup at 29-NOV-14
current log archived
using channel ORA_DISK_1
using channel ORA_DISK_2
channel ORA_DISK_1: starting compressed archived log backup set
channel ORA_DISK_1: specifying archived log(s) in backup set
input archived log thread=1 sequence=17 RECID=3 STAMP=864928320
channel ORA_DISK_1: starting piece 1 at 29-NOV-14
channel ORA_DISK_1: finished piece 1 at 29-NOV-14
piece handle=/home/oracle/oracle_bk/rman/full_RMANxxxx_20141129_864928320_17.bak tag=TAG20141129T175200 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
channel ORA_DISK_1: deleting archived log(s)
archived log file name=/u01/app/oracle/product/11.2.0/dbhome_1/dbs/arch1_17_852155780.dbf RECID=3 STAMP=864928320
Finished backup at 29-NOV-14
Starting Control File and SPFILE Autobackup at 29-NOV-14
piece handle=/home/oracle/oracle_bk/rman/control_c-1738582916-20141129-01.bak comment=NONE
Finished Control File and SPFILE Autobackup at 29-NOV-14
RMAN> list backup;
List of Backup Sets
===================
BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
1 Full 76.19M DISK 00:00:47 28-JUL-14
BP Key: 1 Status: AVAILABLE Compressed: YES Tag: FULLDB_RMAN
Piece Name: /home/oracle/oracle_bk/rman/full_RMANxxxx_20140728_854128504_7_1.bak
Keep: NOLOGS Until: FOREVER
List of Datafiles in backup set 1
File LV Type Ckp SCN Ckp Time Name
---- -- ---- ---------- --------- ----
2 Full 1228637 28-JUL-14 /u01/app/oracle/oradata/rman/sysaux01.dbf
3 Full 1228637 28-JUL-14 /u01/app/oracle/oradata/rman/undotbs01.dbf
5 Full 1228637 28-JUL-14 /u01/app/oracle/oradata/rman/rman.dbf
BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
2 Full 179.63M DISK 00:01:06 28-JUL-14
BP Key: 2 Status: AVAILABLE Compressed: YES Tag: FULLDB_RMAN
Piece Name: /home/oracle/oracle_bk/rman/full_RMANxxxx_20140728_854128504_6_1.bak
Keep: NOLOGS Until: FOREVER
List of Datafiles in backup set 2
File LV Type Ckp SCN Ckp Time Name
---- -- ---- ---------- --------- ----
1 Full 1228637 28-JUL-14 /u01/app/oracle/oradata/rman/system01.dbf
4 Full 1228637 28-JUL-14 /u01/app/oracle/oradata/rman/users01.dbf
BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
3 Full 80.00K DISK 00:00:00 28-JUL-14
BP Key: 3 Status: AVAILABLE Compressed: YES Tag: FULLDB_RMAN
Piece Name: /home/oracle/oracle_bk/rman/full_RMANxxxx_20140728_854128581_8_1.bak
Keep: NOLOGS Until: FOREVER
SPFILE Included: Modification time: 28-JUL-14
SPFILE db_unique_name: RMAN
BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
4 Full 78.43M DISK 00:00:38 29-NOV-14
BP Key: 4 Status: AVAILABLE Compressed: YES Tag: FULL_BACKUP
Piece Name: /tmp/backup/back_864922690
List of Datafiles in backup set 4
File LV Type Ckp SCN Ckp Time Name
---- -- ---- ---------- --------- ----
2 Full 1281676 29-NOV-14 /u01/app/oracle/oradata/rman/sysaux01.dbf
3 Full 1281676 29-NOV-14 /u01/app/oracle/oradata/rman/undotbs01.dbf
5 Full 1281676 29-NOV-14 /u01/app/oracle/oradata/rman/rman.dbf
BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
5 Full 179.62M DISK 00:00:50 29-NOV-14
BP Key: 5 Status: AVAILABLE Compressed: YES Tag: FULL_BACKUP
Piece Name: /tmp/backup/back_864922689
List of Datafiles in backup set 5
File LV Type Ckp SCN Ckp Time Name
---- -- ---- ---------- --------- ----
1 Full 1281675 29-NOV-14 /u01/app/oracle/oradata/rman/system01.dbf
4 Full 1281675 29-NOV-14 /u01/app/oracle/oradata/rman/users01.dbf
BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
6 Full 9.36M DISK 00:00:01 29-NOV-14
BP Key: 6 Status: AVAILABLE Compressed: NO Tag: TAG20141129T161905
Piece Name: /home/oracle/oracle_bk/rman/control_c-1738582916-20141129-00.bak
SPFILE Included: Modification time: 29-NOV-14
SPFILE db_unique_name: RMAN
Control File Included: Ckp SCN: 1281701 Ckp time: 29-NOV-14
BS Key Size Device Type Elapsed Time Completion Time
------- ---------- ----------- ------------ ---------------
7 1.51M DISK 00:00:00 29-NOV-14
BP Key: 7 Status: AVAILABLE Compressed: YES Tag: TAG20141129T175102
Piece Name: /home/oracle/oracle_bk/rman/full_RMANxxxx_20141129_864928263_14.bak
List of Archived Logs in backup set 7
Thrd Seq Low SCN Low Time Next SCN Next Time
---- ------- ---------- --------- ---------- ---------
1 16 1281382 29-NOV-14 1285293 29-NOV-14
BS Key Size Device Type Elapsed Time Completion Time
------- ---------- ----------- ------------ ---------------
8 7.56M DISK 00:00:01 29-NOV-14
BP Key: 8 Status: AVAILABLE Compressed: YES Tag: TAG20141129T175102
Piece Name: /home/oracle/oracle_bk/rman/full_RMANxxxx_20141129_864928263_13.bak
List of Archived Logs in backup set 8
Thrd Seq Low SCN Low Time Next SCN Next Time
---- ------- ---------- --------- ---------- ---------
1 15 1255521 29-NOV-14 1281382 29-NOV-14
BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
9 Full 75.85M DISK 00:00:42 29-NOV-14
BP Key: 9 Status: AVAILABLE Compressed: YES Tag: TAG20141129T175104
Piece Name: /home/oracle/oracle_bk/rman/full_RMANxxxx_20141129_864928264_16.bak
List of Datafiles in backup set 9
File LV Type Ckp SCN Ckp Time Name
---- -- ---- ---------- --------- ----
2 Full 1285309 29-NOV-14 /u01/app/oracle/oradata/rman/sysaux01.dbf
3 Full 1285309 29-NOV-14 /u01/app/oracle/oradata/rman/undotbs01.dbf
5 Full 1285309 29-NOV-14 /u01/app/oracle/oradata/rman/rman.dbf
BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
10 Full 179.63M DISK 00:00:51 29-NOV-14
BP Key: 10 Status: AVAILABLE Compressed: YES Tag: TAG20141129T175104
Piece Name: /home/oracle/oracle_bk/rman/full_RMANxxxx_20141129_864928264_15.bak
List of Datafiles in backup set 10
File LV Type Ckp SCN Ckp Time Name
---- -- ---- ---------- --------- ----
1 Full 1285308 29-NOV-14 /u01/app/oracle/oradata/rman/system01.dbf
4 Full 1285308 29-NOV-14 /u01/app/oracle/oradata/rman/users01.dbf
BS Key Size Device Type Elapsed Time Completion Time
------- ---------- ----------- ------------ ---------------
11 3.00K DISK 00:00:00 29-NOV-14
BP Key: 11 Status: AVAILABLE Compressed: YES Tag: TAG20141129T175200
Piece Name: /home/oracle/oracle_bk/rman/full_RMANxxxx_20141129_864928320_17.bak
List of Archived Logs in backup set 11
Thrd Seq Low SCN Low Time Next SCN Next Time
---- ------- ---------- --------- ---------- ---------
1 17 1285293 29-NOV-14 1285333 29-NOV-14
BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
12 Full 9.36M DISK 00:00:00 29-NOV-14
BP Key: 12 Status: AVAILABLE Compressed: NO Tag: TAG20141129T175202
Piece Name: /home/oracle/oracle_bk/rman/control_c-1738582916-20141129-01.bak
SPFILE Included: Modification time: 29-NOV-14
SPFILE db_unique_name: RMAN
Control File Included: Ckp SCN: 1285344 Ckp time: 29-NOV-14
RMAN>
6.3 linux下生成pfile
------------------------------------------ linux 下操作
[oracle@rhel6 ~]$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.1.0 Production on Sat Nov 29 12:55:58 2014
Copyright (c) 1982, 2009, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> create pfile='/home/oracle/oracle_bk/rman/initrman.ora' from spfile;
File created.
(三)查看数据文件的路径:
SQL> select name from v$datafile;
NAME
--------------------------------------------------------------------------------
/u01/app/oracle/oradata/rman/system01.dbf
/u01/app/oracle/oradata/rman/sysaux01.dbf
/u01/app/oracle/oradata/rman/undotbs01.dbf
/u01/app/oracle/oradata/rman/users01.dbf
/u01/app/oracle/oradata/rman/rman.dbf
6.4 把linux上/home/oracle/oracle_bk/rman/下的所有备份文件复制到windows平台上
利用ftp工具把linux上/home/oracle/oracle_bk/rman/下的所有备份文件复制到windows平台上,如下图:
7 windows 下操作
7.1 创建一个rman的实例,注意SID要与linux服务器中的相同
使用命令为Windows 添加相同的服务,并启动它
------------------------------------------ windows 下操作
C:\Documents and Settings\Administrator>oradim -new -sid rman
实例已创建。
7.2 修改初始化参数文件,并创建相关目录
修改之前:
rman.__db_cache_size=192937984
rman.__java_pool_size=4194304
rman.__large_pool_size=4194304
rman.__oracle_base='/u01/app/oracle'#ORACLE_BASE set from environment
rman.__pga_aggregate_target=100663296
rman.__sga_target=423624704
rman.__shared_io_pool_size=0
rman.__shared_pool_size=209715200
rman.__streams_pool_size=0
*.audit_file_dest='/u01/app/oracle/admin/rman/adump'
*.audit_trail='db'
*.compatible='11.2.0.0.0'
*.control_files='/u01/app/oracle/oradata/rman/control01.ctl','/u01/app/oracle/oradata/rman/control02.ctl'
*.db_block_size=8192
*.db_domain='lhr.com'
*.db_name='rman'
*.diagnostic_dest='/u01/app/oracle'
*.dispatchers='(PROTOCOL=TCP) (SERVICE=rmanXDB)'
*.memory_target=500M
*.open_cursors=500
*.pga_aggregate_target=58720256
*.processes=1000
*.remote_login_passwordfile='EXCLUSIVE'
*.sessions=300
*.undo_tablespace='UNDOTBS1'
-----------修改之后
rman.__db_cache_size=192937984
rman.__java_pool_size=4194304
rman.__large_pool_size=4194304
rman.__oracle_base=F:\app\oracle #ORACLE_BASE set from environment
rman.__pga_aggregate_target=100663296
rman.__sga_target=423624704
rman.__shared_io_pool_size=0
rman.__shared_pool_size=209715200
rman.__streams_pool_size=0
*.audit_file_dest=F:\app\oracle\admin\rman\adump
*.audit_trail='db'
*.compatible='11.2.0.0.0'
*.control_files='F:\app\oracle\oradata\rman\control01.ctl','F:\app\oracle\oradata\rman\control02.ctl'
*.db_block_size=8192
*.db_domain='lhr.com'
*.db_name='rman'
*.diagnostic_dest=F:\app\oracle
*.dispatchers='(PROTOCOL=TCP) (SERVICE=rmanXDB)'
*.memory_target=500M
*.open_cursors=500
*.pga_aggregate_target=58720256
*.processes=1000
*.remote_login_passwordfile='EXCLUSIVE'
*.sessions=300
*.undo_tablespace='UNDOTBS1'
C:\Documents and Settings\Administrator>mkdir F:\app\oracle\admin\rman\adump
C:\Documents and Settings\Administrator>mkdir F:\app\oracle\oradata\rman
7.3 创建spfile并启动到nomount状态
C:\Documents and Settings\Administrator>set ORACLE_SID=rman
C:\Documents and Settings\Administrator>echo %ORACLE_SID%
rman
C:\Documents and Settings\Administrator>sqlplus / as sysdba
SQL*Plus: Release 11.2.0.1.0 Production on 星期六 11月 29 13:36:42 2014
Copyright (c) 1982, 2010, Oracle. All rights reserved.
已连接到空闲例程。
SQL> create spfile from pfile='E:\rman\initrman.ora';
文件已创建。
SQL> startup nomount;
ORACLE 例程已经启动。
Total System Global Area 523108352 bytes
Fixed Size 1375704 bytes
Variable Size 318767656 bytes
Database Buffers 197132288 bytes
Redo Buffers 5832704 bytes
SQL>
7.4 rman 进行数据文件的恢复
先准备run块,在source database上:
select 'set newname for datafile '||a.FILE#||' to "'||a.NAME||'";' from v$datafile a
union all
select 'set newname for tempfile '||a.FILE#||' to "'||a.NAME||'";' from v$tempfile a;
修改一下文件名,加入logfile,注意controlfile已经在pfile中指定了:
RUN{
set newname for datafile 1 to "F:\APP\ORACLE\ORADATA\RMAN\system01.dbf";
set newname for datafile 2 to "F:\APP\ORACLE\ORADATA\RMAN\sysaux01.dbf";
set newname for datafile 3 to "F:\APP\ORACLE\ORADATA\RMAN\undotbs01.dbf";
set newname for datafile 4 to "F:\APP\ORACLE\ORADATA\RMAN\users01.dbf";
set newname for datafile 5 to "F:\APP\ORACLE\ORADATA\RMAN\rman.dbf";
set newname for tempfile 1 to "F:\APP\ORACLE\ORADATA\RMAN\temp01.dbf";
duplicate target database to "rman" backup location 'e:\rman' nofilenamecheck
LOGFILE
'F:\APP\ORACLE\ORADATA\RMAN\redo01.log' SIZE 20M,
'F:\APP\ORACLE\ORADATA\RMAN\redo02.log' SIZE 20M,
'F:\APP\ORACLE\ORADATA\RMAN\redo03.log' SIZE 20M;
};
C:\Documents and Settings\Administrator>rman auxiliary /
Recovery Manager: Release 11.2.0.1.0 - Production on Sat Nov 29 18:54:51 2014
Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.
connected to auxiliary database: RMAN (not mounted)
RMAN> RUN{
2> set newname for datafile 1 to "F:\APP\ORACLE\ORADATA\RMAN\system01.dbf";
3> set newname for datafile 2 to "F:\APP\ORACLE\ORADATA\RMAN\sysaux01.dbf";
4> set newname for datafile 3 to "F:\APP\ORACLE\ORADATA\RMAN\undotbs01.dbf";
5> set newname for datafile 4 to "F:\APP\ORACLE\ORADATA\RMAN\users01.dbf";
6> set newname for datafile 5 to "F:\APP\ORACLE\ORADATA\RMAN\rman.dbf";
7> set newname for tempfile 1 to "F:\APP\ORACLE\ORADATA\RMAN\temp01.dbf";
8> duplicate target database to "rman" backup location 'e:\rman' nofilenamecheck
9> LOGFILE
10> 'F:\APP\ORACLE\ORADATA\RMAN\redo01.log' SIZE 20M,
11> 'F:\APP\ORACLE\ORADATA\RMAN\redo02.log' SIZE 20M,
12> 'F:\APP\ORACLE\ORADATA\RMAN\redo03.log' SIZE 20M;
13> };
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
Starting Duplicate Db at 29-NOV-14
contents of Memory Script:
{
sql clone "alter system set db_name =
''RMAN'' comment=
''Modified by RMAN duplicate'' scope=spfile";
sql clone "alter system set db_unique_name =
''RMAN'' comment=
''Modified by RMAN duplicate'' scope=spfile";
shutdown clone immediate;
startup clone force nomount
restore clone primary controlfile from 'E:\rman\control_c-1738582916-20141129-01.bak';
alter clone database mount;
}
executing Memory Script
sql statement: alter system set db_name = ''RMAN'' comment= ''Modified by RMAN duplicate'' scope=spfile
sql statement: alter system set db_unique_name = ''RMAN'' comment= ''Modified by RMAN duplicate'' scope=spfile
Oracle instance shut down
Oracle instance started
Total System Global Area 523108352 bytes
Fixed Size 1375704 bytes
Variable Size 318767656 bytes
Database Buffers 197132288 bytes
Redo Buffers 5832704 bytes
Starting restore at 29-NOV-14
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: SID=18 device type=DISK
channel ORA_AUX_DISK_1: restoring control file
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:01
output file name=F:\APP\ORACLE\ORADATA\RMAN\CONTROL01.CTL
output file name=F:\APP\ORACLE\ORADATA\RMAN\CONTROL02.CTL
Finished restore at 29-NOV-14
database mounted
released channel: ORA_AUX_DISK_1
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: SID=18 device type=DISK
contents of Memory Script:
{
set until scn 1285333;
set newname for datafile 1 to
"F:\APP\ORACLE\ORADATA\RMAN\system01.dbf";
set newname for datafile 2 to
"F:\APP\ORACLE\ORADATA\RMAN\sysaux01.dbf";
set newname for datafile 3 to
"F:\APP\ORACLE\ORADATA\RMAN\undotbs01.dbf";
set newname for datafile 4 to
"F:\APP\ORACLE\ORADATA\RMAN\users01.dbf";
set newname for datafile 5 to
"F:\APP\ORACLE\ORADATA\RMAN\rman.dbf";
restore
clone database
;
}
executing Memory Script
executing command: SET until clause
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
Starting restore at 29-NOV-14
using channel ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_AUX_DISK_1: restoring datafile 00001 to F:\APP\ORACLE\ORADATA\RMAN\system01.dbf
channel ORA_AUX_DISK_1: restoring datafile 00004 to F:\APP\ORACLE\ORADATA\RMAN\users01.dbf
channel ORA_AUX_DISK_1: reading from backup piece E:\RMAN\FULL_RMANXXXX_20141129_864928264_15.BAK
channel ORA_AUX_DISK_1: piece handle=E:\RMAN\FULL_RMANXXXX_20141129_864928264_15.BAK tag=TAG20141129T175104
channel ORA_AUX_DISK_1: restored backup piece 1
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:35
channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_AUX_DISK_1: restoring datafile 00002 to F:\APP\ORACLE\ORADATA\RMAN\sysaux01.dbf
channel ORA_AUX_DISK_1: restoring datafile 00003 to F:\APP\ORACLE\ORADATA\RMAN\undotbs01.dbf
channel ORA_AUX_DISK_1: restoring datafile 00005 to F:\APP\ORACLE\ORADATA\RMAN\rman.dbf
channel ORA_AUX_DISK_1: reading from backup piece E:\RMAN\FULL_RMANXXXX_20141129_864928264_16.BAK
channel ORA_AUX_DISK_1: piece handle=E:\RMAN\FULL_RMANXXXX_20141129_864928264_16.BAK tag=TAG20141129T175104
channel ORA_AUX_DISK_1: restored backup piece 1
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:35
Finished restore at 29-NOV-14
contents of Memory Script:
{
switch clone datafile all;
}
executing Memory Script
datafile 1 switched to datafile copy
input datafile copy RECID=6 STAMP=864932186 file name=F:\APP\ORACLE\ORADATA\RMAN\SYSTEM01.DBF
datafile 2 switched to datafile copy
input datafile copy RECID=7 STAMP=864932186 file name=F:\APP\ORACLE\ORADATA\RMAN\SYSAUX01.DBF
datafile 3 switched to datafile copy
input datafile copy RECID=8 STAMP=864932186 file name=F:\APP\ORACLE\ORADATA\RMAN\UNDOTBS01.DBF
datafile 4 switched to datafile copy
input datafile copy RECID=9 STAMP=864932187 file name=F:\APP\ORACLE\ORADATA\RMAN\USERS01.DBF
datafile 5 switched to datafile copy
input datafile copy RECID=10 STAMP=864932187 file name=F:\APP\ORACLE\ORADATA\RMAN\RMAN.DBF
contents of Memory Script:
{
set until scn 1285333;
recover
clone database
delete archivelog
;
}
executing Memory Script
executing command: SET until clause
Starting recover at 29-NOV-14
using channel ORA_AUX_DISK_1
starting media recovery
channel ORA_AUX_DISK_1: starting archived log restore to default destination
channel ORA_AUX_DISK_1: restoring archived log
archived log thread=1 sequence=17
channel ORA_AUX_DISK_1: reading from backup piece E:\RMAN\FULL_RMANXXXX_20141129_864928320_17.BAK
channel ORA_AUX_DISK_1: piece handle=E:\RMAN\FULL_RMANXXXX_20141129_864928320_17.BAK tag=TAG20141129T175200
channel ORA_AUX_DISK_1: restored backup piece 1
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:01
archived log file name=F:\APP\ORACLE\PRODUCT\RDBMS\ARC0000000017_0852155780.0001 thread=1 sequence=17
channel clone_default: deleting archived log(s)
archived log file name=F:\APP\ORACLE\PRODUCT\RDBMS\ARC0000000017_0852155780.0001 RECID=1 STAMP=864932188
media recovery complete, elapsed time: 00:00:00
Finished recover at 29-NOV-14
contents of Memory Script:
{
shutdown clone immediate;
startup clone nomount;
sql clone "alter system set db_name =
''RMAN'' comment=
''Reset to original value by RMAN'' scope=spfile";
sql clone "alter system reset db_unique_name scope=spfile";
shutdown clone immediate;
startup clone nomount;
}
executing Memory Script
database dismounted
Oracle instance shut down
connected to auxiliary database (not started)
Oracle instance started
Total System Global Area 523108352 bytes
Fixed Size 1375704 bytes
Variable Size 318767656 bytes
Database Buffers 197132288 bytes
Redo Buffers 5832704 bytes
sql statement: alter system set db_name = ''RMAN'' comment= ''Reset to original value by RMAN'' scope=spfile
sql statement: alter system reset db_unique_name scope=spfile
Oracle instance shut down
connected to auxiliary database (not started)
Oracle instance started
Total System Global Area 523108352 bytes
Fixed Size 1375704 bytes
Variable Size 318767656 bytes
Database Buffers 197132288 bytes
Redo Buffers 5832704 bytes
sql statement: CREATE CONTROLFILE REUSE SET DATABASE "RMAN" RESETLOGS ARCHIVELOG
MAXLOGFILES 16
MAXLOGMEMBERS 3
MAXDATAFILES 100
MAXINSTANCES 8
MAXLOGHISTORY 292
LOGFILE
GROUP 1 'F:\APP\ORACLE\ORADATA\RMAN\redo01.log' SIZE 20 M ,
GROUP 2 'F:\APP\ORACLE\ORADATA\RMAN\redo02.log' SIZE 20 M ,
GROUP 3 'F:\APP\ORACLE\ORADATA\RMAN\redo03.log' SIZE 20 M
DATAFILE
'F:\APP\ORACLE\ORADATA\RMAN\SYSTEM01.DBF'
CHARACTER SET ZHS16GBK
contents of Memory Script:
{
set newname for tempfile 1 to
"F:\APP\ORACLE\ORADATA\RMAN\temp01.dbf";
switch clone tempfile all;
catalog clone datafilecopy "F:\APP\ORACLE\ORADATA\RMAN\SYSAUX01.DBF",
"F:\APP\ORACLE\ORADATA\RMAN\UNDOTBS01.DBF",
"F:\APP\ORACLE\ORADATA\RMAN\USERS01.DBF",
"F:\APP\ORACLE\ORADATA\RMAN\RMAN.DBF";
switch clone datafile all;
}
executing Memory Script
executing command: SET NEWNAME
renamed tempfile 1 to F:\APP\ORACLE\ORADATA\RMAN\temp01.dbf in control file
cataloged datafile copy
datafile copy file name=F:\APP\ORACLE\ORADATA\RMAN\SYSAUX01.DBF RECID=1 STAMP=864932211
cataloged datafile copy
datafile copy file name=F:\APP\ORACLE\ORADATA\RMAN\UNDOTBS01.DBF RECID=2 STAMP=864932211
cataloged datafile copy
datafile copy file name=F:\APP\ORACLE\ORADATA\RMAN\USERS01.DBF RECID=3 STAMP=864932211
cataloged datafile copy
datafile copy file name=F:\APP\ORACLE\ORADATA\RMAN\RMAN.DBF RECID=4 STAMP=864932211
datafile 2 switched to datafile copy
input datafile copy RECID=1 STAMP=864932211 file name=F:\APP\ORACLE\ORADATA\RMAN\SYSAUX01.DBF
datafile 3 switched to datafile copy
input datafile copy RECID=2 STAMP=864932211 file name=F:\APP\ORACLE\ORADATA\RMAN\UNDOTBS01.DBF
datafile 4 switched to datafile copy
input datafile copy RECID=3 STAMP=864932211 file name=F:\APP\ORACLE\ORADATA\RMAN\USERS01.DBF
datafile 5 switched to datafile copy
input datafile copy RECID=4 STAMP=864932211 file name=F:\APP\ORACLE\ORADATA\RMAN\RMAN.DBF
contents of Memory Script:
{
Alter clone database open resetlogs;
}
executing Memory Script
database opened
RMAN-06900: WARNING: unable to generate V$RMAN_STATUS or V$RMAN_OUTPUT row
RMAN-06901: WARNING: disabling update of the V$RMAN_STATUS and V$RMAN_OUTPUT rows
ORACLE error from auxiliary database: ORA-00604: error occurred at recursive SQL level 1
ORA-06553: PLS-801: internal error [56327]
ORA-06553: PLS-801: internal error [56327]
Finished Duplicate Db at 29-NOV-14
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-12005: error during channel cleanup
ORA-00604: error occurred at recursive SQL level 1
ORA-06553: PLS-801: internal error [56327]
ORA-06544: PL/SQL: internal error, arguments: [56327], [], [], [], [], [], [], []
ORA-06553: PLS-801: internal error [56327]
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-00558: error encountered while parsing input commands
RMAN-01009: syntax error: found ";": expecting one of: "advise, allocate, alter, backup, @, catalog, change, configure,
connect, convert, copy, create, crosscheck, delete, drop, duplicate, exit, flashback, grant, host, import, list, mount,
open, print, quit, recover, register, release, repair, replace, report, reset, restore, resync, revoke, run, send, set,
show, shutdown, spool, sql, startup, switch, transport, unregister, upgrade, validate, {, "
RMAN-01007: at line 0 column 2 file: standard input
RMAN>
在rman恢复的最后步骤我们看到报错:RMAN-06900: WARNING: unable to generate V$RMAN_STATUS or V$RMAN_OUTPUT row,其实恢复是完成了的,正常的复制结束为如下标识,那么为啥报错呢?这里由于64位复制到32位系统引起的数据库对象失效,所以执行后边的编译工作即可。。
执行建表报错,但是查询不报错:
SQL> create table tt(id number);
create table tt(id number)
*
ERROR at line 1:
ORA-00604: error occurred at recursive SQL level 1
ORA-06553: PLS-801: internal error [56327]
ORA-00604: error occurred at recursive SQL level 1
ORA-06553: PLS-801: internal error [56327]
SQL> select * from test_duplicate;
ID TEXT
---------- ------------------------------------------------------------
1 a
2 b
7.5 由于是64位到32位操作系统,所以需要编译一下内核代码
错误原因:用64位系统上的备份片将数据库还原到32位系统中所产生,反过来也会产生此错误。
解决方案:运行脚本用32位系统重新编译一下内核参数即可
以下是详细描述:
$ sqlplus / as sysdba
SQL*Plus: Release 10.2.0.5.0 - Production on Fri Jul 30 11:21:16 2010
Copyright (c) 1982, 2010, Oracle. All Rights Reserved.
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
ERROR:
ORA-06553: PLS-801: internal error [56319]
SQL> conn xxx/xxx
Connected.
ERROR at line 1:
ORA-06553: PLS-801: internal error [56319]
解决方法如下:
SQL> shutdown immediate;
SQL> startup upgrade;
SQL> @?/rdbms/admin/utlirp.sql
SQL> @?/rdbms/admin/utlrp.sql
SQL> shutdown immediate;
SQL> startup;
其中:
utlirp.sql的作用是把相关内容全部在32bit平台下编译一遍.
utlrp.sql的作用是编译所有失效对象.
然后再重新连接,就不会报错了。
告警日志报错内容:
Error 604 in kwqmnpartition(), aborting txn
Sat Nov 29 14:00:09 2014
Errors in file f:\app\oracle\diag\rdbms\rman\rman\trace\rman_mmon_5476.trc:
ORA-06553: PLS-801: internal error [56327]
Errors in file f:\app\oracle\diag\rdbms\rman\rman\trace\rman_mmon_5476.trc:
ORA-06553: PLS-801: internal error [56327]
Errors in file f:\app\oracle\diag\rdbms\rman\rman\trace\rman_ora_5436.trc:
ORA-00604: 递归 SQL 级别 1 出现错误
ORA-06553: PLS-801: 内部错误 [56327]
Errors in file f:\app\oracle\diag\rdbms\rman\rman\trace\rman_ora_5436.trc:
ORA-00604: 递归 SQL 级别 1 出现错误
ORA-06553: PLS-801: 内部错误 [56327]
Completed: alter database open
Errors in file f:\app\oracle\diag\rdbms\rman\rman\trace\rman_mmon_5476.trc:
ORA-06553: PLS-801: internal error [56327]
Errors in file f:\app\oracle\diag\rdbms\rman\rman\trace\rman_mmon_5476.trc:
ORA-06553: PLS-801: internal error [56327]
Sat Nov 29 14:00:11 2014
Starting background process CJQ0
Sat Nov 29 14:00:11 2014
CJQ0 started with pid=21, OS id=3048
Errors in file f:\app\oracle\diag\rdbms\rman\rman\trace\rman_cjq0_3048.trc:
ORA-00604: error occurred at recursive SQL level 1
ORA-06544: PL/SQL: internal error, arguments: [56327], [], [], [], [], [], [], []
ORA-06553: PLS-801: internal error [56327]
Sat Nov 29 14:00:15 2014
Errors in file f:\app\oracle\diag\rdbms\rman\rman\trace\rman_j000_5048.trc:
ORA-12012: error on auto execute of job 57371
ORA-06553: PLS-801: internal error [56327]
Sat Nov 29 14:00:18 2014
Errors in file f:\app\oracle\diag\rdbms\rman\rman\trace\rman_q000_1940.trc:
ORA-06553: PLS-801: internal error [56327]
ORA-06553: PLS-801: internal error [56327]
Errors in file f:\app\oracle\diag\rdbms\rman\rman\trace\rman_cjq0_3048.trc:
ORA-00604: error occurred at recursive SQL level 1
ORA-06544: PL/SQL: internal error, arguments: [56327], [], [], [], [], [], [], []
ORA-06553: PLS-801: internal error [56327]
Sat Nov 29 14:00:25 2014
Errors in file f:\app\oracle\diag\rdbms\rman\rman\trace\rman_cjq0_3048.trc:
ORA-00604: error occurred at recursive SQL level 1
ORA-06544: PL/SQL: internal error, arguments: [56327], [], [], [], [], [], [], []
ORA-06553: PLS-801: internal error [56327]
Errors in file f:\app\oracle\diag\rdbms\rman\rman\trace\rman_cjq0_3048.trc:
ORA-00604: error occurred at recursive SQL level 1
ORA-06544: PL/SQL: internal error, arguments: [56327], [], [], [], [], [], [], []
ORA-06553: PLS-801: internal error [56327]
Sat Nov 29 14:00:35 2014
Errors in file f:\app\oracle\diag\rdbms\rman\rman\trace\rman_cjq0_3048.trc:
ORA-00604: error occurred at recursive SQL level 1
ORA-06544: PL/SQL: internal error, arguments: [56327], [], [], [], [], [], [], []
ORA-06553: PLS-801: internal error [56327]
Errors in file f:\app\oracle\diag\rdbms\rman\rman\trace\rman_cjq0_3048.trc:
ORA-00604: error occurred at recursive SQL level 1
ORA-06544: PL/SQL: internal error, arguments: [56327], [], [], [], [], [], [], []
ORA-06553: PLS-801: internal error [56327]
Sat Nov 29 14:00:45 2014
Errors in file f:\app\oracle\diag\rdbms\rman\rman\trace\rman_cjq0_3048.trc:
ORA-00604: error occurred at recursive SQL level 1
ORA-06544: PL/SQL: internal error, arguments: [56327], [], [], [], [], [], [], []
ORA-06553: PLS-801: internal error [56327]
Errors in file f:\app\oracle\diag\rdbms\rman\rman\trace\rman_cjq0_3048.trc:
ORA-00604: error occurred at recursive SQL level 1
ORA-06544: PL/SQL: internal error, arguments: [56327], [], [], [], [], [], [], []
ORA-06553: PLS-801: internal error [56327]
Sat Nov 29 14:00:55 2014
Errors in file f:\app\oracle\diag\rdbms\rman\rman\trace\rman_cjq0_3048.trc:
ORA-00604: error occurred at recursive SQL level 1
ORA-06544: PL/SQL: internal error, arguments: [56327], [], [], [], [], [], [], []
ORA-06553: PLS-801: internal error [56327]
7.6 其它配置工作
重配一下listener及tnsnames,重建密码文件等等其它工作,你懂的。。。。
7.7 测试OK
原linux上rman库:
SQL> select dbid,name,current_scn,database_role,force_logging,open_mode from v$database;
DBID NAME CURRENT_SCN DATABASE_ROLE FOR OPEN_MODE
---------- --------- ----------- ---------------- --- --------------------
1738582916 RMAN 1288502 PRIMARY NO READ WRITE
windows上的rman库:
SQL> select dbid,name,current_scn,database_role,force_logging,open_mode from v$database;
DBID NAME CURRENT_SCN DATABASE_ROLE FOR OPEN_MODE
---------- --------- ----------- ---------------- --- --------------------
1738582916 RMAN 1311898 PRIMARY NO READ WRITE
注意:我原来是在没有编译内核代码的时候测试建表语句的时候内部错误,从告警日志也可以看出是内部错误,最后重新编译了内核后建表就没有问题了
SQL> select * from test_duplicate;
ID TEXT
---------- ------------------------------------------------------------
1 a
2 b
SQL> create table t as select * from dual;
表已创建。
SQL> insert into t select * from dual;
已创建 1 行。
SQL> commit;
提交完成。
SQL> delete from t;
已删除2行。
SQL> commit;
提交完成。
SQL> drop table t;
表已删除。
SQL>
7.8 删除数据库做其它测试
SQL> shutdown abort
ORACLE 例程已经关闭。
SQL> startup mount restrict;
ORACLE 例程已经启动。
Total System Global Area 221790208 bytes
Fixed Size 1373684 bytes
Variable Size 138414604 bytes
Database Buffers 79691776 bytes
Redo Buffers 2310144 bytes
数据库装载完毕。
SQL> drop database;
数据库已删除。
从 Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options 断开
SQL>