知识大全 RMAN的备份及恢复-丢失所有控制文件

Posted 文件

篇首语:身体的财富是健康,思想的财富是知识。本文由小常识网(cha138.com)小编为大家整理,主要介绍了知识大全 RMAN的备份及恢复-丢失所有控制文件相关的知识,希望对你有一定的参考价值。

RMAN的备份及恢复-丢失所有控制文件  以下文字资料是由(全榜网网www.cha138.com)小编为大家搜集整理后发布的内容,让我们赶快一起来看一下吧!

   数据库基本信息

  [oracle@standby oracle]$ sqlplus / as sysdba

  SQL*Plus: Release Production on Wed Mar : :

  Copyright (c) Oracle Corporation   All rights reserved

  Connected to:  Oracle i Enterprise Edition Release Production  With the Partitioning option  JServer Release Production

  SQL> select name from v$datafile;

  NAME     /opt/oracle/oradata/primary/system dbf  /opt/oracle/oradata/primary/undotbs dbf  /opt/oracle/oradata/primary/users dbf

  SQL> archive log list;  Database log mode        Archive Mode  Automatic archival       Enabled  Archive destination      /opt/oracle/oradata/primary/archive  Oldest online log sequence       Next log sequence to archive     Current log sequence       SQL> select name from v$archived_log;

  NAME     /opt/oracle/oradata/primary/archive/ _ dbf  /opt/oracle/oradata/primary/archive/ _ dbf  /opt/oracle/oradata/primary/archive/ _ dbf  /opt/oracle/oradata/primary/archive/ _ dbf  /opt/oracle/oradata/primary/archive/ _ dbf  /opt/oracle/oradata/primary/archive/ _ dbf  /opt/oracle/oradata/primary/archive/ _ dbf  /opt/oracle/oradata/primary/archive/ _ dbf  /opt/oracle/oradata/primary/archive/ _ dbf  /opt/oracle/oradata/primary/archive/ _ dbf  /opt/oracle/oradata/primary/archive/ _ dbf

  NAME     /opt/oracle/oradata/primary/archive/ _ dbf  /opt/oracle/oradata/primary/archive/ _ dbf  /opt/oracle/oradata/primary/archive/ _ dbf  /opt/oracle/oradata/primary/archive/ _ dbf

   rows selected

  SQL> select name from v$controlfile;

  NAME     /opt/oracle/oradata/primary/control ctl  /opt/oracle/oradata/primary/control ctl  /opt/oracle/oradata/primary/control ctl

  SQL> exit  Disconnected from Oracle i Enterprise Edition Release Production  With the Partitioning option  JServer Release Production

   启用控制文件的自动备份

  [oracle@standby oracle]$ rman target /

  Recovery Manager: Release Production

  Copyright (c) Oracle Corporation   All rights reserved

  connected to target database: PRIMARY (DBID= )

  RMAN> configure controlfile autobackup on;

  using target database controlfile instead of recovery catalog  new RMAN configuration parameters:  CONFIGURE CONTROLFILE AUTOBACKUP ON;  new RMAN configuration parameters are successfully stored

  RMAN> exit

  Recovery Manager plete

   执行RMAN全备份

  [oracle@standby oracle]$ ls   g  admin  dictionary ora  initprimary ora  jre  oradata  oraInventory  oui  [oracle@standby oracle]$ mkdir orabak  [oracle@standby oracle]$ rman target /

  Recovery Manager: Release Production

  Copyright (c) Oracle Corporation   All rights reserved

  connected to target database: PRIMARY (DBID= )

  RMAN> run    > backup database   > format /opt/oracle/orabak/full_%d_%T_%s    > plus archivelog   > format /opt/oracle/orabak/arch_%d_%T_%s    > delete all input;

  Starting backup at MAR   current log archived  using target database controlfile instead of recovery catalog  allocated channel: ORA_DISK_   channel ORA_DISK_ : sid= devtype=DISK  channel ORA_DISK_ : starting archive log backupset  channel ORA_DISK_ : specifying archive log(s) in backup set  input archive log thread= sequence= recid= stamp=   input archive log thread= sequence= recid= stamp=   input archive log thread= sequence= recid= stamp=   input archive log thread= sequence= recid= stamp=   input archive log thread= sequence= recid= stamp=   input archive log thread= sequence= recid= stamp=   input archive log thread= sequence= recid= stamp=   input archive log thread= sequence= recid= stamp=   input archive log thread= sequence= recid= stamp=   input archive log thread= sequence= recid= stamp=   input archive log thread= sequence= recid= stamp=   input archive log thread= sequence= recid= stamp=   input archive log thread= sequence= recid= stamp=   input archive log thread= sequence= recid= stamp=   input archive log thread= sequence= recid= stamp=   input archive log thread= sequence= recid= stamp=   channel ORA_DISK_ : starting piece at MAR   channel ORA_DISK_ : finished piece at MAR   piece handle=/opt/oracle/orabak/arch_PRIMARY_ _ ment=NONE  channel ORA_DISK_ : backup set plete elapsed time: : :   channel ORA_DISK_ : deleting archive log(s)  archive log filename=/opt/oracle/oradata/primary/archive/ _ dbf recid= stamp=   archive log filename=/opt/oracle/oradata/primary/archive/ _ dbf recid= stamp=   archive log filename=/opt/oracle/oradata/primary/archive/ _ dbf recid= stamp=   archive log filename=/opt/oracle/oradata/primary/archive/ _ dbf recid= stamp=   archive log filename=/opt/oracle/oradata/primary/archive/ _ dbf recid= stamp=   archive log filename=/opt/oracle/oradata/primary/archive/ _ dbf recid= stamp=   archive log filename=/opt/oracle/oradata/primary/archive/ _ dbf recid= stamp=   archive log filename=/opt/oracle/oradata/primary/archive/ _ dbf recid= stamp=   archive log filename=/opt/oracle/oradata/primary/archive/ _ dbf recid= stamp=   archive log filename=/opt/oracle/oradata/primary/archive/ _ dbf recid= stamp=   archive log filename=/opt/oracle/oradata/primary/archive/ _ dbf recid= stamp=   archive log filename=/opt/oracle/oradata/primary/archive/ _ dbf recid= stamp=   archive log filename=/opt/oracle/oradata/primary/archive/ _ dbf recid= stamp=   archive log filename=/opt/oracle/oradata/primary/archive/ _ dbf recid= stamp=   archive log filename=/opt/oracle/oradata/primary/archive/ _ dbf recid= stamp=   archive log filename=/opt/oracle/oradata/primary/archive/ _ dbf recid= stamp=   Finished backup at MAR

  Starting backup at MAR   using channel ORA_DISK_   channel ORA_DISK_ : starting full datafile backupset  channel ORA_DISK_ : specifying datafile(s) in backupset  input datafile fno= name=/opt/oracle/oradata/primary/system dbf  input datafile fno= name=/opt/oracle/oradata/primary/undotbs dbf  input datafile fno= name=/opt/oracle/oradata/primary/users dbf  channel ORA_DISK_ : starting piece at MAR   channel ORA_DISK_ : finished piece at MAR   piece handle=/opt/oracle/orabak/full_PRIMARY_ _ ment=NONE  channel ORA_DISK_ : backup set plete elapsed time: : :   Finished backup at MAR

  Starting backup at MAR   current log archived  using channel ORA_DISK_   channel ORA_DISK_ : starting archive log backupset  channel ORA_DISK_ : specifying archive log(s) in backup set  input archive log thread= sequence= recid= stamp=   channel ORA_DISK_ : starting piece at MAR   channel ORA_DISK_ : finished piece at MAR   piece handle=/opt/oracle/orabak/arch_PRIMARY_ _ ment=NONE  channel ORA_DISK_ : backup set plete elapsed time: : :   channel ORA_DISK_ : deleting archive log(s)  archive log filename=/opt/oracle/oradata/primary/archive/ _ dbf recid= stamp=   Finished backup at MAR

  Starting Control File and SPFILE Autobackup at MAR   piece handle=/opt/oracle/product/ /dbs/c ment=NONE  Finished Control File and SPFILE Autobackup at MAR

  RMAN> exit

  Recovery Manager plete

   移除所有控制文件及数据文件

  [oracle@standby oracle]$ sqlplus / as sysdba

  SQL*Plus: Release Production on Wed Mar : :

  Copyright (c) Oracle Corporation   All rights reserved

  Connected to:  Oracle i Enterprise Edition Release Production  With the Partitioning option  JServer Release Production

  SQL> shutdown immediate;  Database closed   Database dismounted   ORACLE instance shut down   SQL> exit  Disconnected from Oracle i Enterprise Edition Release Production  With the Partitioning option  JServer Release Production  [oracle@standby oracle]$ cd oradata/  [oracle@standby oradata]$ ls  primary

  [oracle@standby oradata]$ mv primary/ primarybak  [oracle@standby oradata]$ mkdir primary  [oracle@standby oradata]$ ls  primary  primarybak

   从自动备份中恢复控制文件

  [oracle@standby oradata]$ rman target /

  Recovery Manager: Release Production

  Copyright (c) Oracle Corporation   All rights reserved

  connected to target database (not started)

  RMAN> startup nomount;

  Oracle instance started

  Total System Global Area     bytes

  Fixed Size          bytes  Variable Size     bytes  Database Buffers        bytes  Redo Buffers        bytes

  RMAN> restore controlfile to /opt/oracle/oradata/control ctl from autobackup;

  Starting restore at MAR

  using target database controlfile instead of recovery catalog  allocated channel: ORA_DISK_   channel ORA_DISK_ : sid= devtype=DISK  RMAN : ===========================================================  RMAN : =============== ERROR MESSAGE STACK FOLLOWS ===============  RMAN : ===========================================================  RMAN : failure of restore mand at / / : :   RMAN : must explicitly specify DBID with SET DBID mand

  RMAN> set DBID=

  executing mand: SET DBID

  RMAN> restore controlfile to /opt/oracle/oradata/control ctl from autobackup;

  Starting restore at MAR

  using channel ORA_DISK_   channel ORA_DISK_ : looking for autobackup on day:   channel ORA_DISK_ : autobackup found: c   channel ORA_DISK_ : controlfile restore from autobackup plete  Finished restore at MAR

  RMAN> exit

  Recovery Manager plete

   你可能需要修改spfile文件

  当然如果文件位置等信息没有变化就无需修改

  [oracle@standby oradata]$ sqlplus / as sysdba

  SQL*Plus: Release Production on Wed Mar : :

  Copyright (c) Oracle Corporation   All rights reserved

  Connected to:  Oracle i Enterprise Edition Release Production  With the Partitioning option  JServer Release Production

  SQL> create pfile from spfile;

  File created

  SQL> !  [oracle@standby oradata]$ cd $ORACLE_HOME/dbs  [oracle@standby dbs]$ vi initprimary ora

  * aq_tm_processes=   * background_dump_dest= /opt/oracle/admin/primary/bdump   patible=   ntrol_files= /opt/oracle/oradata/control ctl   re_dump_dest= /opt/oracle/admin/primary/cdump   * db_block_size=   * db_cache_size=   * db_domain=   * db_file_multiblock_read_count=   * db_name= primary   * fast_start_mttr_target=   * hash_join_enabled=TRUE  * instance_name= primary   * java_pool_size=   * job_queue_processes=   * large_pool_size=   * log_archive_dest_ = LOCATION=/opt/oracle/oradata/primary/archive   * log_archive_format= %t_%s dbf   * log_archive_start=true  * open_cursors=   * pga_aggregate_target=   * processes=   * query_rewrite_enabled= FALSE   * remote_login_passwordfile= EXCLUSIVE   * resource_manager_plan= SYSTEM_PLAN   * shared_pool_size=   * sort_area_size=   * star_transformation_enabled= FALSE   * timed_statistics=TRUE  * undo_management= AUTO   * undo_retention=   * undo_tablespace= UNDOTBS   * user_dump_dest= /opt/oracle/admin/primary/udump   * utl_file_dir= /opt/oracle   ~  ~  ~  ~  ~   initprimary ora L C written  [oracle@standby dbs]$ exit  exit

  SQL> shutdown immediate;  ORA : database not mounted

  ORACLE instance shut down   SQL> create spfile from pfile;

  File created

  SQL> startup mount;  ORACLE instance started

  Total System Global Area  bytes  Fixed Size       bytes  Variable Size       bytes  Database Buffers     bytes  Redo Buffers     bytes  Database mounted   SQL> exit  Disconnected from Oracle i Enterprise Edition Release Production  With the Partitioning option  JServer Release Production

   使用rman进行恢复

  [oracle@standby oradata]$ rman target /

  Recovery Manager: Release Production

  Copyright (c) Oracle Corporation   All rights reserved

  connected to target database: PRIMARY (DBID= )

  RMAN> restore database;

  Starting restore at MAR

  using target database controlfile instead of recovery catalog  allocated channel: ORA_DISK_   channel ORA_DISK_ : sid= devtype=DISK  channel ORA_DISK_ : starting datafile backupset restore  channel ORA_DISK_ : specifying datafile(s) to restore from backup set  restoring datafile to /opt/oracle/oradata/primary/system dbf  restoring datafile to /opt/oracle/oradata/primary/undotbs dbf  restoring datafile to /opt/oracle/oradata/primary/users dbf  channel ORA_DISK_ : restored backup piece   piece handle=/opt/oracle/orabak/full_PRIMARY_ _ tag=TAG T params=NULL  channel ORA_DISK_ : restore plete  Finished restore at MAR

  RMAN> recover database;

  Starting recover at MAR   using channel ORA_DISK_

  starting media recovery

  channel ORA_DISK_ : starting archive log restore to default destination  channel ORA_DISK_ : restoring archive log  archive log thread= sequence=   channel ORA_DISK_ : restored backup piece   piece handle=/opt/oracle/orabak/arch_PRIMARY_ _ tag=TAG T params=NULL  channel ORA_DISK_ : restore plete  archive log filename=/opt/oracle/oradata/primary/archive _ dbf thread= sequence=   unable to find archive log  archive log thread= sequence=   RMAN : ===========================================================  RMAN : =============== ERROR MESSAGE STACK FOLLOWS ===============  RMAN : ===========================================================  RMAN : failure of recover mand at / / : :   RMAN : media recovery requesting unknown log: thread scn

  RMAN> alter database open resetlogs;

  database opened

  RMAN>

cha138/Article/program/Oracle/201311/18221

相关参考

知识大全 无备份丢失部分数据文件和控制文件恢复

  前提:         需要有除丢失文件以外其他文件的备份       &n

知识大全 oraclerman命令

  从网络上找到rman命令集合  一list常用命令总结备忘  list命令列出控制文件RMAN恢复目录中备份信息是我们对所有可见的数据库备份文件的一个最直观的了解的方法  listincarnat

知识大全 数据库备份与恢复测试(6)

  [测试]数据库在非归档模式数据库MOUNT数据文件丢失有表空间备份  RMAN>backuptablespaceusers;  启动backup于月分配的通道:ORA_DISK_通道ORA_

知识大全 如何恢复一个丢失的数据文件

  如果您目前拥有一个冷备份但是缺少了其中的一个数据文件但你目前存在所有的归档如果您要恢复数据文件可以参考以下的示例  [oracle@jumpereygle]$sqlplus/assysdba  S

知识大全 RMAN(备份与恢复管理器)

Oracle数据库备份与恢复之四:RMAN(备份与恢复管理器)  以下文字资料是由(全榜网网www.cha138.com)小编为大家搜集整理后发布的内容,让我们赶快一起来

知识大全 如何简单测试Rman的备份恢复功能?

如何简单测试Rman的备份恢复功能?  以下文字资料是由(全榜网网www.cha138.com)小编为大家搜集整理后发布的内容,让我们赶快一起来看一下吧!  本文只是简单

知识大全 完整的oracle rman备份恢复的例子

  建rman库作为repository  $morecreaterman_dbsh  setechoon  spoolmakedblog  createdatabaserman  datafile/

知识大全 oracle从备份的控制文件进行完全恢复

  oracle从备份的控制文件进行完全恢复  SYS@orcl#shutdownabort;  ORACLE例程已经关闭  SYS@orcl#  oracle@oracle:~/product//d

知识大全 oracle配置归档模式

  非归档  数据能恢复到最后一次备份  只能做全部恢复不能做部分恢复  只能脱机备份  归档  数据能恢复到失败点无数据丢失  可以热备份  完全恢复和部分恢复都行部分恢复文件中不一致的检查点可以用

知识大全 表的许多分区被意外drop用rman不完全恢复

  如果表的很多分区被意外drop需要利用带库上的备份集在测试机上做不完全恢复具体日期需要达到一个特定的时间那么我们可以参考下文  ◆首先需要用logminer查出删除语句    unpress/or