rman备份temp表空间吗?temp文件为稀疏文件?

来源:互联网 发布:谁有数据人生txt下载 编辑:程序博客网 时间:2024/05/18 20:48

  今天是2013-11-25,有个陌生的朋友说rman备份数据库的时候会备份表空间,下面进行如下讨论:

事实验证:

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@oracle-one RHYS]$ rman target /

Recovery Manager: Release 11.2.0.4.0 - Production on Mon Nov 25 16:40:47 2013

Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.

connected to target database: RHYS (DBID=2743302915)

RMAN> backup database include current controlfile plus archivelog delete input;


Starting backup at 25-NOV-13
current log archived
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=32 device type=DISK
channel ORA_DISK_1: starting archived log backup set
channel ORA_DISK_1: specifying archived log(s) in backup set
input archived log thread=1 sequence=49 RECID=6 STAMP=832368653
input archived log thread=1 sequence=50 RECID=7 STAMP=832368754
input archived log thread=1 sequence=51 RECID=8 STAMP=832369118
input archived log thread=1 sequence=52 RECID=9 STAMP=832412860
input archived log thread=1 sequence=53 RECID=10 STAMP=832437672
channel ORA_DISK_1: starting piece 1 at 25-NOV-13
channel ORA_DISK_1: finished piece 1 at 25-NOV-13
piece handle=/opt/app/oracle/fast_recovery_area/RHYS/backupset/2013_11_25/o1_mf_annnn_TAG20131125T164113_99639b1m_.bkp tag=TAG20131125T164113 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:08
channel ORA_DISK_1: deleting archived log(s)
archived log file name=/opt/app/oracle/fast_recovery_area/RHYS/archivelog/2013_11_24/o1_mf_1_49_993zwf0w_.arc RECID=6 STAMP=832368653
archived log file name=/opt/app/oracle/fast_recovery_area/RHYS/archivelog/2013_11_24/o1_mf_1_50_993zzlsy_.arc RECID=7 STAMP=832368754
archived log file name=/opt/app/oracle/fast_recovery_area/RHYS/archivelog/2013_11_24/o1_mf_1_51_9940bxds_.arc RECID=8 STAMP=832369118
archived log file name=/opt/app/oracle/fast_recovery_area/RHYS/archivelog/2013_11_25/o1_mf_1_52_995c1vxo_.arc RECID=9 STAMP=832412860
archived log file name=/opt/app/oracle/fast_recovery_area/RHYS/archivelog/2013_11_25/o1_mf_1_53_99639770_.arc RECID=10 STAMP=832437672
Finished backup at 25-NOV-13

Starting backup at 25-NOV-13
using channel ORA_DISK_1
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00001 name=/opt/app/oracle/oradata/RHYS/system01.dbf
input datafile file number=00004 name=/opt/app/oracle/oradata/RHYS/users01.dbf
input datafile file number=00002 name=/opt/app/oracle/oradata/RHYS/sysaux01.dbf
input datafile file number=00006 name=/opt/app/oracle/oradata/RHYS/test01.dbf
input datafile file number=00003 name=/opt/app/oracle/oradata/RHYS/undotbs01.dbf
input datafile file number=00005 name=/opt/app/oracle/oradata/RHYS/test.dbf

channel ORA_DISK_1: starting piece 1 at 25-NOV-13
channel ORA_DISK_1: finished piece 1 at 25-NOV-13
piece handle=/opt/app/oracle/fast_recovery_area/RHYS/backupset/2013_11_25/o1_mf_nnndf_TAG20131125T164122_99639lv5_.bkp tag=TAG20131125T164122 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:01:05
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
including current SPFILE in backup set
channel ORA_DISK_1: starting piece 1 at 25-NOV-13
channel ORA_DISK_1: finished piece 1 at 25-NOV-13
piece handle=/opt/app/oracle/fast_recovery_area/RHYS/backupset/2013_11_25/o1_mf_ncsnf_TAG20131125T164122_9963co39_.bkp tag=TAG20131125T164122 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 25-NOV-13

Starting backup at 25-NOV-13
current log archived
using channel ORA_DISK_1
channel ORA_DISK_1: starting archived log backup set
channel ORA_DISK_1: specifying archived log(s) in backup set
input archived log thread=1 sequence=54 RECID=11 STAMP=832437750
channel ORA_DISK_1: starting piece 1 at 25-NOV-13
channel ORA_DISK_1: finished piece 1 at 25-NOV-13
piece handle=/opt/app/oracle/fast_recovery_area/RHYS/backupset/2013_11_25/o1_mf_annnn_TAG20131125T164230_9963cps7_.bkp tag=TAG20131125T164230 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=/opt/app/oracle/fast_recovery_area/RHYS/archivelog/2013_11_25/o1_mf_1_54_9963cpcd_.arc RECID=11 STAMP=832437750
Finished backup at 25-NOV-13

RMAN>

可以看到是没有备份临时表空间的,如果在删除了临时表空间后在次启动的时候会自动创建临时表空间

SQL> select * from v$tempfile;

     FILE# CREATION_CHANGE# CREATION_        TS#     RFILE# STATUS  ENABLED         BYTES     BLOCKS CREATE_BYTES BLOCK_SIZE
---------- ---------------- --------- ---------- ---------- ------- ---------- ---------- ---------- ------------ ----------
NAME
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
         1           925795 07-NOV-13          3          1 ONLINE  READ WRITE   10477568       1279     20971520       8192
/opt/app/oracle/oradata/RHYS/temp01.dbf

         2          1578328 25-NOV-13          7          1 ONLINE  READ WRITE  209715200      25600    209715200       8192
/opt/app/oracle/oradata/RHYS/temp02.dbf


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@oracle-one RHYS]$ ls -l temp*
-rw-r-----. 1 oracle oinstall  10485760 Nov 25 15:48 temp01.dbf
-rw-r-----. 1 oracle oinstall 209723392 Nov 25 16:32 temp02.dbf
[oracle@oracle-one RHYS]$ rm temp01.dbf
[oracle@oracle-one RHYS]$ rm temp02.dbf

[oracle@oracle-one RHYS]$

SQL> shutdown abort;
ORACLE instance shut down.
SQL> startup
ORACLE instance started.

Total System Global Area  471830528 bytes
Fixed Size                  2254344 bytes
Variable Size             197134840 bytes
Database Buffers          268435456 bytes
Redo Buffers                4005888 bytes
Database mounted.
Database opened.
SQL>

2、临时表空间文件是稀疏文件,这也就带来一个磁盘空间不足的时候产生问题。查看如下:

 

我创建了一个20M的临时表空间和20M的普通表空间。使用ls -lh查看每个文件发现大小一致,但是使用du -sh 查看文件大小时,临时表空间的大小却只有80K,普通表空间足足是21M。这也说明了临时表空间为sparse文件。使用ls -lh 查看的只是文件头的空间记录信息,而du 查看的确实真实的占用空间大小。

如何避免这种关系呢?顺序是首先创建临时表空间,然后删除临时表空间,然后使用cp -sparess参数复制临时表空间文件,然后再创建临时表空间reuse临时文件。

eg:

SQL> drop tablespace temp02;

Tablespace dropped.

[oracle@tf tf1]$ cp --sparse=never /u01/oracle/oradata/tf1/temp02.dbf /u01/oracle/oradata/tf1/temp03.dbf
[oracle@tf tf1]$ sqlplus / as sysdba

SQL*Plus: Release 10.2.0.1.0 - Production on Mon Nov 25 01:35:59 2013

Copyright (c) 1982, 2005, Oracle.  All rights reserved.


Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options

SQL> create temporary tablespace temp02 tempfile '/u01/oracle/oradata/tf1/temp03.dbf'reuse;

Tablespace created.

SQL> exit
Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
[oracle@tf tf1]$ ls -l temp03.dbf
-rw-r----- 1 oracle oinstall 20979712 Nov 25 01:36 temp03.dbf
[oracle@tf tf1]$ ls -lh temp03.dbf
-rw-r----- 1 oracle oinstall 21M Nov 25 01:36 temp03.dbf

[oracle@tf tf1]$ du -sh temp03.dbf
21M     temp03.dbf

[oracle@tf tf1]$

 

That‘s  all!

原创粉丝点击