说明:适用于从win 64位下的Oracle11G使用rman备份,恢复到Linux 64位下的Oracle11G
使用rman备份win下的Oracle数据库
1、在SQL plus下执行,单实例用这个登录(sqlplus / as sysdba);如果不是单实例,就用这个登录(sqlplus admin/xxx@interlib as sysdba)。
create pfile=‘D:\bak\init20191203backup.ora‘ from memory;
shutdown immediate;
startup mount;
2、在rman下执行,单实例用这个登录(rman target admin/xxx@interlib);如果不是单实例,就用这个登录(rman target admin/xxx@interlib)。
configure controlfile autobackup on;
run {
allocate channel c1 type disk;
allocate channel c2 type disk;
backup as compressed backupset database format ‘D:\bak\full_%T_%u‘;
backup spfile format ‘D:\bak\spfile_%u_%T.bak‘;
backup current controlfile format ‘D:\bak\ctl_%u_%T.bak‘;
release channel c1;
release channel c2;
}
复制ctl.bak和full_%U文件到Linux下
在Linux下的恢复步骤:
1、SQLPLUS启动Linux数据库到unmount模式
startup nomount;
##########以下2-8是在rman target / 下执行的##########
2、设置dbid
set dbid=31111111110;
3、恢复控制文件
restore controlfile from ‘/home/oracle/interlib/CTL.BAK‘;
4、挂载数据库到mount模式
sql ‘alter database mount‘;
5、导入备份集信息到控制文件
catalog start with "/home/oracle/interlib/";
6、运行下面代码块修改数据文件路径为本地路径
run{
set newname for datafile 1 to ‘/home/oracle/interlib/db/SYSTEM01.DBF‘;
set newname for datafile 2 to ‘/home/oracle/interlib/db/SYSAUX01.DBF‘;
set newname for datafile 3 to ‘/home/oracle/interlib/db/UNDOTBS01.DBF‘;
set newname for datafile 4 to ‘/home/oracle/interlib/db/USERS01.DBF‘;
set newname for datafile 5 to ‘/home/oracle/interlib/db/INTERLIB.DBF‘;
restore database;
switch datafile all;
}
7、恢复数据库
recover database;
8、resetlogs打开数据库
sql ‘alter database open resetlogs‘;
##################################################
9、进SQLPLUS重建临时表空间
create temporary tablespace temp01 tempfile ‘/home/oracle/interlib/db/TEMP01.DBF‘ size 1024M autoextend on;
alter database default temporary tablespace temp01;
drop tablespace temp including contents and datafiles;