rman 的高级恢复主题
使用resetlogs,在不完全恢复期间,通常需要使用resetlogs命令打开数据库,这是因为我们要从已经建立的现有重做流中脱离出来。并且向oracle说明这个情况。
resetlogs 命令表示一个数据库逻辑生存期的结束和另一个数据库逻辑生存期的开始。数据库的逻辑生存期间也称为一个对应物。
创建恢复点
基于时间的恢复
tartup mount;
restore database until time "to_date('06/28/06 13:00:00','MM/DD/YYYY HH24:MI:SS')";
recover database until time "to_date('06/28/06 13:00:00','MM/DD/YYYY HH24:MI:SS')";
alter database open resetlogs;
基于scn的恢复
startup mount;
restore database until scn 10000;
recover database until scn 10000;
alter database open resetlogs;
基于日志序列的恢复
startup mount;
restore database until sequence 100 thread 1;
recover database until sequence 100 thread 1;
alter database open resetlogs;
基于删除的恢复
使用还原点恢复
startup mount;
restore database until restore point tango_one;
recover database until restore point tango_one;
alter database open resetlogs;
只读表空间的恢复
restore database check readonly;(默认情况下,丢失了只读数据文件,执行完全数据库还原也不会还原只读数据文件,必须在命令中使用check readonly才可以还原只读数据文件)
归档重做日志还原
restore archivelog all;
restore archivelog from logseq=20 thread=1;
restore archivelog from logseq=20 until logseq=30 thread=1;
数据文件副本还原(从数据库副本而不是备份集中还原数据库数据文件)
restore (datafile 5) from datafilecopy;这条命令会识别需要还原的数据文件的最新副本,然后从这个副本中还原这些数据文件,数据文件的最新副本可能在一个数据文件副本中,而不是在备份集中。
recover datafile 5;
sql "alter database datafile 5 online";
恢复损坏的数据块
blockrecover datafile 10 block 44,55,99
恢复前一个对应物
I使用恢复目录恢复前一个对应物
startup forces nomount
reset database to incarnation 2;
restore controlfile;
restore database until scn 7623545;
recover database until scn 7623545;
alter database open resetlogs;
II不使用恢复目录恢复前一个对应物
shutdown immediate;
startup mount
reset database to incarnation 2;
restore database until scn 7623545;
recover database until scn 7623545;
alter database open resetlogs;
表空间时间点恢复
确保还原的时间点
确保对象完全包含在希望还原的表空间中
确保可能丢失的对象或数据
验证备份可恢复
restore database preview;
restore database validate;
跨平台的数据库移动和rman
尾数格式与字节排序有关,它有两种不同的格式,大尾数和小尾数。要在不同尾数字节格式的平台之间移动数据,则需要手动操作,并且使用rman的convert datafile或convert tablespace命令将传送的数据文件转换为正确的尾数格式。
只有在设置为可读写或联机时,只读文件和脱机数据文件才可支持跨平台操作。
如果字节排序方案不同,则需要在rman中使用convert命令将表空间转换为目标平台所需的格式。
select endian_format from v$transportable_platform tp ,v$database d where tp.platform_name=d.platform_name;
select platform_name from v$transportable_platform;
使用rman转换表空间尾数格式
将表空间设置为只读模式,启动rman并使用新的convert tablespace命令
rman> convert tablespace users to platform='AIX-Based Systems (64-bit)'
db_file_name_convert='c:\oracle\oradata\betatwo','c:\oracle\admin\transport_aix'
也可以转换目标站点上的数据文件
rman> convert datafile ='c:\oracle\oradata\betatwo\*' platform='AIX-Based Systems (64-bit)'
db_file_name_convert='c:\oracle\oradata\betatwo','c:\oracle\admin\transport_aix'
跨平台移动数据:;
(1) startup mount;
alter database open read only;
(2)使用dbms_tdb.check_db进程来检查数据库状态
set serveroutput on
declare
db_ready boolean;
begin
db_ready:=dbms_tdb.check_db
('Microsoft Windows IA (32-bit)',dbms_tdb.skip_Readonly);
end;
/
(3)使用dbms_tdb.check_external进程来标识外部对象
set serveroutput on
declare
extrnal boolean
begin
external:=dbms_tdb.check_external;
end;
/
(4)当数据库可以传送时,就可以使用rman的convert database命令。rman创建数据库移动所需的脚本,但不真正移动操作。而是创建移动所需的文件。
convert database new database 'copydb' transport script 'c:\oracle\copydb\copysripts' to platform 'Microsoft Windows IA (32-bit)'
可选参数db_file_name_convert 允许用户为需要转换的数据文件定义目录文件名。
convert database new database 'copydb' transport script 'c:\oracle\copydb\copysripts' to platform 'Microsoft Windows IA (32-bit)'
db_file_name_convert 'c:\oracle\product\10.2.0\oradata\rob10r2','c:\oracle\newdbdest'
使用resetlogs,在不完全恢复期间,通常需要使用resetlogs命令打开数据库,这是因为我们要从已经建立的现有重做流中脱离出来。并且向oracle说明这个情况。
resetlogs 命令表示一个数据库逻辑生存期的结束和另一个数据库逻辑生存期的开始。数据库的逻辑生存期间也称为一个对应物。
创建恢复点
基于时间的恢复
tartup mount;
restore database until time "to_date('06/28/06 13:00:00','MM/DD/YYYY HH24:MI:SS')";
recover database until time "to_date('06/28/06 13:00:00','MM/DD/YYYY HH24:MI:SS')";
alter database open resetlogs;
基于scn的恢复
startup mount;
restore database until scn 10000;
recover database until scn 10000;
alter database open resetlogs;
基于日志序列的恢复
startup mount;
restore database until sequence 100 thread 1;
recover database until sequence 100 thread 1;
alter database open resetlogs;
基于删除的恢复
使用还原点恢复
startup mount;
restore database until restore point tango_one;
recover database until restore point tango_one;
alter database open resetlogs;
只读表空间的恢复
restore database check readonly;(默认情况下,丢失了只读数据文件,执行完全数据库还原也不会还原只读数据文件,必须在命令中使用check readonly才可以还原只读数据文件)
归档重做日志还原
restore archivelog all;
restore archivelog from logseq=20 thread=1;
restore archivelog from logseq=20 until logseq=30 thread=1;
数据文件副本还原(从数据库副本而不是备份集中还原数据库数据文件)
restore (datafile 5) from datafilecopy;这条命令会识别需要还原的数据文件的最新副本,然后从这个副本中还原这些数据文件,数据文件的最新副本可能在一个数据文件副本中,而不是在备份集中。
recover datafile 5;
sql "alter database datafile 5 online";
恢复损坏的数据块
blockrecover datafile 10 block 44,55,99
恢复前一个对应物
I使用恢复目录恢复前一个对应物
startup forces nomount
reset database to incarnation 2;
restore controlfile;
restore database until scn 7623545;
recover database until scn 7623545;
alter database open resetlogs;
II不使用恢复目录恢复前一个对应物
shutdown immediate;
startup mount
reset database to incarnation 2;
restore database until scn 7623545;
recover database until scn 7623545;
alter database open resetlogs;
表空间时间点恢复
确保还原的时间点
确保对象完全包含在希望还原的表空间中
确保可能丢失的对象或数据
验证备份可恢复
restore database preview;
restore database validate;
跨平台的数据库移动和rman
尾数格式与字节排序有关,它有两种不同的格式,大尾数和小尾数。要在不同尾数字节格式的平台之间移动数据,则需要手动操作,并且使用rman的convert datafile或convert tablespace命令将传送的数据文件转换为正确的尾数格式。
只有在设置为可读写或联机时,只读文件和脱机数据文件才可支持跨平台操作。
如果字节排序方案不同,则需要在rman中使用convert命令将表空间转换为目标平台所需的格式。
select endian_format from v$transportable_platform tp ,v$database d where tp.platform_name=d.platform_name;
select platform_name from v$transportable_platform;
使用rman转换表空间尾数格式
将表空间设置为只读模式,启动rman并使用新的convert tablespace命令
rman> convert tablespace users to platform='AIX-Based Systems (64-bit)'
db_file_name_convert='c:\oracle\oradata\betatwo','c:\oracle\admin\transport_aix'
也可以转换目标站点上的数据文件
rman> convert datafile ='c:\oracle\oradata\betatwo\*' platform='AIX-Based Systems (64-bit)'
db_file_name_convert='c:\oracle\oradata\betatwo','c:\oracle\admin\transport_aix'
跨平台移动数据:;
(1) startup mount;
alter database open read only;
(2)使用dbms_tdb.check_db进程来检查数据库状态
set serveroutput on
declare
db_ready boolean;
begin
db_ready:=dbms_tdb.check_db
('Microsoft Windows IA (32-bit)',dbms_tdb.skip_Readonly);
end;
/
(3)使用dbms_tdb.check_external进程来标识外部对象
set serveroutput on
declare
extrnal boolean
begin
external:=dbms_tdb.check_external;
end;
/
(4)当数据库可以传送时,就可以使用rman的convert database命令。rman创建数据库移动所需的脚本,但不真正移动操作。而是创建移动所需的文件。
convert database new database 'copydb' transport script 'c:\oracle\copydb\copysripts' to platform 'Microsoft Windows IA (32-bit)'
可选参数db_file_name_convert 允许用户为需要转换的数据文件定义目录文件名。
convert database new database 'copydb' transport script 'c:\oracle\copydb\copysripts' to platform 'Microsoft Windows IA (32-bit)'
db_file_name_convert 'c:\oracle\product\10.2.0\oradata\rob10r2','c:\oracle\newdbdest'