文档介绍:2022年Oracle RMAN快速入门指南ORACLE教程
?
RMAN可以用来备份和还原数据库文件、归档日志和限制文件。它也可以用来执行完全或不完全的数据库复原。
留意:RMAN不能用于备份初始化>create catalog tablespace rman_ts;
RMAN-06431:复原书目已创建
留意:虽然运用RMAN不肯定必需复原书目,但是举荐运用。因为复原书目记载的信息大部分可以通过限制文件来记载,RMAN在复原数据库时运用这些信息。不运用复原书目将会对备份复原操作有限制。
可以存储脚本;
记载较长时间的备份复原操作;
4. 启动RMAN
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前,设置NLS_DATE_FORMAT 和NLS_LANG环境变量,许多RMAN LIST吩咐的输出结果是与日期时间相关的,这点在用户希望执行以时间为基准的复原工作也很重要。
下例是环境变量的示范:
NLS_LANG= SIMPLIFIED
NLS_DATE_FORMAT=DD-MON-YYYY HH24:MI:SS
为了保证RMAN运用时能连接复原书目,复原书目数据库必需打开,目标数据库至少要STARTED(unmount),否则RMAN会返回一个错误,目标数据库必需置于归档模式下。
设置目标数据库的 ORACLE_SID ,执行:
% rman nocatalog
RMAN> connect target
RMAN> connect target internal/<password>***@his
% rman rman_ts rman/******@rman
RMAN> connect target
% rman rman_ts rman/******@rman target internal/<password>***@his
一旦连接到目标数据库,可以通过交互界面或者事先存储的脚本执行指定RMAN吩咐, 下面是一个运用RMAN交互界面的实例:
RMAN> resync catalog;
RMAN-03022:正在编译吩咐:resync
RMAN-03023:正在执行吩咐:resync
RMAN-08002:正在启动全部复原书目的 resync
RMAN-08004:完成全部 resync
运用脚本的实例:
RMAN> execute script alloc_1_disk;
创建或者替代存储的脚本:
RMAN> replace script alloc_1_disk {
2> allocate channel d1 type disk;
3> }
数据库状态:
复原书目状态:打开
目标数据库:加载或者打开
目标数据库在第一次运用RMAN之前必需在复原书目中注册:
第一步,启动复原管理器,并且连接目标数据库:
C:\>rman target internal/******@his catalog rman/******@rman
复原管理器: - Production
RMAN-06005:连接到目标数据库