RMAN全库备份
说明:详情请参考oracle dba高可用、备份与恢复与性能优化这本书的第232页
一、RMAN实现脱机备份
1、要实现脱机备份首先需要使用RMAN登录到数据库服务器,关闭数据库然后启动数据库导mount状态,再执行backup database指令备份整个数据库
[oracle@i-1pbhgm8j root]$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.4.0 Production on Thu Sep 21 11:25:27 2017
Copyright (c) 1982, 2013, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup mount
ORACLE instance started.
Total System Global Area 2471931904 bytes
Fixed Size 2255752 bytes
Variable Size 620758136 bytes
Database Buffers 1828716544 bytes
Redo Buffers 20201472 bytes
Database mounted.
SQL> exit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
[oracle@i-1pbhgm8j root]$ rman target /
Recovery Manager: Release 11.2.0.4.0 - Production on Thu Sep 21 11:26:00 2017
Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
connected to target database: ORCL (DBID=1482393104, not open)
RMAN>
backup as compressed backupset database ;
Starting backup at 21-SEP-17
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=63 device type=DISK
channel ORA_DISK_1: starting compressed full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00001 name=/u01/app/oracle/oradata/orcl/system01.dbf
input datafile file number=00003 name=/u01/app/oracle/oradata/orcl/undotbs01.dbf
input datafile file number=00002 name=/u01/app/oracle/oradata/orcl/sysaux01.dbf
input datafile file number=00005 name=/u01/app/oracle/oradata/orcl/kmdata01.dbf
input datafile file number=00006 name=/u01/app/oracle/oradata/orcl/kmdata02.dbf
input datafile file number=00007 name=/u01/app/oracle/oradata/orcl/kmdata03.dbf
input datafile file number=00008 name=/u01/app/oracle/oradata/orcl/KMPRODUCT_INDEX01.dbf
input datafile file number=00009 name=/u01/app/oracle/oradata/orcl/KMUSER_INDEX01.dbf
input datafile file number=00010 name=/u01/app/oracle/oradata/orcl/KMORDER_INDEX01.dbf
input datafile file number=00011 name=/u01/app/oracle/oradata/orcl/KMSEARCH01.dbf
input datafile file number=00004 name=/u01/app/oracle/oradata/orcl/users01.dbf
channel ORA_DISK_1: starting piece 1 at 21-SEP-17
channel ORA_DISK_1: finished piece 1 at 21-SEP-17
piece handle=/u01/app/oracle/product/11.2.0/db_1/dbs/03sf0q6t_1_1 tag=TAG20170921T112621 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:35
channel ORA_DISK_1: starting compressed full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
including current control file in backup set
including current SPFILE in backup set
channel ORA_DISK_1: starting piece 1 at 21-SEP-17
channel ORA_DISK_1: finished piece 1 at 21-SEP-17
piece handle=/u01/app/oracle/product/11.2.0/db_1/dbs/04sf0q81_1_1 tag=TAG20170921T112621 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 21-SEP-17
打开数据库
RMAN> sql 'alter database open';
sql statement: alter database open
二、RMAN实现联机备份
1、在使用联机备份前,必须设置快闪恢复区,将
db_recovery_file_dest参数执行的目录作为归档重做日志备份的默认位置,并且将快闪恢复区的尺寸设置的要足够大
2、
需要将数据库设置为归档模式
[oracle@i-1pbhgm8j root]$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.4.0 Production on Thu Sep 21 11:53:02 2017
Copyright (c) 1982, 2013, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
[oracle@i-1pbhgm8j root]$
rman target /
Recovery Manager: Release 11.2.0.4.0 - Production on Thu Sep 21 13:44:46 2017
Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
connected to target database: ORCL (DBID=1482393104)
RMAN>
backup as compressed backupset database plus archivelog delete all input;
小结:backup database联机备份整个数据库。目的是不但备份数据文件同时备份归档日志文件,在备份完成归档日志文件后,将之前已经备份的归档日志文件从存储目录中删除,这样既备份了归档日志文件,同时清理了归档空间
Starting backup at 21-SEP-17
current log archived
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=68 device type=DISK
channel ORA_DISK_1: starting compressed archived log backup set
channel ORA_DISK_1: specifying archived log(s) in backup set
input archived log thread=1 sequence=90 RECID=1 STAMP=955287920
channel ORA_DISK_1: starting piece 1 at 21-SEP-17
channel ORA_DISK_1: finished piece 1 at 21-SEP-17
piece handle=/u01/app/oracle/product/11.2.0/db_1/dbs/05sf12bg_1_1 tag=TAG20170921T134520 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
channel ORA_DISK_1: deleting archived log(s)
archived log file name=/u01/app/oracle/product/11.2.0/db_1/dbs/arch1_90_954612368.dbf RECID=1 STAMP=955287920
Finished backup at 21-SEP-17
Starting backup at 21-SEP-17
using channel ORA_DISK_1
channel ORA_DISK_1: starting compressed full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00001 name=/u01/app/oracle/oradata/orcl/system01.dbf
input datafile file number=00003 name=/u01/app/oracle/oradata/orcl/undotbs01.dbf
input datafile file number=00002 name=/u01/app/oracle/oradata/orcl/sysaux01.dbf
input datafile file number=00005 name=/u01/app/oracle/oradata/orcl/kmdata01.dbf
input datafile file number=00006 name=/u01/app/oracle/oradata/orcl/kmdata02.dbf
input datafile file number=00007 name=/u01/app/oracle/oradata/orcl/kmdata03.dbf
input datafile file number=00008 name=/u01/app/oracle/oradata/orcl/KMPRODUCT_INDEX01.dbf
input datafile file number=00009 name=/u01/app/oracle/oradata/orcl/KMUSER_INDEX01.dbf
input datafile file number=00010 name=/u01/app/oracle/oradata/orcl/KMORDER_INDEX01.dbf
input datafile file number=00011 name=/u01/app/oracle/oradata/orcl/KMSEARCH01.dbf
input datafile file number=00004 name=/u01/app/oracle/oradata/orcl/users01.dbf
channel ORA_DISK_1: starting piece 1 at 21-SEP-17
channel ORA_DISK_1: finished piece 1 at 21-SEP-17
piece handle=/u01/app/oracle/product/11.2.0/db_1/dbs/06sf12bh_1_1 tag=TAG20170921T134521 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:35
channel ORA_DISK_1: starting compressed full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
including current control file in backup set
including current SPFILE in backup set
channel ORA_DISK_1: starting piece 1 at 21-SEP-17
channel ORA_DISK_1: finished piece 1 at 21-SEP-17
piece handle=/u01/app/oracle/product/11.2.0/db_1/dbs/07sf12cl_1_1 tag=TAG20170921T134521 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 21-SEP-17
Starting backup at 21-SEP-17
current log archived
using channel ORA_DISK_1
channel ORA_DISK_1: starting compressed archived log backup set
channel ORA_DISK_1: specifying archived log(s) in backup set
input archived log thread=1 sequence=91 RECID=2 STAMP=955287961
channel ORA_DISK_1: starting piece 1 at 21-SEP-17
channel ORA_DISK_1: finished piece 1 at 21-SEP-17
piece handle=/u01/app/oracle/product/11.2.0/db_1/dbs/08sf12cp_1_1 tag=TAG20170921T134601 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
channel ORA_DISK_1: deleting archived log(s)
archived log file name=/u01/app/oracle/product/11.2.0/db_1/dbs/arch1_91_954612368.dbf RECID=2 STAMP=955287961
Finished backup at 21-SEP-17