设为首页 收藏本站
查看: 695|回复: 0

[经验分享] DB Smart Flash Cache in Oracle 11g

[复制链接]

尚未签到

发表于 2018-9-10 10:40:18 | 显示全部楼层 |阅读模式
http://dbaora.com/db-smart-flash-cache-in-oracle-11g/
In case you don’t have budget to buy Exadata you can still buy huge number of flash disks and put on them part of your database. But what should be stored on flash disks(very fast) and what on magnetic disks(very slow) ?
  It’s not your businesses to know let decide database DSC0000.jpg
  Introduction
  DB Smart Flash Cache is new extension for buffer cache area. This extra area should be defined on solid state disks (SSD) and has following features:

  • make performance improvements at moderate cost(cheaper than DRAM)
  • low latency compared to magnetic disks
  • higher throughput compared to magnetic disks
  •   easy to setup
  •   easy to control
  •   can be used for RAC cache fusion keeps consistency
  •   direct I/O bypasses buffer cache so as well bypasses DB smart flash cache
  •   can cache only clean blocks from buffer cache
  •   flash cache is not auto-tuned
  •   only blocks from standard buffer pool are cached in DB smart flash cache
Oracle recommends:

  • flash disks should have comparable read IOPs and IOPs write
  • this new layer should be at least 2-10 times bigger than buffer cache in DRAM
  •   mainly for OLTP systems
  Architecture
  jpg1
  if a oracle server process needs to read a block from database at first it must read it from magnetic disk(physical read). Then the block is stored in buffer cache memory and added to standard “LRU chain” list.
  When “in memory buffers area” is getting full Oracle must decide which blocks needs to be removed from cache. If you have DB Smart Flash Cache enabled “clean” blocks are written to “Flash cache” by DBWR process so next time they can be read into memory from Flash Cache and improve your performance.
  NOTE: “Dirty” blocks are never stored in Flash Cache
List of blocks cached in DB smart flash cache are stored in buffer cache area on two dedicated flash “LRU lists” depending on object attribute FLASH_CACHE:

  • DEFAULT – standard last recently used algorithm decides how long such blocks are cached in flash cache. It’s default value assigned to each object in database.
  • KEEP – such blocks are not removed from flash cache as long as the flash cache is large enough
alter|create table|index objectname  
storage
  
(
  
   buffer_pool { keep | recycle | default }
  
   flash_cache { keep | none    | default }
  
);
  NONE value for FLASH_CACHE is blocking flash caching for a given object.
  Statistics
  All I/O operations from DB smart flash cache are counted as physical I/O however Oracle also collects such informations in new columns.
V$SQL - OPTIMIZED_PHY_READ_REQUESTS  
V$SQLAREA - OPTIMIZED_PHY_READ_REQUESTS
  
V$FILESTAT - OPTIMIZED_PHYBLKRD
select name from v$statname where name like 'physical%optimized%';  

  
NAME
  
----------------------------------------------------------------
  
physical read requests optimized
  
physical read total bytes optimized
  You can see such stats in V$SESSTAT and V$SYSSTAT
  Setup
  Two parameters must be set on database level to turn on DB smart flash cache:

  •   DB_FLASH_CACHE_FILE – defines (OS disk path or ASM disk group) and file name to store this data

  •   DB_FLASH_CACHE_SIZE – defines>
DB_FLASH_CACHE_FILE='/os path/flash_cache_file.dbf'  
DB_FLASH_CACHE_FILE='+FLASH_DISK_GROUP/flash_cache_file.dbf'
  
DB_FLASH_CACHE_SIZE=200m
  After setting both parameters you need to restart database.
DB_FLASH_CACHE_FILE

  • can’t be shared between many databases or instances
DB_FLASH_CACHE_SIZE

  • can’t be dynamically resized
  • can be set to 0 to disable DB smart flash cache
  • can be set to original>
  Performance improvements

  Oracle conducted interesting test for a OLTP database 70GB>  jpg2

  Following picture shows improvement in transaction response time versus DB smart cache>  jpg3
  Example
  I simulate SSD disk by creation ramdisk – disk based in memory using following steps:
  1. create directory to mount ramdisk and change owner to oracle and group dba
[root@oel5 /]mkdir /ramdisk  
[root@oel5 /]chown oracle:dba -R /ramdisk
  2. mount ramdisk and check it
[root@oel5 /]# mount -t tmpfs none /ramdisk -o size=256m  
[root@oel5 /]# mount | grep ramdisk
  
none on /ramdisk type tmpfs (rw,size=256m)
  3. set parameters for database and restart it as user oracle
SQL> alter system set db_flash_cache_file='/ramdisk/ram.dbf'  
SQL> scope=spfile;
  

  
System altered.
  

  
SQL> alter system set db_flash_cache_size=200M scope=spfile;
  

  
System altered.
  

  
SQL> startup force
  
ORACLE instance started.
  

  
Total System Global Area  835104768 bytes
  
Fixed Size                  2232960 bytes
  
Variable Size             507514240 bytes
  
Database Buffers          322961408 bytes
  
Redo Buffers                2396160 bytes
  
Database mounted.
  
Database opened.
  
SQL> show parameter flash_cache
  

  
NAME                    TYPE        VALUE
  
----------------------- ----------- ------------------------------
  
db_flash_cache_file     string      /ramdisk/ram.dbf
  
db_flash_cache_size     big integer 200M
  4. Check new file exists in /ramdisk
[root@oel5 ramdisk]# ll  
total 8
  
-rw-r----- 1 oracle asmadmin 209715200 Feb 24 22:54 ram.dbf
  5. Let’s create tables with flash_cache keep reference in storage clause so Oracle will try to keep the blocks in DB smart cache as long as possible.
create table test_tbl1  
(id number,
  
id1 number,
  
id2 number)
  
storage(flash_cache keep);
  

  
begin
  
  for i in 1..1000000
  
  loop
  
    insert into test_tbl1 values(i, i, i);
  
  end loop;
  
  commit;
  
end;
  
/
  6. Eventually after some time you can see some data in flash cache – v$bh view.
select status, count(*) from v$bh  
group by status;
  

  
STATUS       COUNT(*)
  
---------- ----------
  
xcur            36915
  
flashcur        25583
  
cr                 13
  7. If you clean buffer cache as well db smart flash cache is purged
alter system flush buffer_cache;  
system FLUSH altered.
  

  
STATUS       COUNT(*)
  
---------- ----------
  
xcur              520
  
free            36411
  Have a fun
  Tomasz



运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.iyunv.com/thread-570840-1-1.html 上篇帖子: Oracle提示错误消息ORA-28001: the password has expired, 下篇帖子: Oracle GoldenGate系统之----相关参数说明
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表