{"id":2503,"date":"2010-10-08T18:28:44","date_gmt":"2010-10-08T10:28:44","guid":{"rendered":"http:\/\/www.orczhou.com\/?p=2503"},"modified":"2010-10-08T18:28:44","modified_gmt":"2010-10-08T10:28:44","slug":"how-to-setup-flashcace","status":"publish","type":"post","link":"https:\/\/www.orczhou.com\/index.php\/2010\/10\/how-to-setup-flashcace\/","title":{"rendered":"Flashcace\u5b89\u88c5 How-to"},"content":{"rendered":"<p><a href=\"http:\/\/www.facebook.com\/note.php?note_id=388112370932\">Flashcache<\/a>\u7684\u5b89\u88c5\u5728\u5176<a href=\"http:\/\/github.com\/facebook\/flashcache\/blob\/master\/README\">README<\/a>\u548c<a href=\"http:\/\/github.com\/facebook\/flashcache\/blob\/master\/README-CentOS5.4\">README-CentOS5.4<\/a>\u5df2\u7ecf\u6709\u4e00\u4e2a\u5f88\u8be6\u7ec6\u7684\u8bf4\u660e\u4e86\uff0c\u4f46\u662f\u5b9e\u9645\u64cd\u4f5c\u5e76\u4e0d\u662f\u5f88\u987a\u5229\uff0c\u800c\u4e14\u6709\u4e9b\u540c\u4e8b\u8868\u793a\u5728\u7f16\u8bd1\u8fc7\u7a0b\u4e2d<a href=\"http:\/\/www.orczhou.com\/index.php\/2010\/09\/flachcache-first-view\/#comment-1310\">\u4ecd\u9047\u5230\u4e86\u4e00\u4e9b\u95ee\u9898<\/a>\uff0c\u8fd9\u91cc\u8be6\u7ec6\u7684\u8bb0\u5f55\u4e00\u4e0b\u81ea\u5df1\u7684\u7f16\u8bd1\u3001\u5b89\u88c5\u8fc7\u7a0b\u3002<\/p>\n<div class=\"myt1\">1. \u73af\u5883\u8bf4\u660e<\/div>\n<p>\u4f7f\u7528\u7684\u662fRHEL5.4\u7684\u7cfb\u7edf\uff1a<\/p>\n<div class=\"mycode\">$cat \/etc\/issue<br \/>\nRed Hat Enterprise Linux Server release 5.4 (Tikanga)<br \/>\n$uname -a<br \/>\nLinux myhost 2.6.18-164.el5 #1 SMP Tue Aug 18 15:51:48 EDT 2009 x86_64 x86_64 x86_64 GNU\/Linux\n<\/div>\n<p><!--more--><\/p>\n<div class=\"myt1\">2. \u9700\u8981\u7684RPM\u5305<\/div>\n<p>\u5b89\u88c5\u57fa\u672c\u5de5\u5177\u5305\uff1arpm-build redhat-rpm-config unifdef\u3002\u4e00\u822c\u60c5\u51b5\u8fd9\u4e09\u4e2a\u5305\u90fd\u662f\u5b89\u88c5\u8fc7\u7684\uff0c\u68c0\u67e5\u4e00\u4e0b\u5373\u53ef\u3002<\/p>\n<div class=\"mycode\">$sudo yum install rpm-build<br \/>\nPackage rpm-build-4.4.2.3-18.el5.x86_64 already installed and latest version<br \/>\n$sudo yum install redhat-rpm-config<br \/>\nPackage redhat-rpm-config-8.0.45-32.el5.noarch already installed and latest version<br \/>\n$sudo yum install unifdef<br \/>\nPackage unifdef-1.171-5.fc6.x86_64 already installed and latest version<\/div>\n<div class=\"myt1\">3. \u4e0b\u8f7d\u5e76\u5b89\u88c5\u6e90\u7801\u5305<\/div>\n<p>\u73b0\u5728\u7684RHEL\u53d1\u884c\u7248\u4e2d\uff0c\u5df2\u7ecf\u4e0d\u518d\u5e26\u6e90\u7801\u5305\uff0c\u6240\u4ee5\u9700\u8981\u5355\u72ec\u4e0b\u8f7d\uff0c\u4f9bFlashcache\u7f16\u8bd1\u4f7f\u7528\u3002<\/p>\n<div class=\"myt2\">3.1 \u51c6\u5907\u76ee\u5f55<\/div>\n<div class=\"mycode\">[supu@host]$ cd<br \/>\n[supu@host]$ mkdir -p rpmbuild\/{BUILD,RPMS,SOURCES,SPECS,SRPMS}<br \/>\n[supu@host]$ echo &#8216;%_topdir %(echo $HOME)\/rpmbuild&#8217; &gt; .rpmmacros<\/div>\n<div class=\"myt2\">3.2 \u4e0b\u8f7d\u6e90\u7801\u5305<\/div>\n<p>\u53ef\u4ee5\u5728<a href=\"ftp:\/\/ftp.redhat.com\/pub\/redhat\/linux\/enterprise\/5Server\/en\/os\/SRPMS\">ftp:\/\/ftp.redhat.com\/<\/a>\u4e0b\u8f7d\u5230\u5bf9\u5e94\u7684\u6e90\u7801\u5305\u3002\u8fd9\u91cc\u7684\u5185\u6838\u7248\u672c\u53f7\u662f\uff1a<\/p>\n<div class=\"mycode\">$uname -r<br \/>\n2.6.18-164.el5<\/div>\n<p>\u6240\u4ee5\u9700\u8981\u4e0b\u8f7d\u7684\u662fkernel-2.6.18-164.el5.src.rpm\uff0c\u5b8c\u6574\u7684URL\u662f\uff1a<\/p>\n<div class=\"mycode\">ftp:\/\/ftp.redhat.com\/pub\/redhat\/linux\/enterprise\/5Server\/en\/os\/SRPMS\/kernel-2.6.18-164.el5.src.rpm<\/div>\n<p>\u6ce8\uff1a\u6700\u597d<a href=\"http:\/\/sitka.triumf.ca\/pub\/linux\/redhat-mirror2.html\">\u9009\u62e9\u5408\u9002<\/a>\u7684\u955c\u50cf\u4e0b\u8f7d\uff0c\u901f\u5ea6\u4f1a\u5dee\u5f88\u591a\u7684\u3002<\/p>\n<div class=\"myt2\">3.3 \u5b89\u88c5\u6e90\u7801\u5305<\/div>\n<p>\u6709\u4e86\u524d\u9762\u7684\u76ee\u5f55\u51c6\u5907\uff0c\u73b0\u5728\u53ef\u4ee5\u5b89\u88c5\u6e90\u7801\u5305\u4e86<\/p>\n<div class=\"mycode\">sudo rpm -i kernel-2.6.18-164.el5.src.rpm<br \/>\ncd ~\/rpmbuild\/SPECS<br \/>\nrpmbuild -bp &#8211;target=`uname -m` kernel-2.6.spec 2> prep-err.log | tee prep-out.log<\/div>\n<p>OK\uff0c\u8fd9\u65f6\u5019\u6e90\u7801\u5305\u5c31\u5b89\u88c5\u5230\u4e86\u5982\u4e0b\u76ee\u5f55\uff1a\/home\/supu\/rpmbuild\/BUILD\/kernel-2.6.18\/linux-2.6.18.x86_64<\/p>\n<div class=\"myt2\">3.4 \u51c6\u5907\u6a21\u5757\u7f16\u8bd1<\/div>\n<p>\u5728\u6e90\u7801\u76ee\u5f55\u6267\u884c\u5982\u4e0b\u547d\u4ee4\uff0c\u4e3b\u5907Flashcache\u6a21\u5757\u7f16\u8bd1<\/p>\n<div class=\"mycode\">cd ~\/rpmbuild\/BUILD\/kernel-2.6.18\/linux-2.6.18.x86_64<br \/>\nmake oldconfig<br \/>\nmake prepare<br \/>\nmake modules_prepare<\/div>\n<div class=\"myt1\">4. \u7f16\u8bd1Flashcache<\/div>\n<p>\u53ef\u4ee5\u5728<a href=\"http:\/\/github.com\/facebook\/flashcache\">github<\/a>\u4e0a\u4e0b\u8f7dFlashcache\u7684\u6e90\u4ee3\u7801\uff0c\u548cLinux\u6e90\u7801\u4e00\u8d77\u7f16\u8bd1\uff0c\u7f16\u8bd1\u5b8c\u6210\u540e\u4f1a\u751f\u6210\u4e09\u4e2a\u53ef\u6267\u884c\u7a0b\u5e8f\u548c\u4e00\u4e2a\u53ef\u52a8\u6001\u52a0\u8f7d\u7684\u5185\u6838\u6a21\u5757\uff1a<\/p>\n<div class=\"mycode\">flashcache_create<br \/>\nflashcache_load<br \/>\nflashcache_destroy<br \/>\nflashcache.ko<\/div>\n<div class=\"myt2\">4.1 \u4e0b\u8f7d\u5e76\u51c6\u5907\u7f16\u8bd1<\/div>\n<p>\u5728\u5728<a href=\"http:\/\/github.com\/facebook\/flashcache\">github<\/a>\u4e0a\u53ef\u4ee5\u4e0b\u8f7d\u5230Flashcache\u6700\u65b0\u7684\u6e90\u7801\u3002\u8fd9\u91cc\u4e0b\u8f7d\u7684\u662fflashcache-1.0.11\uff0c\u89e3\u538b\u540e\uff0c\u6709\u5982\u4e0b\u76ee\u5f55\uff1a<\/p>\n<div class=\"mycode\">[supu@host facebook-flashcache-15adea8]$ ls<br \/>\ndoc  flashcache-wt  LICENSE  Makefile  README  README-CentOS5.4  README-DKMS  src<\/div>\n<p>\u5176\u4e2dsrc\u5305\u542b\u4e86\u666e\u901a\u7684Flashcache\uff08\u8fd9\u91cc\u7684\u666e\u901a\u6307\u7684\u662fWrite-back\u7248\u672c\u7684Flashcache\uff09\uff0cflashcache-wt\u5305\u542b\u4e86Write-Through\u7248\u672c\u7684\u6e90\u7801\uff1b\u6587\u4ef6README-CentOS5.4\u4e2d\u5305\u542b\u4e86\u5728RHEL5.4\u4e0b\u7f16\u8bd1\u7684\u6ce8\u610f\u4e8b\u9879\uff0c\u672c\u6587\u4e3b\u8981\u53c2\u8003\u8be5\u6587\u4ef6\u3002<\/p>\n<p>\u6309\u7167README-CentOS5.4\u4e2d\u7684\u8bf4\u660e\uff0c\u4fee\u6539\u6587\u4ef6src\/Makefile\uff0c\u5c06\u884cEXTRA_CFLAGS\uff08\u7b2c\u4e00\u884c\uff09\uff0c\u7528\u5982\u4e0b\u5185\u5bb9\u66ff\u6362\uff1a<\/p>\n<pre><div class=\"mycode\">EXTRA_CFLAGS=-I$(KERNEL_TREE)\/drivers\/md -I$(KERNEL_TREE)\/include\/linux  -I.\/<\/div><\/pre>\n<div style=\"color:red\">\u6ce8\u610f\uff1a\u8fd9\u91cc\u6ca1\u6709\u6362\u884c\u3002<\/div>\n<div class=\"myt2\">4.2 \u7f16\u8bd1\u4e4b<\/div>\n<div class=\"mycode\">make KERNEL_TREE=\/home\/supu\/rpmbuild\/BUILD\/kernel-2.6.18\/linux-2.6.18.x86_64\/<\/div>\n<div class=\"myt2\">4.3 \u52a8\u6001\u52a0\u8f7d\u6a21\u5757<\/div>\n<p>\u6700\u540e\u9700\u8981\u5c06\u6a21\u5757flashcache.ko\u52a0\u8f7d\u5230\u5185\u6838\uff0c\u8fd9\u91cc\u53ef\u4ee5\u5c06flashcache.ko\u62f7\u8d1d\u5230\u76f8\u5e94\u76ee\u5f55\uff1a<\/p>\n<div class=\"mycode\">sudo cp flashcache.ko \/lib\/modules\/2.6.18-164.el5\/kernel\/drivers\/block<\/div>\n<p>\u6216\u8005\u4f7f\u7528insmod\u547d\u4ee4\uff0c\u52a8\u6001\u52a0\u8f7d\u4e4b\uff1a<\/p>\n<div class=\"mycode\">sudo insmod flashcache.ko <\/div>\n<p>Job Done! Enjoy!<\/p>\n<p>\u53c2\u8003\uff1a<\/p>\n<p>1. <a href=\"http:\/\/github.com\/facebook\/flashcache\/blob\/master\/README-CentOS5.4\">Flashcache README-CentOS5.4<\/a><\/p>\n<p>2. <a href=\"http:\/\/github.com\/facebook\/flashcache\/blob\/master\/README\">Flashcache README<\/a><\/p>\n<p>3. <a href=\"http:\/\/www.cyberciti.biz\/faq\/rhel5-installing-kernel-source-code\/\">Redhat enterprise Linux \/ CentOS installing kernel source code<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Flashcache\u7684\u5b89\u88c5\u5728\u5176README\u548cREADME-CentOS5.4\u5df2\u7ecf\u6709\u4e00\u4e2a\u5f88\u8be6\u7ec6\u7684\u8bf4\u660e\u4e86\uff0c\u4f46\u662f\u5b9e\u9645\u64cd\u4f5c\u5e76\u4e0d\u662f\u5f88\u987a\u5229\uff0c\u800c\u4e14\u6709\u4e9b\u540c\u4e8b\u8868\u793a\u5728\u7f16\u8bd1\u8fc7\u7a0b\u4e2d\u4ecd\u9047\u5230\u4e86\u4e00\u4e9b\u95ee\u9898\uff0c\u8fd9\u91cc\u8be6\u7ec6\u7684\u8bb0\u5f55\u4e00\u4e0b\u81ea\u5df1\u7684\u7f16\u8bd1\u3001\u5b89\u88c5\u8fc7\u7a0b\u3002 1. \u73af\u5883\u8bf4\u660e \u4f7f\u7528\u7684\u662fRHEL5.4\u7684\u7cfb\u7edf\uff1a $cat \/etc\/issue Red Hat Enterprise Linux Server release 5.4 (Tikanga) $uname -a Linux myhost 2.6.18-164.el5 #1 SMP Tue Aug 18 15:51:48 EDT 2009 x86_64 x86_64 x86_64 GNU\/Linux<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_eb_attr":"","inline_featured_image":false,"_tocer_settings":[],"footnotes":""},"categories":[27,6],"tags":[60,121],"class_list":["post-2503","post","type-post","status-publish","format-standard","hentry","category-linux","category-mysql","tag-flashcache","tag-linux"],"_links":{"self":[{"href":"https:\/\/www.orczhou.com\/index.php\/wp-json\/wp\/v2\/posts\/2503","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.orczhou.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.orczhou.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.orczhou.com\/index.php\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.orczhou.com\/index.php\/wp-json\/wp\/v2\/comments?post=2503"}],"version-history":[{"count":23,"href":"https:\/\/www.orczhou.com\/index.php\/wp-json\/wp\/v2\/posts\/2503\/revisions"}],"predecessor-version":[{"id":2625,"href":"https:\/\/www.orczhou.com\/index.php\/wp-json\/wp\/v2\/posts\/2503\/revisions\/2625"}],"wp:attachment":[{"href":"https:\/\/www.orczhou.com\/index.php\/wp-json\/wp\/v2\/media?parent=2503"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.orczhou.com\/index.php\/wp-json\/wp\/v2\/categories?post=2503"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.orczhou.com\/index.php\/wp-json\/wp\/v2\/tags?post=2503"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}