冷备份 Oracle 的流程

下周的工作主要是进行一次 Oracle 的恢复演练,主要的操作就是利用 Oracle 的 RMAN 工具利用 Tivoli Storage Manager 的磁带中备份数据把 Oracle 数据库恢复到制定时间,由于只是恢复演练,所以工作完成后,还需要把演练用的数据库恢复到到演练前的状态,所以只能事先用 Oracle 冷...显示全部
下周的工作主要是进行一次 Oracle 的恢复演练,主要的操作就是利用 Oracle 的 RMAN 工具利用 Tivoli Storage Manager 的磁带中备份数据把 Oracle 数据库恢复到制定时间,由于只是恢复演练,所以工作完成后,还需要把演练用的数据库恢复到到演练前的状态,所以只能事先用 Oracle 冷备份的方式把 Oracle 备份一下,我咨询了我们公司的 DBA 详细的冷备份流程,决定写到这里加强记忆一下,冷备份的过程还是很简单易懂的,Oracle 冷备份的通常步骤如下:

    正常关闭数据库
    备份所有重要的文件到备份目录(数据文件、控制文件、重做日志文件等)
    完成备份后启动数据库

用冷备份进行恢复时,只需要将所有文件恢复到原有位置,就可以启动数据库了 。其详细的冷备份过程如下:

    进入数据库:#sqlplus “/as sysdba”
    查看数据库当前状态:SQL>select status from v$instance;
    如果没有启动则要启动:SQL>startup;
    查询数据文件 datafile 的所在目录:SQL>SELECT name FROM v$datafile;
    查询控制文件 controlfile 的所在目录:SQL>SELECT name FROM v$controlfile;
    查询重做日志文件的所在目录:SQL> SELECT member FROM v$logfile;
    查询归档日志文件的所在目录:
    SQL> show parameter arch;
    SQL> SELECT name from V$ARCHIVED_LOG;
    关闭数据库:SQL>shutdown immediate;
    备份相关文件到备份的目录:
    #cp /home/oracle/oradata/Test/*.dbf /home/BackupDatabase/datafiles
    #cp /home/oracle/oradata/Test/*.ctl /home/BackupDatabase/controlfiles
    #cp /home/oracle/oradata/Test/*.log /home/BackupDatabase/redologs
    #cp /home/oracle/arch/*.dbf /home/BackupDatabase/archivelogs
    启动数据库:SQL>startup;

下面日志的是我今天在实验机上做的冷备份实践,贴在这里以后参考一下:

    [root@newtest ~]# su – oracle

    [oracle@newtest ~]$ env | grep SID

    ORACLE_SID=Test

    [oracle@newtest ~]$ sqlplus ‘/as sysdba’

    SQL*Plus: Release 10.2.0.4.0 – Production on Fri Apr 29 09:32:22 2011

    Copyright (c) 1982, 2007, Oracle. All Rights Reserved.

    Connected to:

    Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 – 64bit Production

    With the Partitioning, OLAP, Data Mining and Real Application Testing options

    SQL> select status from v$instance;

    STATUS
    ————
    OPEN

    SQL> SELECT name FROM v$datafile;

    NAME
    ——————————————————————————–
    /home/oracle/oradata/Test/system01.dbf
    /home/oracle/oradata/Test/undotbs01.dbf
    /home/oracle/oradata/Test/sysaux01.dbf
    /home/oracle/oradata/Test/users01.dbf
    /home/oracle/oradata/Test/aeonlife.dbf
    /home/oracle/oradata/Test/jbpm.dbf
    /home/oracle/oradata/Test/lportal.dbf
    /home/oracle/oradata/recovery/recovery.dbf

    8 rows selected.

    SQL> SELECT name FROM v$controlfile;

    NAME
    ——————————————————————————–
    /home/oracle/oradata/Test/control01.ctl
    /home/oracle/oradata/Test/control02.ctl
    /home/oracle/oradata/Test/control03.ctl

    SQL> SELECT member FROM v$logfile;

    MEMBER
    ——————————————————————————–
    /home/oracle/oradata/Test/redo03.log
    /home/oracle/oradata/Test/redo02.log
    /home/oracle/oradata/Test/redo01.log

    SQL> show parameter arch;

    NAME TYPE VALUE
    ———————————— ———– ——————————
    archive_lag_target integer 0
    log_archive_config string
    log_archive_dest string
    log_archive_dest_1 string location=/home/oracle/arch
    log_archive_dest_10 string
    log_archive_dest_2 string
    log_archive_dest_3 string
    log_archive_dest_4 string
    log_archive_dest_5 string
    log_archive_dest_6 string
    log_archive_dest_7 string

    NAME TYPE VALUE
    ———————————— ———– ——————————
    log_archive_dest_8 string
    log_archive_dest_9 string
    log_archive_dest_state_1 string enable
    log_archive_dest_state_10 string enable
    log_archive_dest_state_2 string enable
    log_archive_dest_state_3 string enable
    log_archive_dest_state_4 string enable
    log_archive_dest_state_5 string enable
    log_archive_dest_state_6 string enable
    log_archive_dest_state_7 string enable
    log_archive_dest_state_8 string enable

    NAME TYPE VALUE
    ———————————— ———– ——————————
    log_archive_dest_state_9 string enable
    log_archive_duplex_dest string
    log_archive_format string %t_%s_%r.dbf
    log_archive_local_first boolean TRUE
    log_archive_max_processes integer 3
    log_archive_min_succeed_dest integer 1
    log_archive_start boolean FALSE
    log_archive_trace integer 0
    remote_archive_enable string true
    standby_archive_dest string ?/dbs/arch

    SQL> select name from V$ARCHIVED_LOG;

    NAME
    ——————————————————————————–
    /home/oracle/arch/1_391_739032328.dbf
    /home/oracle/arch/1_392_739032328.dbf
    /home/oracle/arch/1_393_739032328.dbf
    /home/oracle/arch/1_394_739032328.dbf
    /home/oracle/arch/1_395_739032328.dbf
    /home/oracle/arch/1_396_739032328.dbf
    /home/oracle/arch/1_397_739032328.dbf
    /home/oracle/arch/1_398_739032328.dbf
    /home/oracle/arch/1_399_739032328.dbf
    /home/oracle/arch/1_400_739032328.dbf
    /home/oracle/arch/1_401_739032328.dbf

    NAME
    ——————————————————————————–
    /home/oracle/arch/1_402_739032328.dbf
    /home/oracle/arch/1_403_739032328.dbf
    /home/oracle/arch/1_404_739032328.dbf
    /home/oracle/arch/1_405_739032328.dbf
    /home/oracle/arch/1_406_739032328.dbf
    /home/oracle/arch/1_407_739032328.dbf
    /home/oracle/arch/1_408_739032328.dbf
    /home/oracle/arch/1_409_739032328.dbf
    /home/oracle/arch/1_410_739032328.dbf
    /home/oracle/arch/1_411_739032328.dbf
    /home/oracle/arch/1_412_739032328.dbf

    NAME
    ——————————————————————————–
    /home/oracle/arch/1_413_739032328.dbf
    /home/oracle/arch/1_414_739032328.dbf
    /home/oracle/arch/1_415_739032328.dbf
    /home/oracle/arch/1_416_739032328.dbf
    /home/oracle/arch/1_417_739032328.dbf
    /home/oracle/arch/1_418_739032328.dbf
    /home/oracle/arch/1_419_739032328.dbf
    /home/oracle/arch/1_420_739032328.dbf
    /home/oracle/arch/1_421_739032328.dbf
    /home/oracle/arch/1_422_739032328.dbf
    /home/oracle/arch/1_423_739032328.dbf

    NAME
    ——————————————————————————–
    /home/oracle/arch/1_424_739032328.dbf
    /home/oracle/arch/1_425_739032328.dbf

    35 rows selected.

    SQL> shutdown immediate;

    Database closed.

    Database dismounted.

    ORACLE instance shut down.

    SQL> host;

    [oracle@newtest ~]$ cp /home/oracle/oradata/Test/*.dbf /home/BackupDatabase/datafiles

    [oracle@newtest ~]$ cp /home/oracle/oradata/Test/*.ctl /home/BackupDatabase/controlfiles

    [oracle@newtest ~]$ cp /home/oracle/oradata/Test/*.log /home/BackupDatabase/redologs

    [oracle@newtest ~]$ cp /home/oracle/arch/*.dbf /home/BackupDatabase/archivelogs

    [oracle@newtest home]$ exit

    exit

    SQL> startup;

    ORACLE instance started.

    Total System Global Area 1224736768 bytes

    Fixed Size 2083560 bytes

    Variable Size 654312728 bytes

    Database Buffers 553648128 bytes

    Redo Buffers 14692352 bytes

    Database mounted.

    Database opened.

    SQL>收起
参与3

查看其它 1 个回答liuhua027的回答

liuhua027liuhua027数据库管理员xx
不错,学习了。
金融其它 · 2012-03-29
浏览925

回答者

liuhua027
数据库管理员xx

liuhua027 最近回答过的问题

回答状态

  • 发布时间:2012-03-29
  • 关注会员:1 人
  • 回答浏览:925
  • X社区推广