sql> create user rman identified by rman default tablespace rman_ts temporary tablespace temp quota unlimited on rman_ts;用户已创建。sql> grant recovery_catalog_owner to rman;授权成功。sql> grant connect, resource to rman;授权成功。
the target database is called "his" and has the same tns alias user rman has been granted "recovery_catalog_owner "privileges 目标数据库的连接用户为internal帐号,或者以其他sysdba类型帐号连接 the recovery catalog database is called "rman" and has the same tns alias the schema containing the recovery catalog is "rman" (same password)
rman>allocate channel for delete type disk;rman-03022:正在编译命令:allocaterman-03023:正在执行命令:allocaterman-08030:分配的通道:deleterman-08500:通道 delete:sid=19 devtype=disk
rman>allocate channel for delete type disk;rman>allocate channel for maintenance type disk; 7.在非归档模式下备份 数据库状态:
恢复目录:打开
目标数据库:例程启动或者数据库加载
恢复目录数据库需要打开,目标数据库必须启动(或者加载)。因为目标数据库不在归档模式下,所以当进行备份恢复操作的时候数据库无法打开。不可以将表空间置于热备份模式上进行等同于文件系统级的拷贝,如果在非归档模式,数据库打开的状态下不能进行数据文件的备份。 7.1.数据库完全备份 rman> run { 2> # backup the complete database to disk 3> allocate channel dev1 type disk; 4> backup 5> full 6> tag full_db_backup 7> format "/oracle/backups/db_t%t_s%s_p%p" 8> (database); 9> release channel dev1; 10> }
行#2: 表明该行为注释行(#是注释符)3&9: see section 15 - channels通道定义5: full backup (default if full or incremental not specified)完全备份模式(缺省模式)6: meaningful string (<=30 chars)(备份集标识,<=30个字符)7: filename to use for backup pieces, including substitution variables. 备份片使用的文件名,可以包含代替变量。8: indicates all files including controlfiles are to be backed up表明备份所有数据文件包括控制文件
通过下面的命令显示恢复目录中记载的备份集信息:
rman> list backupset of database; 7.2.备份表空间 rman> run { 2> allocate channel dev1 type disk; 3> backup 4> tag tbs_users_read_only 5> format "/oracle/backups/tbs_users_t%t_s%s" 6> (tablespace users) 7> }
rman> run { 2> allocate channel dev1 type disk; 3> backup 4> format "/oracle/backups/log_t%t_s%s_p%p" 5> (archivelog from time "sysdate-1" all delete input); 6> release channel dev1; 7> }
使用下面的命令显示恢复目录中的归档日志:
rman> list backupset of archivelog all;
注意:rman找到归档日志后会备份指定日志,如果无法找到日志,它也不会返回错误信息。 8.2. backing up the online logs 备份联机日志 联机日志不能用rman来备份,必须先将其归档。
为了实现这点,必须在rman中执行如下sql语句:
rman> run { 2> allocate channel dev1 type disk; 3> sql "alter system archive log current"; 4> backup 5> format "/oracle/backups/log_t%t_s%s_p%p" 6> (archivelog from time "sysdate-1" all delete input); 7> release channel dev1; 8> }
rman> replace script backup_db_full { 2> # performs a complete backup 3> execute script alloc_disk; 4> set maxcorrupt for datafile 1 to 0; 5> backup 6> ..... 7> execute script rel_disk; 8> }
上面的脚本maxcorrupt for datafile 1 to 0设置为0,所以如果有错误数据块在数据文件1中发现,上面的脚本执行就会失败。 13. 通道 一个通道是rman和目标数据库之间的一个连接,"allocate channel"命令在目标数据库启动一个服务器进程,同时必须定义服务器进程执行备份或者恢复操作使用的i/o类型
通道控制命令可以用来: 控制rman使用的o/s资源 影响并行度 指定i/o带宽的限制值(设置limit read rate参数) 定义备份片大小的限制(设置limit kbytes) 指定当前打开文件的限制值(设置limit maxopenfiles) 14. report & list commands14.1. list list命令查询恢复目录并且产生格式化的查询内容:
rman> list backupset of datafile 1; key file type lv completion_time ckp scn ckp time ------- ---- ------------ -- --------------- ---------- -------- 165 1 full oct 03 11:24 32022 oct 03 11:24 208 1 full oct 24 14:27 52059 oct 24 14:26 219 1 full oct 24 14:31 52061 oct 24 14:31 << other entries here >> rman> list backupset of archivelog all; key thrd seq completion time ------- ---- ------- --------------- 179 1 94 oct 03 11:26 179 1 95 oct 03 11:26 << other entries here >> 14.2. report report命令同样可以查询恢复目录,但是report命令语法可以构建获得更为有用的信息的指令,report命令输出可以保存到消息日志文件中,但是必须在连接恢复目录时指定msglog或者log选项。
可以列出所有数据库中不能恢复的文件列表:
rman> report unrecoverable database;
显示全部数据文件:
rman> report schema;rman-03022:正在编译命令:report 数据库模式报表文件 千字节 表空间 rb segs 名称 1 121472 system yes d:/oracle/oradata/his ystem01.dbf 2 327680 rbs yes d:/oracle/oradata/his/rbs01.dbf 3 110592 users no d:/oracle/oradata/his/users01.dbf 4 73728 temp no d:/oracle/oradata/his/temp01.dbf 5 12288 tools no d:/oracle/oradata/his/tools01.dbf 6 59392 indx no d:/oracle/oradata/his/indx01.dbf 15. 小提示 经常同步恢复目录