1.备份数据库
RMAN> backup database format '/u01/app/RMANBK/bk_dir/%u'; |
2.关闭数据库
SQL> shutdown immediate Database closed. Database dismounted. ORACLE instance shut down. |
3.模拟数据丢失
删除控制文件、数据文件、日志文件、参数文件、密码文件
[oracle@localhost myorcl]$ pwd /u01/app/oradata/myorcl [oracle@localhost myorcl]$ rm -rf * [oracle@localhost dbs]$ ls hc_myorcl.datinit.oraorapwmyorclspfilemyorcl.ora initdw.oralkMYORCLsnapcf_myorcl.f [oracle@localhost dbs]$ pwd /u01/app/oracle/dbs [oracle@localhost dbs]$ rm -rf spfilemyorcl.ora [oracle@localhost dbs]$ rm -rf orapwmyorcl |
4.启动数据库到nomount状态
此时需要用到参数文件:
[oracle@localhost pfile]$ ls init.ora.226201419515 [oracle@localhost pfile]$ pwd /u01/app/admin/myorcl/pfile [oracle@localhost pfile]$ mv init.ora.226201419515 init.ora [oracle@localhost pfile]$ ls init.ora |
启动数据库到nomount状态:
[oracle@localhost ~]$ sqlplus / as sysdba SQL*Plus: Release 10.2.0.1.0 - Production on Thu Mar 27 22:11:17 2014 Copyright (c) 1982, 2005, Oracle.All rights reserved. Connected to an idle instance. SQL> startup nomount pfile='/u01/app/admin/myorcl/pfile/init.ora'; ORACLE instance started. Total System Global Area281018368 bytes Fixed Size2020160 bytes Variable Size88083648 bytes Database Buffers184549376 bytes Redo Buffers6365184 bytes SQL> |
4.使用RMAN恢复数据库参数文件
[oracle@localhost ~]$ rman target / Recovery Manager: Release 10.2.0.1.0 - Production on Thu Mar 27 22:13:59 2014 Copyright (c) 1982, 2005, Oracle.All rights reserved. connected to target database: myorcl (not mounted) RMAN> restore spfile from autobackup; |
然后关闭数据库启动到nomount状态呢:
SQL> shutdown immediate; ORACLE instance shut down. SQL> startup nomount; ORACLE instance started. Total System Global Area281018368 bytes Fixed Size2020160 bytes Variable Size113249472 bytes Database Buffers159383552 bytes Redo Buffers6365184 bytes |
5.使用RMAN恢复数据库控制文件
RMAN> restore controlfile from autobackup; Starting restore at 27-MAR-14 using target database control file instead of recovery catalog allocated channel: ORA_DISK_1 channel ORA_DISK_1: sid=155 devtype=DISK recovery area destination: /u01/app/flash_recovery_area database name (or database unique name) used for search: MYORCL channel ORA_DISK_1: autobackup found in the recovery area channel ORA_DISK_1: autobackup found: /u01/app/flash_recovery_area/MYORCL/autobackup/2014_03_27/o1_mf_s_843343359_9m8cw0g0_.bkp channel ORA_DISK_1: control file restore from autobackup complete output filename=/u01/app/oradata/myorcl/control01.ctl output filename=/u01/app/oradata/myorcl/control02.ctl output filename=/u01/app/oradata/myorcl/control03.ctl Finished restore at 27-MAR-14 |
6.启动数据库至mount状态
SQL> alter database mount; Database altered. |
7.恢复数据库
RMAN> restore database; |
接下来执行recover database,出现错误,链接如下:
http://dayong2015.blog.51cto.com/7185873/1397289
8.创建密码文件
[oracle@localhost ~]$ orapwd file=$ORACLE_HOME/dbs/orapwmyorcl password=oracle; |
转载于:https://blog.51cto.com/dayong2015/1397257