flashcache

페이지 정보

작성자 조희승 댓글 0건 조회 11,093회 작성일 13-06-27 17:55

본문

 
flashcache_create -v -p back fc1 /dev/ssd1 /dev/hdd1
 
flashcache_load ssd_devname [cachedev]
// cachedev 필요없음. 리부팅시 flashcache_load로 로딩
 
flashcache_destroy ssd_devname
dmsetup remove
destroy전에 먼저 remove할 것
 
dmsetup status
dmsetup table
 
 
 
 
 
 
flashcache facebook
 
http://www.gerrit-tamboer.net/using-flashcache-to-speed-up-your-io-on-ubuntu-12-04/
 
 
 Using flash cahce with a SSD (/dev/sda) and a hardrive to spedd up access.
I suggest to use SSD drive with SLC memory instead off MLC as using a ssd as a cahce drive is expenisve in read/writa and te SSD as a limit. Intel SSD 313 (http://www.intel.com/content/www/us/en/solid-state-drives/solid-state-drives-313-series.html) are specially done for this.
 
#! flashcache
 #
 
usefull documents reference :
 
# https://github.com/facebook/flashcache
 # http://www.gerrit-tamboer.net/using-flashcache-to-speed-up-your-io-on-ubuntu-12-04/
 # https://github.com/facebook/flashcache/wiki/QuickStart-Recipe-for-Ubuntu-11.10
 # https://github.com/facebook/flashcache/blob/master/doc/flashcache-sa-guide.txt
 # https://github.com/facebook/flashcache/blob/master/README-DKMS
 #
 

 # step 1 - Clonning Git Repository
 apt-get install git-core
 #> mkdir -p ~/Build/ ; cd ~/Build/
 #> git clone https://github.com/facebook/flashcache.git
 Cloning into 'flashcache'...
 remote: Counting objects: 914, done.
 remote: Compressing objects: 100% (357/357), done.
 remote: Total 914 (delta 631), reused 831 (delta 553)
 Receiving objects: 100% (914/914), 252.91 KiB | 199 KiB/s, done.
 Resolving deltas: 100% (631/631), done.
 # Step 2a - Building
 # install building tools
 sudo apt-get install git build-essential dkms linux-headers-`uname -r` uuid-dev
 cd flashcache
 sudo make -f Makefile.dkms all boot_conf
 # Step 2b - Installation
 sudo make install
 cat <<EOF>>/etc/sysctl.conf

 ###################################################################
 # FlashCache
 #
 # disable writing dirty cache data at shutdown (do this only if you really trust FC)
 # dev.flashcache.fast_remove = 1
 #
 # change the reclaim policy from FIFO to LRU" >>/etc/sysctl.conf
 dev.flashcache.reclaim_policy = 1
 #
 # Writeback
 # do not write "stale" data to disk until evicted due to lack of space
 #dev.flashcache.fallow_delay = 0
 #
 EOF
 # Step 3 - Init
 sudo modprobe flashcache
 sudo echo "flashcache" >> /etc/modules
 # Verification :
 dmesg | tail
 ....................
 [159671.822040] flashcache: flashcache-1.0 initialized
 #
 lsmod |grep flashcache
 flashcache             82901  0
 # Step 4 - montage volume simple DATA/Home
 # Find the UUID of the volume you want to cache:
 ls -la /dev/disk/by-uuid/
 
 #### Home drive
 sudo umount /home/yoyo
 sudo flashcache_create -v -p back filecache_home /dev/sda2 /dev/disk/by-uuid/c85a514b-0a7d-4c4c-8af6-dcea99ed773c
 vi /etc/fstab
 # Comment out the line with the device you want to cache
 # Add a new line for the flashcache similar this:
 # /home/yoyo/ was on /dev/sda5 during installation
 # UUID=c85a514b-0a7d-4c4c-8af6-dcea99ed773c /home           reiserfs defaults        0       2
 /dev/mapper/filecache_data /home/yoyo     reiserfs defaults        0       2

 #Step 5 - check
 ~# sudo dmsetup status
 filecache_data: 0 325122048 flashcache stats:
     reads(2775), writes(37)
     read hits(3), read hit percent(0)
     write hits(11) write hit percent(29)
     dirty write hits(0) dirty write hit percent(0)
     replacement(0), write replacement(0)
     write invalidates(0), read invalidates(0)
     pending enqueues(0), pending inval(0)
     metadata dirties(37), metadata cleans(0)
     metadata batch(3) metadata ssd writes(34)
     cleanings(0) fallow cleanings(0)
     no room(0) front merge(0) back merge(0)
     disk reads(2772), disk writes(0) ssd reads(3) ssd writes(2843)
     uncached reads(0), uncached writes(0), uncached IO requeue(0)
     uncached sequential reads(0), uncached sequential writes(0)
     pid_adds(0), pid_dels(0), pid_drops(0) pid_expiry(0)
 ~# sudo dmsetup table
 filecache_data: 0 325122048 flashcache conf:
     ssd dev (/dev/sda3), disk dev (/dev/disk/by-uuid/45e71c47-a88f-4493-8b1a-e5bfcf7562b0) cache mode(WRITE_BACK)
     capacity(14092M), associativity(512), data block size(4K) metadata block size(4096b)
     skip sequential thresh(0K)
     total blocks(3607552), cached blocks(2132154), cache percent(59)
     dirty blocks(11), dirty percent(0)
     nr_queued(0)
 Size Hist: 4096:61231

 # Step 6 - startup script to write data on exit
 cat <<EOF>/etc/init.d/unflashcache
 #! /bin/sh
 ### BEGIN INIT INFO
 # Provides: unflashcache
 # Required-Start:
 # Required-Stop:
 # Should-Stop:
 # Default-Start:
 # Default-Stop: 0 6   
 # Short-Description: Unload flashcache module and fs.
 ### END INIT INFO
 
 PATH=/sbin:/bin
 . /lib/init/vars.sh
 
 . /lib/lsb/init-functions
 
 do_stop () {
     echo Unload cachedev
     umount /data
     dmsetup remove cachedev
     rmmod flashcache  
 }
 
 case "$1" in
   start)
     # No-op
     ;;
   restart|reload|force-reload)
     echo "Error: argument '$1' not supported" >&2
     exit 3
     ;;
   stop)
     do_stop
     ;;
   *)
     echo "Usage: $0 start|stop" >&2
     exit 3
     ;;
 esac
 EOF
 chmod 755  /etc/init.d/unflashcache
 update-rc.d unflashcache start 39 0 6 .

 # ################
# Step 7 - on root drive
 sudo vi /etc/fstab
 # Comment out the line with the device you want to cache
 # Add a new line for the flashcache similar this:
 # / was on /dev/sda1 during installation
 #UUID=a8da2c39-109c-4be9-b70a-74d5720f30df /               btrfs   defaults,subvol=@ 0       1
 /dev/mapper/filecache_root /               btrfs   defaults,subvol=@ 0       1
 #Edit your /boot/grub/grub.cfg to change the root device to the flashcache device you intend to use.
 - Boot off a live CD like the Ubuntu desktop installer.
 - mount the partition with flashcache compiled
 mount /dev/disk/by-uuid/c85a514b-0a7d-4c4c-8af6-dcea99ed773c /mnt
 cd /mnt/yoyo/Build/flashcache
 # install binary
 make install
 modprobe flashcache
 # create root flashcache
 flashcache_create -v -p back filecache_root /dev/sda1 /dev/disk/by-uuid/a8da2c39-109c-4be9-b70a-74d5720f30df
 #if ok
 reboot

 ######
# Step 8 - if needed
 ## Removing Flashcache from a Boot Volume
 # First, ensure that dev.flashcache.fast_remove = 0 and reboot to minimize potential lost data
 # Edit fstab
 vi /etc/fstab
 # Comment out the flashcache line and un-comment the original device line

 # Reboot to recovery mode (hold left shift during boot)
 # Mount / using the non-flashcache drive
 mount -o relatime /dev/md0 /
 # Remove the FC device mapper device
 dmsetup remove fc-md
 # Remove FC special SSD signature (change /dev/sdb with whatever your FC device is)
 flashcache_destroy /dev/sdb
 # Done, continue booting normally
 exit
 
# remove module
dkms remove -m flashcache -v $(git describe  --always --abbrev=12) --all

댓글목록

등록된 댓글이 없습니다.