`
oboaix
  • 浏览: 269231 次
社区版块
存档分类
最新评论

Rman学习笔记记录

阅读更多

记录前段时间学习ORACLE10g  (10.2.0 )RMAN笔记
1.
sqlplus /nolog
conn / as sysdba;
archive log list;--看是否具有备份条件
--database log mod   Archive Mod
--Automatic archival Enabled
修改方式  切换的归档模式备份
startup mount
alter database archivelog;

2.
raman
或者
rman nocatalog

connect target /    --连接到目标数据库

list backupset;

backup database;
备份数据库 也叫全备份

backup database format='d:\oralce\....';

sql "Alter System Archive Log Current";

Backup filesperset 10 ArchiveLog all format='d:\oracle\...'

 


list backupset;--查看

3. 非catalog方式备份
show all;
---自动备份控制文件
CONFIGURE CONTROLFILE AUTOBACK OFF;
CONFIGURE CONTROLFILE AUTOBACK ON;

0级增量备份
backup incremental level=0 database;
或者
backup incremental level 0 database;

0级别和全备份的基本完全一样
0级备份可以继续进行后面的备份 是基础 而全备份不行

list bacupset;

1级增量备份 必须在0级增量备份基础之上
backup incremental level 1 database;

list bacupset;

4.备份archivelog
backup database plus archivelog delete input;--备份基本上所有的数据库文件 删除归档日志文件


/*
在rman下一样的启动数据库
startup --mount nomount
--启动监听
lsnrctl  start
*/


5. 备份表空间
report schema;

backup tablespace chmoddata;

list backupset;

6. 备份控制文件
backup current controlfile;--只备份当前的控制文件

backup database include current controlfile;--在备份database时备份控制文件


list backupset;

--恢复时数据库会自动拿到最新时间的

备份集 backupset
镜像备份 image copies

report schema;


copy datafile 5 to 'd:\oracle\product\10.2.0\bak';

list copy;--历史拷贝


7. 单命令 批命令
backup database;--单
run{            --批
allocate channel cha1 type disk;--disk磁盘 tps磁带
backup
format 'd:\oracle\product\10.2.0\bak\full_%t'
tag 'full-backup'
database; --incremental level 0 database;
release channel cha1;
}

--%d 数据库名称  %T年月日格式 %t备份集时间戳


--channel 是rman和目标数据库之间的一个连接


rman工具 在A Target Database B Auxiliary Database
           C Disk/SBT Tape   D Catalog Database/Controlfile
同时连接以上各种Database 将数据放到Disk/Tps
用来连接、备份、恢复数据库、拷贝等
(下面是一套备份方案)

0  周日 level 0
1  周一 level 2
2  周二 level 2
3  周三 level 1
4  周四 level 2
5  周五 level 2
6  周六 level 2

差量增量备份
增量增量备份 博客上介绍


0级增量备份的脚本bakl0
run{
allocate channel c1 type disk;
backup
incremental level 0
format 'd:\oracle\product\10.2.0\bak\inc0_%u_%T'
tag 'monday_incr0'
databse;
release channel c1;
}

 

1级增量备份的脚本 bakl1
run{
allocate channel c1 type disk;
backup
incremental level 1
format 'd:\oracle\product\10.2.0\bak\inc1_%u_%T'
tag 'monday_incr1'
databse;
release channel c1;
}


2级增量备份的脚本bakl2
run{
allocate channel c1 type disk;
backup
incremental level 2
format 'd:\oracle\product\10.2.0\bak\inc2_%u_%T'
tag 'monday_incr2'
databse;
release channel c1;
}

unix:  crontab -e 30 6 * * 1
执行脚本
rman target / msglog='d:\oracle\bakl0.log' cmdfile='d:\oracle\product\10.2.0\bak\bak10';
时间较长
rman target / msglog='d:\oracle\bakl1.log' cmdfile='d:\oracle\product\10.2.0\bak\bak11';

rman target / msglog='d:\oracle\bakl2.log' cmdfile='d:\oracle\product\10.2.0\bak\bak12';


8. 备份恢复
Configure controlfile autobackup on;
前提是需要记得DBID

show all;

configure controlfile autobackup off;
configure controlfile autobackup on;

list backupset;


delete backupset 24;

--configure controlfile autobackup on;
backup format 'd:\oracle\product\10.2.0\bak\full_%T_%t.bak' database plus archivelog;
将会自动备份控制文件


9. 口令文件丢失    需要记住的是DBID参数值
orapw file=orapwsid password=pass entries=5;

10. spfile丢失
数据库启动为nomount  启动实例 但是不读取参数文件和控制文件

rman target /
startup nomount;

set dbid=111111;

restore spfile from autobackup;
--no autobackup found
如果找不到,直接找到指定文件路径

restore spfile from 'd:\oracle\product\10.2.0\bak\....bkp';
再查看spfile文件是否生成了

shutdown immediate;
(set dbid=111111)

startup

如果startup启动有问题 再设置下面
set dbid=1111111;
再启动startup

11. 控制文件丢失恢复 *.ctl
数据库启动为nomount   ---shutdown abort;

rman target /
startup nomount;

restore controlfile from autobackup;

alter database mount;

recover database;

alter database open resetlogs;


rman>sql "select * from dual;";


12. Redolog file恢复丢失的*.log   --sequence存储 相关

rman target /
(sqlplus /nolog  conn / a sysdba;)

shutdown immediate;

startup mount;
---有时需要增加下面的一句话运行启动 认证的问题  需要在sqlplus 的连接情况下
recover database until cancel;

alter database open resetlogs;


13. datafile丢失的恢复  更恢复表空间大致一样
--先删除一个datafile文件
rman target /

reprot schema;---555
----只要将表空间置为offline
sql "alter database  datafile 5 offline";--在rman下面执行SQL语句

restore datafile 5;

recover datafile 5;

sql "alter database datafile 5 online";
---alter database open resetlogs;  //可能丢失数据 清空了数据 需要full database backup;
---必须有全备份 才能继续操作该条语句alter database open resetlogs;

14.tablespace丢失恢复
rman target /

sql "alter tablespace users offline";
(sql "alter tablespace users offline immediate";)--不正常时加上immediate

restore tablespace tbs1;

recover tablespace tbs1;

sql "alter tablespace tbs1 online";

登入验证数据是否恢复存在


15. 非catalog方式的完全的恢复
先删除oral下面的所有文件
rman target /  ;----就会报错丢失掉控制文件
---如果连spfile文件 就应该首先将spfile文件给恢复 再是控制文件
sqlplus /nolog
conn / as sysdba;
shutdown abort;

rman target /

startup nomount;

restore controlfile from autobackup;

alter database mount;

restore database;

recover database;---应该报错问题, 因为 online redolog文件不存在
(recover database until cancel;)--sqlplus

sqlplus /nolog
conn  / as sydba;

(recover database until cancel;)--估计还是会有问题

--------------------------------------------------
sqlplus /nolog
conn  / as sydba;
create pfile from spfile;
在文件的末尾添加一行
initorcl.ora---文本文件格式的   允许没有redolog文件时执行恢复
*._allow_resetlogs_corruption='TRUE'


再次
sqlplus /nolog
conn / as sysdba;

shutdown immediate;

startup pfile='D:\oracle\product\10.2.0\db_1\dbs\initorcl.ora' mount;

alter database open resetlogs;---sequence 从1开始了 一般而言会存在文件的丢失


16. 基于时间的恢复
run{
set until time "to_date('09/05/03 15:00:00','yy/mm/dd hh24:mi:ss')"
restore database;
recover database;
alter database oepn resetlogs;--不完全恢复 数据会丢失
}


17. 基于SCN的恢复
shutdown immediate;
startup mount;

restore database UNTIL SCN 10000;
recover database UNTIL SCN  10000;
alter database open resetlogs;--不完全恢复


report schema;
list backup;---这些内容全部存储在你控制文件中的
list backupset;


crosscheck backup;
delete;--删除你的目录和你的真实文件
delete backupset 38;--删除你的目录和你的真实文件


18.catalog模式下面的操作将备份集信息存在我们的rman的表空间中了 不像以前那样将数据是存在系统的控制文件 中的
sqlplus /nolog
conn / as sysdba;

create tablespace rman_ts datafile 'D:\oracle\product\10.2.0\oradata\orcl\rmants.dbf' size 20M;
(create tablespace rman_ts datafile 'D:\oracle\product\10.2.0\oradata\orcl\rmants.dbf' reuse;)


create user rman identified by rman default tablespace
rman_ts quota unlimited on rman_ts;

grant recovery_catalog_owner to rman;--已经具备了connect和resource的权限了

exit

rman catalog rman/rman;

create catalog tablespace rman_ts;

register database;

connect target /

connect target / catalog rman/rman;---前部分代表target database 后部分代表catalog database;
(connected to recovery catalog database)

backup database;
---全备份
backup format 'd:\oracle\product\10.2.0\orcl\....'  database;

 

-----------------10-02-20-----------------------
-----备份好所有的文件除(日志文件和口令参数文件)  最后删除原来的归档日志文件  腾出空间
backup database plus archivelog delete input;

--备份表空间
backup tablespace user;
--备份当前的控制文件
backup current controlfile;
--备份数据库 包含控制文件
backup database include current controlfile ;


--查看数据库表空间
report schema;

---直接拷贝文件
copy datafile 5  to 'd:\oracle\product\10.2.0\bak\tbs.dbf';

--拷贝
list copy;


---批命令执行备份
run{
allocate channel cha1 type disk;
backup format 'd:\oracle\product\...\full_%t'
tag full_backup_bat
database;
release channel cha1;
}

 

-----备份时自动备份控制文件和spfile参数文件
show all;

configure controlfile autobackup on;

---处理口令文件  dbs 目录下面
orapwd file=orapwherming password=pass1234 entries=5;

 


分享到:
评论

相关推荐

    rman学习笔记.txt

    rman学习笔记.txt rman学习笔记.txt rman学习笔记.txt

    DAVE Oracle RMAN 学习笔记

    DAVE Oracle RMAN 学习笔记

    RMAN学习笔记

    ORACLE RMAN 一步一步学习笔记,初级入门教程

    rman读书笔记

    读书笔记之 RMAN 备份命令,涉及,数据库备份,文件备份,表空间备份,控制文件备份,初始化参数备份,增量备份(差异和累积),命令总列,删除总命令列,

    RMAN备份学习笔记

    RMAN备份学习笔记,oracle备份,oracle

    rman恢复管理器学习笔记

    rman恢复管理器学习笔记,欢迎下载学习。笔记包含理论知识和常用恢复管理命令。

    一步一步学Rman 三思笔记

    很好的学习RMAN恢复和备份的资料,请大家一定要珍惜并好好学习

    rman(三思笔记)

    rman(三思笔记)

    [三思笔记]一步一步学RMAN

    《[三思笔记]一步一步学rman(01)-进入rman.doc》 《[三思笔记]一步一步学rman(02)-rman命令知多少.doc》 《[三思笔记]一步一步学rman(03)-rman备份演练初级篇.doc》 《[三思笔记]一步一步学rman(04)-rman备份演练...

    三思笔记Rman

    三思笔记Rman。三思笔记Rman。三思笔记Rman。三思笔记Rman。三思笔记Rman。三思笔记Rman。三思笔记Rman。三思笔记Rman。三思笔记Rman。三思笔记Rman。三思笔记Rman。三思笔记Rman。三思笔记Rman。三思笔记Rman。三思...

    ORACLE--Rman学习教程

    一步一步教你如何学习RMAN,简单实用。

    [三思笔记] 一步一步学RMAN

    [三思笔记]一步一步学rman 一、进入rman 二、rman命令知多少 三、rman备份演练初级篇 四、rman备份演练进阶篇 五、rman外传-基础资料篇1 六、实战rman备份 七、rman外传-基础资料篇2 八、演练rman恢复 九、实战rman...

    RMAN学习

    学习RMAN挺好的手册

    linux下rman备份笔记

    NULL 博文链接:https://microjava.iteye.com/blog/510054

    三思笔记--rman chm版本

    第一篇 进入RMAN ...第11篇 RMAN笔记之综述 Duplicate复制数据库之基本概述 Duplicate复制数据库之创建辅助实例 Duplicate复制数据库之不同环境下的复制流程 Duplicate复制数据库之实战 Duplicate复制数据库之附录

    Oracle RMAN增量备份恢复测试记录.docx

    Oracle RMAN增量备份恢复测试记录

    RMAN学习篇

    Oracle rman的备份学习,详细教程

    oracle rman笔记

    oracle rman的学习笔记,!!!

    oracle rman 笔记

    oracle rman学习的笔记,供大家参考。谢谢

Global site tag (gtag.js) - Google Analytics