完整的oracle rman备份恢复的例子

来源:网络 责任编辑:栏目编辑 发表时间:2013-07-01 17:10 点击:

完整的oracle rman备份恢复的例子
 
作者:zhumy
1、 建rman库作为repository
$more createrman_db1.sh
set echo on
spool makedb1.log
create database rman
datafile '/export/home/oracle/oradata/rman_data/system.dbf' size 50m autoextend
on next 640K
logfile '/export/home/oracle/oradata/rman_data/redo0101.log' SIZE 10M,
'/export/home/oracle/oradata/rman_data/redo0201.log' SIZE 10M
maxdatafiles 30
maxinstances 8
maxlogfiles 64
character set US7ASCII
national character set US7ASCII
;
disconnect
spool off
exit

@/export/home/oracle/8.1.6/rdbms/admin/catalog.sql;

REM ********** ALTER SYSTEM TABLESPACE *********
ALTER TABLESPACE SYSTEM
DEFAULT STORAGE ( INITIAL 64K NEXT 64K MINEXTENTS 1 MAXEXTENTS UNLIMITED PCTINCR
EASE 50);
ALTER TABLESPACE SYSTEM
MINIMUM EXTENT 64K;

REM ********** TABLESPACE FOR ROLLBACK **********
CREATE TABLESPACE RBS DATAFILE '/export/home/oracle/oradata/rman_data/rbs.dbf' s
ize 50m
AUTOEXTEND ON NEXT 512K
MINIMUM EXTENT 512K
DEFAULT STORAGE ( INITIAL 512K NEXT 512K MINEXTENTS 10 MAXEXTENTS UNLIMITED PC
TINCREASE 0 );

REM ********** TABLESPACE FOR TEMPORARY **********
CREATE TABLESPACE TEMP DATAFILE '/export/home/oracle/oradata/rman_data/temp.dbf'
size 50m
AUTOEXTEND ON NEXT 64K
MINIMUM EXTENT 64K
DEFAULT STORAGE ( INITIAL 64K NEXT 64K MINEXTENTS 1 MAXEXTENTS UNLIMITED PCTINCR
EASE 0) TEMPORARY;

REM **** Creating four rollback segments ****************
CREATE PUBLIC ROLLBACK SEGMENT RBS_0 TABLESPACE RBS
STORAGE ( OPTIMAL 64000K );
ALTER ROLLBACK SEGMENT "RBS_0" ONLINE;


REM **** SYS and SYSTEM users ****************
alter user sys temporary tablespace TEMP;
alter user system temporary tablespace TEMP;
disconnect
spool off
exit

$more createrman_db3.sh
spool crdb3.log
@/export/home/oracle/8.1.6/rdbms/admin/catproc.sql
@/export/home/oracle/8.1.6/rdbms/admin/caths.sql
@/export/home/oracle/8.1.6/rdbms/admin/otrcsvr.sql
connect system/manager
@/export/home/oracle/8.1.6/sqlplus/admin/pupbld.sql

disconnect
spool off
exit

2、建repository存放的表空间和rman用户
$more createrman_db4.sh
connect internal
create tablespace rman_ts
datafile '/export/home/oracle/oradata/rman_data/rman_ts.dbf'
size 20M default storage (initial 100K next 100K pctincrease 0);
create user rman_hainan identified by rman_hainan
temporary tablespace TEMP
default tablespace rman_ts quota unlimited on
rman_ts;
grant recovery_catalog_owner to rman_hainan;
grant connect ,resource to rman_hainan;

3、建catalog,注册目标数据库
$more createrman_db5.sh
rman catalog rman_hainan/rman_hainan@rman msglog=rman.log
create catalog ;
exit;
rman target sys/oracle@db1
connect catalog rman_hainan/rman_hainan@rman
register database;
exit;

4、可以开始做备份了。
5、做全备
$more rmanshell
. /export/home/oracle/.profile
rman rcvcat rman_hainan/rman_hainan@rman target / cmdfile /export/home/oracle/ba
ckup_level0.rcv log /export/home/oracle/backup.log

$more backup_level0.rcv
resync catalog;
run {
allocate channel t1 type disk;
backup
incremental level 0
skip inaccessible
tag hot_db_bk_level0
filesperset 3
format '/export/home/oracle/bk_%s_%p_%t.bk'
(database);
sql 'alter system archive log current';
backup
filesperset 10
format '/export/home/oracle/a1_%s_%p_%t.ac'
(archivelog all delete input);
backup
format '/export/home/oracle/df_t

    发表评论
    请自觉遵守互联网相关的政策法规,严禁发布色情、暴力、反动的言论。
    用户名: 验证码:点击我更换图片
    最新评论 更多>>

    推荐热点

    • Table函数使用简介
    • Oracle数据库Constraint约束的常用操作及异常处理
    • Bulk Collect性能分析(zz)
    • export/import的使用
    • OCP043第十五讲 Database Security
    • ORACLE10gr2数据导入MySQL方案
    • oracle 让sys用户可以使用isqlplus
    • 在oracle数据库下使用iSQL*Plus DBA访问数据库
    • Oracle行列转换小结
    网站首页 - 友情链接 - 网站地图 - TAG标签 - RSS订阅 - 内容搜索
    Copyright © 2008-2015 计算机技术学习交流网. 版权所有

    豫ICP备11007008号-1