本文用step by step的方式介绍一下RMAN的入门使用,通常保存备份目录的目录数据库和目标数据库应该在不同的机器上,这里两个数据库在同一台机器上.在listener.ora中加入 (SID_DESC =
(GLOBAL_DBNAME = rmtgt)
(Oracle_HOME = D:oracleproduct10.2.0db_1)
(SID_NAME = but)
)tns配置如下:(让target 为静态注册,这样startup nomount的时候才能从rman连上)target =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = NBK-DAL-625040.ap.bt.com)(PORT = 1521))
)
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = rmtgt)
)
)
catalog =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = NBK-DAL-625040.ap.bt.com)(PORT = 1521))
)
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = orcl)
)
)1,在保存备份目录的目录数据库建立一个rman用户并创建相应的权限sqlplus sys/sys@catalog as sysdbacreate tablespace rmants datafile "D:oracleproduct10.2.0oradataorcl
mants.dbf" size 20M;create user rman identified by rman default tablespace rmants temporary tablespace temp quota unlimited on rmants;
grant recovery_catalog_owner to rman;
grant connect, resource to rman;2,在目录数据库中创建恢复目录C:>rman catalog rman/rman@catalog
Recovery Manager: Release 10.2.0.1.0 - Production on Thu Jan 12 15:02:22 2012
Copyright (c) 1982, 2005, Oracle. All rights reserved.
connected to recovery catalog database
RMAN> create catalog tablespace rmants;
recovery catalog created注册目标数据库到恢复目录,注意这里的连接串是targe
C:>rman target sys/sys@target
Recovery Manager: Release 10.2.0.1.0 - Production on Thu Jan 12 15:08:42 2012
Copyright (c) 1982, 2005, Oracle. All rights reserved.
connected to target database: BUT (DBID=1215064705)连接到目录数据库,注册目标数据库
RMAN> connect catalog rman/rman@catalog;
connected to recovery catalog databaseRMAN> register database;
database registered in recovery catalog
starting full resync of recovery catalog
full resync complete到此为止前面的准备工作都做好了,下面就可以使用RMAN 来进行备份和恢复了。下面来进行备份:1,创建一个目录 D:oracle
manrep2,C:>rman target sys/sys@target catalog rman/rman@catalog
3,RMAN> run{
2> allocate channel c1 type disk;
3> backup database format "D:oracle
manreputdb.dmp";
4> }目标数据库备份为D:oracle
manreputdb.dmpRMAN> list backup; 可以查看备份的信息.如果想删掉备份,(194 为备份的BS key)RMAN> allocate channel for delete type disk;
RMAN> change backupset 194 delete;下面来做恢复1,将目标数据库shutdown,将UNDOTBS01.DBF文件重命名为UNDOTBS01.DBF.bak模拟数据文件丢失.2,将目标数据库 startup mount3,在rman下恢复a,C:>rman target sys/sys@target
Recovery Manager: Release 10.2.0.1.0 - Production on Thu Jan 12 17:59:50 2012
Copyright (c) 1982, 2005, Oracle. All rights reserved.
connected to target database: BUT (DBID=3712141887, not open)注意这里可以看到数据库不是open状态,网络字符串"target"必须是通过静态注册的才能连接上.这时候open数据库
b,RMAN> alter database open;
using target database control file instead of recovery catalog
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of alter db command at 01/12/2012 18:01:42
ORA-01157: cannot identify/lock data file 4 - see DBWR trace file
ORA-01110: data file 4: "D:ORACLEPRODUCT10.2.0ORADATABUTUSERS01.DBF"可以看到datafile 4找不到c,
RMAN> restore datafile 4;Starting restore at 12-JAN-12
using channel ORA_DISK_1channel ORA_DISK_1: starting datafile backupset restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
restoring datafile 00004 to D:ORACLEPRODUCT10.2.0ORADATABUTUSERS01.DBF
channel ORA_DISK_1: reading from backup piece D:ORACLERMANREPBUTDB.DMP
channel ORA_DISK_1: restored backup piece 1
piece handle=D:ORACLERMANREPBUTDB.DMP tag=TAG20120112T172743
channel ORA_DISK_1: restore complete, elapsed time: 00:00:03Finished restore at 12-JAN-12d,RMAN> recover datafile 4;Starting recover at 12-JAN-12
using channel ORA_DISK_1starting media recovery
media recovery complete, elapsed time: 00:00:04Finished recover at 12-JAN-12e,恢复成功,打开数据库,RMAN> alter database open;database openedLinux 平台安装 Oracle TimestenOracle 服务器端客户端字符集设置对应用程序的影响相关资讯 Oracle基础教程
- Oracle块编程返回结果集详解 (11/10/2013 10:45:58)
- Oracle基础教程之设置系统全局区 (08/22/2013 14:24:00)
- Oracle基础教程知识点总结 (06/18/2013 07:43:32)
| - Oracle基础教程之tkprof程序详解 (10/22/2013 11:49:50)
- Oracle基础教程之sqlplus汉字乱码 (07/18/2013 16:30:00)
- Oracle 管理之 Linux 网络基础 (02/16/2013 18:37:35)
|
本文评论 查看全部评论 (0)