同事进行年末的异机还原测试,到快还原完成才发现空间不足.原来,原数据库服务器的硬盘分区是/u02,/u03,/u09各200G,
而还原测试是把rman的备份複製到另一台服务器上做的,这个服务器的硬盘分区是/u02,/u03,/u09,/u10各120G,而且
实际数据库在/u02,/u03所占都空间都有130多G了,超过了目标数据库的/u02,/u03的120G.同事准备对硬盘重新进行分
区再做还原.但我想到rman可以通过set newname把文件还原到其他地方.
具体实施如下(oracle 10.2.0.4):
[oracle@srhel10g02 dbs]$ ORACLE_SID=rh10g02
[oracle@srhel10g02 dbs]$ rman target /
RMAN> startup nomount;
RMAN> restore spfile from '/u09/rman/rh10g03/control/c-3997128934-20141127-01';
RMAN> shutdown immediate;
RMAN> startup nomount; --注意nomount之前,一定要记得把spfile中指定的各dump等的目录先建好
RMAN> restore controlfile from '/u09/rman/rh10g03/control/c-3997128934-20141127-01';
RMAN> sql 'alter database mount';
RMAN>quit
[oracle@srhel10g02 dbs]$ sqlplus / as sysdba
SQL> select name from v$datafile; --查看控制文件中记录的文件信息,用来建对应目录
/*产生要需要set newname的文件脚本,等一下rman用到,这里是把超过100g后的文件都移/u10,因为公司规范单文件最大为4G,所以用100/4
取大概会超过100g之后文件,当然具体也可以根据自己的情况*/
SQL>select rman_set from
(select 'set newname for datafile '||rfile#||' to '''||replace(name,substr(name,1,4),'/u10')||''';' rman_set,
row_number() over (partition by substr(name,1,4) order by rfile# ) rn
from v$datafile) where rn>100/4;
SQL>quit
[oracle@srhel10g02 dbs]$ rman target /
RMAN>crosscheck backup;
RMAN>delete expired backup;
RMAN>catalog start with '/u09 /rman/rh10g03';
RMAN>run
{
allocate channel d1 type disk maxpiecesize 4000m;
allocate channel d2 type disk maxpiecesize 4000m;
allocate channel d3 type disk maxpiecesize 4000m;
allocate channel d4 type disk maxpiecesize 4000m;
set newname for datafile 29 to '/u10/oradata/rh10g02/user001.dbf'; --这里的set newname是取处上面sqlplus里产生的结果
restore database;
switch datafile all; --这步一定要有,不然控制文件中的文件位置信息不会改过来
recover database;
release channel d4;
release channel d3;
release channel d2;
release channel d1;
}
RMAN>alter database open resetlogs;
而还原测试是把rman的备份複製到另一台服务器上做的,这个服务器的硬盘分区是/u02,/u03,/u09,/u10各120G,而且
实际数据库在/u02,/u03所占都空间都有130多G了,超过了目标数据库的/u02,/u03的120G.同事准备对硬盘重新进行分
区再做还原.但我想到rman可以通过set newname把文件还原到其他地方.
具体实施如下(oracle 10.2.0.4):
[oracle@srhel10g02 dbs]$ ORACLE_SID=rh10g02
[oracle@srhel10g02 dbs]$ rman target /
RMAN> startup nomount;
RMAN> restore spfile from '/u09/rman/rh10g03/control/c-3997128934-20141127-01';
RMAN> shutdown immediate;
RMAN> startup nomount; --注意nomount之前,一定要记得把spfile中指定的各dump等的目录先建好
RMAN> restore controlfile from '/u09/rman/rh10g03/control/c-3997128934-20141127-01';
RMAN> sql 'alter database mount';
RMAN>quit
[oracle@srhel10g02 dbs]$ sqlplus / as sysdba
SQL> select name from v$datafile; --查看控制文件中记录的文件信息,用来建对应目录
/*产生要需要set newname的文件脚本,等一下rman用到,这里是把超过100g后的文件都移/u10,因为公司规范单文件最大为4G,所以用100/4
取大概会超过100g之后文件,当然具体也可以根据自己的情况*/
SQL>select rman_set from
(select 'set newname for datafile '||rfile#||' to '''||replace(name,substr(name,1,4),'/u10')||''';' rman_set,
row_number() over (partition by substr(name,1,4) order by rfile# ) rn
from v$datafile) where rn>100/4;
SQL>quit
[oracle@srhel10g02 dbs]$ rman target /
RMAN>crosscheck backup;
RMAN>delete expired backup;
RMAN>catalog start with '/u09 /rman/rh10g03';
RMAN>run
{
allocate channel d1 type disk maxpiecesize 4000m;
allocate channel d2 type disk maxpiecesize 4000m;
allocate channel d3 type disk maxpiecesize 4000m;
allocate channel d4 type disk maxpiecesize 4000m;
set newname for datafile 29 to '/u10/oradata/rh10g02/user001.dbf'; --这里的set newname是取处上面sqlplus里产生的结果
restore database;
switch datafile all; --这步一定要有,不然控制文件中的文件位置信息不会改过来
recover database;
release channel d4;
release channel d3;
release channel d2;
release channel d1;
}
RMAN>alter database open resetlogs;
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/28539951/viewspace-1364840/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/28539951/viewspace-1364840/