- 最后登录
- 2023-8-16
- 在线时间
- 1686 小时
- 威望
- 2135
- 金钱
- 50532
- 注册时间
- 2011-10-12
- 阅读权限
- 200
- 帖子
- 5207
- 精华
- 39
- 积分
- 2135
- UID
- 2
|
3#
发表于 2012-6-11 21:45:59
FOR QUESTION 2
2)如何使用RMAN备份时不备份空块?只备份有数据的块?
RMAN 默认就不会备份空快, 只备份有“数据”的块! 这不需要任何设置
SQL> select * from v$version;
BANNER
--------------------------------------------------------------------------------
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
PL/SQL Release 11.2.0.3.0 - Production
CORE 11.2.0.3.0 Production
TNS for Linux: Version 11.2.0.3.0 - Production
NLSRTL Version 11.2.0.3.0 - Production
SQL> create tablespace IAMEMPTY datafile size 100M;
Tablespace created.
RMAN> backup validate tablespace IAMEMPTY;
Starting backup at 11-JUN-12
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=156 instance=VPROD1 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=00007 name=+DATA/vprod/datafile/iamempty.742.785669531
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
List of Datafiles
=================
File Status Marked Corrupt Empty Blocks Blocks Examined High SCN
---- ------ -------------- ------------ --------------- ----------
7 OK 0 12673 12800 3749002
File Name: +DATA/vprod/datafile/iamempty.742.785669531
Block Type Blocks Failing Blocks Processed
---------- -------------- ----------------
Data 0 0
Index 0 0
Other 0 127
Finished backup at 11-JUN-12
12800 个块中 12673个empty block
RMAN> backup tablespace IAMEMPTY format '/s01/%U.bak';
Starting backup at 11-JUN-12
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=00007 name=+DATA/vprod/datafile/iamempty.742.785669531
channel ORA_DISK_1: starting piece 1 at 11-JUN-12
channel ORA_DISK_1: finished piece 1 at 11-JUN-12
piece handle=/s01/0ind8nev_1_1.bak tag=TAG20120611T093319 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 11-JUN-12
[oracle@vrh1 ~]$ ls -lh /s01/0ind8nev_1_1.bak
-rw-r----- 1 oracle asmadmin 1.1M Jun 11 09:33 /s01/0ind8nev_1_1.bak
实际大小仅 1.1MB 约等于 12800-12673= 0.99MB
SQL> create table maclean1 (t1 int) tablespace IAMEMPTY;
Table created.
SQL> alter table maclean1 allocate extent (size 50M);
Table altered.
RMAN> backup validate tablespace IAMEMPTY;
Starting backup at 11-JUN-12
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=141 instance=VPROD1 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=00007 name=+DATA/vprod/datafile/iamempty.742.785669531
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
List of Datafiles
=================
File Status Marked Corrupt Empty Blocks Blocks Examined High SCN
---- ------ -------------- ------------ --------------- ----------
7 OK 0 12570 12800 3749187
File Name: +DATA/vprod/datafile/iamempty.742.785669531
Block Type Blocks Failing Blocks Processed
---------- -------------- ----------------
Data 0 0
Index 0 0
Other 0 230
Finished backup at 11-JUN-12
可以看到虽然分配了50MB extent给 表空间上的表对象, 但是实际这些块仍算作 empty block
SQL> alter table maclean1 pctfree 99 pctused 1;
Table altered.
SQL> insert into maclean1 select 1 from dual connect by level <=100000;
insert into maclean1 select 1 from dual connect by level <=100000
*
ERROR at line 1:
ORA-01653: unable to extend table SYS.MACLEAN1 by 1024 in tablespace IAMEMPTY
SQL> insert into maclean1 select 1 from dual connect by level <=50000;
50000 rows created.
SQL> commit;
Commit complete.
RMAN> backup validate tablespace IAMEMPTY;
Starting backup at 11-JUN-12
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=141 instance=VPROD1 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=00007 name=+DATA/vprod/datafile/iamempty.742.785669531
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
List of Datafiles
=================
File Status Marked Corrupt Empty Blocks Blocks Examined High SCN
---- ------ -------------- ------------ --------------- ----------
7 OK 0 377 12800 3874267
File Name: +DATA/vprod/datafile/iamempty.742.785669531
Block Type Blocks Failing Blocks Processed
---------- -------------- ----------------
Data 0 12150
Index 0 0
Other 0 273
Finished backup at 11-JUN-12
实际插入数据到表后 empty block的数量大幅减少
SQL> truncate table maclean1 ;
Table truncated.
RMAN> backup validate tablespace IAMEMPTY;
Starting backup at 11-JUN-12
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=32 instance=VPROD1 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=00007 name=+DATA/vprod/datafile/iamempty.742.785669531
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
List of Datafiles
=================
File Status Marked Corrupt Empty Blocks Blocks Examined High SCN
---- ------ -------------- ------------ --------------- ----------
7 OK 0 377 12800 3886817
File Name: +DATA/vprod/datafile/iamempty.742.785669531
Block Type Blocks Failing Blocks Processed
---------- -------------- ----------------
Data 0 12150
Index 0 0
Other 0 273
Finished backup at 11-JUN-12
以上可以看到普通的 truncate 是无法让 empty block 变多的! 更不用说DELETE了,DELETE 甚至不会下降高水位!
SQL> truncate table maclean1 drop all storage;
Table truncated.
SQL> Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,
Data Mining and Real Application Testing options
[oracle@vrh1 ~]$ rman target /
Recovery Manager: Release 11.2.0.3.0 - Production on Mon Jun 11 09:43:28 2012
Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
connected to target database: VPROD (DBID=896680541)
RMAN> backup validate tablespace IAMEMPTY;
Starting backup at 11-JUN-12
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=34 instance=VPROD1 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=00007 name=+DATA/vprod/datafile/iamempty.742.785669531
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
List of Datafiles
=================
File Status Marked Corrupt Empty Blocks Blocks Examined High SCN
---- ------ -------------- ------------ --------------- ----------
7 OK 0 377 12800 3887038
File Name: +DATA/vprod/datafile/iamempty.742.785669531
Block Type Blocks Failing Blocks Processed
---------- -------------- ----------------
Data 0 12150
Index 0 0
Other 0 273
Finished backup at 11-JUN-12
truncate table drop all storage; 也无法做到 让empty block还原!
SQL> drop table maclean1 purge;
Table dropped.
File Status Marked Corrupt Empty Blocks Blocks Examined High SCN
---- ------ -------------- ------------ --------------- ----------
7 OK 0 377 12800 3887121
File Name: +DATA/vprod/datafile/iamempty.742.785669531
Block Type Blocks Failing Blocks Processed
---------- -------------- ----------------
Data 0 12150
Index 0 0
Other 0 273
Finished backup at 11-JUN-12
drop table 也是一样的 虽然 表空间实际上大把的FREE SPACE
SQL> select block_id,file_id,blocks from dba_free_space where TABLESPACE_NAME='IAMEMPTY';
BLOCK_ID FILE_ID BLOCKS
---------- ---------- ----------
128 7 12672 |
|