RMAN备份恢复(控制文件)

           1

控制文件中存在什么:

----BDIDDB_NAME,DBID,INSTANCE_NAME,SID,DB_GLOBAL_NAME)

----数据文件的物理位置

----当前的检查点信息(v$datafile

SQL> select name from v$database;

 

NAME

---------

ENMOEDU

SQL> show parameter db_name;

 

NAME                                     TYPE         VALUE

------------------------------------ ----------- ------------------------------

db_name                              string         enmoedu------相当于人的名字

SQL> select dbid from v$database;

 

      DBID-------用来区分数据文件是属于哪一个数据库的

----------

 163971148--------------相当于人的身份证号 (在创建数据库时,根据db_name随机的算出来的一个数字)

SQL> show parameter db_unique_name;

 

NAME                                     TYPE         VALUE

------------------------------------ ----------- ------------------------------

db_unique_name                             string         enmoedu-------------默认和db_name是一致的;在DG中来区分每一个数据库的名字

SQL> show parameter instance_name;

 

NAME                                     TYPE         VALUE

------------------------------------ ----------- ------------------------------

instance_name                             string         enmoedu---------------------数据库的实例,默认和SID是一样的;用在RAC架构下。

[oracle@enmoedu alert]$ echo $ORACLE_SID

enmoedu

[oracle@enmoedu alert]$ ps -ef |grep pmon

oracle     6449      1  0 14:37 ?        00:00:01 ora_pmon_enmoedu-----------SID,用来区分SGA

oracle     7267   2610  0 16:09 pts/0    00:00:00 grep pmon

 

2

控制文件怎么做备份
假如删除了一个控制文件,只需要将没有删除的控制文件拷贝一份,然后重命名就可以恢复了;

备份控制文件的语句:

RMAN> list backup of controlfile;----查看备份文件的语句;没有开启自动备份,却有备份,这样的备份我们叫隐式备份;

RMAN> show all;

 

RMAN configuration parameters for database with db_unique_name ENMOEDU are:

CONFIGURE RETENTION POLICY TO REDUNDANCY 1; # default

CONFIGURE BACKUP OPTIMIZATION OFF; # default

CONFIGURE DEFAULT DEVICE TYPE TO DISK; # default

CONFIGURE CONTROLFILE AUTOBACKUP OFF; # default-----------自动备份控制文件是关闭的;

RMAN> CONFIGURE CONTROLFILE AUTOBACKUP ON;------------------开启自动备份控制文件

 

new RMAN configuration parameters:

CONFIGURE CONTROLFILE AUTOBACKUP ON;

new RMAN configuration parameters are successfully stored

 

RMAN> BACKUP TABLESPACE EXAMPLE;

 

Starting backup at 13-MAR-16

allocated channel: ORA_DISK_1

channel ORA_DISK_1: SID=19 device type=DISK

channel ORA_DISK_1: starting full datafile backup set

channel ORA_DISK_1: specifying datafile(s) in backup set

input datafile file number=00005 name=/u01/app/oracle/oradata/enmoedu/example01.dbf

channel ORA_DISK_1: starting piece 1 at 13-MAR-16

channel ORA_DISK_1: finished piece 1 at 13-MAR-16

piece handle=/u01/app/oracle/fast_recovery_area/ENMOEDU/backupset/2016_03_13/o1_mf_nnndf_TAG20160313T162551_cgb90hfj_.bkp tag=TAG20160313T162551 comment=NONE

channel ORA_DISK_1: backup set complete, elapsed time: 00:00:03

Finished backup at 13-MAR-16

 

Starting Control File and SPFILE Autobackup at 13-MAR-16

piece handle=/u01/app/oracle/fast_recovery_area/ENMOEDU/autobackup/2016_03_13/o1_mf_s_906395154_cgb90lph_.bkp comment=NONE

Finished Control File and SPFILE Autobackup at 13-MAR-16

 

RMAN> list backup of controlfile;

 

 

List of Backup Sets

===================

 

 

BS Key  Type LV Size       Device Type Elapsed Time Completion Time

------- ---- -- ---------- ----------- ------------ ---------------

4       Full    9.36M      DISK        00:00:00     13-MAR-16     

        BP Key: 4   Status: AVAILABLE  Compressed: NO  Tag: TAG20160313T162554

        Piece Name: /u01/app/oracle/fast_recovery_area/ENMOEDU/autobackup/2016_03_13/o1_mf_s_906395154_cgb90lph_.bkp---------因为是开启了自动备份

  Control File Included: Ckp SCN: 1046493      Ckp time: 13-MAR-16

 

 

 

RMAN> backup current controlfile;-------------手动备份控制文件

 

Starting backup at 13-MAR-16

using target database control file instead of recovery catalog

allocated channel: ORA_DISK_1

channel ORA_DISK_1: SID=21 device type=DISK

channel ORA_DISK_1: starting full datafile backup set

channel ORA_DISK_1: specifying datafile(s) in backup set

including current control file in backup set

channel ORA_DISK_1: starting piece 1 at 13-MAR-16

channel ORA_DISK_1: finished piece 1 at 13-MAR-16

piece handle=/u01/app/oracle/fast_recovery_area/ENMOEDU/backupset/2016_03_13/o1_mf_ncnnf_TAG20160313T163100_cgb9b5n3_.bkp tag=TAG20160313T163100 comment=NONE

channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01

Finished backup at 13-MAR-16

现在我们删除控制文件做一下恢复控制文件的实验;

[oracle@enmoedu enmoedu]$ ls

control01.ctl  redo01.log  redo03.log    system01.dbf  undotbs01.dbf

example01.dbf  redo02.log  sysaux01.dbf  temp01.dbf    users01.dbf

[oracle@enmoedu enmoedu]$ rm control01.ctl

[oracle@enmoedu enmoedu]$ ls

example01.dbf  redo02.log  sysaux01.dbf  temp01.dbf     users01.dbf

redo01.log     redo03.log  system01.dbf  undotbs01.dbf

 

SQL> startup

ORACLE instance started.

 

Total System Global Area  830930944 bytes

Fixed Size                    2257800 bytes

Variable Size                  536874104 bytes

Database Buffers          285212672 bytes

Redo Buffers                    6586368 bytes

ORA-00205: error in identifying control file, check alert log for more info----------------控制文件丢失了,所以数据库是启动不了了;那么现在就恢复控制文件;

 

RMAN> restore controlfile;

 

Starting restore at 13-MAR-16

using target database control file instead of recovery catalog

allocated channel: ORA_DISK_1

channel ORA_DISK_1: SID=10 device type=DISK

 

RMAN-00571: ===========================================================

RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============

RMAN-00571: ===========================================================

RMAN-03002: failure of restore command at 03/13/2016 20:10:38

RMAN-06563: control file or SPFILE must be restored using FROM AUTOBACKUP-------因为我手动备份了一份控制文件,又自动备份了一份控制文件,所以他不知道去哪找,所以必须得指定一个位置;

 

RMAN> restore controlfile from autobackup;

 

Starting restore at 13-MAR-16

using channel ORA_DISK_1

 

recovery area destination: /u01/app/oracle/fast_recovery_area

database name (or database unique name) used for search: ENMOEDU

channel ORA_DISK_1: AUTOBACKUP /u01/app/oracle/fast_recovery_area/ENMOEDU/autobackup/2016_03_13/o1_mf_s_906408140_cgbow726_.bkp found in the recovery area

AUTOBACKUP search with format "%F" not attempted because DBID was not set

channel ORA_DISK_1: restoring control file from AUTOBACKUP /u01/app/oracle/fast_recovery_area/ENMOEDU/autobackup/2016_03_13/o1_mf_s_906408140_cgbow726_.bkp

channel ORA_DISK_1: control file restore from AUTOBACKUP complete

output file name=/u01/app/oracle/oradata/enmoedu/control01.ctl

output file name=/u01/app/oracle/fast_recovery_area/enmoedu/control02.ctl

Finished restore at 13-MAR-16

现在我们看数据库能不能启动、???SQL> shutdown immediate

ORA-01507: database not mounted

 

 

ORACLE instance shut down.

SQL> startup

ORACLE instance started.

 

Total System Global Area  830930944 bytes

Fixed Size                    2257800 bytes

Variable Size                  536874104 bytes

Database Buffers          285212672 bytes

Redo Buffers                    6586368 bytes

Database mounted.

ORA-01589: must use RESETLOGS or NORESETLOGS option for database open----------此时就得做一次不完全恢复

 

 

SQL> alter database open resetlogs;

 

Database altered.

SQL> startup

ORACLE instance started.

 

Total System Global Area  830930944 bytes

Fixed Size                    2257800 bytes

Variable Size                  536874104 bytes

Database Buffers          285212672 bytes

Redo Buffers                    6586368 bytes

Database mounted.

Database opened.-------------数据库成功启动

看看控制文件有没有回来????

[oracle@enmoedu enmoedu]$ ls

control01.ctl  example01.dbf  redo02.log  sysaux01.dbf  temp01.dbf     users01.dbf

control02.ctl  redo01.log     redo03.log  system01.dbf  undotbs01.dbf

 

3

SQL> select GROUP#,STATUS,sequence# from v$log;

 

    GROUP# STATUS             SEQUENCE#

---------- ---------------- ----------

 1 CURRENT                     1--------------因为刚刚做了一个不完全恢复,做了一次化身,等于清空了以前的日志记录;而没做完一次化身我们必须得做一次全库备份的好习惯;

 2 UNUSED                     0

 3 UNUSED                     0

4

切换几次日志看一下;

SQL> select group#,status,sequence# from v$log;

 

    GROUP# STATUS             SEQUENCE#

---------- ---------------- ----------

 1 INACTIVE                     4

 2 INACTIVE                     5

 3 CURRENT                     6

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/30606702/viewspace-2058427/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/30606702/viewspace-2058427/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值