Flashcache

Allikas: Kuutõrvaja

Flashcache

Flashcashe on tehnoloogia selleks, et cacheda kirjutamisi-lugemisi kasutades kiiret SSD ketast vahelaona.

# apt-get install gcc make git-core dkms build-essential linux-headers-`uname -r` -y
# git clone https://github.com/facebook/flashcache.git
# cd flashcache
# make
# make install

Meil on serveris kaks ketast

  • /dev/rbd1 (cehphis loodud võrguketas)
  • /dev/sdb (lokaalne ssd)

Laadime mooduli

# modprobe flashcache

Dmesg peaks raporteerima

[1023454.971735] flashcache: flashcache-3.1.1 initialized

Järgmisena on vaja flascache_create töövahendiga kombineerida kaks blokkseadet device mapperis. Pole vaja karta, midagi olemasoleva rbd ketta ja sela oleva infoga ei juhtu

Haagime rbd ketta lahti

# umount /home

Süntaks on käsul järgnev

  • flashcache_create home_cached <võtmed> <tekitatav ketas> <ssd> <aeglane ketas>
# flashcache_create -p back -s 230G -b 4k backup_cached /dev/sdb /dev/rbd0
cachedev backup_cached, ssd_devname /dev/sdb, disk_devname /dev/rbd0 cache mode WRITE_BACK
block_size 8, md_block_size 8, cache_size 482344960
Flashcache metadata will use 1265MB of your 24154MB main memory

Võtmete selgitused

  • -p: operate in writeback mode, which means that we cache both write and read requests
  • -s: set the size of the cache, it should be the same as the size of your partition
  • -b: set the block size to 4K
  • backup_cached: flashcache seadme nimetus

haagime tekkinud seadme külge

# mount /dev/mapper/backup_cached /mnt/

Vaatame tulemust

# df -h
Filesystem                 Size  Used Avail Use% Mounted on
...
/dev/mapper/backup_cached   32T   65G   32T   1% /mnt

Statistika vaatmiseks

# dmsetup table
backup_cached: 0 68719460352 flashcache conf:
    ssd dev (/dev/sdb), disk dev (/dev/rbd0p1) cache mode(WRITE_BACK)
    capacity(237542M), associativity(512), data block size(4K) metadata block size(4096b)
    disk assoc(0K)
    skip sequential thresh(0K)
    total blocks(60810752), cached blocks(60160782), cache percent(98)
    dirty blocks(46144348), dirty percent(75)
    nr_queued(0)
Size Hist: 1024:5 4096:217130775 

Selleks, et boodil võetaks süsteem külge tuleb flashcache kaustas käivitada käsk

# make -f Makefile.dkms boot_conf

Seadme laadimiseks

# flashcache_load /dev/sdb1 backup_cached

Seadme hävitamiseks

# flashcache_destroy /dev/sdb1