ITPub博客

首页 > 数据库 > Oracle > [20150717]备份变大.txt

[20150717]备份变大.txt

原创 Oracle 作者:lfree 时间:2015-07-17 09:56:11 0 删除 编辑

[20150717]备份变大.txt

--前几天别人系统升级,11.2.0.3升级到11.2.0.4出现备份增大的情况,我看了他升级的文档,感觉最大的可能建立了restore point。
--升级完成后没有删除。自己做一个测试。

1.建立测试环境:
SCOTT@test> @ &r/ver1
PORT_STRING                    VERSION        BANNER
------------------------------ -------------- ----------------------------------------------------------------
x86_64/Linux 2.4.xx            10.2.0.4.0     Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bi

SCOTT@test> select FLASHBACK_ON from v$database ;
FLASHBACK_ON
------------------
NO

--建立新的表空间:
-- drop tablespace mssm including contents;

CREATE TABLESPACE MSSM DATAFILE
  '/mnt/ramdisk/test/mssm01.dbf' SIZE 64M AUTOEXTEND OFF
LOGGING
ONLINE
EXTENT MANAGEMENT LOCAL AUTOALLOCATE
BLOCKSIZE 8K
SEGMENT SPACE MANAGEMENT MANUAL
FLASHBACK ON;

SCOTT@test> create table t tablespace mssm as select rownum id ,cast('testtesttesttest' as varchar2(20)) name from xmltable('1 to 100000');
Table created.

--这样建立文件大小13M。

SCOTT@test> truncate table t ;
Table truncated.

2.开始备份:
RMAN> backup  datafile 6 format '/home/oracle/backup/DATAFILE6_%u' ;

$  ll -lh DATAFILE6_*
-rw-r----- 1 oracle oinstall 616K 2015-07-17 09:28:50 DATAFILE6_14qc8rii
--仅仅616K。

SCOTT@test> create restore point test0717 ;
Restore point created.

$  ll -lh DATAFILE6_*
-rw-r----- 1 oracle oinstall 616K 2015-07-17 09:28:50 DATAFILE6_14qc8rii
-rw-r----- 1 oracle oinstall 616K 2015-07-17 09:34:58 DATAFILE6_15qc8ru2
--没有变化。

SYS@test> create restore point test0717x guarantee flashback database;
create restore point test0717x guarantee flashback database
*
ERROR at line 1:
ORA-38784: Cannot create restore point 'TEST0717X'.
ORA-38787: Creating the first guaranteed restore point requires mount mode when flashback database is off.
--说明他升级在mount状态建立的guarantee flashback point。

SYS@test> shutdown immediate ;
Database closed.
Database dismounted.
ORACLE instance shut down.

SYS@test> startup mount
ORACLE instance started.
Total System Global Area    473956352 bytes
Fixed Size                    2084776 bytes
Variable Size               260046936 bytes
Database Buffers            201326592 bytes
Redo Buffers                 10498048 bytes
Database mounted.

SYS@test> create restore point test0717x guarantee flashback database;
Restore point created.

SYS@test> alter database open ;
Database altered.

RMAN> backup  datafile 6 format '/home/oracle/backup/DATAFILE6_%u' ;
..

$  ll -lh DATAFILE6_*
-rw-r----- 1 oracle oinstall 616K 2015-07-17 09:28:50 DATAFILE6_14qc8rii
-rw-r----- 1 oracle oinstall 616K 2015-07-17 09:34:58 DATAFILE6_15qc8ru2
-rw-r----- 1 oracle oinstall  13M 2015-07-17 09:38:41 DATAFILE6_16qc8s51

--很明显备份变成了13M。建立了restore point并且属性guarantee flashback database;

SYS@test> select * from V$RESTORE_POINT;

         SCN DATABASE_INCARNATION# GUA STORAGE_SIZE TIME                           NAME
------------ --------------------- --- ------------ ------------------------------ --------------------
12695497118                     1 YES      8192000 2015-07-17 09:38:02.000000000  TEST0717X
12695496814                     1 NO             0 2015-07-17 09:34:43.000000000  TEST0717

3.打开FLASHBACK_ON看看:
--10g仅仅在mount状态下打开。
SYS@test> alter database flashback  on;
Database altered.

SYS@test> alter database open ;
Database altered.

$  ll -lh DATAFILE6_*
-rw-r----- 1 oracle oinstall 616K 2015-07-17 09:28:50 DATAFILE6_14qc8rii
-rw-r----- 1 oracle oinstall 616K 2015-07-17 09:34:58 DATAFILE6_15qc8ru2
-rw-r----- 1 oracle oinstall  13M 2015-07-17 09:38:41 DATAFILE6_16qc8s51
-rw-r----- 1 oracle oinstall  13M 2015-07-17 09:49:06 DATAFILE6_17qc8soi

SYS@test> drop restore point TEST0717X;
Restore point dropped.

RMAN> backup  datafile 6 format '/home/oracle/backup/DATAFILE6_%u' ;
..

$  ll -lh DATAFILE6_*
-rw-r----- 1 oracle oinstall 616K 2015-07-17 09:28:50 DATAFILE6_14qc8rii
-rw-r----- 1 oracle oinstall 616K 2015-07-17 09:34:58 DATAFILE6_15qc8ru2
-rw-r----- 1 oracle oinstall  13M 2015-07-17 09:38:41 DATAFILE6_16qc8s51
-rw-r----- 1 oracle oinstall  13M 2015-07-17 09:49:06 DATAFILE6_17qc8soi
-rw-r----- 1 oracle oinstall 616K 2015-07-17 09:50:39 DATAFILE6_18qc8srf

--很明显正是建立了restore point并且属性guarantee flashback database;导致备份变大。

4.收尾还原:
SYS@test> drop restore point TEST0717;
Restore point dropped.

SYS@test> alter database flashback  off;
Database altered.

RMAN> delete backupset 31,32,33,34,35;
using channel ORA_DISK_1

List of Backup Pieces
BP Key  BS Key  Pc# Cp# Status      Device Type Piece Name
------- ------- --- --- ----------- ----------- ----------
31      31      1   1   AVAILABLE   DISK        /home/oracle/backup/DATAFILE6_14qc8rii
32      32      1   1   AVAILABLE   DISK        /home/oracle/backup/DATAFILE6_15qc8ru2
33      33      1   1   AVAILABLE   DISK        /home/oracle/backup/DATAFILE6_16qc8s51
34      34      1   1   AVAILABLE   DISK        /home/oracle/backup/DATAFILE6_17qc8soi
35      35      1   1   AVAILABLE   DISK        /home/oracle/backup/DATAFILE6_18qc8srf

Do you really want to delete the above objects (enter YES or NO)? yes
deleted backup piece
backup piece handle=/home/oracle/backup/DATAFILE6_14qc8rii recid=31 stamp=885288530
deleted backup piece
backup piece handle=/home/oracle/backup/DATAFILE6_15qc8ru2 recid=32 stamp=885288898
deleted backup piece
backup piece handle=/home/oracle/backup/DATAFILE6_16qc8s51 recid=33 stamp=885289121
deleted backup piece
backup piece handle=/home/oracle/backup/DATAFILE6_17qc8soi recid=34 stamp=885289746
deleted backup piece
backup piece handle=/home/oracle/backup/DATAFILE6_18qc8srf recid=35 stamp=885289839
Deleted 5 objects

--总结:
--注意这些细节,升级完成正常后删除这些restore point。

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

请登录后发表评论 登录
全部评论
熟悉oracle相关技术,擅长sql优化,rman备份与恢复,熟悉linux shell编程。

注册时间:2008-01-03

  • 博文量
    2468
  • 访问量
    6276799