<?xml version="1.0" encoding="utf-8"?><?xml-stylesheet href='http://rss.ningoo.net/styles/feedsky1.xsl' type='text/xsl' ?><!--这是一个由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><atom:link href="http://rss.ningoo.net" type="application/rss+xml" rel="self"></atom:link><fs:self_link href="http://feed.feedsky.com/NinGoo" type="application/rss+xml"></fs:self_link><lastBuildDate>Mon, 01 Mar 2010 12:42:31 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>Mon, 08 Mar 2010 13:35:20 GMT</pubDate><item><title>Cassandra Commitlog</title><link>http://item.feedsky.com/~feedsky/NinGoo/~1461473/339934196/1237504/1/item.html</link><content:encoded>&lt;p&gt;Author:&lt;a href='http://www.ningoo.net'&gt;NinGoo&lt;/a&gt; posted on &lt;a href='http://www.ningoo.net/html/2010/cassandra_commitlog.html'&gt;NinGoo.net&lt;/a&gt; &lt;a href='http://rss.ningoo.net'&gt;&lt;img style='border: 0pt none;' align='middle' src='http://www.feedsky.com/feed/NinGoo/sc/gif'&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;&lt;a href=&quot;http://www.ningoo.net/html/2010/cassandra_storage.html&quot;&gt;上一篇blog&lt;/a&gt;中，大致介绍了一下Cassandra的存储机制，通过将最新的写操作放在内存中的Memtable，然后定期刷新到磁盘持久化为SSTable，Cassandra将随机写操作转换成了顺序写操作，这可以提升IO性能。&lt;/p&gt;
&lt;p&gt;最新写入的脏数据是在内存Memtable表中，因此必须有机制来确保异常情况下，能够将内存中的数据恢复出来。和关系型数据库系统一样，Cassandra也是采用的先写日志再写数据的方式，其日志称之为Commitlog。&lt;/p&gt;
&lt;p&gt;和Memtable/SSTable不一样的是，&lt;strong&gt;Commitlog是server级别的，不是Column Family级别的&lt;/strong&gt;。每个Commitlog文件的大小是固定的，称之为一个Commitlog Segment，目前版本(0.5.1)中，这个大小是128MB，这是硬编码在代码(src\java\org\apache\cassandra\db\Commitlog.java)中的。当一个Commitlog文件写满以后，会新建一个的文件。当旧的Commitlog文件不再需要时，会自动清除。&lt;/p&gt;
&lt;p&gt;每个Commitlog文件(Segment)都有一个固定大小（大小根据Column Family的数目而定）的&lt;strong&gt;CommitlogHeader&lt;/strong&gt;结构，其中有两个重要的数组，每一个Column Family在这两个数组中都存在一个对应的元素。其中一个是位图数组(&lt;strong&gt;BitSet dirty&lt;/strong&gt;)，如果Column Family对应的Memtable中有脏数据，则置为1，否则为0，这在恢复的时候可以指出哪些Column Family是需要利用Commitlog进行恢复的。另外一个是整数数组(&lt;strong&gt;int[] lastFlushedAt&lt;/strong&gt;)，保存的是Column Family在上一次Flush时日志的偏移位置，恢复时则可以从这个位置读取Commitlog记录。通过这两个数组结构，Cassandra可以在异常重启服务的时候根据持久化的SSTable和Commitlog重构内存中Memtable的内容，也就是类似Oracle等关系型数据库的实例恢复。&lt;/p&gt;
&lt;p&gt;当Memtable flush到磁盘的SStable时，会将所有Commitlog文件的dirty数组对应的位清零，而在Commitlog达到大小限制创建新的文件时，dirty数组会从上一个文件中继承过来。如果一个Commitlog文件的dirty数组全部被清零，则表示这个Commitlog在恢复的时候不再需要，可以被清除。因此，在恢复的时候，所有的磁盘上存在的Commitlog文件都是需要的。&lt;/p&gt;
&lt;p&gt;参考文章：&lt;br /&gt;
[1].&lt;a href=&quot;http://wiki.apache.org/cassandra/ArchitectureCommitLog&quot;&gt;http://wiki.apache.org/cassandra/ArchitectureCommitLog&lt;/a&gt;&lt;/p&gt;
&lt;br/&gt;&lt;b&gt;Related Articles&lt;/b&gt;&lt;p&gt;&lt;ul class=&quot;related_post&quot;&gt;&lt;li&gt;&lt;a href=&quot;http://www.ningoo.net/html/2010/cassandra_storage.html&quot; title=&quot;Cassandra存储机制&quot;&gt;Cassandra存储机制&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;http://www.ningoo.net/html/2009/nosql_teminator_of_rdbms.html&quot; title=&quot;NoSQL，关系数据库终结者？&quot;&gt;NoSQL，关系数据库终结者？&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;http://www.ningoo.net/html/2008/zz_shu_dao_and_earthquake.html&quot; title=&quot;转载：恕道&quot;&gt;转载：恕道&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;http://www.ningoo.net/html/2009/amoeba_for_mysql_distribute_environment.html&quot; title=&quot;用Amoeba构架MySQL分布式数据库环境&quot;&gt;用Amoeba构架MySQL分布式数据库环境&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;http://www.ningoo.net/html/2007/introduction_of_oracle_olap_component.html&quot; title=&quot;Oracle OLAP组件简介&quot;&gt;Oracle OLAP组件简介&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;http://www.ningoo.net/html/2008/an_accident_in_zhejiang_university.html&quot; title=&quot;小心慢行，安全第一&quot;&gt;小心慢行，安全第一&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;PermLink:&lt;/b&gt; &lt;a href='http://www.ningoo.net/html/2010/cassandra_commitlog.html'&gt;http://www.ningoo.net/html/2010/cassandra_commitlog.html&lt;/a&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;&lt;a href='http://www.ningoo.net/html/2010/cassandra_commitlog.html#comment'&gt;Add Comments(0)&lt;/a&gt;&lt;/b&gt; | &lt;b&gt;&lt;a href='http://twitter.com/NinGoo'&gt;Follow NinGoo@Twitter&lt;/a&gt;&lt;/b&gt; | &lt;b&gt;&lt;a href='http://www.google.com/ig/add?feedurl=http://rss.ningoo.net'&gt;Google Reader&lt;/a&gt;&lt;/b&gt;&lt;/p&gt;&lt;img src=&quot;http://www1.feedsky.com/t1/339934196/NinGoo/feedsky/s.gif?r=http://item.feedsky.com/~feedsky/NinGoo/~1461473/339934196/1237504/1/item.html&quot; border=&quot;0&quot; height=&quot;0&quot; width=&quot;0&quot; style=&quot;position:absolute&quot; /&gt;&lt;p class=&quot;fswww1&quot;&gt;&lt;a href=&quot;http://www1.feedsky.com/r/l/feedsky/NinGoo/339934196/art01.html&quot; target=&quot;_blank&quot;&gt;&lt;img border=&quot;0&quot; ismap=&quot;ismap&quot; src=&quot;http://www1.feedsky.com/r/i/feedsky/NinGoo/339934196/art01.gif&quot; onerror=&quot;this.style.display='none'&quot; /&gt;&lt;/a&gt;&lt;/p&gt;</content:encoded><wfw:commentRss>http://www.ningoo.net/html/2010/cassandra_commitlog.html/feed</wfw:commentRss><slash:comments>0</slash:comments><description>Author:NinGoo posted on NinGoo.net 上一篇blog中，大致介绍了一下Cassandra的存储机制，通过将最新的写操作放在内存中的Memtable，然后定期刷新到磁盘持久化为SSTable，Cassandra将随机写操作转换成了顺序...&lt;img src=&quot;http://www1.feedsky.com/t1/339934196/NinGoo/feedsky/s.gif?r=http://item.feedsky.com/~feedsky/NinGoo/~1461473/339934196/1237504/1/item.html&quot; border=&quot;0&quot; height=&quot;0&quot; width=&quot;0&quot; style=&quot;position:absolute&quot; /&gt;&lt;p class=&quot;fswww1&quot;&gt;&lt;a href=&quot;http://www1.feedsky.com/r/l/feedsky/NinGoo/339934196/art01.html&quot; target=&quot;_blank&quot;&gt;&lt;img border=&quot;0&quot; ismap=&quot;ismap&quot; src=&quot;http://www1.feedsky.com/r/i/feedsky/NinGoo/339934196/art01.gif&quot; onerror=&quot;this.style.display='none'&quot; /&gt;&lt;/a&gt;&lt;/p&gt;</description><category>Commitlog</category><category>NoSQL</category><category>Cassandra</category><pubDate>Mon, 01 Mar 2010 20:42:31 +0800</pubDate><author>NinGoo</author><comments>http://www.ningoo.net/html/2010/cassandra_commitlog.html#comments</comments><guid isPermaLink="false">http://www.ningoo.net/?p=1195</guid><dc:creator>NinGoo</dc:creator><fs:srclink>http://www.ningoo.net/html/2010/cassandra_commitlog.html</fs:srclink><fs:srcfeed>http://www.ningoo.net/feed/</fs:srcfeed><fs:itemid>feedsky/NinGoo/~1461473/339934196/1237504</fs:itemid></item><item><title>Cassandra存储机制</title><link>http://item.feedsky.com/~feedsky/NinGoo/~1461473/339934197/1237504/1/item.html</link><content:encoded>&lt;p&gt;Author:&lt;a href='http://www.ningoo.net'&gt;NinGoo&lt;/a&gt; posted on &lt;a href='http://www.ningoo.net/html/2010/cassandra_storage.html'&gt;NinGoo.net&lt;/a&gt; &lt;a href='http://rss.ningoo.net'&gt;&lt;img style='border: 0pt none;' align='middle' src='http://www.feedsky.com/feed/NinGoo/sc/gif'&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;在2009年兴起的&lt;a href=&quot;http://www.ningoo.net/html/2009/nosql_teminator_of_rdbms.html&quot;&gt;NoSQL&lt;/a&gt;运动中，Cassandra是其中重要的一个分布式key-value数据库产品，由Facebook在2008年开源，目前是Apache的顶级项目。最近twitter的&lt;a href=&quot;http://www.computerworld.com/s/article/9161078/Twitter_growth_prompts_switch_from_MySQL_to_NoSQL_database?taxonomyId=9&quot;&gt;一篇声明&lt;/a&gt;，表示将从MySQL迁移到Cassandra，更让其声名大振。Cassandra是结合了Google Bigtable的数据模型和Amazon Dynamo高可用框架的一个产品。其数据模型可以参考张瑞的&lt;a href=&quot;http://www.hellodba.net/&quot;&gt;blog&lt;/a&gt;。&lt;/p&gt;
&lt;p&gt;值得说一下的是Cassandra的存储机制，也是借鉴了Bigtable的设计，采用Memtable和SSTable的方式。和关系数据库一样，Cassandra在写数据之前，也需要先记录日志，称之为&lt;strong&gt;commitlog&lt;/strong&gt;，然后数据才会写入到Column Family对应的Memtable中，并且Memtable中的内容是按照key排序好的。Memtable是一种内存结构，满足一定条件后批量刷新到磁盘上，存储为SSTable。这种机制，相当于缓存写回机制(Write-back Cache)，优势在于将随机IO写变成顺序IO写，降低大量的写操作对于存储系统的压力。SSTable一旦完成写入，就不可变更，只能读取。下一次Memtable需要刷新到一个新的SSTable文件中。&lt;strong&gt;所以对于Cassandra来说，可以认为只有顺序写，没有随机写操作。&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;因为SSTable数据不可更新，可能导致同一个Column Family的数据存储在多个SSTable中，这时查询数据时，需要去合并读取Column Family所有的SSTable和Memtable，这样到一个Column Family的数量很大的时候，可能导致查询效率严重下降。因此需要有一种机制能快速定位查询的Key落在哪些SSTable中，而不需要去读取合并所有的SSTable。Cassandra采用的是&lt;strong&gt;Bloom Filter&lt;/strong&gt;算法，通过多个hash函数将key映射到一个位图中，来快速判断这个key属于哪个SSTable。关于Bloom Filter，有兴趣的可以去看看参考文章4,5和6。&lt;/p&gt;
&lt;p&gt;为了避免大量SSTable带来的性能影响，Cassandra也提供一种定期将多个SSTable合并成一个新的SSTable的机制，因为每个SSTable中的key都是已经排序好的，因此只需要做一次合并排序就可以完成该任务，代价还是可以接受的。所以在Cassandra的数据存储目录中，可以看到三种类型的文件，格式类似于：&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Column Family Name-序号-Data.db&lt;/li&gt;
&lt;li&gt;Column Family Name-序号-Filter.db&lt;/li&gt;
&lt;li&gt;Column Family Name-序号-index.db&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;其中Data.db文件是SSTable数据文件，SSTable是Sorted Strings Table的缩写，按照key排序后存储key/value键值字符串。index.db是索引文件，保存的是每个key在数据文件中的偏移位置，而Filter.db则是Bloom Filter算法生产的映射文件。&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;参考文章：&lt;/strong&gt;&lt;br /&gt;
[1].&lt;a href=&quot;http://wiki.apache.org/cassandra/ArchitectureOverview&quot;&gt;http://wiki.apache.org/cassandra/ArchitectureOverview&lt;/a&gt;&lt;br /&gt;
[2].&lt;a href=&quot;http://wiki.apache.org/cassandra/MemtableSSTable&quot;&gt;http://wiki.apache.org/cassandra/MemtableSSTable&lt;/a&gt;&lt;br /&gt;
[3].&lt;a href=&quot;http://wiki.apache.org/cassandra/ArchitectureSSTable&quot;&gt;http://wiki.apache.org/cassandra/ArchitectureSSTable&lt;/a&gt;&lt;br /&gt;
[4].&lt;a href=&quot;http://blog.csdn.net/jiaomeng/archive/2007/01/27/1495500.aspx&quot;&gt;http://blog.csdn.net/jiaomeng/archive/2007/01/27/1495500.aspx&lt;/a&gt;&lt;br /&gt;
[5].&lt;a href=&quot;http://www.hellodba.net/2009/04/bloom_filter.html&quot;&gt;http://www.hellodba.net/2009/04/bloom_filter.html&lt;/a&gt;&lt;br /&gt;
[6].&lt;a href=&quot;http://www.googlechinablog.com/2007/07/bloom-filter.html&quot;&gt;http://www.googlechinablog.com/2007/07/bloom-filter.html&lt;/a&gt;&lt;br /&gt;
[7].&lt;a href=&quot;http://labs.google.com/papers/bigtable.html&quot;&gt;http://labs.google.com/papers/bigtable.html&lt;/a&gt;&lt;/p&gt;
&lt;br/&gt;&lt;b&gt;Related Articles&lt;/b&gt;&lt;p&gt;&lt;ul class=&quot;related_post&quot;&gt;&lt;li&gt;&lt;a href=&quot;http://www.ningoo.net/html/2010/cassandra_commitlog.html&quot; title=&quot;Cassandra Commitlog&quot;&gt;Cassandra Commitlog&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;http://www.ningoo.net/html/2010/cap_theorem_and_eventually_consistent.html&quot; title=&quot;CAP原理与最终一致性&quot;&gt;CAP原理与最终一致性&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;http://www.ningoo.net/html/2009/nosql_teminator_of_rdbms.html&quot; title=&quot;NoSQL，关系数据库终结者？&quot;&gt;NoSQL，关系数据库终结者？&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;http://www.ningoo.net/html/2009/amoeba_for_mysql_distribute_environment.html&quot; title=&quot;用Amoeba构架MySQL分布式数据库环境&quot;&gt;用Amoeba构架MySQL分布式数据库环境&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;http://www.ningoo.net/html/2008/how_to_dump_file_to_hex_and_reverse.html&quot; title=&quot;Linux中如何将文件dump成16进制值&quot;&gt;Linux中如何将文件dump成16进制值&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;http://www.ningoo.net/html/2009/ora-00494_and_oracle10_2_0_4.html&quot; title=&quot;ORA-00494与Oracle10.2.0.4&quot;&gt;ORA-00494与Oracle10.2.0.4&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;PermLink:&lt;/b&gt; &lt;a href='http://www.ningoo.net/html/2010/cassandra_storage.html'&gt;http://www.ningoo.net/html/2010/cassandra_storage.html&lt;/a&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;&lt;a href='http://www.ningoo.net/html/2010/cassandra_storage.html#comment'&gt;Add Comments(1)&lt;/a&gt;&lt;/b&gt; | &lt;b&gt;&lt;a href='http://twitter.com/NinGoo'&gt;Follow NinGoo@Twitter&lt;/a&gt;&lt;/b&gt; | &lt;b&gt;&lt;a href='http://www.google.com/ig/add?feedurl=http://rss.ningoo.net'&gt;Google Reader&lt;/a&gt;&lt;/b&gt;&lt;/p&gt;&lt;img src=&quot;http://www1.feedsky.com/t1/339934197/NinGoo/feedsky/s.gif?r=http://item.feedsky.com/~feedsky/NinGoo/~1461473/339934197/1237504/1/item.html&quot; border=&quot;0&quot; height=&quot;0&quot; width=&quot;0&quot; style=&quot;position:absolute&quot; /&gt;&lt;p class=&quot;fswww1&quot;&gt;&lt;a href=&quot;http://www1.feedsky.com/r/l/feedsky/NinGoo/339934197/art01.html&quot; target=&quot;_blank&quot;&gt;&lt;img border=&quot;0&quot; ismap=&quot;ismap&quot; src=&quot;http://www1.feedsky.com/r/i/feedsky/NinGoo/339934197/art01.gif&quot; onerror=&quot;this.style.display='none'&quot; /&gt;&lt;/a&gt;&lt;/p&gt;</content:encoded><wfw:commentRss>http://www.ningoo.net/html/2010/cassandra_storage.html/feed</wfw:commentRss><slash:comments>1</slash:comments><description>Author:NinGoo posted on NinGoo.net 在2009年兴起的NoSQL运动中，Cassandra是其中重要的一个分布式key-value数据库产品，由Facebook在2008年开源，目前是Apache的顶级项目。最近twitter的一篇声明，表示将从MySQL迁...&lt;img src=&quot;http://www1.feedsky.com/t1/339934197/NinGoo/feedsky/s.gif?r=http://item.feedsky.com/~feedsky/NinGoo/~1461473/339934197/1237504/1/item.html&quot; border=&quot;0&quot; height=&quot;0&quot; width=&quot;0&quot; style=&quot;position:absolute&quot; /&gt;&lt;p class=&quot;fswww1&quot;&gt;&lt;a href=&quot;http://www1.feedsky.com/r/l/feedsky/NinGoo/339934197/art01.html&quot; target=&quot;_blank&quot;&gt;&lt;img border=&quot;0&quot; ismap=&quot;ismap&quot; src=&quot;http://www1.feedsky.com/r/i/feedsky/NinGoo/339934197/art01.gif&quot; onerror=&quot;this.style.display='none'&quot; /&gt;&lt;/a&gt;&lt;/p&gt;</description><category>Dynamo</category><category>Bloom Filter</category><category>NoSQL</category><category>Cassandra</category><category>Memtable</category><category>SSTable</category><category>分布式</category><pubDate>Thu, 25 Feb 2010 17:17:58 +0800</pubDate><author>NinGoo</author><comments>http://www.ningoo.net/html/2010/cassandra_storage.html#comments</comments><guid isPermaLink="false">http://www.ningoo.net/?p=737</guid><dc:creator>NinGoo</dc:creator><fs:srclink>http://www.ningoo.net/html/2010/cassandra_storage.html</fs:srclink><fs:srcfeed>http://www.ningoo.net/feed/</fs:srcfeed><fs:itemid>feedsky/NinGoo/~1461473/339934197/1237504</fs:itemid></item><item><title>CAP原理与最终一致性</title><link>http://item.feedsky.com/~feedsky/NinGoo/~1461473/339934198/1237504/1/item.html</link><content:encoded>&lt;p&gt;Author:&lt;a href='http://www.ningoo.net'&gt;NinGoo&lt;/a&gt; posted on &lt;a href='http://www.ningoo.net/html/2010/cap_theorem_and_eventually_consistent.html'&gt;NinGoo.net&lt;/a&gt; &lt;a href='http://rss.ningoo.net'&gt;&lt;img style='border: 0pt none;' align='middle' src='http://www.feedsky.com/feed/NinGoo/sc/gif'&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;CAP原理(CAP Theorem)&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;在足球比赛里，一个球员在一场比赛中进三个球，称之为帽子戏法(Hat-trick)。在分布式数据系统中，也有一个帽子原理(CAP Theorem)，不过此帽子非彼帽子。CAP原理中，有三个要素：&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;一致性(&lt;strong&gt;C&lt;/strong&gt;onsistency)&lt;/li&gt;
&lt;li&gt;可用性(&lt;strong&gt;A&lt;/strong&gt;vailability)&lt;/li&gt;
&lt;li&gt;分区容忍性(&lt;strong&gt;P&lt;/strong&gt;artition tolerance)&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;CAP原理指的是，这三个要素最多只能同时实现两点，不可能三者兼顾。因此在进行分布式架构设计时，必须做出取舍。而&lt;strong&gt;对于分布式数据系统，分区容忍性是基本要求&lt;/strong&gt;，否则就失去了价值。因此设计分布式数据系统，就是在一致性和可用性之间取一个平衡。对于大多数web应用，其实并不需要强一致性，因此牺牲一致性而换取高可用性，是目前多数分布式数据库产品的方向。&lt;/p&gt;
&lt;p&gt;当然，牺牲一致性，并不是完全不管数据的一致性，否则数据是混乱的，那么系统可用性再高分布式再好也没有了价值。牺牲一致性，只是不再要求关系型数据库中的强一致性，而是只要系统能达到&lt;strong&gt;最终一致性&lt;/strong&gt;即可，考虑到客户体验，这个最终一致的时间窗口，要尽可能的对用户透明，也就是需要保障“用户感知到的一致性”。通常是通过数据的多份异步复制来实现系统的高可用和数据的最终一致性的，“用户感知到的一致性”的时间窗口则取决于数据复制到一致状态的时间。&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;最终一致性(eventually consistent)&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;对于一致性，可以分为从客户端和服务端两个不同的视角。从客户端来看，一致性主要指的是多并发访问时更新过的数据如何获取的问题。从服务端来看，则是更新如何复制分布到整个系统，以保证数据最终一致。一致性是因为有并发读写才有的问题，因此在理解一致性的问题时，一定要注意结合考虑并发读写的场景。&lt;/p&gt;
&lt;p&gt;从客户端角度，多进程并发访问时，更新过的数据在不同进程如何获取的不同策略，决定了不同的一致性。对于关系型数据库，要求更新过的数据能被后续的访问都能看到，这是&lt;strong&gt;强一致性&lt;/strong&gt;。如果能容忍后续的部分或者全部访问不到，则是&lt;strong&gt;弱一致性&lt;/strong&gt;。如果经过一段时间后要求能访问到更新后的数据，则是最终一致性。&lt;/p&gt;
&lt;p&gt;最终一致性根据更新数据后各进程访问到数据的时间和方式的不同，又可以区分为：&lt;/p&gt;
&lt;blockquote&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;因果一致性&lt;/strong&gt;。如果进程A通知进程B它已更新了一个数据项，那么进程B的后续访问将返回更新后的值，且一次写入将保证取代前一次写入。与进程A无因果关系的进程C的访问遵守一般的最终一致性规则。&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;“读己之所写（read-your-writes）”一致性&lt;/strong&gt;。当进程A自己更新一个数据项之后，它总是访问到更新过的值，绝不会看到旧值。这是因果一致性模型的一个特例。&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;会话（Session）一致性&lt;/strong&gt;。这是上一个模型的实用版本，它把访问存储系统的进程放到会话的上下文中。只要会话还存在，系统就保证“读己之所写”一致性。如果由于某些失败情形令会话终止，就要建立新的会话，而且系统的保证不会延续到新的会话。&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;单调（Monotonic）读一致性&lt;/strong&gt;。如果进程已经看到过数据对象的某个值，那么任何后续访问都不会返回在那个值之前的值。&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;单调写一致性&lt;/strong&gt;。系统保证来自同一个进程的写操作顺序执行。要是系统不能保证这种程度的一致性，就非常难以编程了。&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;
&lt;p&gt;上述最终一致性的不同方式可以进行组合，例如单调读一致性和读己之所写一致性就可以组合实现。并且从实践的角度来看，这两者的组合，读取自己更新的数据，和一旦读取到最新的版本不会再读取旧版本，对于此架构上的程序开发来说，会少很多额外的烦恼。&lt;/p&gt;
&lt;p&gt;从服务端角度，如何尽快将更新后的数据分布到整个系统，降低达到最终一致性的时间窗口，是提高系统的可用度和用户体验非常重要的方面。对于分布式数据系统：&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;N &amp;#8212; 数据复制的份数&lt;/li&gt;
&lt;li&gt;W &amp;#8212; 更新数据是需要保证写完成的节点数&lt;/li&gt;
&lt;li&gt;R &amp;#8212; 读取数据的时候需要读取的节点数&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;如果W+R&gt;N，写的节点和读的节点重叠，则是强一致性。例如对于典型的一主一备同步复制的关系型数据库，N=2,W=2,R=1，则不管读的是主库还是备库的数据，都是一致的。&lt;/p&gt;
&lt;p&gt;如果W+R&lt;=N，则是弱一致性。例如对于一主一备异步复制的关系型数据库，N=2,W=1,R=1，则如果读的是备库，就可能无法读取主库已经更新过的数据，所以是弱一致性。&lt;/p&gt;
&lt;p&gt;对于分布式系统，为了保证高可用性，一般设置N&gt;=3。不同的N,W,R组合，是在可用性和一致性之间取一个平衡，以适应不同的应用场景。&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;如果N=W,R=1，任何一个写节点失效，都会导致写失败，因此可用性会降低，但是由于数据分布的N个节点是同步写入的，因此可以保证强一致性。&lt;/li&gt;
&lt;li&gt;
如果N=R,W=1，只需要一个节点写入成功即可，写性能和可用性都比较高。但是读取其他节点的进程可能不能获取更新后的数据，因此是弱一致性。这种情况下，如果W&lt;(N+1)/2，并且写入的节点不重叠的话，则会存在写冲突&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;&lt;br /&gt;
参考文章：&lt;/strong&gt;&lt;br /&gt;
[1].&lt;a href=&quot;http://devblog.streamy.com/2009/08/24/cap-theorem/&quot;&gt;http://devblog.streamy.com/2009/08/24/cap-theorem/&lt;/a&gt;&lt;br /&gt;
[2].&lt;a href=&quot;http://www.julianbrowne.com/article/viewer/brewers-cap-theorem&quot;&gt;http://www.julianbrowne.com/article/viewer/brewers-cap-theorem&lt;/a&gt;&lt;br /&gt;
[3].&lt;a href=&quot;http://www.allthingsdistributed.com/2008/12/eventually_consistent.html&quot;&gt;http://www.allthingsdistributed.com/2008/12/eventually_consistent.html&lt;/a&gt;&lt;br /&gt;
[4].&lt;a href=&quot;http://www.infoq.com/cn/news/2008/01/consistency-vs-availability&quot;&gt;http://www.infoq.com/cn/news/2008/01/consistency-vs-availability&lt;/a&gt;&lt;/p&gt;
&lt;br/&gt;&lt;b&gt;Related Articles&lt;/b&gt;&lt;p&gt;&lt;ul class=&quot;related_post&quot;&gt;&lt;li&gt;&lt;a href=&quot;http://www.ningoo.net/html/2010/cassandra_storage.html&quot; title=&quot;Cassandra存储机制&quot;&gt;Cassandra存储机制&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;http://www.ningoo.net/html/2009/amoeba_for_mysql_distribute_environment.html&quot; title=&quot;用Amoeba构架MySQL分布式数据库环境&quot;&gt;用Amoeba构架MySQL分布式数据库环境&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;http://www.ningoo.net/html/2008/why_such_big_snows.html&quot; title=&quot;高峡出平湖，冰雪满人间&quot;&gt;高峡出平湖，冰雪满人间&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;http://www.ningoo.net/html/2007/blackberry_zhejiang_library_and_corn.html&quot; title=&quot;黑莓·浙图·玉米&quot;&gt;黑莓·浙图·玉米&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;http://www.ningoo.net/html/2007/dreamhost_database_down.html&quot; title=&quot;遭遇DreamHost数据库故障&quot;&gt;遭遇DreamHost数据库故障&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;http://www.ningoo.net/html/2008/top_10_reason_avoid_the_simpledb.html&quot; title=&quot;不使用SimpleDB的10个理由&quot;&gt;不使用SimpleDB的10个理由&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;PermLink:&lt;/b&gt; &lt;a href='http://www.ningoo.net/html/2010/cap_theorem_and_eventually_consistent.html'&gt;http://www.ningoo.net/html/2010/cap_theorem_and_eventually_consistent.html&lt;/a&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;&lt;a href='http://www.ningoo.net/html/2010/cap_theorem_and_eventually_consistent.html#comment'&gt;Add Comments(0)&lt;/a&gt;&lt;/b&gt; | &lt;b&gt;&lt;a href='http://twitter.com/NinGoo'&gt;Follow NinGoo@Twitter&lt;/a&gt;&lt;/b&gt; | &lt;b&gt;&lt;a href='http://www.google.com/ig/add?feedurl=http://rss.ningoo.net'&gt;Google Reader&lt;/a&gt;&lt;/b&gt;&lt;/p&gt;&lt;img src=&quot;http://www1.feedsky.com/t1/339934198/NinGoo/feedsky/s.gif?r=http://item.feedsky.com/~feedsky/NinGoo/~1461473/339934198/1237504/1/item.html&quot; border=&quot;0&quot; height=&quot;0&quot; width=&quot;0&quot; style=&quot;position:absolute&quot; /&gt;&lt;p class=&quot;fswww1&quot;&gt;&lt;a href=&quot;http://www1.feedsky.com/r/l/feedsky/NinGoo/339934198/art01.html&quot; target=&quot;_blank&quot;&gt;&lt;img border=&quot;0&quot; ismap=&quot;ismap&quot; src=&quot;http://www1.feedsky.com/r/i/feedsky/NinGoo/339934198/art01.gif&quot; onerror=&quot;this.style.display='none'&quot; /&gt;&lt;/a&gt;&lt;/p&gt;</content:encoded><wfw:commentRss>http://www.ningoo.net/html/2010/cap_theorem_and_eventually_consistent.html/feed</wfw:commentRss><slash:comments>0</slash:comments><description>Author:NinGoo posted on NinGoo.net CAP原理(CAP Theorem)
在足球比赛里，一个球员在一场比赛中进三个球，称之为帽子戏法(Hat-trick)。在分布式数据系统中，也有一个帽子原理(CAP Theorem)，不过此帽子非彼帽...&lt;img src=&quot;http://www1.feedsky.com/t1/339934198/NinGoo/feedsky/s.gif?r=http://item.feedsky.com/~feedsky/NinGoo/~1461473/339934198/1237504/1/item.html&quot; border=&quot;0&quot; height=&quot;0&quot; width=&quot;0&quot; style=&quot;position:absolute&quot; /&gt;&lt;p class=&quot;fswww1&quot;&gt;&lt;a href=&quot;http://www1.feedsky.com/r/l/feedsky/NinGoo/339934198/art01.html&quot; target=&quot;_blank&quot;&gt;&lt;img border=&quot;0&quot; ismap=&quot;ismap&quot; src=&quot;http://www1.feedsky.com/r/i/feedsky/NinGoo/339934198/art01.gif&quot; onerror=&quot;this.style.display='none'&quot; /&gt;&lt;/a&gt;&lt;/p&gt;</description><category>CAP</category><category>NoSQL</category><category>最终一致性</category><category>分布式</category><pubDate>Thu, 25 Feb 2010 12:32:00 +0800</pubDate><author>NinGoo</author><comments>http://www.ningoo.net/html/2010/cap_theorem_and_eventually_consistent.html#comments</comments><guid isPermaLink="false">http://www.ningoo.net/?p=1239</guid><dc:creator>NinGoo</dc:creator><fs:srclink>http://www.ningoo.net/html/2010/cap_theorem_and_eventually_consistent.html</fs:srclink><fs:srcfeed>http://www.ningoo.net/feed/</fs:srcfeed><fs:itemid>feedsky/NinGoo/~1461473/339934198/1237504</fs:itemid></item><item><title>dstat:一款简单直观的os实时监控工具</title><link>http://item.feedsky.com/~feedsky/NinGoo/~1461473/339934200/1237504/1/item.html</link><content:encoded>&lt;p&gt;Author:&lt;a href='http://www.ningoo.net'&gt;NinGoo&lt;/a&gt; posted on &lt;a href='http://www.ningoo.net/html/2010/dstat_os_monitor_tool.html'&gt;NinGoo.net&lt;/a&gt; &lt;a href='http://rss.ningoo.net'&gt;&lt;img style='border: 0pt none;' align='middle' src='http://www.feedsky.com/feed/NinGoo/sc/gif'&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;在&lt;a href=&quot;http://www.oschina.net/&quot;&gt;oschina&lt;/a&gt;上闲逛，发现一款不错的os实时监控工具&lt;a href=&quot;http://dag.wieers.com/home-made/dstat/&quot;&gt;dstat&lt;/a&gt;，整合了vmstat, iostat, ifstat, netstat等常见os监控工具的优点，输出的结果简单直观，并且结果可以保存到csv文件，这样再写一个简单的perl脚本，就能将os的主要监控信息一次性全部抓取出来，保存到监控数据库中用于分析展示。试用了一下觉得非常不错，因此在这里分享一下这个用python写的工具。&lt;/p&gt;
&lt;pre&gt;
$dstat
----total-cpu-usage---- -dsk/total- -net/total- ---paging-- ---system--
usr sys idl wai hiq siq| read  writ| recv  send|  in   out | int   csw
  2   0  98   0   0   0|  80k   54k|   0     0 | 335B  381B|1297  1301
 22   2  74   0   0   2|   0   416k| 621k  219k|   0     0 |1158    26k
 23   3  72   0   0   2|  64k  484k|  11k   11k|   0     0 |1109    30k
 21   3  75   0   0   2|4096B  416k|  77k   77k|   0     0 |2104    25k
 29   4  66   0   0   2|   0  1240k| 996k  425k|   0     0 |1350    28k
&lt;/pre&gt;
&lt;pre&gt;
$dstat -ta --output osstat.csv
-----time----- ----total-cpu-usage---- -dsk/total- -net/total- ---paging-- ---system--
  date/time   |usr sys idl wai hiq siq| read  writ| recv  send|  in   out | int   csw
05-02 11:37:08|  2   0  98   0   0   0|  80k   54k|   0     0 | 335B  381B|1297  1301
05-02 11:37:09| 16   4  78   0   0   3|   0  1404k|1478k  939k|   0     0 |4316    33k
05-02 11:37:10| 20   2  76   0   0   2|   0  1144k|1109k  828k|   0     0 |5653    28k
05-02 11:37:11| 13   2  83   0   0   2|   0   588k|2590k 1684k|   0     0 |4256    23k
&lt;/pre&gt;
&lt;pre&gt;
$dstat -h
Usage: dstat [-afv] [options..] [delay [count]]
Versatile tool for generating system resource statistics

Dstat options:
  -c, --cpu              enable cpu stats
     -C 0,3,total           include cpu0, cpu3 and total
  -d, --disk             enable disk stats
     -D total,hda           include hda and total
  -g, --page             enable page stats
  -i, --int              enable interrupt stats
     -I 5,eth2              include int5 and interrupt used by eth2
  -l, --load             enable load stats
  -m, --mem              enable memory stats
  -n, --net              enable network stats
     -N eth1,total          include eth1 and total
  -p, --proc             enable process stats
  -s, --swap             enable swap stats
     -S swap1,total         include swap1 and total
  -t, --time             enable time/date output
  -T, --epoch            enable time counter (seconds since epoch)
  -y, --sys              enable system stats
  --ipc                  enable ipc stats
  --lock                 enable lock stats
  --raw                  enable raw stats
  --tcp                  enable tcp stats
  --udp                  enable udp stats
  --unix                 enable unix stats

  -M stat1,stat2         enable external stats
     --mods stat1,stat2

  -a, --all              equals -cdngy (default)
  -f, --full             expand -C, -D, -I, -N and -S discovery lists
  -v, --vmstat           equals -pmgdsc -D total

  --integer              show integer values
  --nocolor              disable colors (implies --noupdate)
  --noheaders            disable repetitive headers
  --noupdate             disable intermediate updates
  --output file          write CSV output to file

  delay is the delay in seconds between each update
  count is the number of updates to display before exiting
  The default delay is 1 and count is unspecified (unlimited)
&lt;/pre&gt;
&lt;br/&gt;&lt;b&gt;Related Articles&lt;/b&gt;&lt;p&gt;&lt;ul class=&quot;related_post&quot;&gt;&lt;li&gt;&lt;a href=&quot;http://www.ningoo.net/html/2010/tbstat_a_tool_for_oracle_sysstat_realtime_monitor.html&quot; title=&quot;tbstat:实时监控数据库统计状态的小工具&quot;&gt;tbstat:实时监控数据库统计状态的小工具&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;http://www.ningoo.net/html/2009/use_jpgraph_for_database_monitor.html&quot; title=&quot;使用jpgraph绘制数据库监控图形&quot;&gt;使用jpgraph绘制数据库监控图形&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;http://www.ningoo.net/html/2009/use_oracle_regexp_monitor_database_session.html&quot; title=&quot;使用Oracle正则表达式监控应用到数据库的连接情况&quot;&gt;使用Oracle正则表达式监控应用到数据库的连接情况&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;http://www.ningoo.net/html/2009/how_to_monitor_stats_of_memcached.html&quot; title=&quot;如何监控MemCached的状态&quot;&gt;如何监控MemCached的状态&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;http://www.ningoo.net/html/2009/use_jquery_and_tablesorter_for_data_sort_and_pager.html&quot; title=&quot;用jQuery+Tablesorter实现客户端分页与排序&quot;&gt;用jQuery+Tablesorter实现客户端分页与排序&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;http://www.ningoo.net/html/2008/using_perl_monitor_database.html&quot; title=&quot;用Perl的hash数组实现个性化监控&quot;&gt;用Perl的hash数组实现个性化监控&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;PermLink:&lt;/b&gt; &lt;a href='http://www.ningoo.net/html/2010/dstat_os_monitor_tool.html'&gt;http://www.ningoo.net/html/2010/dstat_os_monitor_tool.html&lt;/a&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;&lt;a href='http://www.ningoo.net/html/2010/dstat_os_monitor_tool.html#comment'&gt;Add Comments(3)&lt;/a&gt;&lt;/b&gt; | &lt;b&gt;&lt;a href='http://twitter.com/NinGoo'&gt;Follow NinGoo@Twitter&lt;/a&gt;&lt;/b&gt; | &lt;b&gt;&lt;a href='http://www.google.com/ig/add?feedurl=http://rss.ningoo.net'&gt;Google Reader&lt;/a&gt;&lt;/b&gt;&lt;/p&gt;&lt;img src=&quot;http://www1.feedsky.com/t1/339934200/NinGoo/feedsky/s.gif?r=http://item.feedsky.com/~feedsky/NinGoo/~1461473/339934200/1237504/1/item.html&quot; border=&quot;0&quot; height=&quot;0&quot; width=&quot;0&quot; style=&quot;position:absolute&quot; /&gt;&lt;p class=&quot;fswww1&quot;&gt;&lt;a href=&quot;http://www1.feedsky.com/r/l/feedsky/NinGoo/339934200/art01.html&quot; target=&quot;_blank&quot;&gt;&lt;img border=&quot;0&quot; ismap=&quot;ismap&quot; src=&quot;http://www1.feedsky.com/r/i/feedsky/NinGoo/339934200/art01.gif&quot; onerror=&quot;this.style.display='none'&quot; /&gt;&lt;/a&gt;&lt;/p&gt;</content:encoded><wfw:commentRss>http://www.ningoo.net/html/2010/dstat_os_monitor_tool.html/feed</wfw:commentRss><slash:comments>3</slash:comments><description>Author:NinGoo posted on NinGoo.net 在oschina上闲逛，发现一款不错的os实时监控工具dstat，整合了vmstat, iostat, ifstat, netstat等常见os监控工具的优点，输出的结果简单直观，并且结果可以保存到csv文件，这...&lt;img src=&quot;http://www1.feedsky.com/t1/339934200/NinGoo/feedsky/s.gif?r=http://item.feedsky.com/~feedsky/NinGoo/~1461473/339934200/1237504/1/item.html&quot; border=&quot;0&quot; height=&quot;0&quot; width=&quot;0&quot; style=&quot;position:absolute&quot; /&gt;&lt;p class=&quot;fswww1&quot;&gt;&lt;a href=&quot;http://www1.feedsky.com/r/l/feedsky/NinGoo/339934200/art01.html&quot; target=&quot;_blank&quot;&gt;&lt;img border=&quot;0&quot; ismap=&quot;ismap&quot; src=&quot;http://www1.feedsky.com/r/i/feedsky/NinGoo/339934200/art01.gif&quot; onerror=&quot;this.style.display='none'&quot; /&gt;&lt;/a&gt;&lt;/p&gt;</description><category>dstat</category><category>工具</category><category>python</category><category>监控</category><pubDate>Fri, 05 Feb 2010 11:43:21 +0800</pubDate><author>NinGoo</author><comments>http://www.ningoo.net/html/2010/dstat_os_monitor_tool.html#comments</comments><guid isPermaLink="false">http://www.ningoo.net/?p=1255</guid><dc:creator>NinGoo</dc:creator><fs:srclink>http://www.ningoo.net/html/2010/dstat_os_monitor_tool.html</fs:srclink><fs:srcfeed>http://www.ningoo.net/feed/</fs:srcfeed><fs:itemid>feedsky/NinGoo/~1461473/339934200/1237504</fs:itemid></item><item><title>PostgreSQL备份</title><link>http://item.feedsky.com/~feedsky/NinGoo/~1461473/339934202/1237504/1/item.html</link><content:encoded>&lt;p&gt;Author:&lt;a href='http://www.ningoo.net'&gt;NinGoo&lt;/a&gt; posted on &lt;a href='http://www.ningoo.net/html/2010/postgresql_backup.html'&gt;NinGoo.net&lt;/a&gt; &lt;a href='http://rss.ningoo.net'&gt;&lt;img style='border: 0pt none;' align='middle' src='http://www.feedsky.com/feed/NinGoo/sc/gif'&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;PostgreSQL也支持逻辑备库和物理备份两种方式。物理备份可以和Oracle一样实现联机热备份，并且同样也需要将数据库设置为归档模式。&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;逻辑备份&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;PostgreSQL提供了pg_dump/pg_dumpall两个程序可以用来将数据dump成文本文件，实现数据的逻辑备份。使用不同的参数，可以将数据dump成PostgreSQL专用的数据格式(生成copy语句)或者标准SQL语句(生成insert语句)格式。恢复只需要简单的使用psql将文件执行一遍即可。另外也可以使用pg_restore工具来恢复数据。&lt;/p&gt;
&lt;p&gt;利用pg_dump备份test数据库(只有一张test表)，包括重建表的DDL语句，授权语句等所有信息，生成copy格式的文件：&lt;/p&gt;
&lt;pre&gt;
$ ./pg_dump test
--
-- PostgreSQL database dump
--
SET statement_timeout = 0;
SET client_encoding = 'UTF8';
SET standard_conforming_strings = off;
SET check_function_bodies = false;
SET client_min_messages = warning;
SET escape_string_warning = off;
SET search_path = public, pg_catalog;
SET default_tablespace = '';
SET default_with_oids = false;
--
-- Name: test; Type: TABLE; Schema: public; Owner: postgres; Tablespace:
--
CREATE TABLE test (
    i integer
);
ALTER TABLE public.test OWNER TO postgres;
--
-- Data for Name: test; Type: TABLE DATA; Schema: public; Owner: postgres
--
COPY test (i) FROM stdin;
1
2
\.
--
-- Name: public; Type: ACL; Schema: -; Owner: postgres
--
REVOKE ALL ON SCHEMA public FROM PUBLIC;
REVOKE ALL ON SCHEMA public FROM postgres;
GRANT ALL ON SCHEMA public TO postgres;
GRANT ALL ON SCHEMA public TO PUBLIC;
--
-- PostgreSQL database dump complete
--
&lt;/pre&gt;
&lt;p&gt;利用pg_dump备份test库，只保存数据，insert语句格式：&lt;/p&gt;
&lt;pre&gt;
[postgres@dbconsole bin]$ ./pg_dump --inserts -a test
--
-- PostgreSQL database dump
--
SET statement_timeout = 0;
SET client_encoding = 'UTF8';
SET standard_conforming_strings = off;
SET check_function_bodies = false;
SET client_min_messages = warning;
SET escape_string_warning = off;
SET search_path = public, pg_catalog;
--
-- Data for Name: test; Type: TABLE DATA; Schema: public; Owner: postgres
--
INSERT INTO test VALUES (1);
INSERT INTO test VALUES (2);
--
-- PostgreSQL database dump complete
--
&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;物理备份&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;和Oracle一样，物理备份可以分为冷备份和热备份。冷备份就是将数据库实例关闭，然后直接复制data目录的所有文件，恢复时只需要将文件copy到data目录，无须利用日志(WAL&amp;#8211;Write-Ahead Logging）进行恢复。而热备份，则需要利用日志将数据库恢复到一致状态，因此需要先将数据库置于归档模式。&lt;/p&gt;
&lt;p&gt;PostgreSQL归档模式使用参数archive_mode控制，这是一个静态参数，修改postgresql.conf文件，加入如下参数，然后重启生效：&lt;/p&gt;
&lt;pre&gt;
archive_mode = on
archive_command = 'cp &quot;%p&quot; /u01/postgresql/arch/&quot;%f&quot;'
archive_timeout = 600
&lt;/pre&gt;
&lt;pre&gt;
postgres=# show archive_mode;
 archive_mode
--------------
 on
(1 row)
&lt;/pre&gt;
&lt;p&gt;由于postgresql没有归档进程，因此归档是通过外部命令(OS)完成的，archive_command用于指定该外部命令，具体格式请参考文档。如果是linux归档到本地，使用cp即可，如果是到远程，则可以使用scp或者rsync。archive_timeout强制N秒以后进行一次归档，这个和Oracle的archive_lag_target参数的作用一样。当然也可以手工进行日志切换：&lt;/p&gt;
&lt;pre&gt;
postgres=# select pg_switch_xlog();
 pg_switch_xlog
----------------
 0/7000000
(1 row)
&lt;/pre&gt;
&lt;p&gt;热备份前，需要先将数据库置于备份状态，这一点和Oracle的手工也备份也是一样的。该命令会导致一次checkpoint，可能在业务高峰期会带来一些压力和风险，因此备份还是需要安排在业务低谷期间执行比较稳妥。&lt;/p&gt;
&lt;pre&gt;
postgres=# select pg_start_backup('test_backup');
 pg_start_backup
-----------------
 0/8000020
(1 row)
&lt;/pre&gt;
&lt;p&gt;然后在os层面将data目录进行复制备份。完成后，再取消备份状态，该命令同时会执行一次日志切换，并进行归档，以保证热备份期间的日志都已经归档，保证恢复数据库到一致状态的所有日志都能从归档中找到：&lt;/p&gt;
&lt;pre&gt;
postgres=# select pg_stop_backup();
 pg_stop_backup
----------------
 0/8000088
(1 row)
&lt;/pre&gt;
&lt;p&gt;备份完成后，可以在归档目录找到一个记录了本次备份信息的文件：&lt;/p&gt;
&lt;pre&gt;
$ more 000000010000000000000008.00000020.backup
START WAL LOCATION: 0/8000020 (file 000000010000000000000008)
STOP WAL LOCATION: 0/8000088 (file 000000010000000000000008)
CHECKPOINT LOCATION: 0/8000020
START TIME: 2010-02-03 12:24:57 CST
LABEL: test_backup
STOP TIME: 2010-02-03 12:24:59 CST
&lt;/pre&gt;
&lt;p&gt;PostgreSQL官方并没有提供和Oracle的rman一样的备份工具，不过因为PostgreSQL是开源的数据库，因此也有一个开源的工具&lt;a href=&quot;http://code.google.com/p/pg-rman/wiki/readme&quot;&gt;pg_rman&lt;/a&gt;可以使用，从命令行来看功能已经非常强大，暂时还没有测试，有兴趣的可以研究一下。&lt;/p&gt;
&lt;pre&gt;
pg_rman [ OPTIONS ] { init | backup | restore | show [ DATE | timeline ] |
 validate [ DATE ] | delete DATE }
&lt;/pre&gt;
&lt;br/&gt;&lt;b&gt;Related Articles&lt;/b&gt;&lt;p&gt;&lt;ul class=&quot;related_post&quot;&gt;&lt;li&gt;&lt;a href=&quot;http://www.ningoo.net/html/2010/installpostgresql.html&quot; title=&quot;PostgreSQL安装&quot;&gt;PostgreSQL安装&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;http://www.ningoo.net/html/2010/introduce_to_postgresql.html&quot; title=&quot;PostgreSQL简介&quot;&gt;PostgreSQL简介&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;http://www.ningoo.net/html/2007/my_2007.html&quot; title=&quot;懵懵懂懂又一年&quot;&gt;懵懵懂懂又一年&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;http://www.ningoo.net/html/2008/dba_feature_usage_statistics.html&quot; title=&quot;你的数据库使用了哪些特性?&quot;&gt;你的数据库使用了哪些特性?&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;http://www.ningoo.net/html/2008/ssd_harddisk_is_coming_soon.html&quot; title=&quot;SSD硬盘时代即将到来？&quot;&gt;SSD硬盘时代即将到来？&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;http://www.ningoo.net/html/2007/starcraft2_coming_soon.html&quot; title=&quot;StarCraft II呼之欲出&quot;&gt;StarCraft II呼之欲出&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;PermLink:&lt;/b&gt; &lt;a href='http://www.ningoo.net/html/2010/postgresql_backup.html'&gt;http://www.ningoo.net/html/2010/postgresql_backup.html&lt;/a&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;&lt;a href='http://www.ningoo.net/html/2010/postgresql_backup.html#comment'&gt;Add Comments(0)&lt;/a&gt;&lt;/b&gt; | &lt;b&gt;&lt;a href='http://twitter.com/NinGoo'&gt;Follow NinGoo@Twitter&lt;/a&gt;&lt;/b&gt; | &lt;b&gt;&lt;a href='http://www.google.com/ig/add?feedurl=http://rss.ningoo.net'&gt;Google Reader&lt;/a&gt;&lt;/b&gt;&lt;/p&gt;&lt;img src=&quot;http://www1.feedsky.com/t1/339934202/NinGoo/feedsky/s.gif?r=http://item.feedsky.com/~feedsky/NinGoo/~1461473/339934202/1237504/1/item.html&quot; border=&quot;0&quot; height=&quot;0&quot; width=&quot;0&quot; style=&quot;position:absolute&quot; /&gt;&lt;p class=&quot;fswww1&quot;&gt;&lt;a href=&quot;http://www1.feedsky.com/r/l/feedsky/NinGoo/339934202/art01.html&quot; target=&quot;_blank&quot;&gt;&lt;img border=&quot;0&quot; ismap=&quot;ismap&quot; src=&quot;http://www1.feedsky.com/r/i/feedsky/NinGoo/339934202/art01.gif&quot; onerror=&quot;this.style.display='none'&quot; /&gt;&lt;/a&gt;&lt;/p&gt;</content:encoded><wfw:commentRss>http://www.ningoo.net/html/2010/postgresql_backup.html/feed</wfw:commentRss><slash:comments>0</slash:comments><description>Author:NinGoo posted on NinGoo.net PostgreSQL也支持逻辑备库和物理备份两种方式。物理备份可以和Oracle一样实现联机热备份，并且同样也需要将数据库设置为归档模式。
逻辑备份
PostgreSQL提供了pg_dump/pg_...&lt;img src=&quot;http://www1.feedsky.com/t1/339934202/NinGoo/feedsky/s.gif?r=http://item.feedsky.com/~feedsky/NinGoo/~1461473/339934202/1237504/1/item.html&quot; border=&quot;0&quot; height=&quot;0&quot; width=&quot;0&quot; style=&quot;position:absolute&quot; /&gt;&lt;p class=&quot;fswww1&quot;&gt;&lt;a href=&quot;http://www1.feedsky.com/r/l/feedsky/NinGoo/339934202/art01.html&quot; target=&quot;_blank&quot;&gt;&lt;img border=&quot;0&quot; ismap=&quot;ismap&quot; src=&quot;http://www1.feedsky.com/r/i/feedsky/NinGoo/339934202/art01.gif&quot; onerror=&quot;this.style.display='none'&quot; /&gt;&lt;/a&gt;&lt;/p&gt;</description><category>pg_rman</category><category>备份</category><category>数据库</category><category>postgresql</category><category>pg_dump</category><pubDate>Wed, 03 Feb 2010 12:31:55 +0800</pubDate><author>NinGoo</author><comments>http://www.ningoo.net/html/2010/postgresql_backup.html#comments</comments><guid isPermaLink="false">http://www.ningoo.net/?p=1240</guid><dc:creator>NinGoo</dc:creator><fs:srclink>http://www.ningoo.net/html/2010/postgresql_backup.html</fs:srclink><fs:srcfeed>http://www.ningoo.net/feed/</fs:srcfeed><fs:itemid>feedsky/NinGoo/~1461473/339934202/1237504</fs:itemid></item><item><title>PostgreSQL安装</title><link>http://item.feedsky.com/~feedsky/NinGoo/~1461473/339934204/1237504/1/item.html</link><content:encoded>&lt;p&gt;Author:&lt;a href='http://www.ningoo.net'&gt;NinGoo&lt;/a&gt; posted on &lt;a href='http://www.ningoo.net/html/2010/installpostgresql.html'&gt;NinGoo.net&lt;/a&gt; &lt;a href='http://rss.ningoo.net'&gt;&lt;img style='border: 0pt none;' align='middle' src='http://www.feedsky.com/feed/NinGoo/sc/gif'&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;PostgreSQL8.x版本的安装已经非常的简单了。EnterpriseDB制作了一键安装的版本，包括FreeBSD/Linux/Mac OS X/Solaris/Windows平台都有。不过即使使用源码编译，也非常的简单。各个版本的源码可以点&lt;a href=&quot;http://www.postgresql.org/ftp/source/&quot;&gt;这里下载&lt;/a&gt;。&lt;/p&gt;
&lt;p&gt;创建os用户&lt;/p&gt;
&lt;pre&gt;
#useradd -g dba postgres
#su - postgres
&lt;/pre&gt;
&lt;p&gt;编译&lt;/p&gt;
&lt;pre&gt;
$tar -zxvf postgresql-8.4.2.tar.gz
$cd postgresql-8.4.2
$./configure --prefix=/OPT/postgresql --enable-profiling
--with-blocksize=8 --with-wal-blocksize=8
$make &amp;#038;&amp;#038; make install
&lt;/pre&gt;
&lt;p&gt;其中with-blocksize指定数据块大小，默认8k，with-wal-blocksize指定日志块大小，默认也是8k。更多编译配置选项，可以通过./configure &amp;#8211;help查看。&lt;/p&gt;
&lt;p&gt;初始化database，注意PostgreSQL在服务端不支持GBK编码。&lt;/p&gt;
&lt;pre&gt;
$cd /opt/postgresql/bin
$ ./initdb --encoding=utf8 -D /opt/postgresql/data
The files belonging to this database system will be owned by user &quot;postgres&quot;.
This user must also own the server process.

The database cluster will be initialized with locale en_US.UTF-8.
The default text search configuration will be set to &quot;english&quot;.

creating directory /opt/postgresql/data ... ok
creating subdirectories ... ok
selecting default max_connections ... 100
selecting default shared_buffers ... 32MB
creating configuration files ... ok
creating template1 database in /opt/postgresql/data/base/1 ... ok
initializing pg_authid ... ok
initializing dependencies ... ok
creating system views ... ok
loading system objects' descriptions ... ok
creating conversions ... ok
creating dictionaries ... ok
setting privileges on built-in objects ... ok
creating information schema ... ok
vacuuming database template1 ... ok
copying template1 to template0 ... ok
copying template1 to postgres ... ok

WARNING: enabling &quot;trust&quot; authentication for local connections
You can change this by editing pg_hba.conf or using the -A option the
next time you run initdb.

Success. You can now start the database server using:

    ./postgres -D /opt/postgresql/data
or
    ./pg_ctl -D /opt/postgresql/data -l logfile start
&lt;/pre&gt;
&lt;p&gt;初始化完成后，会在 /opt/postgresql/data目录生成数据库的文件，至此，软件安装完毕，数据库创建完毕。&lt;/p&gt;
&lt;p&gt;启动数据库&lt;/p&gt;
&lt;pre&gt;
./pg_ctl -D /opt/postgresql/data/ -l /opt/postgresql/log/alert.log start
&lt;/pre&gt;
&lt;p&gt;启动后，可以发现PostgreSQL实例一共运行了5个进程&lt;/p&gt;
&lt;pre&gt;
$ ps -ef | grep postgres
postgres 17572     1  0 16:41 pts/2    00:00:00 /opt/postgresql/bin/postgres
-D /opt/postgresql/data
postgres 17574 17572  0 16:41 ?        00:00:00 postgres: writer process
postgres 17575 17572  0 16:41 ?        00:00:00 postgres: wal writer process
postgres 17576 17572  0 16:41 ?        00:00:00 postgres: autovacuum launcher process
postgres 17577 17572  0 16:41 ?        00:00:00 postgres: stats collector process
postgres 18679 20791  0 16:47 pts/2    00:00:00 grep postgres
&lt;/pre&gt;
&lt;p&gt;其中wal writer process是日志写进程。&lt;/p&gt;
&lt;br/&gt;&lt;b&gt;Related Articles&lt;/b&gt;&lt;p&gt;&lt;ul class=&quot;related_post&quot;&gt;&lt;li&gt;&lt;a href=&quot;http://www.ningoo.net/html/2010/postgresql_backup.html&quot; title=&quot;PostgreSQL备份&quot;&gt;PostgreSQL备份&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;http://www.ningoo.net/html/2010/introduce_to_postgresql.html&quot; title=&quot;PostgreSQL简介&quot;&gt;PostgreSQL简介&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;http://www.ningoo.net/html/2009/how_to_set_lilina_rss_full_out.html&quot; title=&quot;如何设置lilina的rss全文输出&quot;&gt;如何设置lilina的rss全文输出&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;http://www.ningoo.net/html/2007/unicode_encode_in_oracle.html&quot; title=&quot;关于Unicode字符集&quot;&gt;关于Unicode字符集&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;http://www.ningoo.net/html/2008/happy_new_year.html&quot; title=&quot;大年三十，新年快乐&quot;&gt;大年三十，新年快乐&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;http://www.ningoo.net/html/2008/a_ssd_orion_test.html&quot; title=&quot;SSD硬盘的IO性能测试&quot;&gt;SSD硬盘的IO性能测试&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;PermLink:&lt;/b&gt; &lt;a href='http://www.ningoo.net/html/2010/installpostgresql.html'&gt;http://www.ningoo.net/html/2010/installpostgresql.html&lt;/a&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;&lt;a href='http://www.ningoo.net/html/2010/installpostgresql.html#comment'&gt;Add Comments(4)&lt;/a&gt;&lt;/b&gt; | &lt;b&gt;&lt;a href='http://twitter.com/NinGoo'&gt;Follow NinGoo@Twitter&lt;/a&gt;&lt;/b&gt; | &lt;b&gt;&lt;a href='http://www.google.com/ig/add?feedurl=http://rss.ningoo.net'&gt;Google Reader&lt;/a&gt;&lt;/b&gt;&lt;/p&gt;&lt;img src=&quot;http://www1.feedsky.com/t1/339934204/NinGoo/feedsky/s.gif?r=http://item.feedsky.com/~feedsky/NinGoo/~1461473/339934204/1237504/1/item.html&quot; border=&quot;0&quot; height=&quot;0&quot; width=&quot;0&quot; style=&quot;position:absolute&quot; /&gt;&lt;p class=&quot;fswww1&quot;&gt;&lt;a href=&quot;http://www1.feedsky.com/r/l/feedsky/NinGoo/339934204/art01.html&quot; target=&quot;_blank&quot;&gt;&lt;img border=&quot;0&quot; ismap=&quot;ismap&quot; src=&quot;http://www1.feedsky.com/r/i/feedsky/NinGoo/339934204/art01.gif&quot; onerror=&quot;this.style.display='none'&quot; /&gt;&lt;/a&gt;&lt;/p&gt;</content:encoded><wfw:commentRss>http://www.ningoo.net/html/2010/installpostgresql.html/feed</wfw:commentRss><slash:comments>4</slash:comments><description>Author:NinGoo posted on NinGoo.net PostgreSQL8.x版本的安装已经非常的简单了。EnterpriseDB制作了一键安装的版本，包括FreeBSD/Linux/Mac OS X/Solaris/Windows平台都有。不过即使使用源码编译，也非常的简单。各个...&lt;img src=&quot;http://www1.feedsky.com/t1/339934204/NinGoo/feedsky/s.gif?r=http://item.feedsky.com/~feedsky/NinGoo/~1461473/339934204/1237504/1/item.html&quot; border=&quot;0&quot; height=&quot;0&quot; width=&quot;0&quot; style=&quot;position:absolute&quot; /&gt;&lt;p class=&quot;fswww1&quot;&gt;&lt;a href=&quot;http://www1.feedsky.com/r/l/feedsky/NinGoo/339934204/art01.html&quot; target=&quot;_blank&quot;&gt;&lt;img border=&quot;0&quot; ismap=&quot;ismap&quot; src=&quot;http://www1.feedsky.com/r/i/feedsky/NinGoo/339934204/art01.gif&quot; onerror=&quot;this.style.display='none'&quot; /&gt;&lt;/a&gt;&lt;/p&gt;</description><category>数据库</category><category>postgresql</category><pubDate>Sat, 23 Jan 2010 22:35:10 +0800</pubDate><author>NinGoo</author><comments>http://www.ningoo.net/html/2010/installpostgresql.html#comments</comments><guid isPermaLink="false">http://www.ningoo.net/?p=1230</guid><dc:creator>NinGoo</dc:creator><fs:srclink>http://www.ningoo.net/html/2010/installpostgresql.html</fs:srclink><fs:srcfeed>http://www.ningoo.net/feed/</fs:srcfeed><fs:itemid>feedsky/NinGoo/~1461473/339934204/1237504</fs:itemid></item><item><title>PostgreSQL简介</title><link>http://item.feedsky.com/~feedsky/NinGoo/~1461473/339934208/1237504/1/item.html</link><content:encoded>&lt;p&gt;Author:&lt;a href='http://www.ningoo.net'&gt;NinGoo&lt;/a&gt; posted on &lt;a href='http://www.ningoo.net/html/2010/introduce_to_postgresql.html'&gt;NinGoo.net&lt;/a&gt; &lt;a href='http://rss.ningoo.net'&gt;&lt;img style='border: 0pt none;' align='middle' src='http://www.feedsky.com/feed/NinGoo/sc/gif'&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;上个周末，无聊的时候关注了一下PostgreSQL。第一次尝试去安装PostgreSQL，还是好几年前的事了，那是8.0版本刚出来，终于开始原生的支持windows了，所以在自己电脑上折腾了一个。不过那时候也仅限于安装了一次而已，甚至psql的命令行都不知道怎么用。&lt;/p&gt;
&lt;p&gt;同样作为开源关系型数据库，MySQL在这几年获得了更多的关注。大量的互联网公司都基于MySQL来构架系统，也导致MySQL DBA开始火热，一大堆年轻有为的同学投入到其中，渐成燎原之势。MySQL数据库火热了，MySQL AB公司却被&lt;a href=&quot;http://www.ningoo.net/html/2008/sun_acquires_mysql.html&quot;&gt;sun收购&lt;/a&gt;，现在又随着sun要投入Oracle的怀抱，而且欧盟已经无条件批准这个收购，只剩下中国和俄罗斯，大局已定。作为商业数据库的绝对老大，Oracle的这次收购，让MySQL的支持者感到了威胁，其创始人甚至发起了一场&lt;a href=&quot;http://monty-says.blogspot.com/2009/12/help-saving-mysql.html&quot;&gt;保护MySQL&lt;/a&gt;（有墙），阻击Oracle收购的运动。&lt;/p&gt;
&lt;p&gt;这也是PostgreSQL的机会，最近PostgreSQL的开发节奏很快，8.5已经连续出到了alpha3版，在这个版本中，最吸引我的是&lt;strong&gt;hot standby&lt;/strong&gt;，类似于Oracle11g的active data guard，hot standby也可以在恢复的同时提供读服务，而以往版本，PostgreSQL的物理备库&lt;strong&gt;warm standby&lt;/strong&gt;，则只能处于恢复状态，一旦open，则需要重做，比较痛苦。PostgreSQL的很多特性，都和Oracle相当的类似，甚至有一家商业化的公司&lt;strong&gt;EnterpriseDB&lt;/strong&gt;，在致力于将PostgreSQL打包，使得应用程序从Oracle迁移到PostgreSQL更方便，据说80%的Oracle应用代码甚至不需要做修改就能在PostgreSQL运行。因此，我在&lt;a href=&quot;http://twitter.com/NinGoo&quot;&gt;twitter&lt;/a&gt;上说，如果PostgreSQL在人机交互的工具和配置部分，能够更加友好一点，完全是一个影子版本的Oracle。&lt;/p&gt;
&lt;p&gt;PostgreSQL也支持mvcc多版本一致性控制。不过其实现的机制，和innodb的方式比较像，而和Oracle的不一样。Oracle是将变化的前映像记录到单独的undo段中，而PostgreSQL则只是将前映像(Tuples)上做个标记，如果是delete，则相当于是逻辑删除，实际的数据还是在原来的段中，如果是insert，相当于先delete，再insert，而且会在原来的记录上加一条指向新记录的指针，形成一个链表，查询的时候需要沿着这个链表找到一致的数据。这样会造成一个问题，一段时间以后，dml操作使得数据段和索引段中都有大量的前映像信息存在，会严重影响数据查询的效率。PostgreSQL的mvcc的这种实现方式，带来的一个好处是回滚非常快，只需要修改前映像上的几个标志位即可，而不像oracle需要从undo段将前映像再复制回来。但是，这种方便回滚，却会损失查询性能的设计思路，真的比较诡异。PostgreSQL中有一个专门用来清理这些旧版本数据的程序，叫做vacuum。在以前的版本中，需要定期执行vacuum来优化数据存储结构。这对于DBA来说，无疑是一件痛苦的事情。直到8.1版本，引入了&lt;a href=&quot;http://www.pgsqldb.org/pgsqldoc-cvs/maintenance.html#AUTOVACUUM&quot;&gt;autovacuum&lt;/a&gt;，系统可以自动来进行这些清理工作，终于人性化了一点点。&lt;/p&gt;
&lt;p&gt;在8.3版本，引入了一个新的特性HOT(Heap Only Tuples)，主要的目的是努力避免update造成的性能低下的问题。其实这个HOT，说白了很简单，对于update，要实现mvcc，其机制还是一样的，区别在于select，在沿着链表找一致性数据的过程中，如果发现这个检查过的版本已经没有任何事物在引用了，就会顺便把清理工作做掉，而不是像以前要等vacuum来做。因此这会加大一点select的压力，但前人栽树，后人乘凉，接下来需要访问这些数据的其他select就会快很多了，这和Oracle的延迟块清除其实有些类似的，当然两者的设计目的并不一样。&lt;/p&gt;
&lt;br/&gt;&lt;b&gt;Related Articles&lt;/b&gt;&lt;p&gt;&lt;ul class=&quot;related_post&quot;&gt;&lt;li&gt;&lt;a href=&quot;http://www.ningoo.net/html/2010/postgresql_backup.html&quot; title=&quot;PostgreSQL备份&quot;&gt;PostgreSQL备份&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;http://www.ningoo.net/html/2010/installpostgresql.html&quot; title=&quot;PostgreSQL安装&quot;&gt;PostgreSQL安装&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;http://www.ningoo.net/html/2009/mysql_replication_fatal_error_1236.html&quot; title=&quot;遭遇MySQL Replication Fatal Error 1236&quot;&gt;遭遇MySQL Replication Fatal Error 1236&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;http://www.ningoo.net/html/2009/gearman-for-mysql.html&quot; title=&quot;Gearman for MySQL&quot;&gt;Gearman for MySQL&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;http://www.ningoo.net/html/2009/about_innodb_thread_concurrency.html&quot; title=&quot;InnoDB线程并发检查机制&quot;&gt;InnoDB线程并发检查机制&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;http://www.ningoo.net/html/2009/xtradb_enhancements_in_show-innodb-status.html&quot; title=&quot;从show innodb status看XtraDB的增强特性&quot;&gt;从show innodb status看XtraDB的增强特性&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;PermLink:&lt;/b&gt; &lt;a href='http://www.ningoo.net/html/2010/introduce_to_postgresql.html'&gt;http://www.ningoo.net/html/2010/introduce_to_postgresql.html&lt;/a&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;&lt;a href='http://www.ningoo.net/html/2010/introduce_to_postgresql.html#comment'&gt;Add Comments(4)&lt;/a&gt;&lt;/b&gt; | &lt;b&gt;&lt;a href='http://twitter.com/NinGoo'&gt;Follow NinGoo@Twitter&lt;/a&gt;&lt;/b&gt; | &lt;b&gt;&lt;a href='http://www.google.com/ig/add?feedurl=http://rss.ningoo.net'&gt;Google Reader&lt;/a&gt;&lt;/b&gt;&lt;/p&gt;&lt;img src=&quot;http://www1.feedsky.com/t1/339934208/NinGoo/feedsky/s.gif?r=http://item.feedsky.com/~feedsky/NinGoo/~1461473/339934208/1237504/1/item.html&quot; border=&quot;0&quot; height=&quot;0&quot; width=&quot;0&quot; style=&quot;position:absolute&quot; /&gt;&lt;p class=&quot;fswww1&quot;&gt;&lt;a href=&quot;http://www1.feedsky.com/r/l/feedsky/NinGoo/339934208/art01.html&quot; target=&quot;_blank&quot;&gt;&lt;img border=&quot;0&quot; ismap=&quot;ismap&quot; src=&quot;http://www1.feedsky.com/r/i/feedsky/NinGoo/339934208/art01.gif&quot; onerror=&quot;this.style.display='none'&quot; /&gt;&lt;/a&gt;&lt;/p&gt;</content:encoded><wfw:commentRss>http://www.ningoo.net/html/2010/introduce_to_postgresql.html/feed</wfw:commentRss><slash:comments>4</slash:comments><description>Author:NinGoo posted on NinGoo.net 上个周末，无聊的时候关注了一下PostgreSQL。第一次尝试去安装PostgreSQL，还是好几年前的事了，那是8.0版本刚出来，终于开始原生的支持windows了，所以在自己电脑上折...&lt;img src=&quot;http://www1.feedsky.com/t1/339934208/NinGoo/feedsky/s.gif?r=http://item.feedsky.com/~feedsky/NinGoo/~1461473/339934208/1237504/1/item.html&quot; border=&quot;0&quot; height=&quot;0&quot; width=&quot;0&quot; style=&quot;position:absolute&quot; /&gt;&lt;p class=&quot;fswww1&quot;&gt;&lt;a href=&quot;http://www1.feedsky.com/r/l/feedsky/NinGoo/339934208/art01.html&quot; target=&quot;_blank&quot;&gt;&lt;img border=&quot;0&quot; ismap=&quot;ismap&quot; src=&quot;http://www1.feedsky.com/r/i/feedsky/NinGoo/339934208/art01.gif&quot; onerror=&quot;this.style.display='none'&quot; /&gt;&lt;/a&gt;&lt;/p&gt;</description><category>MySQL</category><category>EnterpriseDB</category><category>数据库</category><category>postgresql</category><pubDate>Sat, 23 Jan 2010 11:18:46 +0800</pubDate><author>NinGoo</author><comments>http://www.ningoo.net/html/2010/introduce_to_postgresql.html#comments</comments><guid isPermaLink="false">http://www.ningoo.net/?p=1221</guid><dc:creator>NinGoo</dc:creator><fs:srclink>http://www.ningoo.net/html/2010/introduce_to_postgresql.html</fs:srclink><fs:srcfeed>http://www.ningoo.net/feed/</fs:srcfeed><fs:itemid>feedsky/NinGoo/~1461473/339934208/1237504</fs:itemid></item><item><title>tbstat:实时监控数据库统计状态的小工具</title><link>http://item.feedsky.com/~feedsky/NinGoo/~1461473/339934214/1237504/1/item.html</link><content:encoded>&lt;p&gt;Author:&lt;a href='http://www.ningoo.net'&gt;NinGoo&lt;/a&gt; posted on &lt;a href='http://www.ningoo.net/html/2010/tbstat_a_tool_for_oracle_sysstat_realtime_monitor.html'&gt;NinGoo.net&lt;/a&gt; &lt;a href='http://rss.ningoo.net'&gt;&lt;img style='border: 0pt none;' align='middle' src='http://www.feedsky.com/feed/NinGoo/sc/gif'&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;用perl写了一个简单的工具，用于实时查看数据库的统计状态信息，展现信息主要来源于Oracle数据字典中v$systat和v$system_event。写这个工具的初衷，是因为目前我们对于数据库的监控，更多的是分钟级别抽样的数据来绘制的图形，粒度相对还比较粗，有一些比较深的问题，需要更加细粒度的数据。而如果把监控的粒度做到秒级，则收集的数据量就会非常大，因此需要一个平衡，平时采用分钟级别的抽样数据已经足够用于预警，而秒级的则用于某个具体问题的分析。&lt;/p&gt;
&lt;p&gt;当前tbstat功能还比较简单，类似于iostat/vmstat等os工具，tbstat可以通过指定抽样间隔和抽样次数，来循环抓取Oracle的统计状态信息。tbstat支持三个参数 -i 表示间隔时间 -c 表示循环次数 -n 表示需要查看的统计信息的名字(使用前后%的like来查询) &lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;tbstat -i 2 -c 10 表示间隔时间2s，循环次数10次，展示经过人工筛选的36项统计信息&lt;/li&gt;
&lt;li&gt;tbstat -i 2 -c 10 -n parse 表示间隔时间2s，循环次数10次，展示所有名字包含parse的统计信息&lt;/li&gt;
&lt;li&gt;tbstat -i 2 -c 10 -n all 表示间隔时间2s，循环次数10次，展示所有不为零的统计信息&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;也可以使用简化的参数输入方法，第一位表示间隔时间，第二位表示循环次数，第三位表示统计信息名。直接敲入tbstat，则默认的参数为间隔时间10s，次数无限，经过挑选过滤的一些常用的v$sysstat中的统计信息。如果name参数传入的值是event，则展示v$system_event中的等待事件的信息。&lt;/p&gt;
&lt;pre&gt;
$tbstat 1 0
--------------------------------------------------------------------------
-- tbstat v0.3.3 --- a tool for oracle system statistics and event.
-- Powered by NinGoo.net
--------------------------------------------------------------------------                      

               CPU used by this session:     40                       CR blocks created:       5
        DBWR checkpoint buffers written:    569                  DBWR undo block writes:      64
 bytes received via SQL*Net from client: 314297        bytes sent via SQL*Net to client: 2761660
  cleanouts only - consistent read gets:      4                         consistent gets:   48855
                       db block changes:   2122                           db block gets:    3714
                       enqueue requests:    900                           enqueue waits:       7
                          execute count:   3145                   free buffer requested:    1402
         index crx upgrade (positioned):      3            index fast full scans (full):       0
                 leaf node 90-10 splits:      0                        leaf node splits:       0
                      logons cumulative:      1                  parse count (failures):       0
                     parse count (hard):      0                          physical reads:    1546
          physical reads cache prefetch:      0                         physical writes:     603
                              redo size: 618436                         redo synch time:      16
                      redo synch writes:    181                         redo write time:      15
                            redo writes:    174   rollbacks only - consistent read gets:       0
                           sorts (disk):      0                          sorts (memory):     259
              table scans (long tables):      0              table scans (short tables):       9
                  transaction rollbacks:      0                            user commits:     182
&lt;/pre&gt;
&lt;pre&gt;
$tbstat 1 0 event
-------------------------------------------------------------------------------
-- tbstat v0.3.3 --- a tool for oracle system statistics and event.
-- Powered by NinGoo.net
-------------------------------------------------------------------------------              

                   Event Name:   waits   time                       Event Name: waits   time
--------------------------------------------------------------------------------------------
      LGWR wait for redo copy:       1   0.01    SQL*Net more data from client:   151  19.95
  SQL*Net more data to client:    1218   0.01                buffer busy waits:     2   0.01
  control file parallel write:       1   0.51     control file sequential read:     1   0.26
                cursor: pin S:       0   0.00          cursor: pin S wait on X:     0   0.00
        db file parallel read:       0   0.00           db file parallel write:     0   0.00
       db file scattered read:       0   0.00          db file sequential read:  2040   3.43
             direct path read:     269   0.71            direct path read temp:     0   0.00
            direct path write:      23   0.26           direct path write temp:     0   0.00
         enq: CF - contention:       0   0.00             enq: HW - contention:     7   9.00
         enq: SQ - contention:       0   0.00     enq: TX - allocate ITL entry:     0   0.00
   enq: TX - index contention:       0   0.00    enq: TX - row lock contention:     0   0.00
                   latch free:       0   0.00      latch: cache buffers chains:     0   0.00
         latch: library cache:       0   0.00              latch: redo writing:     0   0.00
    latch: session allocation:       0   0.00               library cache lock:     0   0.00
             log buffer space:       0   0.00          log file parallel write:   145   0.60
     log file sequential read:     145   0.53       log file switch completion:     0   0.00
                log file sync:     147   0.78                os thread startup:     0   0.00
        read by other session:       0   0.00                   row cache lock:     0   0.00
       undo segment extension:       0   0.00
&lt;/pre&gt;
&lt;p&gt;如果输入的name是精确匹配到只有一条统计信息的，会在后面打印出间隔时间内排名前10的sid的值。利用此功能，可以很方便的抓到造成某些统计信息异常的会话和SQL语句，会话和SQL信息是通过关联v$session来获取的。因此需要注意，如果统计信息对应的事件持续时间很短，从v$session里抓取到的sql可能并不是造成统计信息升高的罪魁祸首，但是sid一般来说还是准确的，因为应用采用的大多是连接池来连接数据库的，因此还是可以更具sid和machine信息来看看造成异常的是哪个具体的应用。&lt;/p&gt;
&lt;p&gt;例如，全表扫描一般会导致physical reads cache prefetch等待事件，因此可以通过查看该事件对应的top sid来获得具体的语句，当然，不是所有的physical reads cache prefetch都是全表扫描导致的，因此对于获得的结果，还需要DBA根据具体情况做进一步分析：&lt;/p&gt;
&lt;pre&gt;
$tbstat 1 0 'physical reads cache prefetch'
-------------------------------------------------------------------------------
-- tbstat v0.3.3 --- a tool for oracle system statistics and event.
-- Powered by NinGoo.net
-------------------------------------------------------------------------------
 physical reads cache prefetch:         526                             

              sid        value     %              machine         sql_id
       ----------  ----------- -----  ------------------- --------------
             2928          302  69.7               test11  79db58a3dg921
             4902           67  15.5               test71  79db58a3dg921
             4821           64  14.8               test33  3afdq50xt03ch
             4544            0   0.0               test54  3afdq50xt03ch
             1801            0   0.0               test06  79db58a3dg921
             2830            0   0.0               test12  79db58a3dg921
              898            0   0.0               test09  4n7675hwwcndc
             1031            0   0.0               test16  79db58a3dg921
              463            0   0.0               test04  3afdq50xt03ch
             1364            0   0.0               test08 cq749u66x06uj
             1408            0   0.0               test27  39rbqj3ck76w3
              722            0   0.0               test37  26hdkf07336uf
&lt;/pre&gt;
&lt;p&gt;当然，tbstat只是一个用于抽取统计状态的小工具而已，如果要用于故障诊断，则还是要求DBA对于v$systat和v$system_event中各种统计和事件非常的熟悉。tbstat使用了DBD::Oracle以sysdba身份来连接数据库，因此需要为Perl安装DBI和DBD::Oracle模块，并且在数据库服务器本机上执行。如果你对于这个工具有兴趣，可以&lt;a href=&quot;http://www.ningoo.net/software/tbstat&quot;&gt;在这里下载源代码&lt;/a&gt;，使用过程中，如果有什么建议和需求，欢迎告诉我。&lt;/p&gt;
&lt;br/&gt;&lt;b&gt;Related Articles&lt;/b&gt;&lt;p&gt;&lt;ul class=&quot;related_post&quot;&gt;&lt;li&gt;&lt;a href=&quot;http://www.ningoo.net/html/2009/use_oracle_regexp_monitor_database_session.html&quot; title=&quot;使用Oracle正则表达式监控应用到数据库的连接情况&quot;&gt;使用Oracle正则表达式监控应用到数据库的连接情况&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;http://www.ningoo.net/html/2010/dstat_os_monitor_tool.html&quot; title=&quot;dstat:一款简单直观的os实时监控工具&quot;&gt;dstat:一款简单直观的os实时监控工具&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;http://www.ningoo.net/html/2009/use_jpgraph_for_database_monitor.html&quot; title=&quot;使用jpgraph绘制数据库监控图形&quot;&gt;使用jpgraph绘制数据库监控图形&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;http://www.ningoo.net/html/2009/bbed_and_oracle_data_block_structure.html&quot; title=&quot;使用BBED帮助理解Oracle数据块结构&quot;&gt;使用BBED帮助理解Oracle数据块结构&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;http://www.ningoo.net/html/2009/how_to_link_oracle_bbed_tools.html&quot; title=&quot;安装使用BBED&quot;&gt;安装使用BBED&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;http://www.ningoo.net/html/2009/ora-600_4000_affter_redo_corruption.html&quot; title=&quot;记一次redo损坏导致ora-600[4000]的恢复&quot;&gt;记一次redo损坏导致ora-600[4000]的恢复&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;PermLink:&lt;/b&gt; &lt;a href='http://www.ningoo.net/html/2010/tbstat_a_tool_for_oracle_sysstat_realtime_monitor.html'&gt;http://www.ningoo.net/html/2010/tbstat_a_tool_for_oracle_sysstat_realtime_monitor.html&lt;/a&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;&lt;a href='http://www.ningoo.net/html/2010/tbstat_a_tool_for_oracle_sysstat_realtime_monitor.html#comment'&gt;Add Comments(9)&lt;/a&gt;&lt;/b&gt; | &lt;b&gt;&lt;a href='http://twitter.com/NinGoo'&gt;Follow NinGoo@Twitter&lt;/a&gt;&lt;/b&gt; | &lt;b&gt;&lt;a href='http://www.google.com/ig/add?feedurl=http://rss.ningoo.net'&gt;Google Reader&lt;/a&gt;&lt;/b&gt;&lt;/p&gt;&lt;img src=&quot;http://www1.feedsky.com/t1/339934214/NinGoo/feedsky/s.gif?r=http://item.feedsky.com/~feedsky/NinGoo/~1461473/339934214/1237504/1/item.html&quot; border=&quot;0&quot; height=&quot;0&quot; width=&quot;0&quot; style=&quot;position:absolute&quot; /&gt;&lt;p class=&quot;fswww1&quot;&gt;&lt;a href=&quot;http://www1.feedsky.com/r/l/feedsky/NinGoo/339934214/art01.html&quot; target=&quot;_blank&quot;&gt;&lt;img border=&quot;0&quot; ismap=&quot;ismap&quot; src=&quot;http://www1.feedsky.com/r/i/feedsky/NinGoo/339934214/art01.gif&quot; onerror=&quot;this.style.display='none'&quot; /&gt;&lt;/a&gt;&lt;/p&gt;</content:encoded><wfw:commentRss>http://www.ningoo.net/html/2010/tbstat_a_tool_for_oracle_sysstat_realtime_monitor.html/feed</wfw:commentRss><slash:comments>9</slash:comments><description>Author:NinGoo posted on NinGoo.net 用perl写了一个简单的工具，用于实时查看数据库的统计状态信息，展现信息主要来源于Oracle数据字典中v$systat和v$system_event。写这个工具的初衷，是因为目前我们对于...&lt;img src=&quot;http://www1.feedsky.com/t1/339934214/NinGoo/feedsky/s.gif?r=http://item.feedsky.com/~feedsky/NinGoo/~1461473/339934214/1237504/1/item.html&quot; border=&quot;0&quot; height=&quot;0&quot; width=&quot;0&quot; style=&quot;position:absolute&quot; /&gt;&lt;p class=&quot;fswww1&quot;&gt;&lt;a href=&quot;http://www1.feedsky.com/r/l/feedsky/NinGoo/339934214/art01.html&quot; target=&quot;_blank&quot;&gt;&lt;img border=&quot;0&quot; ismap=&quot;ismap&quot; src=&quot;http://www1.feedsky.com/r/i/feedsky/NinGoo/339934214/art01.gif&quot; onerror=&quot;this.style.display='none'&quot; /&gt;&lt;/a&gt;&lt;/p&gt;</description><category>工具</category><category>oracle</category><category>统计信息</category><category>监控</category><category>tbstat</category><pubDate>Mon, 11 Jan 2010 14:11:22 +0800</pubDate><author>NinGoo</author><comments>http://www.ningoo.net/html/2010/tbstat_a_tool_for_oracle_sysstat_realtime_monitor.html#comments</comments><guid isPermaLink="false">http://www.ningoo.net/?p=1202</guid><dc:creator>NinGoo</dc:creator><fs:srclink>http://www.ningoo.net/html/2010/tbstat_a_tool_for_oracle_sysstat_realtime_monitor.html</fs:srclink><fs:srcfeed>http://www.ningoo.net/feed/</fs:srcfeed><fs:itemid>feedsky/NinGoo/~1461473/339934214/1237504</fs:itemid></item><item><title>安昌古镇与乔波冰雪世界</title><link>http://item.feedsky.com/~feedsky/NinGoo/~1461473/339934216/1237504/1/item.html</link><content:encoded>&lt;p&gt;Author:&lt;a href='http://www.ningoo.net'&gt;NinGoo&lt;/a&gt; posted on &lt;a href='http://www.ningoo.net/html/2010/anchang_and_qiaobo_ice_snow_world.html'&gt;NinGoo.net&lt;/a&gt; &lt;a href='http://rss.ningoo.net'&gt;&lt;img style='border: 0pt none;' align='middle' src='http://www.feedsky.com/feed/NinGoo/sc/gif'&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;元旦小假，第一天窝在家里，睡到自然醒，醒到自然睡，好好的放纵了一整天。2号一大早就赶到东站，出发去绍兴柯桥，计划去乔波冰雪世界滑雪，晚上则夜宿安昌古镇。&lt;/p&gt;
&lt;blockquote&gt;&lt;p&gt;“乔波冰雪世界”是由前速滑世界冠军叶乔波女士倡导，清华科技园（启迪控股）投资建设，为我国唯一一家以室内滑雪为主、酒店（住宿、会议、餐饮、娱乐）为辅的综合性高档运动休闲场所。公司目标是成为我国运动与休闲产业的行业巨人。“绍兴乔波冰雪世界”是“乔波冰雪世界”在全国范围内的连锁企业之一，于 2009年10月初隆重开业。&lt;/p&gt;
&lt;p&gt;公司坐落于国家AAAA级风景名胜“浙江省绍兴县鉴湖-柯岩风景区”内，南傍山北依水。项目总投资超过4亿元，建筑面积逾6万㎡。以大型室内滑雪馆、真冰溜冰场为主，并配套四星级会议休闲酒店，是一家集四季滑雪、溜冰、旅游、会议、餐饮、度假、娱乐为一体的综合性运动休闲场所。&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;结果11点多到的时候，人满为患，滑雪服等用具已经被先到的人一扫而空，无奈之下，只能临时改变计划，先去安昌，第二天再赶个大早过来，反正买的是全天票，正好可以多玩点时间。3号早上9点赶到，刚开门没几个人，玩的更high。&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;http://pic.yupoo.com/ningoo/345178a5704a/medium.jpg&quot; alt=&quot;乔波冰雪世界&quot; /&gt;&lt;/p&gt;
&lt;blockquote&gt;&lt;p&gt;位于浙江省绍兴县安昌镇，始建于北宋时期，后因战乱，多次焚毁，又于明清时期重建，其建筑风格传承了典型的江南水乡特色，一依带水，古朴典雅，为浙江省重点历史保护地，其特产安昌腊肠、扯白糖远近闻名，具有水乡风情的水上婚礼也是别具特色。&lt;/p&gt;
&lt;p&gt;安昌镇南靠柯桥，北邻杭甬高速公路，是一个具有千年历史的典型江南水乡古镇。境内现存白洋新石器时代越族先民遗址。相传大禹曾在镇东涂山娶妻成家。公元896年，钱镠奉唐王朝之命屯兵该地平董昌之乱，因命其乡为安昌。现存老街始建于明成化、弘治年间，数百年来，棉、布、米集散旺盛，蔚为越北大市重镇。抗战前夕尚有商号933家，是城区外市集之最。&lt;/p&gt;
&lt;p&gt;安昌明清老街依河而建，全长1747米，至今保存完好。粼粼河水，石板街路，错落有致的翻轩骑楼，传统特色的店铺作坊，姿态各异的拱桥石梁，古老凝重的台门，幽深僻静的弄堂，风貌古朴典雅，无不体现出浓浓的水乡特色。&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;安昌也可以算是典型的江南水乡古镇，可惜河水已经是惨不忍睹，不知何年能重见清清河水沿街流，小小乌篷河上游的写意画卷了。到达的时候沿街人声鼎沸，熙熙攘攘，可以说无趣。唯一可让人怀念的，则是满街满门口挂的腊肠，确实名不虚传。&lt;br /&gt;
&lt;img src=&quot;http://pic.yupoo.com/ningoo/117768a56827/xdhbebbi.jpg&quot; alt=&quot;安昌古镇&quot; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;http://pic.yupoo.com/ningoo/281778a56c05/qipo22zn.jpg&quot; alt=&quot;安昌古镇&quot; /&gt;&lt;/p&gt;
&lt;p&gt;第二天从乔波冰雪世界出来已经是下午2点，精疲力尽的赶到轻纺城汽车站，不幸的是回杭州的班车最早的也要到5点多了。最后四个人一咬牙，决定倒公交车回去，先从柯桥坐到萧山，再在萧山转301到武林小广场，一路辗转，到家已是晚上6点。&lt;/p&gt;
&lt;br/&gt;&lt;b&gt;Related Articles&lt;/b&gt;&lt;p&gt;&lt;ul class=&quot;related_post&quot;&gt;&lt;li&gt;&lt;a href=&quot;http://www.ningoo.net/html/2010/my_2010_plan.html&quot; title=&quot;2010，风生水起&quot;&gt;2010，风生水起&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;http://www.ningoo.net/html/2009/my_2009_never_gone_with_wind.html&quot; title=&quot;往事不会随风-记我的2009&quot;&gt;往事不会随风-记我的2009&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;http://www.ningoo.net/html/2009/get_usa_vis.html&quot; title=&quot;签证是个体力活&quot;&gt;签证是个体力活&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;http://www.ningoo.net/html/2009/welcome_to_change.html&quot; title=&quot;拥抱变化&quot;&gt;拥抱变化&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;http://www.ningoo.net/html/2009/2009_07_22_total_solar_eclipse.html&quot; title=&quot;日全食&quot;&gt;日全食&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;http://www.ningoo.net/html/2009/zong_guan_xian_hangzhou.html&quot; title=&quot;纵贯线，老男人的春天&quot;&gt;纵贯线，老男人的春天&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;PermLink:&lt;/b&gt; &lt;a href='http://www.ningoo.net/html/2010/anchang_and_qiaobo_ice_snow_world.html'&gt;http://www.ningoo.net/html/2010/anchang_and_qiaobo_ice_snow_world.html&lt;/a&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;&lt;a href='http://www.ningoo.net/html/2010/anchang_and_qiaobo_ice_snow_world.html#comment'&gt;Add Comments(3)&lt;/a&gt;&lt;/b&gt; | &lt;b&gt;&lt;a href='http://twitter.com/NinGoo'&gt;Follow NinGoo@Twitter&lt;/a&gt;&lt;/b&gt; | &lt;b&gt;&lt;a href='http://www.google.com/ig/add?feedurl=http://rss.ningoo.net'&gt;Google Reader&lt;/a&gt;&lt;/b&gt;&lt;/p&gt;&lt;img src=&quot;http://www1.feedsky.com/t1/339934216/NinGoo/feedsky/s.gif?r=http://item.feedsky.com/~feedsky/NinGoo/~1461473/339934216/1237504/1/item.html&quot; border=&quot;0&quot; height=&quot;0&quot; width=&quot;0&quot; style=&quot;position:absolute&quot; /&gt;&lt;p class=&quot;fswww1&quot;&gt;&lt;a href=&quot;http://www1.feedsky.com/r/l/feedsky/NinGoo/339934216/art01.html&quot; target=&quot;_blank&quot;&gt;&lt;img border=&quot;0&quot; ismap=&quot;ismap&quot; src=&quot;http://www1.feedsky.com/r/i/feedsky/NinGoo/339934216/art01.gif&quot; onerror=&quot;this.style.display='none'&quot; /&gt;&lt;/a&gt;&lt;/p&gt;</content:encoded><wfw:commentRss>http://www.ningoo.net/html/2010/anchang_and_qiaobo_ice_snow_world.html/feed</wfw:commentRss><slash:comments>3</slash:comments><description>Author:NinGoo posted on NinGoo.net 元旦小假，第一天窝在家里，睡到自然醒，醒到自然睡，好好的放纵了一整天。2号一大早就赶到东站，出发去绍兴柯桥，计划去乔波冰雪世界滑雪，晚上则夜宿安昌...&lt;img src=&quot;http://www1.feedsky.com/t1/339934216/NinGoo/feedsky/s.gif?r=http://item.feedsky.com/~feedsky/NinGoo/~1461473/339934216/1237504/1/item.html&quot; border=&quot;0&quot; height=&quot;0&quot; width=&quot;0&quot; style=&quot;position:absolute&quot; /&gt;&lt;p class=&quot;fswww1&quot;&gt;&lt;a href=&quot;http://www1.feedsky.com/r/l/feedsky/NinGoo/339934216/art01.html&quot; target=&quot;_blank&quot;&gt;&lt;img border=&quot;0&quot; ismap=&quot;ismap&quot; src=&quot;http://www1.feedsky.com/r/i/feedsky/NinGoo/339934216/art01.gif&quot; onerror=&quot;this.style.display='none'&quot; /&gt;&lt;/a&gt;&lt;/p&gt;</description><category>安昌</category><category>乔波冰雪世界</category><category>滑雪</category><category>life</category><category>杂记</category><pubDate>Mon, 04 Jan 2010 22:32:58 +0800</pubDate><author>NinGoo</author><comments>http://www.ningoo.net/html/2010/anchang_and_qiaobo_ice_snow_world.html#comments</comments><guid isPermaLink="false">http://www.ningoo.net/?p=1196</guid><dc:creator>NinGoo</dc:creator><fs:srclink>http://www.ningoo.net/html/2010/anchang_and_qiaobo_ice_snow_world.html</fs:srclink><fs:srcfeed>http://www.ningoo.net/feed/</fs:srcfeed><fs:itemid>feedsky/NinGoo/~1461473/339934216/1237504</fs:itemid></item><item><title>2010，风生水起</title><link>http://item.feedsky.com/~feedsky/NinGoo/~1461473/339934220/1237504/1/item.html</link><content:encoded>&lt;p&gt;Author:&lt;a href='http://www.ningoo.net'&gt;NinGoo&lt;/a&gt; posted on &lt;a href='http://www.ningoo.net/html/2010/my_2010_plan.html'&gt;NinGoo.net&lt;/a&gt; &lt;a href='http://rss.ningoo.net'&gt;&lt;img style='border: 0pt none;' align='middle' src='http://www.feedsky.com/feed/NinGoo/sc/gif'&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;无可奈何的，到了2010，无可奈何的，三十而立。无可奈何花落去，似曾相识燕归来，当年背得烂熟的诗，年少轻狂未解其意，而今嚼来一声叹息。&lt;/p&gt;
&lt;p&gt;酸气倒完，生活继续。2009年，总体来说，虽有诸多不如意处，也做了不少事，有了不少改变。与己，逐步完成转变，从技术一线开始尝试学习团队管理；与事，数据库整体还算稳定，无奈Q4因为各种原因有点晚节不保，由此也可以看出任重道远，还有很多事情需要去做。一个人做好，一个团队做好，一个部门做好，一个公司做好，挑战各有不同，诚如古人言，修身，治家，齐国，平天下，境界不同，或许可以类比。2009年，挣扎彷徨在个人技术能力与团队之间，结果技术能力没有多大增长，团队管理也不尽如人意，这是硬伤，2010年，这两个方面需要平衡好，最大的挑战。&lt;/p&gt;
&lt;p&gt;2010，我的wishlist，实际上主要三点昨天也在&lt;a href=&quot;http://twitter.com/NinGoo&quot;&gt;twitter&lt;/a&gt;上唠叨过了：&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;技术上远离一线操作，更需要精研深入，Oracle和MySQL方面至少各看一到两本好书&lt;/li&gt;
&lt;li&gt;英语，年年念叨，年年没进步，2010，希望能达到初步口语沟通&lt;/li&gt;
&lt;li&gt;技术之外，看十本书，小说，历史，经管，皆可&lt;/li&gt;
&lt;li&gt;拿到驾照，2009年4月份就报考，却一直没有去练车，拖到2010，必须完成&lt;/li&gt;
&lt;li&gt;拿到房子，准备装修。房子交付在2010年底，估计也只能是先做准备&lt;/li&gt;
&lt;li&gt;写一本书，总结这两年Oracle的经验。如果2010年再不写，估计就再也写不出来了&lt;/li&gt;
&lt;li&gt;买一辆车，不需要太好，代步足矣&lt;/li&gt;
&lt;li&gt;至少出国旅游一次，已经定了4月去东南亚的行程，应该靠谱。&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;希望我的2010，搅他个风生水起。待明年今日，再细数往事前程。&lt;/p&gt;
&lt;br/&gt;&lt;b&gt;Related Articles&lt;/b&gt;&lt;p&gt;&lt;ul class=&quot;related_post&quot;&gt;&lt;li&gt;&lt;a href=&quot;http://www.ningoo.net/html/2010/anchang_and_qiaobo_ice_snow_world.html&quot; title=&quot;安昌古镇与乔波冰雪世界&quot;&gt;安昌古镇与乔波冰雪世界&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;http://www.ningoo.net/html/2009/my_2009_never_gone_with_wind.html&quot; title=&quot;往事不会随风-记我的2009&quot;&gt;往事不会随风-记我的2009&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;http://www.ningoo.net/html/2009/get_usa_vis.html&quot; title=&quot;签证是个体力活&quot;&gt;签证是个体力活&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;http://www.ningoo.net/html/2009/welcome_to_change.html&quot; title=&quot;拥抱变化&quot;&gt;拥抱变化&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;http://www.ningoo.net/html/2009/2009_07_22_total_solar_eclipse.html&quot; title=&quot;日全食&quot;&gt;日全食&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;http://www.ningoo.net/html/2009/zong_guan_xian_hangzhou.html&quot; title=&quot;纵贯线，老男人的春天&quot;&gt;纵贯线，老男人的春天&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;PermLink:&lt;/b&gt; &lt;a href='http://www.ningoo.net/html/2010/my_2010_plan.html'&gt;http://www.ningoo.net/html/2010/my_2010_plan.html&lt;/a&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;&lt;a href='http://www.ningoo.net/html/2010/my_2010_plan.html#comment'&gt;Add Comments(7)&lt;/a&gt;&lt;/b&gt; | &lt;b&gt;&lt;a href='http://twitter.com/NinGoo'&gt;Follow NinGoo@Twitter&lt;/a&gt;&lt;/b&gt; | &lt;b&gt;&lt;a href='http://www.google.com/ig/add?feedurl=http://rss.ningoo.net'&gt;Google Reader&lt;/a&gt;&lt;/b&gt;&lt;/p&gt;&lt;img src=&quot;http://www1.feedsky.com/t1/339934220/NinGoo/feedsky/s.gif?r=http://item.feedsky.com/~feedsky/NinGoo/~1461473/339934220/1237504/1/item.html&quot; border=&quot;0&quot; height=&quot;0&quot; width=&quot;0&quot; style=&quot;position:absolute&quot; /&gt;&lt;p class=&quot;fswww1&quot;&gt;&lt;a href=&quot;http://www1.feedsky.com/r/l/feedsky/NinGoo/339934220/art01.html&quot; target=&quot;_blank&quot;&gt;&lt;img border=&quot;0&quot; ismap=&quot;ismap&quot; src=&quot;http://www1.feedsky.com/r/i/feedsky/NinGoo/339934220/art01.gif&quot; onerror=&quot;this.style.display='none'&quot; /&gt;&lt;/a&gt;&lt;/p&gt;</content:encoded><wfw:commentRss>http://www.ningoo.net/html/2010/my_2010_plan.html/feed</wfw:commentRss><slash:comments>7</slash:comments><description>Author:NinGoo posted on NinGoo.net 无可奈何的，到了2010，无可奈何的，三十而立。无可奈何花落去，似曾相识燕归来，当年背得烂熟的诗，年少轻狂未解其意，而今嚼来一声叹息。
酸气倒完，生活继...&lt;img src=&quot;http://www1.feedsky.com/t1/339934220/NinGoo/feedsky/s.gif?r=http://item.feedsky.com/~feedsky/NinGoo/~1461473/339934220/1237504/1/item.html&quot; border=&quot;0&quot; height=&quot;0&quot; width=&quot;0&quot; style=&quot;position:absolute&quot; /&gt;&lt;p class=&quot;fswww1&quot;&gt;&lt;a href=&quot;http://www1.feedsky.com/r/l/feedsky/NinGoo/339934220/art01.html&quot; target=&quot;_blank&quot;&gt;&lt;img border=&quot;0&quot; ismap=&quot;ismap&quot; src=&quot;http://www1.feedsky.com/r/i/feedsky/NinGoo/339934220/art01.gif&quot; onerror=&quot;this.style.display='none'&quot; /&gt;&lt;/a&gt;&lt;/p&gt;</description><category>2010</category><category>life</category><category>杂记</category><pubDate>Fri, 01 Jan 2010 11:58:59 +0800</pubDate><author>NinGoo</author><comments>http://www.ningoo.net/html/2010/my_2010_plan.html#comments</comments><guid isPermaLink="false">http://www.ningoo.net/?p=1188</guid><dc:creator>NinGoo</dc:creator><fs:srclink>http://www.ningoo.net/html/2010/my_2010_plan.html</fs:srclink><fs:srcfeed>http://www.ningoo.net/feed/</fs:srcfeed><fs:itemid>feedsky/NinGoo/~1461473/339934220/1237504</fs:itemid></item></channel></rss>