根据rman的一个全备份进行异机恢复
一. Target 库准备工作:
备份db
run {
allocate channel ch1 device type disk maxpiecesize=10g;
sql 'alter system archive log current';
change archivelog all crosscheck;
backup full database tag=ora10gdbfullbk
format '/u01/backup/%d_db_%t_%s_%p'
plus archivelog format '/u01/backup/%d_arch_%t_%s_%p' delete all input;
backup current controlfile
format '/u01/backup/%d_ctlfile_%t_%s_%p';
release channel ch1;
}
查看备份文件
-bash-3.1$ ll /u01/backup
total 850468
-rw-r--r-- 1 root root 1277 Apr 20 21:53 initora10g.ora
-rw-r--r-- 1 root root 8484864 Apr 21 04:05 ORA10G_arch_749016313_41_1
-rw-r--r-- 1 root root 386560 Apr 21 04:11 ORA10G_arch_749016700_43_1
-rw-r--r-- 1 root root 7438336 Apr 21 04:11 ORA10G_ctlfile_749016703_44_1
-rw-r--r-- 1 root root 853688320 Apr 21 04:11 ORA10G_db_749016331_42_1
二. Auxiliary库准备工作:
1.创建口令文件
$ orapwd file=/u01/app/Oracle/product/10.2.0/db_1/dbs/orapwhy2 password=oracle
2.创建相关的目录
$ mkdir oradata
$ pwd
/u01/oradata
3.拷贝target库的pfile和备份的db到auxiliary库。
4、使用pfile将auxiliary库启动到nomount状态
SQL> startup nomount pfile=/u01/app/oracle/product/10.2.0/db_1/dbs/orapwhy2;
5、恢复控制文件
$ export ORACLE_SID=hy2
$ rman target /
RMAN>restore controlfile from '/u01/backup/ORA10G_ctlfile_749016703_44_1';
6、将db启动到mount状态
RMAN> alter database mount;
7、restore db
7.1恢复目录不同的情况:
RMAN>
run
{
set newname for datafile 1 to "/u01/oradata/system01.dbf";
set newname for datafile 2 to "/u01/oradata/sysaux01.dbf";
set newname for datafile 3 to "/u01/oradata/undotbs01.dbf";
set newname for datafile 4 to "/u01/oradata/users01.dbf";
restore database;
switch datafile all;
}
7.2恢复目录相同
RMAN>restore database;
8、recover db
RMAN> recover database;
$ export ORACLE_SID=ora10g
9、用open resetlogs?打开数据库
SQL> alter database open resetlogs;
10、mount数据库 用NID命令修改DBID和DBNAME
SQL> shutdown immediate
SQL> startup mount;
$nid target=sys/password dbname=hy2
SQL> alter system set db_name=hy2 scope=spfile;
SQL> shutdown immediate
SQL> startup
SQL> alter database open resetlogs;
验证:
SQL> select name,dbid from v$database;
NAME DBID
--------- ----------
HY2 2874673008