第一步:
最初,建立一张表student
conn member/member
create table student_arch(
id int,
name varchar2(20)
);
insert into student_arch values(1,'name1');
insert into student_arch values(2,'name2');
insert into student_arch values(3,'name3');
然后关闭数据库
shutdown immediate
进行冷备份
tar -zcvf /data/backup/backup_20130620.tar.gz /data/ora11g/
第二步:开启数据库
startup
再插入3条数据
conn member/member
insert into student_arch values(1,'name1');
insert into student_arch values(2,'name2');
insert into student_arch values(3,'name3');
强制归档
alter system switch logfile
然后进行rman的控制文件备份。
run
{
allocate channel c1 device type disk format '/data/backup/rman/con-%U-%T.full';
BACKUP CURRENT CONTROLFILE;
release channel c1;
}
复制当前的controlfile和最近的归档
scp /data/backup/rman/con-7iocl54f_1_1-20130620.full root@172.31.0.139:/root/
开始场景恢复:
startup nomount;
set dbid=1552557445
restore controlfile from '/data/backup/rman/con-7iocl54f_1_1-20130620.full';
RMAN> alter database mount;
RMAN> restore database;(这个由于是冷备,所以不用restore,因为数据是一致性的)
SQL>recover database using backup controlfile until cancel;