签到成功

知道了

CNDBA社区CNDBA社区

Oracle 配置 Multiple Block Sizes 表空间

2016-09-02 17:16 3546 0 原创 Oracle 11g
作者: dave

 

1         参数说明

    数据库的默认块大小受参数db_block_size控制,一般在建库时都是使用默认的8k 块。但Oracle 支持配置Multiple Block Sizes

 

http://www.cndba.cn/dave/article/172

SQL>show parameter cache_size
 
NAME                                        TYPE        VALUE
------------------------------------ ----------- ------------------------------
client_result_cache_size              big integer 0
db_16k_cache_size               big integer 0
db_2k_cache_size                 big integer 0
db_32k_cache_size               big integer 0
db_4k_cache_size                 big integer 0
db_8k_cache_size                 big integer 0
db_cache_size                        big integer 0
db_flash_cache_size                      big integer 0
db_keep_cache_size                      big integer 0
db_recycle_cache_size                  big integer 0
SQL>
 
 
SQL> show parameter db_block_size
 
NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
db_block_size                        integer     8192

 

    如果要配置Multiple Block Sizes,就需要配置db_nK_cache_size 参数,这些参数默认都是0. 配置完这些参数之后,我们在创建相关的表空间时,就可以指定对应的block 这样就完成了Multiple Block Sizes 但是,Multiple Block Sizes 给管理上代理一定的复杂度,除非是VLDB系统的需求,OLTP中一般不使用该特性。

 

注意:http://www.cndba.cn/dave/article/172

    在创建非db_block_size 标准的表空间时,必须先修改对应的DB_nK_CACHE_SIZE 参数,否则会报:

    ORA-29339: tablespace block size xxxx does not match configured block sizes

 

1.1        DB_BLOCK_SIZE

Caution:

    Set this parameter at the time of database creation. Do not alter it afterward.

    DB_BLOCK_SIZE specifies (in bytes) the size of Oracle database blocks. Typical values are 4096 and 8192. The value of this parameter must be a multiple of the physical block size at the device level.

    The value for DB_BLOCK_SIZE in effect at the time you create the database determines the size of the blocks. The value must remain set to its initial value.

    For Real Application Clusters, this parameter affects the maximum value of the FREELISTS storage parameter for tables and indexes. Oracle uses one database block for each freelist group. Decision support system (DSS) and data warehouse database environments tend to benefit from larger block size values.

 

Note:

    132-bit operating systems support a maximum DB_BLOCK_SIZE value of 1638416k

--32位系统,db_block_size 最大16k

    264-bit operating systems support a maximum DB_BLOCK_SIZE value of 3276832k

http://www.cndba.cn/dave/article/172

--64位系统,db_block_size 最大32k

 

 

1.2        DB_nK_CACHE_SIZE 参数 

    DB_nK_CACHE_SIZE (where n = 2, 4, 8, 16, 32) specifies the size of the cache for the nK buffers. You can set this parameter only when DB_BLOCK_SIZE has a value other than nK. For example, if DB_BLOCK_SIZE=4096, then it is illegal to specify the parameter DB_4K_CACHE_SIZE (because the size for the 4 KB block cache is already specified by DB_CACHE_SIZE).

    -- DB_nK_CACHE_SIZE 参数指定nK buffer,在指定cache时,要确保有足够的空间。 不能和DB_BLOCK_SIZE 参数冲突,n 可以取2481632. http://www.cndba.cn/dave/article/172

    Do not set this parameter to zero if there are any online tablespaces with an nK block size.

    Operating system-specific block size restrictions apply. For example, you cannot set DB_32K_CACHE_SIZE if the operating system's maximum block size is less than 32 KB. Also, you cannot set DB_2K_CACHE_SIZE if the minimum block size is greater than 2 KB.http://www.cndba.cn/dave/article/172

    -- DB_nK_CACHE_SIZE要操作系统支持,如果n=32,但操作系统支持,也是不行的。http://www.cndba.cn/dave/article/172

 

See Also:

    Your operating system-specific Oracle documentation for more information on block size restrictionshttp://www.cndba.cn/dave/article/172

 

 

2         测试

 

测试环境:

http://www.cndba.cn/dave/article/172

SQL> select * from v$version;
 
BANNER                                                                                           CON_ID
-------------------------------------------------------------------------------- ----------
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production                0
PL/SQL Release 12.1.0.2.0 - Production                                                            0
CORE        12.1.0.2.0         Production                                                                           0
TNS for Linux: Version 12.1.0.2.0 - Production                                                         0
NLSRTL Version 12.1.0.2.0 - Production                                                            0
 
SQL> show pdbs
 
    CON_ID CON_NAME                            OPEN MODE  RESTRICTED
---------- ------------------------------ ---------- ----------
          2 PDB$SEED                       READ ONLY  NO
          3 PDB1                      READ WRITE NO
          4 IM                                      READ WRITE NO
SQL>
 
 
--查看db_block_size
SQL> show parameter db_block_size
 
NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
db_block_size                        integer     8192
 
 
--查看操作系统系统
[root@cndba.cn ~]# lsb_release -a
LSB Version:     :base-4.0-amd64:base-4.0-noarch:core-4.0-amd64:core-4.0-noarch:graphics-4.0-amd64:graphics-4.0-noarch:printing-4.0-amd64:printing-4.0-noarch
Distributor ID: OracleServer
Description:     Oracle Linux Server release 6.4
Release:  6.4
Codename:      n/a
 
[root@cndba.cn ~]# uname -r
2.6.39-400.17.1.el6uek.x86_64
[root@cndba.cn ~]#
 
 
--查看db_32k_cache_size值
SQL> show parameter db_32k_cache_size
 
NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
db_32k_cache_size                    big integer 0
 
-- 指定32k:
SQL>  alter system set db_32k_cache_size=1M scope=both;
System altered.
 
SQL> show parameter db_32k_cache_size
NAME                                        TYPE        VALUE
------------------------------------ ----------- ------------------------------
db_32k_cache_size               big integer 16M
SQL>
 
这里虽然指定的是1M,但实际上,该参数根据默认的规则进行了调整(4*CPUS)。
 
 
先创建一个16k block的表空间进行测试:
SQL> select file_name from dba_data_files;
 
FILE_NAME
----------------------------------------------------------------------------------------------------------------------------------
/u01/app/oracle/oradata/dave/system01.dbf
/u01/app/oracle/oradata/dave/sysaux01.dbf
/u01/app/oracle/oradata/dave/undotbs01.dbf
/u01/app/oracle/oradata/dave/users01.dbf
/u01/app/oracle/oradata/anqing.dbf
 
SQL> create tablespace tbs16k datafile '/u01/app/oracle/oradata/16ktbs.dbf' size 10M blocksize 16k;
create tablespace tbs16k datafile '/u01/app/oracle/oradata/16ktbs.dbf' size 10M blocksize 16k
*
ERROR at line 1:
ORA-29339: tablespace block size 16384 does not match configured block sizes

 

这里只是演示一下错误。

 

我们创建32k的表空间进行测试:

 

SQL> create tablespace tbs32k datafile '/u01/app/oracle/oradata/32ktbs.dbf' size 30M blocksize 32k;
Tablespace created.
 
--创建一个测试表,放到32k的表空间上
SQL> create table tt32k tablespace tbs32k as select * from dba_objects;
Table created.
 
--验证一下表tbs32k的block 大小
SQL> col segment_name for a15
SQL> select segment_name,blocks from dba_segments where segment_name='TT32K';
 
SEGMENT_NAME        BLOCKS
--------------- ----------
TT32K                       384
 
--当表的每个block 越大时,那么它里面就能够存放更多的block
--我们使用8k的block 来创建一个相同的表,来查看它使用blocks,从而进行对比
 
SQL> create table tt8k as select * from dba_objects;
Table created.
SQL> select segment_name,blocks from dba_segments where segment_name='TT8K';
 
SEGMENT_NAME        BLOCKS
--------------- ----------
TT8K                         1536

 

对比看到,对于同样记录数的表,使用32kblocksize384blocks,使用8k1536blocks

 

http://www.cndba.cn/dave/article/172

所以在VLDB中,在使用大Block size的情况下,如果是顺序读,可以明显改善读的性能。 因此在VLDB 或者DDS系统中可以考虑使用Multiple Block Size,但是在OLTP中,不建议使用。

 

http://www.cndba.cn/dave/article/172

 

版权声明:本文为博主原创文章,未经博主允许不得转载。

用户评论
* 以下用户言论只代表其个人观点,不代表CNDBA社区的观点或立场
dave

dave

关注

人的一生应该是这样度过的:当他回首往事的时候,他不会因为虚度年华而悔恨,也不会因为碌碌无为而羞耻;这样,在临死的时候,他就能够说:“我的整个生命和全部精力,都已经献给世界上最壮丽的事业....."

  • 2261
    原创
  • 3
    翻译
  • 578
    转载
  • 191
    评论
  • 访问:7976569次
  • 积分:4346
  • 等级:核心会员
  • 排名:第1名
精华文章
    最新问题
    查看更多+
    热门文章
      热门用户
      推荐用户
        Copyright © 2016 All Rights Reserved. Powered by CNDBA · 皖ICP备2022006297号-1·

        QQ交流群

        注册联系QQ