恢复镜像拷贝
2015年5月2日
17:11
把增量备份应用到竞相拷贝上面,让镜像拷贝前进
增量备份减少了recovery的时间
第一天创建一个镜像拷贝,第二天创建一个l1增量备份
第三天镜像拷贝也有了,增量备份也有了,把增量备份应用到靠背上
同时第三天产生了一个新的增量拷贝
实现快速恢复,快速切换到镜像拷贝
没有restore 动作
假设删除datafile 4
RMAN> report schema;
using target database control file instead of recovery catalog
Report of database schema for database with db_unique_name YISIDB2
List of Permanent Datafiles
===========================
File Size(MB) Tablespace RB segs Datafile Name
---- -------- -------------------- ------- ------------------------
1 720 SYSTEM *** /u01/app/oracle/oradata/yisidb2/system01.dbf
2 580 SYSAUX *** /u01/app/oracle/oradata/yisidb2/sysaux01.dbf
3 115 UNDOTBS1 *** /u01/app/oracle/oradata/yisidb2/undotbs01.dbf
4 5 USERS *** /u01/app/oracle/oradata/yisidb2/users01.dbf
5 345 EXAMPLE *** /u01/app/oracle/oradata/yisidb2/example01.dbf
[oracle@host2.yisi.net: /u01/app/oracle/oradata/yisidb2]$ mv users01.dbf users01.dbf.bak4
SYS@ yisidb2>startup;
ORACLE instance started.
Total System Global Area 795127808 bytes
Fixed Size 1347876 bytes
Variable Size 490737372 bytes
Database Buffers 297795584 bytes
Redo Buffers 5246976 bytes
Database mounted.
ORA-01157: cannot identify/lock data file 4 - see DBWR trace file
ORA-01110: data file 4: '/u01/app/oracle/oradata/yisidb2/users01.dbf'
启动到mount状态
SYS@ yisidb2>shutdown immediate;
SYS@ yisidb2>startup mount;
开始快速替换
RMAN> run {
2> sql 'alter database datafile 4 offline';
3> switch datafile 4 to datafilecopy '/u01/backup1/data_D-YISIDB2_I-409751439_TS-USERS_FNO-4_0oq5tcgs';
4> recover datafile 4;
5> sql 'alter database datafile 4 online';
6> }
Database mounted.
替换成功可以开库
SYS@ yisidb2>alter database open;
Database altered.
SYS@ yisidb2>select * from scott.emp;
EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
---------- ---------- --------- ---------- --------- ---------- ---------- ----------
7369 SMITH CLERK 7902 17-DEC-80 800 20
7499 ALLEN SALESMAN 7698 20-FEB-81 1600 300 30
7521 WARD SALESMAN 7698 22-FEB-81 1250 500 30
……..
14 rows selected.
已经切换到备份
SYS@ yisidb2>select tablespace_name,file_name from dba_data_files;
TABLESPACE_NAME FILE_NAME
------------------------------ ----------------------------------------------------------------------
USERS /u01/backup1/data_D-YISIDB2_I-409751439_TS-USERS_FNO-4_0oq5tcgs
UNDOTBS1 /u01/app/oracle/oradata/yisidb2/undotbs01.dbf
SYSAUX /u01/app/oracle/oradata/yisidb2/sysaux01.dbf
SYSTEM /u01/app/oracle/oradata/yisidb2/system01.dbf
EXAMPLE /u01/app/oracle/oradata/yisidb2/example01.dbf
数据文件恢复,切换到原来的文件,先进行备份
RMAN> backup as copy device type disk datafile 4 format '/u01/app/oracle/oradata/yisidb2/users01.dbf';
RMAN> run{
2> sql 'alter database datafile 4 offline';
3> switch datafile 4 to datafilecopy '/u01/app/oracle/oradata/yisidb2/users01.dbf';
4> recover datafile 4;
5> sql 'alter database datafile 4 online';
6> }
SYS@ yisidb2>select tablespace_name,file_name from dba_data_files;
TABLESPACE_NAME FILE_NAME
------------------------------ ----------------------------------------------------------------------
USERS /u01/app/oracle/oradata/yisidb2/users01.dbf
UNDOTBS1 /u01/app/oracle/oradata/yisidb2/undotbs01.dbf
SYSAUX /u01/app/oracle/oradata/yisidb2/sysaux01.dbf
SYSTEM /u01/app/oracle/oradata/yisidb2/system01.dbf
EXAMPLE /u01/app/oracle/oradata/yisidb2/example01.dbf
Set newname for datafile 磁盘坏了,恢复到别的地方
非归档模式
一致性开库
---------------------------冷备份
SYS@ yisidb2>shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SYS@ yisidb2>startup mount;
ORACLE instance started.
Total System Global Area 795127808 bytes
Fixed Size 1347876 bytes
Variable Size 494931676 bytes
Database Buffers 293601280 bytes
Redo Buffers 5246976 bytes
Database mounted.
SYS@ yisidb2>alter database noarchivelog;
Database altered.
进行冷备份
RMAN> run {
2> shutdown immediate;
3> startup mount;
4> backup database;
5> sql 'alter database open';
6> }
进行恢复
RMAN> run{
2> shutdown abort;
3> startup mount;
4> restore database;
5> sql 'alter database open';
6> }
里面还是有一些,所以不能正常开库
RMAN> recover database;
Starting recover at 02-MAY-15
using channel ORA_DISK_1
starting media recovery
archived log for thread 1 with sequence 1 is already on disk as file /u01/app/oracle/oradata/yisidb2/redo01.log
archived log for thread 1 with sequence 2 is already on disk as file /u01/app/oracle/oradata/yisidb2/redo02.log
RMAN-08187: WARNING: media recovery until SCN 1100023 complete
Finished recover at 02-MAY-15
RMAN> sql 'alter database open';
sql statement: alter database open
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03009: failure of sql command on default channel at 05/02/2015 06:38:49
RMAN-11003: failure during parse/execution of SQL statement: alter database open
ORA-01589: must use RESETLOGS or NORESETLOGS option for database open
RMAN> sql 'alter database open resetlogs';
sql statement: alter database open resetlogs
控制文件
只要恢复了控制文件,就要执行recover,(recover是redo信息重做)----resetlogs选项开库
SYS@ yisidb2>create pfile from memory;
设置控制文件自动恢复
RMAN> configure controlfile autobackup on;
using target database control file instead of recovery catalog
old RMAN configuration parameters:
CONFIGURE CONTROLFILE AUTOBACKUP ON;
new RMAN configuration parameters:
CONFIGURE CONTROLFILE AUTOBACKUP ON;
new RMAN configuration parameters are successfully stored
设置恢复目录
RMAN> configure controlfile autobackup format for device type disk to '/u01/backup1/%F';
new RMAN configuration parameters:
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '/u01/backup1/%F';
new RMAN configuration parameters are successfully stored
查看设置情况
RMAN> show all;
RMAN configuration parameters for database with db_unique_name YISIDB2 are:
CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 7 DAYS;
CONFIGURE BACKUP OPTIMIZATION OFF; # default
CONFIGURE DEFAULT DEVICE TYPE TO DISK; # default
CONFIGURE CONTROLFILE AUTOBACKUP ON;
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '/u01/backup1/%F';
CONFIGURE DEVICE TYPE DISK PARALLELISM 1 BACKUP TYPE TO BACKUPSET; # default
CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE CHANNEL DEVICE TYPE DISK FORMAT '/u01/backup1/%U';
CONFIGURE MAXSETSIZE TO UNLIMITED; # default
CONFIGURE ENCRYPTION FOR DATABASE OFF; # default
CONFIGURE ENCRYPTION ALGORITHM 'AES128'; # default
CONFIGURE COMPRESSION ALGORITHM 'BASIC' AS OF RELEASE 'DEFAULT' OPTIMIZE FOR LOAD TRUE ; # default
CONFIGURE ARCHIVELOG DELETION POLICY TO BACKED UP 1 TIMES TO DISK;
CONFIGURE SNAPSHOT CONTROLFILE NAME TO '/u01/app/oracle/product/10.2.0/db_1/dbs/snapcf_yisidb2.f'; # default
全库备份
RMAN> backup database plus archivelog;
模拟删除spfile
[oracle@host2.yisi.net: /u01/app/oracle/product/10.2.0/db_1/dbs]$ mv spfileyisidb2.ora spfileyisidb2.ora.bak
先写一个最简单的pfile使其开库
vi inityisidb2.ora
db_name='yisidb2'
SYS@ yisidb2>startup nomount;
开始还原spfile
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/30151911/viewspace-1619844/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/30151911/viewspace-1619844/