linux下rman恢复笔记

su oracle

------ 备份控制文件---------------
rman target /
记下:DBID=3388079157

查看状态:
show all;

开启/关闭(要备份控制文件,必须打开)
configure controlfile autobackup off/on;

list backupset;

bs
24

delete backupset 24;

backup format '/home/oracle/mybackup/full_%T_%u.bak' database plus archivelog;

list backupset;

-----控制文件丢失--
rm *.ctl;
conn / as sysdba;
shutdown abort;
quit;

rman target /
startup nomount;
restore controlfile from autobackup;

rman target /
alter database mount;
recover database;
alter database open resetlogs;

口令文件:
/oracle/product/10.2.0/db_1/dbs/orapwherming
口令文件丢失后恢复:
orapwd file=orapwherming password=pass1234 entries=5(entries=5表示dba用户可以有5个)

-----
记下的:DBID=3388079157
spfile丢失(换成别的名字:mv spfileermp.ora spfileermp2.ora)

shutdown immediate;

startup nomount;

set dbid 3388079157

restore spfile from autobackup;
找不到则:restore spfile from '/..../#####.bkp';(rman备份路径)

shutdown immediate;

startup;(set dbid 3388079157;startup;)

--Redolog file 丢失
su -u oracle
rm *.log

sqlplus /nolog;
conn /as sysdba;

shutdown immediate;
startup mount;
recover database until cancel;
alter database open resetlogs;


---执行sql
su -u oracle;
sqlplus /nolog;
conn /as sysdba;
select * from dual;

-----datafile丢失
su oracle;
rm tbs01.dbf;
rman target /

report schema;(tbs01.dbf的file是5)

sql "alter database datafile 5 offline";
restore datafile 5;
recover datafile 5;
sql "alter database datafile 5 online";

-------表空间恢复---------------
su oracle;
sqlplus /nolog;
conn /as sysdba;

select owner,table_name from all_tables where tablespace_name='ermp';
ermp  role_info
ermp  user_info
ermp  org_info
ermp  user_role

select * from ermp.role_info;

quit;

rm /oracle/oradata/ermp/ermp.dbf

开始恢复:
rman target /
sql "alter tablespace ermp offline";强制:sql "alter tablespace ermp offline immediate";

restore tablespace ermp;
recover tablespace ermp;

sql "alter tablespace ermp online"

quit


------------非catalog方式完全恢复-------------
su oracle;
cd /oracle/oradata/ermp/
rm *;

rman target
conn /as sysdba
shutdown abort;

quit;

rman target /

startup nomount;
restore controlfile from autobackup;
alter database mount;
restore database;
recover database;
不成功则:
su oracle;
sqlplus /nolog
conn /as sysdba
create pfile from spfil
quit;

sqlplus /nolog
conn /as sysdba
shutdown immediate;
startup pfile=/oracle/product/10.2.0/db_1/dbs/initermp.ora mount

alter database open resetlogs;

----------基于时间的恢复------------
run {
set until time "to_date('09/01/02 15:00:00','mm/dd/yy hh24:mi:ss')"
restore database;
recover database;
alter database open resetlogs;
}

----------基于scn的恢复----------
startup mount;
restore database UNTIL SCN 10000;
recover database UNTIL SCN 10000;
alter database open resetlogs;

---------基于日志序列的恢复-------
sqlplus /nolog
conn /as sysdba
查看日志序列 sequence# current:
select * from v$log;

startup mount;
恢复到1:
restore database UNTIL SEQUENCE 100 thread 1;
recover database UNTIL SEQUENCE 100 thread 1;

alter database open resetlogs;

-----命令总结---rman中执行
report schema:
list backup:
crosscheck backup:
delete: delete backupset 23;


---------catalog备份恢复-------

Catalog mode:
sqlplus /nolog
conn / as sysdba
--创建Catalog所用表空间
SQL>create tablespace rman_ts datafile '/oracle/rman.dbf' size 20 M;
--创建rman用户并授权
SQL>create user rman identified by rman default
   tablespace rman_ts quota unlimited on rman_ts;
SQL>grant recovery_catalog_owner to rman;

grant connect to rman;

--创建恢复目录
su oracle;
rman catalog rman/rman
RMAN>create catalog tablespace rman_ts;
RMAN>register database;

connect target /

--
SQL>select * from dba_sys_privs where grantee='CONNECT';
SQL>select * from dba_sys_privs where grantee='RESOURCE';
SQL>select * from dba_sys_privs where grantee='RECOVERY_CATALOG_OWNER';

----开始备份----
su oracle;
rman target / catalog rman/rman

你可能感兴趣的:(thread,oracle,sql,linux)