设为首页收藏本站language 语言切换
查看: 2002|回复: 2
收起左侧

[分享] ORACLE表空间的备份与恢复

[复制链接]
发表于 2012-6-4 15:06:17 | 显示全部楼层 |阅读模式
1、切换服务器归档模式,如果已经是归档模式可跳过此步:
    %sqlplus /nolog (启动sqlplus)
    SQL> conn / as sysdba (以DBA身份连接数据库)
    SQL> shutdown immediate; (立即关闭数据库)
    SQL> startup mount (启动实例并加载数据库,但不打开)
    SQL> alter database archivelog; (更改数据库为归档模式)
    SQL> alter database open; (打开数据库)
    SQL> alter system archive log start; (启用自动归档)
    SQL> exit (退出)
2、连接rman
rman  or  /data/app/oracle/product/11.2.0/dbhome_1/bin/rman
RMAN> connect  target sys/system@orcl     --连接到目标数据库
3、备份表空间 tpm
RMAN>backup tablespace tpm plus archivelog delete input;
4、恢复表空间
SQL>alter tablespace tpm  offline for recover;  //使tpm offline
RMAN>restore tablespace  tpm
RMAN>recover tablespace  tpm
RMAN>alter tablespace tpm online;        //tpm online
5、表空间的增量备份
第一天的增量基本备份:
RMAN> backup incremental level=0 tablespace tpm plus archivelog delete input;
第二天的增量差异备份:
RMAN> backup incremental level=2 tablespace tpm plus archivelog delete input;
第三天的增量差异备份:
RMAN> backup incremental level=2 tablespace tpm plus archivelog delete input;
第四天的增量差异备份:
RMAN> backup incremental level=1 tablespace tpm plus archivelog delete input;
第五天的增量差异备份:
RMAN> backup incremental level=2 tablespace tpm plus archivelog delete input;
第六天的增量差异备份:
RMAN> backup incremental level=2 tablespace tpm plus archivelog delete input;
第七天的增量差异备份:
RMAN> backup incremental level=0 tablespace tpm plus archivelog delete input;
        注:需要用linux crontab 来每天自动运行上面的代码
:创建rman 目录表空间和用户
1、 create tablespace rman_ts datafile '/data/app/oracle/oradata/rman/rman_ts.dbf' size 20M;
2、 create user rman identified by rman default tablespace rman_ts temporary tablespace temp quota unlimited on rman_ts;
3、 grant recovery_catalog_owner to rman;
4、 grant connect, resource to rman


发表于 2012-7-13 21:45:37 | 显示全部楼层
谢谢楼主的分享!
沙发 2012-7-13 21:45:37 回复 收起回复
回复 支持 反对

使用道具 举报

发表于 2012-7-13 10:40:47 | 显示全部楼层
我是初学者,有点看不懂,谢谢分享!
板凳 2012-7-13 10:40:47 回复 收起回复
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 论坛注册

本版积分规则

QQ|Archiver|手机版|小黑屋|sitemap|鸿鹄论坛 ( 京ICP备14027439号 )  

GMT+8, 2025-2-23 10:36 , Processed in 0.060102 second(s), 27 queries , Redis On.  

  Powered by Discuz!

  © 2001-2025 HH010.COM

快速回复 返回顶部 返回列表