<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-5866936448448261654</id><updated>2011-11-28T07:38:41.436+08:00</updated><category term='生活'/><category term='linux'/><category term='安全'/><category term='读书'/><category term='经济'/><category term='mysql优化'/><category term='mysql'/><category term='python'/><category term='存储'/><category term='珠海'/><category term='美食'/><category term='技术'/><category term='媒体'/><category term='管理'/><category term='旅游'/><category term='Job'/><title type='text'>我的陋室我做主</title><subtitle type='html'>上善若水,大智若愚 视远为明,听德为聪</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://moonbingbing.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5866936448448261654/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://moonbingbing.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>wayne</name><uri>http://www.blogger.com/profile/08537956174550037355</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>63</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-5866936448448261654.post-2838482826232770021</id><published>2011-02-16T10:18:00.000+08:00</published><updated>2011-02-16T10:18:08.084+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='mysql'/><title type='text'>MySQL在线增量备份</title><content type='html'>&amp;nbsp;&amp;nbsp; &amp;nbsp;增量备份的好处是可以节省备份的时间和占用的磁盘空间，可以根据业务和数据的特性，指定不同的全备和增量备份策略。&lt;br /&gt;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;备份最好是在slave上面进行，这样可以不对主库造成任何影响。使用&lt;a href="http://www.percona.com/docs/wiki/percona-xtrabackup:start"&gt;xtrabackup&lt;/a&gt;这个工具能实现在线全备和在线增量备份，步骤如下：&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;1、先做一个全备份&lt;br /&gt;xtrabackup --backup --datadir=/data/iscsi/db/ --target-dir=/data/backups/mysql/&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;2、每天增量备份&lt;br /&gt;&lt;br /&gt;xtrabackup --backup --target-dir=/data/backups/inc/tue/ &amp;nbsp; --incremental-basedir=/data/backups/mysql/ &amp;nbsp; &amp;nbsp; &amp;nbsp; #Suppose the full backup is on Monday，Create an incremental backup on Tuesday&lt;br /&gt;&lt;br /&gt;xtrabackup --backup --target-dir=/data/backups/inc/wed/ &amp;nbsp; --incremental-basedir=/data/backups/inc/tue/ &amp;nbsp; &amp;nbsp; #Create an incremental backup on Wednesday&lt;br /&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;发生异常需要恢复时：&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;xtrabackup --prepare --apply-log-only --target-dir=/data/backups/mysql/ &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; #Prepare the base backup from Monday&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;xtrabackup --prepare --apply-log-only --target-dir=/data/backups/mysql/ &amp;nbsp;--incremental-dir=/data/backups/inc/tue/ &amp;nbsp; &amp;nbsp; #Roll Monday's data forward to the state on Tuesday&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;xtrabackup --prepare --apply-log-only --target-dir=/data/backups/mysql/ &amp;nbsp;--incremental-dir=/data/backups/inc/wed/ &amp;nbsp; &amp;nbsp; #Roll forward again to the state on Wednesday&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;你可以用脚本程序和crontab一起来控制全备和增量备份的策略，将备份放在远程的服务器上面（可以在数据库服务器上面连接盘柜），达到数据安全的目的。&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5866936448448261654-2838482826232770021?l=moonbingbing.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://moonbingbing.blogspot.com/feeds/2838482826232770021/comments/default' title='帖子评论'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5866936448448261654&amp;postID=2838482826232770021' title='0 条评论'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5866936448448261654/posts/default/2838482826232770021'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5866936448448261654/posts/default/2838482826232770021'/><link rel='alternate' type='text/html' href='http://moonbingbing.blogspot.com/2011/02/mysql.html' title='MySQL在线增量备份'/><author><name>wayne</name><uri>http://www.blogger.com/profile/08537956174550037355</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5866936448448261654.post-5459993344959439276</id><published>2011-02-15T10:43:00.000+08:00</published><updated>2011-02-15T10:43:01.603+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='mysql'/><title type='text'>在线做MySQL slave</title><content type='html'>&amp;nbsp;&amp;nbsp; &amp;nbsp;之前给MySQL master做slave的时候，为了保证数据一致性，一般选择read lock或者停机，使用直接拷贝文件或者mysqldump的方法来实现。这种方法会使master在一段时间内不可写，影响业务的正常使用。&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;有没有更好的方法，可以在master可读写的情况下，生成一个数据没有差错的slave呢？用&lt;a href="http://www.percona.com/docs/wiki/percona-xtrabackup:start"&gt;innobackupex&lt;/a&gt;可以实现。具体的原理可以去看文档。&lt;a href="http://www.percona.com/docs/wiki/percona-xtrabackup:innobackupex:how_to_recipes"&gt;实现步骤&lt;/a&gt;如下：&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;1. on slave：&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;nc -l 9999 | cat - &amp;gt; /data/backups/backup.tar&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;2. on master：&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;innobackupex --stream=tar --slave-info ./ | nc desthost 9999&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;3. on slave:&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;cd /data/backups/&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;tar -ixvf /data/backups/backup.tar&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;innobackupex --apply-log &amp;nbsp;--use-memory 5000M /data/backups&lt;/blockquote&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5866936448448261654-5459993344959439276?l=moonbingbing.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://moonbingbing.blogspot.com/feeds/5459993344959439276/comments/default' title='帖子评论'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5866936448448261654&amp;postID=5459993344959439276' title='0 条评论'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5866936448448261654/posts/default/5459993344959439276'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5866936448448261654/posts/default/5459993344959439276'/><link rel='alternate' type='text/html' href='http://moonbingbing.blogspot.com/2011/02/mysql-slave.html' title='在线做MySQL slave'/><author><name>wayne</name><uri>http://www.blogger.com/profile/08537956174550037355</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5866936448448261654.post-4132704781232404599</id><published>2010-12-27T17:56:00.001+08:00</published><updated>2010-12-27T17:57:23.686+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='mysql优化'/><category scheme='http://www.blogger.com/atom/ns#' term='mysql'/><title type='text'>MySQL profile中'Sending data'很慢的问题</title><content type='html'>这几天，对MySQL（5.0.77）数据库中一个几百行记录的表（用于任务分配，读写比较频繁），进行的一个简单查询，从1s逐渐增大到15s。&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;mysql&amp;gt; select id from t_task limit 1;&lt;/blockquote&gt;&lt;blockquote&gt;+----------+&lt;br /&gt;| id&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; |&lt;br /&gt;+----------+&lt;br /&gt;| 22865305 |&lt;br /&gt;+----------+&lt;br /&gt;1 row in set (15.24 sec)&lt;/blockquote&gt;&lt;span class="Apple-style-span" style="border-collapse: separate; color: black; font-family: 微软雅黑; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;"&gt;&lt;span class="Apple-style-span" style="font-family: Arial,'Liberation Sans','DejaVu Sans',sans-serif; font-size: 15px; line-height: 19px; text-align: left;"&gt;Profiling&lt;span class="Apple-converted-space"&gt;的结果是：&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;blockquote&gt;&lt;span class="Apple-style-span" style="border-collapse: separate; color: black; font-family: 微软雅黑; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;"&gt;&lt;span class="Apple-style-span" style="font-family: Arial,'Liberation Sans','DejaVu Sans',sans-serif; font-size: 15px; line-height: 19px; text-align: left;"&gt;&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;mysql&amp;gt; show profile for query 1;&lt;br /&gt;+--------------------------------+-----------+&lt;br /&gt;| Status&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; | Duration&amp;nbsp; |&lt;br /&gt;+--------------------------------+-----------+&lt;br /&gt;| starting&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; |&amp;nbsp; 0.000014 |&lt;br /&gt;| checking query cache for query |&amp;nbsp; 0.000032 |&lt;br /&gt;| Opening tables&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; |&amp;nbsp; 0.000012 |&lt;br /&gt;| System lock&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; |&amp;nbsp; 0.000003 |&lt;br /&gt;| Table lock&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; |&amp;nbsp; 0.000006 |&lt;br /&gt;| init&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; |&amp;nbsp; 0.000010 |&lt;br /&gt;| optimizing&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; |&amp;nbsp; 0.000003 |&lt;br /&gt;| statistics&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; |&amp;nbsp; 0.000006 |&lt;br /&gt;| preparing&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; |&amp;nbsp; 0.000004 |&lt;br /&gt;| executing&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; |&amp;nbsp; 0.000003 |&lt;br /&gt;| Sending data&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; | 15.242734 |&lt;br /&gt;| end&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; |&amp;nbsp; 0.000011 |&lt;br /&gt;| query end&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; |&amp;nbsp; 0.000002 |&lt;br /&gt;| freeing items&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; |&amp;nbsp; 0.000013 |&lt;br /&gt;| logging slow query&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; |&amp;nbsp; 0.000003 |&lt;br /&gt;| logging slow query&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; |&amp;nbsp; 0.000002 |&lt;br /&gt;| cleaning up&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; |&amp;nbsp; 0.000002 |&lt;br /&gt;+--------------------------------+-----------+&lt;br /&gt;17 rows in set (0.00 sec)&lt;/blockquote&gt;从字面意思看，是慢在‘传输数据’这一步。&lt;br /&gt;&lt;br /&gt;‘Sending data’的意义查不到具体的说明，这里&lt;span class="Apple-style-span" style="border-collapse: separate; color: black; font-family: 微软雅黑; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;"&gt;&lt;span class="Apple-style-span" style="font-family: Arial,'Liberation Sans','DejaVu Sans',sans-serif; font-size: 15px; line-height: 19px; text-align: left;"&gt;&lt;a href="http://forums.mysql.com/read.php?24,241461,242012#msg-242012" rel="nofollow" style="background-color: transparent; border-width: 0px; color: blue; cursor: pointer; font-size: 15px; font-weight: normal; margin: 0px; padding: 0px; text-decoration: none; vertical-align: baseline;" target="_blank"&gt;http://forums.mysql.com/read.php?24,241461,242012#msg-242012&lt;/a&gt;有人说是：&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="border-collapse: separate; color: black; font-family: 微软雅黑; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;"&gt;&lt;span class="Apple-style-span" style="font-family: Arial,'Liberation Sans','DejaVu Sans',sans-serif; font-size: 15px; line-height: 19px; text-align: left;"&gt;&lt;pre class="prettyprint" style="background-color: #eeeeee; border: 0px solid rgb(136, 136, 136); font-family: Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',monospace,serif; font-size: 15px; margin: 0px 0px 10px; max-height: 600px; overflow: auto; padding: 2px; vertical-align: baseline; width: auto; word-wrap: normal;"&gt;&lt;span class="typ" style="background-color: transparent; border-width: 0px; color: #660066; font-size: 15px; margin: 0px; padding: 0px; vertical-align: baseline;"&gt;Each&lt;/span&gt;&lt;span class="pln" style="background-color: transparent; border-width: 0px; color: black; font-size: 15px; margin: 0px; padding: 0px; vertical-align: baseline;"&gt; time means the time elapsed between the previous &lt;/span&gt;&lt;span class="kwd" style="background-color: transparent; border-width: 0px; color: #000088; font-size: 15px; margin: 0px; padding: 0px; vertical-align: baseline;"&gt;event&lt;/span&gt;&lt;span class="pln" style="background-color: transparent; border-width: 0px; color: black; font-size: 15px; margin: 0px; padding: 0px; vertical-align: baseline;"&gt; &lt;/span&gt;&lt;span class="kwd" style="background-color: transparent; border-width: 0px; color: #000088; font-size: 15px; margin: 0px; padding: 0px; vertical-align: baseline;"&gt;and&lt;/span&gt;&lt;span class="pln" style="background-color: transparent; border-width: 0px; color: black; font-size: 15px; margin: 0px; padding: 0px; vertical-align: baseline;"&gt; the &lt;/span&gt;&lt;span class="kwd" style="background-color: transparent; border-width: 0px; color: #000088; font-size: 15px; margin: 0px; padding: 0px; vertical-align: baseline;"&gt;new&lt;/span&gt;&lt;span class="pln" style="background-color: transparent; border-width: 0px; color: black; font-size: 15px; margin: 0px; padding: 0px; vertical-align: baseline;"&gt; &lt;/span&gt;&lt;span class="kwd" style="background-color: transparent; border-width: 0px; color: #000088; font-size: 15px; margin: 0px; padding: 0px; vertical-align: baseline;"&gt;event&lt;/span&gt;&lt;span class="pun" style="background-color: transparent; border-width: 0px; color: #666600; font-size: 15px; margin: 0px; padding: 0px; vertical-align: baseline;"&gt;.&lt;/span&gt;&lt;span class="pln" style="background-color: transparent; border-width: 0px; color: black; font-size: 15px; margin: 0px; padding: 0px; vertical-align: baseline;"&gt; &lt;/span&gt;&lt;span class="typ" style="background-color: transparent; border-width: 0px; color: #660066; font-size: 15px; margin: 0px; padding: 0px; vertical-align: baseline;"&gt;So&lt;/span&gt;&lt;span class="pun" style="background-color: transparent; border-width: 0px; color: #666600; font-size: 15px; margin: 0px; padding: 0px; vertical-align: baseline;"&gt;,&lt;/span&gt;&lt;span class="pln" style="background-color: transparent; border-width: 0px; color: black; font-size: 15px; margin: 0px; padding: 0px; vertical-align: baseline;"&gt; the line&lt;/span&gt;&lt;span class="pun" style="background-color: transparent; border-width: 0px; color: #666600; font-size: 15px; margin: 0px; padding: 0px; vertical-align: baseline;"&gt;:&lt;/span&gt;&lt;span class="pln" style="background-color: transparent; border-width: 0px; color: black; font-size: 15px; margin: 0px; padding: 0px; vertical-align: baseline;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span class="pun" style="background-color: transparent; border-width: 0px; color: #666600; font-size: 15px; margin: 0px; padding: 0px; vertical-align: baseline;"&gt;|&lt;/span&gt;&lt;span class="pln" style="background-color: transparent; border-width: 0px; color: black; font-size: 15px; margin: 0px; padding: 0px; vertical-align: baseline;"&gt; &lt;/span&gt;&lt;span class="typ" style="background-color: transparent; border-width: 0px; color: #660066; font-size: 15px; margin: 0px; padding: 0px; vertical-align: baseline;"&gt;Sending&lt;/span&gt;&lt;span class="pln" style="background-color: transparent; border-width: 0px; color: black; font-size: 15px; margin: 0px; padding: 0px; vertical-align: baseline;"&gt; data &lt;/span&gt;&lt;span class="pun" style="background-color: transparent; border-width: 0px; color: #666600; font-size: 15px; margin: 0px; padding: 0px; vertical-align: baseline;"&gt;|&lt;/span&gt;&lt;span class="pln" style="background-color: transparent; border-width: 0px; color: black; font-size: 15px; margin: 0px; padding: 0px; vertical-align: baseline;"&gt; &lt;/span&gt;&lt;span class="lit" style="background-color: transparent; border-width: 0px; color: #006666; font-size: 15px; margin: 0px; padding: 0px; vertical-align: baseline;"&gt;0.00016800&lt;/span&gt;&lt;span class="pln" style="background-color: transparent; border-width: 0px; color: black; font-size: 15px; margin: 0px; padding: 0px; vertical-align: baseline;"&gt; &lt;/span&gt;&lt;span class="pun" style="background-color: transparent; border-width: 0px; color: #666600; font-size: 15px; margin: 0px; padding: 0px; vertical-align: baseline;"&gt;|&lt;/span&gt;&lt;span class="pln" style="background-color: transparent; border-width: 0px; color: black; font-size: 15px; margin: 0px; padding: 0px; vertical-align: baseline;"&gt;&lt;br /&gt;means that &lt;/span&gt;&lt;span class="lit" style="background-color: transparent; border-width: 0px; color: #006666; font-size: 15px; margin: 0px; padding: 0px; vertical-align: baseline;"&gt;0.00016800&lt;/span&gt;&lt;span class="pln" style="background-color: transparent; border-width: 0px; color: black; font-size: 15px; margin: 0px; padding: 0px; vertical-align: baseline;"&gt; seconds elapsed between &lt;/span&gt;&lt;span class="str" style="background-color: transparent; border-width: 0px; color: #008800; font-size: 15px; margin: 0px; padding: 0px; vertical-align: baseline;"&gt;"executing"&lt;/span&gt;&lt;span class="pln" style="background-color: transparent; border-width: 0px; color: black; font-size: 15px; margin: 0px; padding: 0px; vertical-align: baseline;"&gt; &lt;/span&gt;&lt;span class="kwd" style="background-color: transparent; border-width: 0px; color: #000088; font-size: 15px; margin: 0px; padding: 0px; vertical-align: baseline;"&gt;and&lt;/span&gt;&lt;span class="pln" style="background-color: transparent; border-width: 0px; color: black; font-size: 15px; margin: 0px; padding: 0px; vertical-align: baseline;"&gt; &lt;/span&gt;&lt;span class="str" style="background-color: transparent; border-width: 0px; color: #008800; font-size: 15px; margin: 0px; padding: 0px; vertical-align: baseline;"&gt;"Sending data"&lt;/span&gt;&lt;span class="pun" style="background-color: transparent; border-width: 0px; color: #666600; font-size: 15px; margin: 0px; padding: 0px; vertical-align: baseline;"&gt;.&lt;/span&gt;&lt;span class="pln" style="background-color: transparent; border-width: 0px; color: black; font-size: 15px; margin: 0px; padding: 0px; vertical-align: baseline;"&gt; &lt;/span&gt;&lt;span class="typ" style="background-color: transparent; border-width: 0px; color: #660066; font-size: 15px; margin: 0px; padding: 0px; vertical-align: baseline;"&gt;It&lt;/span&gt;&lt;span class="pln" style="background-color: transparent; border-width: 0px; color: black; font-size: 15px; margin: 0px; padding: 0px; vertical-align: baseline;"&gt; &lt;/span&gt;&lt;span class="kwd" style="background-color: transparent; border-width: 0px; color: #000088; font-size: 15px; margin: 0px; padding: 0px; vertical-align: baseline;"&gt;is&lt;/span&gt;&lt;span class="pun" style="background-color: transparent; border-width: 0px; color: #666600; font-size: 15px; margin: 0px; padding: 0px; vertical-align: baseline;"&gt;,&lt;/span&gt;&lt;span class="pln" style="background-color: transparent; border-width: 0px; color: black; font-size: 15px; margin: 0px; padding: 0px; vertical-align: baseline;"&gt; it takes &lt;/span&gt;&lt;span class="lit" style="background-color: transparent; border-width: 0px; color: #006666; font-size: 15px; margin: 0px; padding: 0px; vertical-align: baseline;"&gt;0.00016800&lt;/span&gt;&lt;span class="pln" style="background-color: transparent; border-width: 0px; color: black; font-size: 15px; margin: 0px; padding: 0px; vertical-align: baseline;"&gt; seconds to execute the query&lt;/span&gt;&lt;span class="pun" style="background-color: transparent; border-width: 0px; color: #666600; font-size: 15px; margin: 0px; padding: 0px; vertical-align: baseline;"&gt;.&lt;/span&gt;&lt;/pre&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="border-collapse: separate; color: black; font-family: 微软雅黑; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;"&gt;&lt;span class="Apple-style-span" style="font-family: Arial,'Liberation Sans','DejaVu Sans',sans-serif; font-size: 15px; line-height: 19px; text-align: left;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="border-collapse: separate; color: black; font-family: 微软雅黑; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;"&gt;&lt;span class="Apple-style-span" style="font-family: Arial,'Liberation Sans','DejaVu Sans',sans-serif; font-size: 15px; line-height: 19px; text-align: left;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="border-collapse: separate; color: black; font-family: 微软雅黑; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;"&gt;&lt;span class="Apple-style-span" style="font-family: Arial,'Liberation Sans','DejaVu Sans',sans-serif; font-size: 15px; line-height: 19px; text-align: left;"&gt;可以在sql_select.cc里面看到源代码（在里面搜索Sending data），可以看到do_select的时间也算在‘sending data‘里面了。&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="border-collapse: separate; color: black; font-family: 微软雅黑; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;"&gt;&lt;span class="Apple-style-span" style="font-family: Arial,'Liberation Sans','DejaVu Sans',sans-serif; font-size: 15px; line-height: 19px; text-align: left;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="border-collapse: separate; color: black; font-family: 微软雅黑; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;"&gt;&lt;span class="Apple-style-span" style="font-family: Arial,'Liberation Sans','DejaVu Sans',sans-serif; font-size: 15px; line-height: 19px; text-align: left;"&gt;所以这个&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="border-collapse: separate; color: black; font-family: 微软雅黑; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;"&gt;&lt;span class="Apple-style-span" style="font-family: Arial,'Liberation Sans','DejaVu Sans',sans-serif; font-size: 15px; line-height: 19px; text-align: left;"&gt;‘sending data‘并不只是数据传输的时间，也包含select的时间。有人就这个语义含糊的问题给MySQL报过bug：&lt;/span&gt;&lt;/span&gt;&lt;a href="http://bugs.mysql.com/bug.php?id=52492"&gt;http://bugs.mysql.com/bug.php?id=52492&lt;/a&gt;，但是不了了之。&lt;br /&gt;&lt;br /&gt;这个问题最初怀疑是网卡有问题（这台机器之前网卡有问题，更新过驱动），但是新建一张表结构一样，数据量一样的表，做同样的查询，速度又很快。又怀疑是磁盘问题，因为根据pk的查询都很快（因为簇集索引所以都缓存在内存里面），vmstat和iostat都没有发现异常。&lt;br /&gt;&lt;br /&gt;准备晚上升级MySQL，并使用HP BL460刀片机替换这台出过硬件故障的IBM x3650M2。&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5866936448448261654-4132704781232404599?l=moonbingbing.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://moonbingbing.blogspot.com/feeds/4132704781232404599/comments/default' title='帖子评论'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5866936448448261654&amp;postID=4132704781232404599' title='0 条评论'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5866936448448261654/posts/default/4132704781232404599'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5866936448448261654/posts/default/4132704781232404599'/><link rel='alternate' type='text/html' href='http://moonbingbing.blogspot.com/2010/12/mysql-profilesending-data.html' title='MySQL profile中&apos;Sending data&apos;很慢的问题'/><author><name>wayne</name><uri>http://www.blogger.com/profile/08537956174550037355</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5866936448448261654.post-3026757633960515398</id><published>2010-11-29T15:04:00.000+08:00</published><updated>2010-11-29T15:04:05.627+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='mysql'/><title type='text'>动态控制MySQL慢查询日志的设置</title><content type='html'>&lt;span class="Apple-style-span" style="border-collapse: separate; color: black; font-family: 微软雅黑; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;"&gt;&lt;span class="Apple-style-span" style="color: #555555; font-family: helvetica,arial,sans-serif; font-size: 14px; line-height: 25px;"&gt;To control the slow log at runtime, use the global&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;&lt;a href="http://dev.mysql.com/doc/refman/5.1/en/server-system-variables.html#sysvar_slow_query_log" style="background-color: transparent; border-width: 0px; color: #00759f; font-size: 14px; margin: 0px; outline-width: 0px; padding: 0px; text-decoration: underline; vertical-align: baseline;"&gt;&lt;code class="literal" style="background-color: white; border-width: 0px; color: #026789; font-family: 'courier new',courier,fixed,monospace; font-size: 13px; font-weight: bold; margin: 0px; outline-width: 0px; padding: 0px; text-decoration: underline; vertical-align: baseline;"&gt;slow_query_log&lt;/code&gt;&lt;/a&gt;&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;and&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;&lt;a href="http://dev.mysql.com/doc/refman/5.1/en/server-system-variables.html#sysvar_slow_query_log_file" style="background-color: transparent; border-width: 0px; color: #00759f; font-size: 14px; margin: 0px; outline-width: 0px; padding: 0px; text-decoration: underline; vertical-align: baseline;"&gt;&lt;code class="literal" style="background-color: white; border-width: 0px; color: #026789; font-family: 'courier new',courier,fixed,monospace; font-size: 13px; font-weight: bold; margin: 0px; outline-width: 0px; padding: 0px; text-decoration: underline; vertical-align: baseline;"&gt;slow_query_log_file&lt;/code&gt;&lt;/a&gt;&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;system variables. Set&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;&lt;a href="http://dev.mysql.com/doc/refman/5.1/en/server-system-variables.html#sysvar_slow_query_log" style="background-color: transparent; border-width: 0px; color: #00759f; font-size: 14px; margin: 0px; outline-width: 0px; padding: 0px; text-decoration: underline; vertical-align: baseline;"&gt;&lt;code class="literal" style="background-color: white; border-width: 0px; color: #026789; font-family: 'courier new',courier,fixed,monospace; font-size: 13px; font-weight: bold; margin: 0px; outline-width: 0px; padding: 0px; text-decoration: underline; vertical-align: baseline;"&gt;slow_query_log&lt;/code&gt;&lt;/a&gt;&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;to 0 (or&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;&lt;code class="literal" style="background-color: white; border-width: 0px; color: #026789; font-family: 'courier new',courier,fixed,monospace; font-size: 13px; font-weight: bold; margin: 0px; outline-width: 0px; padding: 0px; vertical-align: baseline;"&gt;OFF&lt;/code&gt;) to disable the log or to 1 (or&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;&lt;code class="literal" style="background-color: white; border-width: 0px; color: #026789; font-family: 'courier new',courier,fixed,monospace; font-size: 13px; font-weight: bold; margin: 0px; outline-width: 0px; padding: 0px; vertical-align: baseline;"&gt;ON&lt;/code&gt;) to enable it. Set&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;&lt;a href="http://dev.mysql.com/doc/refman/5.1/en/server-system-variables.html#sysvar_slow_query_log_file" style="background-color: transparent; border-width: 0px; color: #00759f; font-size: 14px; margin: 0px; outline-width: 0px; padding: 0px; text-decoration: underline; vertical-align: baseline;"&gt;&lt;code class="literal" style="background-color: white; border-width: 0px; color: #026789; font-family: 'courier new',courier,fixed,monospace; font-size: 13px; font-weight: bold; margin: 0px; outline-width: 0px; padding: 0px; text-decoration: underline; vertical-align: baseline;"&gt;slow_query_log_file&lt;/code&gt;&lt;/a&gt;&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;to specify the name of the log file. If a log file already is open, it is closed and the new file is opened.Set&lt;a href="http://dev.mysql.com/doc/refman/5.1/en/server-system-variables.html#sysvar_long_query_time"&gt; &lt;span style="color: #d5a6bd;"&gt;long_query_time&lt;/span&gt;&lt;/a&gt; to &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="border-collapse: separate; color: black; font-family: 微软雅黑; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;"&gt;&lt;span class="Apple-style-span" style="color: #555555; font-family: helvetica,arial,sans-serif; font-size: 14px; line-height: 25px;"&gt;specify the seconds。&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="border-collapse: separate; color: black; font-family: 微软雅黑; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;"&gt;&lt;span class="Apple-style-span" style="color: #555555; font-family: helvetica,arial,sans-serif; font-size: 14px; line-height: 25px;"&gt;设置完成后，你可以通过select @@slow_query_log来确认是否设置成功。&lt;/span&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5866936448448261654-3026757633960515398?l=moonbingbing.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://moonbingbing.blogspot.com/feeds/3026757633960515398/comments/default' title='帖子评论'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5866936448448261654&amp;postID=3026757633960515398' title='0 条评论'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5866936448448261654/posts/default/3026757633960515398'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5866936448448261654/posts/default/3026757633960515398'/><link rel='alternate' type='text/html' href='http://moonbingbing.blogspot.com/2010/11/mysql.html' title='动态控制MySQL慢查询日志的设置'/><author><name>wayne</name><uri>http://www.blogger.com/profile/08537956174550037355</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5866936448448261654.post-7801292276443437649</id><published>2010-11-29T14:14:00.001+08:00</published><updated>2010-11-29T14:32:37.030+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='mysql'/><title type='text'>使用maatkit来迁移MySQL数据库</title><content type='html'>&amp;nbsp;&amp;nbsp; 迁移MySQL一般会用两种方法：1、停掉数据库，直接拷贝数据文件。这种方法比较简单，合适用在迁移到更好的服务器上面，MySQL的版本没有大的变化。2、锁住数据库，将数据dump出来，再重新导入新的数据库。&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp; 在第二种方法中，一般会用mysqldump来导出，用mysql来导入。这两个工具都是单线程的，所以在迁移表比较多的情况下，会影响速度。你可以使用&lt;span class="Apple-style-span" style="border-collapse: separate; color: black; font-family: 微软雅黑; font-size: small; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;"&gt;&lt;span class="Apple-style-span" style="color: #555555; font-family: Verdana,'BitStream vera Sans',Tahoma,Helvetica,sans-serif; font-size: 12px; line-height: 17px;"&gt;&lt;a href="http://www.maatkit.org/"&gt;Maatkit&amp;nbsp; &lt;/a&gt;&lt;span style="color: black; font-size: small;"&gt;&lt;span style="font-family: inherit;"&gt;里面的mk-parallel-dump和mk-parallel-restore来导出导入数据。这两个工具都是多线程，并且更好用。&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="border-collapse: separate; color: black; font-family: 微软雅黑; font-size: small; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;"&gt;&lt;span class="Apple-style-span" style="color: #555555; font-family: Verdana,'BitStream vera Sans',Tahoma,Helvetica,sans-serif; font-size: 12px; line-height: 17px;"&gt;&lt;span style="color: black; font-size: small;"&gt;&lt;span style="font-family: inherit;"&gt;&amp;nbsp; &amp;nbsp; 步骤如下：&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;ol&gt;&lt;li&gt;&lt;span class="Apple-style-span" style="border-collapse: separate; color: black; font-family: 微软雅黑; font-size: small; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;"&gt;&lt;span class="Apple-style-span" style="color: #555555; font-family: Verdana,'BitStream vera Sans',Tahoma,Helvetica,sans-serif; font-size: 12px; line-height: 17px;"&gt;&lt;span style="color: black; font-size: small;"&gt;&lt;span style="font-family: inherit;"&gt;锁住需要导出数据的数据库：&lt;span style="background-color: #d5a6bd; color: black;"&gt;flush tables with read lock&lt;/span&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span class="Apple-style-span" style="border-collapse: separate; color: black; font-family: 微软雅黑; font-size: small; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;"&gt;&lt;span class="Apple-style-span" style="color: #555555; font-family: Verdana,'BitStream vera Sans',Tahoma,Helvetica,sans-serif; font-size: 12px; line-height: 17px;"&gt;&lt;span style="color: black; font-size: small;"&gt;&lt;span style="font-family: inherit;"&gt;导出数据：&lt;span style="background-color: white; color: blue;"&gt; &lt;span style="background-color: #d5a6bd; color: black;"&gt;./mk-parallel-dump -udeploy -p123 -h172.28.29.209 --databases&amp;nbsp; cloud --tables t_test --chunk-size 100000 --threads 8 --base-dir /data/dump_data&amp;nbsp; --charset binary --no-gzip&lt;/span&gt;&lt;/span&gt;&lt;span style="background-color: #d5a6bd;"&gt; &lt;/span&gt;&amp;nbsp; 。其中的&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="border-collapse: separate; color: black; font-family: 微软雅黑; font-size: small; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;"&gt;&lt;span class="Apple-style-span" style="color: #555555; font-family: Verdana,'BitStream vera Sans',Tahoma,Helvetica,sans-serif; font-size: 12px; line-height: 17px;"&gt;&lt;span style="color: black; font-size: small;"&gt;&lt;span style="font-family: inherit;"&gt;chunk-size &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="border-collapse: separate; color: black; font-family: 微软雅黑; font-size: small; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;"&gt;&lt;span class="Apple-style-span" style="color: #555555; font-family: Verdana,'BitStream vera Sans',Tahoma,Helvetica,sans-serif; font-size: 12px; line-height: 17px;"&gt;&lt;span style="color: black; font-size: small;"&gt;&lt;span style="font-family: inherit;"&gt;100000&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="border-collapse: separate; color: black; font-family: 微软雅黑; font-size: small; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;"&gt;&lt;span class="Apple-style-span" style="color: #555555; font-family: Verdana,'BitStream vera Sans',Tahoma,Helvetica,sans-serif; font-size: 12px; line-height: 17px;"&gt;&lt;span style="color: black; font-size: small;"&gt;&lt;span style="font-family: inherit;"&gt;是指每次导出的记录数为10w，那么一个1000w的表，就会执行100次SQL语句，生成100个数据文件；&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="border-collapse: separate; color: black; font-family: 微软雅黑; font-size: small; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;"&gt;&lt;span class="Apple-style-span" style="color: #555555; font-family: Verdana,'BitStream vera Sans',Tahoma,Helvetica,sans-serif; font-size: 12px; line-height: 17px;"&gt;&lt;span style="color: black; font-size: small;"&gt;&lt;span style="font-family: inherit;"&gt;&lt;/span&gt;&lt;/span&gt; &lt;span class="Apple-converted-space"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="border-collapse: separate; color: black; font-family: 微软雅黑; font-size: small; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;"&gt;&lt;span class="Apple-style-span" style="color: #555555; font-family: Verdana,'BitStream vera Sans',Tahoma,Helvetica,sans-serif; font-size: 12px; line-height: 17px;"&gt;&lt;span style="color: black; font-size: small;"&gt;&lt;span style="font-family: inherit;"&gt;threads 8是指用8个线程来导出数据，优先导出大表；&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="border-collapse: separate; color: black; font-family: 微软雅黑; font-size: small; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;"&gt;&lt;span class="Apple-style-span" style="color: #555555; font-family: Verdana,'BitStream vera Sans',Tahoma,Helvetica,sans-serif; font-size: 12px; line-height: 17px;"&gt;&lt;span style="color: black; font-size: small;"&gt;&lt;span style="font-family: inherit;"&gt;charset binary指定用二进制来导出数据，可以避免乱码的问题。&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span class="Apple-style-span" style="border-collapse: separate; color: black; font-family: 微软雅黑; font-size: small; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;"&gt;&lt;span class="Apple-style-span" style="color: #555555; font-family: Verdana,'BitStream vera Sans',Tahoma,Helvetica,sans-serif; font-size: 12px; line-height: 17px;"&gt;&lt;span style="color: black; font-size: small;"&gt;&lt;span style="font-family: inherit;"&gt;在要导入的数据库上面修改允许接收的最大包大小为100M，防止导入SQL语句被这个限制住而报错：&lt;span style="background-color: #d5a6bd; color: black;"&gt;set global max_allowed_packet=104857600&lt;/span&gt;;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span class="Apple-style-span" style="border-collapse: separate; color: black; font-family: 微软雅黑; font-size: small; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;"&gt;&lt;span class="Apple-style-span" style="color: #555555; font-family: Verdana,'BitStream vera Sans',Tahoma,Helvetica,sans-serif; font-size: 12px; line-height: 17px;"&gt;&lt;span style="color: black; font-size: small;"&gt;&lt;span style="font-family: inherit;"&gt;导入数据：&lt;span style="background-color: #d5a6bd; color: black;"&gt;./mk-parallel-restore -&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="background-color: #d5a6bd; color: black; font-family: Verdana,'BitStream vera Sans',Tahoma,Helvetica,sans-serif; font-size: 12px; line-height: 17px;"&gt;&lt;span style="color: black; font-size: small;"&gt;&lt;span style="font-family: inherit;"&gt;udeploy &lt;/span&gt;&lt;/span&gt;&lt;span style="color: black; font-size: small;"&gt;&lt;span style="font-family: inherit;"&gt;-p123 -h172.28.28.90 --databases &amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span style="color: black; font-size: small;"&gt;&lt;span style="font-family: inherit;"&gt;cloud &lt;/span&gt;&lt;/span&gt;&lt;span style="color: black; font-size: small;"&gt;&lt;span style="font-family: inherit;"&gt;--fast-index&amp;nbsp; --threads 8&amp;nbsp;&amp;nbsp; /sandata/&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="color: #555555; font-family: Verdana,'BitStream vera Sans',Tahoma,Helvetica,sans-serif; font-size: 12px; line-height: 17px;"&gt;&lt;span style="color: black; font-size: small;"&gt;&lt;span style="font-family: inherit;"&gt;&lt;span style="background-color: #d5a6bd; color: black;"&gt;cloud &lt;/span&gt;。其中fast-index适用于innodb plugin和XtraDB，可以提高创建索引的速度（先插入数据，再创建索引。如果先创建索引，再插入数据，那么对于几千万表来说，后面的插入速度会很慢）。&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span class="Apple-style-span" style="border-collapse: separate; color: black; font-family: 微软雅黑; font-size: small; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;"&gt;&lt;span class="Apple-style-span" style="color: #555555; font-family: Verdana,'BitStream vera Sans',Tahoma,Helvetica,sans-serif; font-size: 12px; line-height: 17px;"&gt;&lt;span style="color: black; font-size: small;"&gt;&lt;span style="font-family: inherit;"&gt;解锁原有数据库，max_allowed_packet改回正常值。迁移完成。&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;/ol&gt;&amp;nbsp; &amp;nbsp; ps:&lt;span style="color: black;"&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: inherit;"&gt;把数据导入innodb plugin 或者XtraDB时，可能会报错errno: 1478。解释在这里：&lt;a href="http://dev.mysql.com/doc/innodb-plugin/1.0/en/innodb-compression-syntax-warnings.html"&gt;http://dev.mysql.com/doc/innodb-plugin/1.0/en/innodb-compression-syntax-warnings.html&lt;/a&gt;，因为my.cnf里面指定了 innodb_strict_mode=1&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5866936448448261654-7801292276443437649?l=moonbingbing.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://moonbingbing.blogspot.com/feeds/7801292276443437649/comments/default' title='帖子评论'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5866936448448261654&amp;postID=7801292276443437649' title='0 条评论'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5866936448448261654/posts/default/7801292276443437649'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5866936448448261654/posts/default/7801292276443437649'/><link rel='alternate' type='text/html' href='http://moonbingbing.blogspot.com/2010/11/maatkitmysql.html' title='使用maatkit来迁移MySQL数据库'/><author><name>wayne</name><uri>http://www.blogger.com/profile/08537956174550037355</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5866936448448261654.post-3972792885069498271</id><published>2010-11-29T09:49:00.000+08:00</published><updated>2010-11-29T09:49:32.735+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='python'/><title type='text'>[翻译]在Python中如何使用Linux的epoll</title><content type='html'>google doc的发布地址是：&lt;a href="https://docs.google.com/document/pub?id=1kH6JKRgAo6BDC3voKInN4TrSgqC0VVs9Op80xl5xGxw"&gt;https://docs.google.com/document/pub?id=1kH6JKRgAo6BDC3voKInN4TrSgqC0VVs9Op80xl5xGxw&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="border-collapse: separate; color: black; font-family: 微软雅黑; font-size: small; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;"&gt;&lt;span class="Apple-style-span" style="font-family: arial,sans,sans-serif;"&gt;&lt;div class="c19" style="direction: ltr; line-height: 1; margin: 0px; text-indent: 0pt;"&gt;&lt;span class="c15" style="color: #20509b; font-family: Verdana; font-size: 17pt; font-weight: bold;"&gt;目录&lt;/span&gt;&lt;/div&gt;&lt;ol class="c8" style="list-style-type: disc; margin: 0px; padding: 0px;"&gt;&lt;li class="c13" style="direction: ltr; line-height: 1.15; margin-left: 36pt; padding-left: 0pt;" value="1"&gt;&lt;span class="c24" style="color: #000099; font-family: Arial; font-size: 11pt; text-decoration: underline;"&gt;&lt;a href="https://docs.google.com/document/pub?id=1kH6JKRgAo6BDC3voKInN4TrSgqC0VVs9Op80xl5xGxw#h.jaxt035lm50"&gt;序言&lt;/a&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class="c13" style="direction: ltr; line-height: 1.15; margin-left: 36pt; padding-left: 0pt;"&gt;&lt;span class="c24" style="color: #000099; font-family: Arial; font-size: 11pt; text-decoration: underline;"&gt;&lt;a href="https://docs.google.com/document/pub?id=1kH6JKRgAo6BDC3voKInN4TrSgqC0VVs9Op80xl5xGxw#h.lmrs1jxxz0kr"&gt;阻塞socket编程示例&lt;/a&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class="c13" style="direction: ltr; line-height: 1.15; margin-left: 36pt; padding-left: 0pt;"&gt;&lt;span class="c24" style="color: #000099; font-family: Arial; font-size: 11pt; text-decoration: underline;"&gt;&lt;a href="https://docs.google.com/document/pub?id=1kH6JKRgAo6BDC3voKInN4TrSgqC0VVs9Op80xl5xGxw#h.twrilsfnvlp"&gt;异步socket的好处以及Linux epoll&lt;/a&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class="c13" style="direction: ltr; line-height: 1.15; margin-left: 36pt; padding-left: 0pt;"&gt;&lt;span class="c24" style="color: #000099; font-family: Arial; font-size: 11pt; text-decoration: underline;"&gt;&lt;a href="https://docs.google.com/document/pub?id=1kH6JKRgAo6BDC3voKInN4TrSgqC0VVs9Op80xl5xGxw#h.o38rfwaii6kc"&gt;带epoll的异步socket编程示例&lt;/a&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class="c13" style="direction: ltr; line-height: 1.15; margin-left: 36pt; padding-left: 0pt;"&gt;&lt;span class="c24" style="color: #000099; font-family: Arial; font-size: 11pt; text-decoration: underline;"&gt;&lt;a href="https://docs.google.com/document/pub?id=1kH6JKRgAo6BDC3voKInN4TrSgqC0VVs9Op80xl5xGxw#h.9c4m549luf7"&gt;性能注意事项&lt;/a&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class="c13" style="direction: ltr; line-height: 1.15; margin-left: 36pt; padding-left: 0pt;"&gt;&lt;span class="c24" style="color: #000099; font-family: Arial; font-size: 11pt; text-decoration: underline;"&gt;&lt;a href="https://docs.google.com/document/pub?id=1kH6JKRgAo6BDC3voKInN4TrSgqC0VVs9Op80xl5xGxw#h.n01rfstchnst"&gt;源代码&lt;/a&gt;&lt;/span&gt;&lt;/li&gt;&lt;/ol&gt;&lt;div class="c19" style="direction: ltr; line-height: 1; margin: 0px; text-indent: 0pt;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="c16 c29" style="direction: ltr; line-height: 1; margin: 0px; padding-bottom: 8pt; padding-top: 17.6pt; text-indent: 0pt;"&gt;&lt;a href="" name="h.jaxt035lm50"&gt;&lt;/a&gt;&lt;a href="https://docs.google.com/document/pub?id=1kH6JKRgAo6BDC3voKInN4TrSgqC0VVs9Op80xl5xGxw#" name="id.l3ldyikvg3gc"&gt;&lt;/a&gt;&lt;span class="c15" style="color: #20509b; font-family: Verdana; font-size: 17pt; font-weight: bold;"&gt;序言&lt;/span&gt;&lt;/div&gt;&lt;div class="c18" style="direction: ltr; line-height: 1; margin: 0px; padding-bottom: 17.6pt; text-indent: 0pt;"&gt;&lt;span class="c2" style="color: black; font-family: Verdana; font-size: 10pt;"&gt;从2.6开始，&lt;/span&gt;&lt;span class="c5" style="color: #000099; font-family: Verdana; font-size: 10pt; text-decoration: underline;"&gt;&lt;a href="http://www.google.com/url?q=http%3A%2F%2Fwww.python.org%2F&amp;amp;sa=D&amp;amp;sntz=1&amp;amp;usg=AFQjCNEP7etIfXhra1IhmVJRuJJxa6wRxQ"&gt;Python&lt;/a&gt;&lt;/span&gt;&lt;span class="c2" style="color: black; font-family: Verdana; font-size: 10pt;"&gt;包含了访问Linux&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span class="c5" style="color: #000099; font-family: Verdana; font-size: 10pt; text-decoration: underline;"&gt;&lt;a href="http://www.google.com/url?q=http%3A%2F%2Flinux.die.net%2Fman%2F4%2Fepoll&amp;amp;sa=D&amp;amp;sntz=1&amp;amp;usg=AFQjCNHaKo97h0G8BLUDZPt-A9XGipBzkQ"&gt;epoll&lt;/a&gt;&lt;/span&gt;&lt;span class="c2" style="color: black; font-family: Verdana; font-size: 10pt;"&gt;库的&lt;/span&gt;&lt;span class="c5" style="color: #000099; font-family: Verdana; font-size: 10pt; text-decoration: underline;"&gt;&lt;a href="http://www.google.com/url?q=http%3A%2F%2Fdocs.python.org%2F3.0%2Flibrary%2Fselect.html%23epoll-objects&amp;amp;sa=D&amp;amp;sntz=1&amp;amp;usg=AFQjCNHiAzgeBto6XJmWCyzIfPEZu2wKWg"&gt;API&lt;/a&gt;&lt;/span&gt;&lt;span class="c2" style="color: black; font-family: Verdana; font-size: 10pt;"&gt;。这篇文章用几个简单的python 3例子来展示下这个API。欢迎大家质疑和&lt;/span&gt;&lt;span class="c5" style="color: #000099; font-family: Verdana; font-size: 10pt; text-decoration: underline;"&gt;&lt;a href="http://www.google.com/url?q=http%3A%2F%2Fscotdoyle.com%2F&amp;amp;sa=D&amp;amp;sntz=1&amp;amp;usg=AFQjCNHueqC4ZaKF7kYM4KiW2dhcoxWjRQ"&gt;反馈&lt;/a&gt;&lt;/span&gt;&lt;span class="c2" style="color: black; font-family: Verdana; font-size: 10pt;"&gt;。&lt;/span&gt;&lt;/div&gt;&lt;a href="https://docs.google.com/document/pub?id=1kH6JKRgAo6BDC3voKInN4TrSgqC0VVs9Op80xl5xGxw#" name="id.831owa6c0nk1"&gt;&lt;/a&gt;&lt;div class="c16" style="direction: ltr; line-height: 1; margin: 0px; padding-bottom: 8pt; text-indent: 0pt;"&gt;&lt;a href="" name="h.lmrs1jxxz0kr"&gt;&lt;/a&gt;&lt;span class="c15" style="color: #20509b; font-family: Verdana; font-size: 17pt; font-weight: bold;"&gt;阻塞socket编程示例&lt;/span&gt;&lt;/div&gt;&lt;div class="c7" style="direction: ltr; line-height: 1; margin: 0px; padding-bottom: 16pt; text-indent: 0pt;"&gt;&lt;span class="c2" style="color: black; font-family: Verdana; font-size: 10pt;"&gt;示例1用python3.0搭建了一个简单的服务：在8080端口监听HTTP请求，把它打印到控制台，并返回一个HTTP响应消息给客户端。&lt;/span&gt;&lt;/div&gt;&lt;ol class="c8" style="list-style-type: disc; margin: 0px; padding: 0px;"&gt;&lt;li class="c11" style="direction: ltr; line-height: 1; margin-left: 30pt; padding-left: 0pt;" value="1"&gt;&lt;span class="c2" style="color: black; font-family: Verdana; font-size: 10pt;"&gt;第9行：创建服务器socket。&lt;/span&gt;&lt;/li&gt;&lt;li class="c11" style="direction: ltr; line-height: 1; margin-left: 30pt; padding-left: 0pt;"&gt;&lt;span class="c2" style="color: black; font-family: Verdana; font-size: 10pt;"&gt;第10行：允许在11行使用bind()来监听指定端口，即使这个端口最近被其他程序监听。没有这个设置的话，服务不能运行，直到一两分钟后，这个端口不再被之前的程序使用。&lt;/span&gt;&lt;/li&gt;&lt;li class="c11" style="direction: ltr; line-height: 1; margin-left: 30pt; padding-left: 0pt;"&gt;&lt;span class="c2" style="color: black; font-family: Verdana; font-size: 10pt;"&gt;第11行：监听这台机器所有可用的IPv4地址上面的8080端口。&lt;/span&gt;&lt;/li&gt;&lt;li class="c11" style="direction: ltr; line-height: 1; margin-left: 30pt; padding-left: 0pt;"&gt;&lt;span class="c2" style="color: black; font-family: Verdana; font-size: 10pt;"&gt;第12行：通知服务端socket开始接受来自客户端的连接。&lt;/span&gt;&lt;/li&gt;&lt;li class="c11" style="direction: ltr; line-height: 1; margin-left: 30pt; padding-left: 0pt;"&gt;&lt;span class="c2" style="color: black; font-family: Verdana; font-size: 10pt;"&gt;第14行：这行代码直到接收到一个客户端连接才会完成。这时，服务端socket会在服务端机器上面创建一个新的socket，用来和客户端通信。这个新的socket在代码里面就是accept()调用返回的clientconnection 对象。返回的address对象代表着客户端的IP和端口。&lt;/span&gt;&lt;/li&gt;&lt;li class="c11" style="direction: ltr; line-height: 1; margin-left: 30pt; padding-left: 0pt;"&gt;&lt;span class="c2" style="color: black; font-family: Verdana; font-size: 10pt;"&gt;第15-17行：组装从客户端传输过来的数据，直到HTTP请求完成。HTTP协议可以参考&lt;/span&gt;&lt;span class="c5" style="color: #000099; font-family: Verdana; font-size: 10pt; text-decoration: underline;"&gt;&lt;a href="http://www.google.com/url?q=http%3A%2F%2Fwww.jmarshall.com%2Feasy%2Fhttp%2F&amp;amp;sa=D&amp;amp;sntz=1&amp;amp;usg=AFQjCNH8eRESrpc9ojWqF2YSsIPP1_oRDw"&gt;这里&lt;/a&gt;&lt;/span&gt;&lt;span class="c2" style="color: black; font-family: Verdana; font-size: 10pt;"&gt;。&lt;/span&gt;&lt;/li&gt;&lt;li class="c11" style="direction: ltr; line-height: 1; margin-left: 30pt; padding-left: 0pt;"&gt;&lt;span class="c2" style="color: black; font-family: Verdana; font-size: 10pt;"&gt;第18行：把请求打印到控制台，验证操作是否正确。&lt;/span&gt;&lt;/li&gt;&lt;li class="c11" style="direction: ltr; line-height: 1; margin-left: 30pt; padding-left: 0pt;"&gt;&lt;span class="c2" style="color: black; font-family: Verdana; font-size: 10pt;"&gt;第19行：发送响应回客户端。&lt;/span&gt;&lt;/li&gt;&lt;li class="c11" style="direction: ltr; line-height: 1; margin-left: 30pt; padding-left: 0pt;"&gt;&lt;span class="c2" style="color: black; font-family: Verdana; font-size: 10pt;"&gt;第20-22行：关闭和客户端的连接以及服务端监听socket。&lt;/span&gt;&lt;/li&gt;&lt;/ol&gt;&lt;div class="c14" style="direction: ltr; line-height: 1; margin: 0px; padding-bottom: 24pt; padding-top: 8pt; text-indent: 0pt;"&gt;&lt;span class="c2" style="color: black; font-family: Verdana; font-size: 10pt;"&gt;官方&lt;/span&gt;&lt;span class="c9" style="color: #9b2d20; font-family: Verdana; font-size: 10pt;"&gt;&lt;a href="http://www.google.com/url?q=http%3A%2F%2Fdocs.python.org%2F3.0%2Fhowto%2Fsockets.html&amp;amp;sa=D&amp;amp;sntz=1&amp;amp;usg=AFQjCNGiML8p3XYTS0kgoO5ZGNk5Cfav5A"&gt;howto&lt;/a&gt;&lt;/span&gt;&lt;span class="c2" style="color: black; font-family: Verdana; font-size: 10pt;"&gt;中对python socket编程有更详细的描述。&lt;/span&gt;&lt;/div&gt;&lt;div class="c19 c21" style="direction: ltr; line-height: 1; margin: 0px 48pt; text-indent: 0pt;"&gt;&lt;span class="c6" style="color: #20509b; font-family: Verdana; font-size: 10pt;"&gt;Example 1&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span class="c6 c10" style="color: #20509b; font-family: Verdana; font-size: 10pt; font-style: italic;"&gt;(All examples use Python 3)&lt;/span&gt;&lt;/div&gt;&lt;div class="c19 c21" style="direction: ltr; line-height: 1; margin: 0px 48pt; text-indent: 0pt;"&gt;&lt;span class="c1" style="color: black; font-family: Georgia; font-size: 11pt;"&gt;1 &amp;nbsp;&lt;/span&gt;&lt;span class="c0" style="color: #20509b; font-family: Georgia; font-size: 11pt; font-weight: bold;"&gt;import&lt;/span&gt;&lt;span class="c1" style="color: black; font-family: Georgia; font-size: 11pt;"&gt;&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;socket&lt;br /&gt;2&lt;br /&gt;3 &amp;nbsp;EOL1 = b&lt;/span&gt;&lt;span class="c4" style="color: #209b43; font-family: Georgia; font-size: 11pt;"&gt;'\n\n'&lt;/span&gt;&lt;span class="c1" style="color: black; font-family: Georgia; font-size: 11pt;"&gt;&lt;br /&gt;4 &amp;nbsp;EOL2 = b&lt;/span&gt;&lt;span class="c4" style="color: #209b43; font-family: Georgia; font-size: 11pt;"&gt;'\n\r\n'&lt;/span&gt;&lt;span class="c1" style="color: black; font-family: Georgia; font-size: 11pt;"&gt;&lt;br /&gt;5 &amp;nbsp;response &amp;nbsp;= b&lt;/span&gt;&lt;span class="c4" style="color: #209b43; font-family: Georgia; font-size: 11pt;"&gt;'HTTP/1.0 200 OK\r\nDate: Mon, 1 Jan 1996 01:01:01 GMT\r\n'&lt;/span&gt;&lt;span class="c1" style="color: black; font-family: Georgia; font-size: 11pt;"&gt;&lt;br /&gt;6 &amp;nbsp;response += b&lt;/span&gt;&lt;span class="c4" style="color: #209b43; font-family: Georgia; font-size: 11pt;"&gt;'Content-Type: text/plain\r\nContent-Length: 13\r\n\r\n'&lt;/span&gt;&lt;span class="c1" style="color: black; font-family: Georgia; font-size: 11pt;"&gt;&lt;br /&gt;7 &amp;nbsp;response += b&lt;/span&gt;&lt;span class="c4" style="color: #209b43; font-family: Georgia; font-size: 11pt;"&gt;'Hello, world!'&lt;/span&gt;&lt;span class="c1" style="color: black; font-family: Georgia; font-size: 11pt;"&gt;&lt;br /&gt;8&lt;br /&gt;9 &amp;nbsp;serversocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)&lt;br /&gt;10 &amp;nbsp;serversocket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)&lt;br /&gt;11 &amp;nbsp;serversocket.bind((&lt;/span&gt;&lt;span class="c4" style="color: #209b43; font-family: Georgia; font-size: 11pt;"&gt;'0.0.0.0'&lt;/span&gt;&lt;span class="c1" style="color: black; font-family: Georgia; font-size: 11pt;"&gt;, 8080))&lt;br /&gt;12 &amp;nbsp;serversocket.listen(1)&lt;br /&gt;13&lt;br /&gt;14 &amp;nbsp;connectiontoclient, address = serversocket.accept()&lt;br /&gt;15 &amp;nbsp;request = b&lt;/span&gt;&lt;span class="c4" style="color: #209b43; font-family: Georgia; font-size: 11pt;"&gt;''&lt;/span&gt;&lt;span class="c1" style="color: black; font-family: Georgia; font-size: 11pt;"&gt;&lt;br /&gt;16 &amp;nbsp;&lt;/span&gt;&lt;span class="c0" style="color: #20509b; font-family: Georgia; font-size: 11pt; font-weight: bold;"&gt;while&lt;/span&gt;&lt;span class="c1" style="color: black; font-family: Georgia; font-size: 11pt;"&gt;&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;EOL1&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span class="c0" style="color: #20509b; font-family: Georgia; font-size: 11pt; font-weight: bold;"&gt;not&lt;/span&gt;&lt;span class="c1" style="color: black; font-family: Georgia; font-size: 11pt;"&gt;&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span class="c0" style="color: #20509b; font-family: Georgia; font-size: 11pt; font-weight: bold;"&gt;in&lt;/span&gt;&lt;span class="c1" style="color: black; font-family: Georgia; font-size: 11pt;"&gt;&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;request&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span class="c0" style="color: #20509b; font-family: Georgia; font-size: 11pt; font-weight: bold;"&gt;and&lt;/span&gt;&lt;span class="c1" style="color: black; font-family: Georgia; font-size: 11pt;"&gt;&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;EOL2&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span class="c0" style="color: #20509b; font-family: Georgia; font-size: 11pt; font-weight: bold;"&gt;not&lt;/span&gt;&lt;span class="c1" style="color: black; font-family: Georgia; font-size: 11pt;"&gt;&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span class="c0" style="color: #20509b; font-family: Georgia; font-size: 11pt; font-weight: bold;"&gt;in&lt;/span&gt;&lt;span class="c1" style="color: black; font-family: Georgia; font-size: 11pt;"&gt;&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;request:&lt;br /&gt;17 &amp;nbsp; &amp;nbsp; request += connectiontoclient.recv(1024)&lt;br /&gt;18 &amp;nbsp;print(request.decode())&lt;br /&gt;19 &amp;nbsp;connectiontoclient.send(response)&lt;br /&gt;20 &amp;nbsp;connectiontoclient.close()&lt;br /&gt;21&lt;br /&gt;22 &amp;nbsp;serversocket.close()&lt;/span&gt;&lt;/div&gt;&lt;div class="c19 c21" style="direction: ltr; line-height: 1; margin: 0px 48pt; text-indent: 0pt;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="c7" style="direction: ltr; line-height: 1; margin: 0px; padding-bottom: 16pt; text-indent: 0pt;"&gt;&lt;span class="c2" style="color: black; font-family: Verdana; font-size: 10pt;"&gt;示例2在15行增加了一个循环来不断的处理来自客户端的连接，直到用户中断（比如键盘中断）。这个例子更清楚的说明服务端socket从不和客户端交换数据。相反的，它接收客户端的连接，然后在这台服务器上面创建一个新的socket用来和客户端通信。&lt;/span&gt;&lt;/div&gt;&lt;div class="c19 c20" style="direction: ltr; line-height: 1; margin: 0px; padding-bottom: 24pt; text-indent: 0pt;"&gt;&lt;span class="c2" style="color: black; font-family: Verdana; font-size: 10pt;"&gt;在23-24行的finally语句，可以确保服务端负责监听的socket会关闭，即使有异常发生。&lt;/span&gt;&lt;/div&gt;&lt;div class="c19 c21" style="direction: ltr; line-height: 1; margin: 0px 48pt; text-indent: 0pt;"&gt;&lt;span class="c6" style="color: #20509b; font-family: Verdana; font-size: 10pt;"&gt;Example 2&lt;/span&gt;&lt;/div&gt;&lt;div class="c19 c21" style="direction: ltr; line-height: 1; margin: 0px 48pt; text-indent: 0pt;"&gt;&lt;span class="c1" style="color: black; font-family: Georgia; font-size: 11pt;"&gt;1 &amp;nbsp;&lt;/span&gt;&lt;span class="c0" style="color: #20509b; font-family: Georgia; font-size: 11pt; font-weight: bold;"&gt;import&lt;/span&gt;&lt;span class="c1" style="color: black; font-family: Georgia; font-size: 11pt;"&gt;&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;socket&lt;br /&gt;2&lt;br /&gt;3 &amp;nbsp;EOL1 = b&lt;/span&gt;&lt;span class="c4" style="color: #209b43; font-family: Georgia; font-size: 11pt;"&gt;'\n\n'&lt;/span&gt;&lt;span class="c1" style="color: black; font-family: Georgia; font-size: 11pt;"&gt;&lt;br /&gt;4 &amp;nbsp;EOL2 = b&lt;/span&gt;&lt;span class="c4" style="color: #209b43; font-family: Georgia; font-size: 11pt;"&gt;'\n\r\n'&lt;/span&gt;&lt;span class="c1" style="color: black; font-family: Georgia; font-size: 11pt;"&gt;&lt;br /&gt;5 &amp;nbsp;response &amp;nbsp;= b&lt;/span&gt;&lt;span class="c4" style="color: #209b43; font-family: Georgia; font-size: 11pt;"&gt;'HTTP/1.0 200 OK\r\nDate: Mon, 1 Jan 1996 01:01:01 GMT\r\n'&lt;/span&gt;&lt;span class="c1" style="color: black; font-family: Georgia; font-size: 11pt;"&gt;&lt;br /&gt;6 &amp;nbsp;response += b&lt;/span&gt;&lt;span class="c4" style="color: #209b43; font-family: Georgia; font-size: 11pt;"&gt;'Content-Type: text/plain\r\nContent-Length: 13\r\n\r\n'&lt;/span&gt;&lt;span class="c1" style="color: black; font-family: Georgia; font-size: 11pt;"&gt;&lt;br /&gt;7 &amp;nbsp;response += b&lt;/span&gt;&lt;span class="c4" style="color: #209b43; font-family: Georgia; font-size: 11pt;"&gt;'Hello, world!'&lt;/span&gt;&lt;span class="c1" style="color: black; font-family: Georgia; font-size: 11pt;"&gt;&lt;br /&gt;8&lt;br /&gt;9 &amp;nbsp;serversocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)&lt;br /&gt;10 &amp;nbsp;serversocket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)&lt;br /&gt;11 &amp;nbsp;serversocket.bind((&lt;/span&gt;&lt;span class="c4" style="color: #209b43; font-family: Georgia; font-size: 11pt;"&gt;'0.0.0.0'&lt;/span&gt;&lt;span class="c1" style="color: black; font-family: Georgia; font-size: 11pt;"&gt;, 8080))&lt;br /&gt;12 &amp;nbsp;serversocket.listen(1)&lt;br /&gt;13&lt;br /&gt;14 &amp;nbsp;&lt;/span&gt;&lt;span class="c0" style="color: #20509b; font-family: Georgia; font-size: 11pt; font-weight: bold;"&gt;try&lt;/span&gt;&lt;span class="c1" style="color: black; font-family: Georgia; font-size: 11pt;"&gt;:&lt;br /&gt;15 &amp;nbsp; &amp;nbsp;&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span class="c0" style="color: #20509b; font-family: Georgia; font-size: 11pt; font-weight: bold;"&gt;while&lt;/span&gt;&lt;span class="c1" style="color: black; font-family: Georgia; font-size: 11pt;"&gt;&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span class="c0" style="color: #20509b; font-family: Georgia; font-size: 11pt; font-weight: bold;"&gt;True&lt;/span&gt;&lt;span class="c1" style="color: black; font-family: Georgia; font-size: 11pt;"&gt;:&lt;br /&gt;16 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;connectiontoclient, address = serversocket.accept()&lt;br /&gt;17 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;request = b&lt;/span&gt;&lt;span class="c4" style="color: #209b43; font-family: Georgia; font-size: 11pt;"&gt;''&lt;/span&gt;&lt;span class="c1" style="color: black; font-family: Georgia; font-size: 11pt;"&gt;&lt;br /&gt;18 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span class="c0" style="color: #20509b; font-family: Georgia; font-size: 11pt; font-weight: bold;"&gt;while&lt;/span&gt;&lt;span class="c1" style="color: black; font-family: Georgia; font-size: 11pt;"&gt;&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;EOL1&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span class="c0" style="color: #20509b; font-family: Georgia; font-size: 11pt; font-weight: bold;"&gt;not&lt;/span&gt;&lt;span class="c1" style="color: black; font-family: Georgia; font-size: 11pt;"&gt;&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span class="c0" style="color: #20509b; font-family: Georgia; font-size: 11pt; font-weight: bold;"&gt;in&lt;/span&gt;&lt;span class="c1" style="color: black; font-family: Georgia; font-size: 11pt;"&gt;&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;request&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span class="c0" style="color: #20509b; font-family: Georgia; font-size: 11pt; font-weight: bold;"&gt;and&lt;/span&gt;&lt;span class="c1" style="color: black; font-family: Georgia; font-size: 11pt;"&gt;&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;EOL2&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span class="c0" style="color: #20509b; font-family: Georgia; font-size: 11pt; font-weight: bold;"&gt;not&lt;/span&gt;&lt;span class="c1" style="color: black; font-family: Georgia; font-size: 11pt;"&gt;&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span class="c0" style="color: #20509b; font-family: Georgia; font-size: 11pt; font-weight: bold;"&gt;in&lt;/span&gt;&lt;span class="c1" style="color: black; font-family: Georgia; font-size: 11pt;"&gt;&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;request:&lt;br /&gt;19 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;request += connectiontoclient.recv(1024)&lt;br /&gt;20 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;print(&lt;/span&gt;&lt;span class="c4" style="color: #209b43; font-family: Georgia; font-size: 11pt;"&gt;'-'&lt;/span&gt;&lt;span class="c1" style="color: black; font-family: Georgia; font-size: 11pt;"&gt;*40 +&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span class="c4" style="color: #209b43; font-family: Georgia; font-size: 11pt;"&gt;'\n'&lt;/span&gt;&lt;span class="c1" style="color: black; font-family: Georgia; font-size: 11pt;"&gt;&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;+ request.decode()[:-2])&lt;br /&gt;21 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;connectiontoclient.send(response)&lt;br /&gt;22 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;connectiontoclient.close()&lt;br /&gt;23 &amp;nbsp;&lt;/span&gt;&lt;span class="c0" style="color: #20509b; font-family: Georgia; font-size: 11pt; font-weight: bold;"&gt;finally&lt;/span&gt;&lt;span class="c1" style="color: black; font-family: Georgia; font-size: 11pt;"&gt;:&lt;br /&gt;24 &amp;nbsp; &amp;nbsp; serversocket.close()&lt;/span&gt;&lt;/div&gt;&lt;div class="c19 c21" style="direction: ltr; line-height: 1; margin: 0px 48pt; text-indent: 0pt;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;a href="https://docs.google.com/document/pub?id=1kH6JKRgAo6BDC3voKInN4TrSgqC0VVs9Op80xl5xGxw#" name="id.884k14yoblzh"&gt;&lt;/a&gt;&lt;div class="c16" style="direction: ltr; line-height: 1; margin: 0px; padding-bottom: 8pt; text-indent: 0pt;"&gt;&lt;a href="" name="h.twrilsfnvlp"&gt;&lt;/a&gt;&lt;span class="c15" style="color: #20509b; font-family: Verdana; font-size: 17pt; font-weight: bold;"&gt;异步socket的好处以及Linux epoll&lt;/span&gt;&lt;/div&gt;&lt;div class="c7" style="direction: ltr; line-height: 1; margin: 0px; padding-bottom: 16pt; text-indent: 0pt;"&gt;&lt;span class="c2" style="color: black; font-family: Verdana; font-size: 10pt;"&gt;示例2中的socket叫做阻塞socket，因为python程序会停止运行，直到一个event发生。16行的accept()调用会阻塞，直到接收到一个客户端连接。19行的recv()调用会阻塞，直到这次接收客户端数据完成（或者没有更多的数据要接收）。21行的send()调用也会阻塞，直到将这次需要返回给客户端的数据都放到Linux的发送缓冲队列中。&lt;/span&gt;&lt;/div&gt;&lt;div class="c7" style="direction: ltr; line-height: 1; margin: 0px; padding-bottom: 16pt; text-indent: 0pt;"&gt;&lt;span class="c2" style="color: black; font-family: Verdana; font-size: 10pt;"&gt;当一个程序使用阻塞socket时，常常使用一个线程（甚至是一个专门的程序）来进行各个socket之间的通信。主程序线程会包含接收客户端连接的服务端监听socket。这个socket一次接收一个客户端连接，把连接传给另外一个线程新建的socket去处理。因为这些线程每个只和一个客户端通信，所以处理时即便在某几个点阻塞也没有关系。这种阻塞并不会对其他线程的处理造成任何影响。&lt;/span&gt;&lt;/div&gt;&lt;div class="c7" style="direction: ltr; line-height: 1; margin: 0px; padding-bottom: 16pt; text-indent: 0pt;"&gt;&lt;span class="c2" style="color: black; font-family: Verdana; font-size: 10pt;"&gt;使用多线程、阻塞socket来处理的话，代码会很直观，但是也会有&lt;/span&gt;&lt;span class="c5" style="color: #000099; font-family: Verdana; font-size: 10pt; text-decoration: underline;"&gt;&lt;a href="http://www.google.com/url?q=http%3A%2F%2Fwww.virtualdub.org%2Fblog%2Fpivot%2Fentry.php%3Fid%3D62&amp;amp;sa=D&amp;amp;sntz=1&amp;amp;usg=AFQjCNEzhYSGdfy0SaEOET0JEkaPIllLAg"&gt;不少缺陷&lt;/a&gt;&lt;/span&gt;&lt;span class="c2" style="color: black; font-family: Verdana; font-size: 10pt;"&gt;。它很难确保线程共享资源没有问题。而且这种编程风格的程序在只有一个CPU的电脑上面效率更低。&lt;/span&gt;&lt;/div&gt;&lt;div class="c7" style="direction: ltr; line-height: 1; margin: 0px; padding-bottom: 16pt; text-indent: 0pt;"&gt;&lt;span class="c5" style="color: #000099; font-family: Verdana; font-size: 10pt; text-decoration: underline;"&gt;&lt;a href="http://www.google.com/url?q=http%3A%2F%2Fwww.kegel.com%2Fc10k.html&amp;amp;sa=D&amp;amp;sntz=1&amp;amp;usg=AFQjCNGtTLrM31SPGEYBDjpjSU6tVYQYKA"&gt;C10K问题&lt;/a&gt;&lt;/span&gt;&lt;span class="c2" style="color: black; font-family: Verdana; font-size: 10pt;"&gt;探讨了一些替代选择，其一是使用&lt;/span&gt;&lt;span class="c2 c10" style="color: black; font-family: Verdana; font-size: 10pt; font-style: italic;"&gt;异步&lt;/span&gt;&lt;span class="c2" style="color: black; font-family: Verdana; font-size: 10pt;"&gt;socket。这种socket只有在一些event触发时才会阻塞。相反，程序在异步socket上面执行一个动作，会立即被告知这个动作是否成功。程序会根据这个信息决定怎么继续下面的操作由于异步socket是非阻塞的，就没有必要再来使用多线程。所有的工作都可以在一个线程中完成。这种单线程模式有它自己的挑战，但可以成为很多方案不错的选择。它也可以结合多线程一起使用：单线程使用异步socket用于处理服务器的网络部分，多线程可以用来访问其他阻塞资源，比如数据库。&lt;/span&gt;&lt;/div&gt;&lt;div class="c18" style="direction: ltr; line-height: 1; margin: 0px; padding-bottom: 17.6pt; text-indent: 0pt;"&gt;&lt;span class="c2" style="color: black; font-family: Verdana; font-size: 10pt;"&gt;Linux的2.6内核有一系列机制来管理异步socket，其中3个有对应的Python的API：select、poll和epoll。epoll和pool比select更好，因为Python程序不需要检查每一个socket感兴趣的event。相反，它可以依赖操作系统来告诉它哪些socket可能有这些event。epoll比pool更好，因为它不要求操作系统每次都去检查python程序需要的所有socket感兴趣的event。而是Linux在event发生的时候会跟踪到，并在Python需要的时候返回一个列表。因此epoll对于大量（成千上万）并发socket连接，是更有效率和可扩展的机制，可以看这里的&lt;/span&gt;&lt;span class="c5" style="color: #000099; font-family: Verdana; font-size: 10pt; text-decoration: underline;"&gt;&lt;a href="http://www.google.com/url?q=http%3A%2F%2Flse.sourceforge.net%2Fepoll%2Findex.html&amp;amp;sa=D&amp;amp;sntz=1&amp;amp;usg=AFQjCNHqYx09zrHtpvJUvGOWYvYFkDpR4g"&gt;图片&lt;/a&gt;&lt;/span&gt;&lt;span class="c2" style="color: black; font-family: Verdana; font-size: 10pt;"&gt;。&lt;/span&gt;&lt;/div&gt;&lt;a href="https://docs.google.com/document/pub?id=1kH6JKRgAo6BDC3voKInN4TrSgqC0VVs9Op80xl5xGxw#" name="id.3j4imd219tmb"&gt;&lt;/a&gt;&lt;div class="c16" style="direction: ltr; line-height: 1; margin: 0px; padding-bottom: 8pt; text-indent: 0pt;"&gt;&lt;a href="" name="h.o38rfwaii6kc"&gt;&lt;/a&gt;&lt;span class="c15" style="color: #20509b; font-family: Verdana; font-size: 17pt; font-weight: bold;"&gt;带epoll的异步socket编程示例&lt;/span&gt;&lt;/div&gt;&lt;div class="c7" style="direction: ltr; line-height: 1; margin: 0px; padding-bottom: 16pt; text-indent: 0pt;"&gt;&lt;span class="c2" style="color: black; font-family: Verdana; font-size: 10pt;"&gt;程序中使用epoll的顺序大都如下：&lt;/span&gt;&lt;/div&gt;&lt;ol class="c31" style="list-style-type: decimal; margin: 0px; padding: 0px;"&gt;&lt;li class="c11" style="direction: ltr; line-height: 1; margin-left: 30pt; padding-left: 0pt;" value="1"&gt;&lt;span class="c2" style="color: black; font-family: Verdana; font-size: 10pt;"&gt;创建一个epoll对象&lt;/span&gt;&lt;/li&gt;&lt;li class="c11" style="direction: ltr; line-height: 1; margin-left: 30pt; padding-left: 0pt;"&gt;&lt;span class="c2" style="color: black; font-family: Verdana; font-size: 10pt;"&gt;告诉epoll对象监控指定socket的指定event&lt;/span&gt;&lt;/li&gt;&lt;li class="c11" style="direction: ltr; line-height: 1; margin-left: 30pt; padding-left: 0pt;"&gt;&lt;span class="c2" style="color: black; font-family: Verdana; font-size: 10pt;"&gt;询问epoll对象自从上次查询以后有哪些socket可能有指定的event发生&lt;/span&gt;&lt;/li&gt;&lt;li class="c11" style="direction: ltr; line-height: 1; margin-left: 30pt; padding-left: 0pt;"&gt;&lt;span class="c2" style="color: black; font-family: Verdana; font-size: 10pt;"&gt;在这些socket上面执行一些动作&lt;/span&gt;&lt;/li&gt;&lt;li class="c11" style="direction: ltr; line-height: 1; margin-left: 30pt; padding-left: 0pt;"&gt;&lt;span class="c2" style="color: black; font-family: Verdana; font-size: 10pt;"&gt;告诉epool对象去修改socket列表和（或者）event监控&lt;/span&gt;&lt;/li&gt;&lt;li class="c11" style="direction: ltr; line-height: 1; margin-left: 30pt; padding-left: 0pt;"&gt;&lt;span class="c2" style="color: black; font-family: Verdana; font-size: 10pt;"&gt;重复步骤3到5，直到完成&lt;/span&gt;&lt;/li&gt;&lt;li class="c11" style="direction: ltr; line-height: 1; margin-left: 30pt; padding-left: 0pt;"&gt;&lt;span class="c2" style="color: black; font-family: Verdana; font-size: 10pt;"&gt;销毁epoll对象&lt;/span&gt;&lt;/li&gt;&lt;/ol&gt;&lt;div class="c7 c27" style="direction: ltr; line-height: 1; margin: 0px; padding-bottom: 16pt; padding-top: 8pt; text-indent: 0pt;"&gt;&lt;span class="c2" style="color: black; font-family: Verdana; font-size: 10pt;"&gt;示例3重复了示例2的功能，同时使用异步socket。这个程序更为复杂，因为一个线程要交错与多个客户端通信。&lt;/span&gt;&lt;/div&gt;&lt;ol class="c8" style="list-style-type: disc; margin: 0px; padding: 0px;"&gt;&lt;li class="c11" style="direction: ltr; line-height: 1; margin-left: 30pt; padding-left: 0pt;" value="1"&gt;&lt;span class="c2" style="color: black; font-family: Verdana; font-size: 10pt;"&gt;第1行：select模块包含epoll功能。&lt;/span&gt;&lt;/li&gt;&lt;li class="c11" style="direction: ltr; line-height: 1; margin-left: 30pt; padding-left: 0pt;"&gt;&lt;span class="c2" style="color: black; font-family: Verdana; font-size: 10pt;"&gt;第13行：因为socket默认是阻塞的，所以需要使用非阻塞（异步）模式。&lt;/span&gt;&lt;/li&gt;&lt;li class="c11" style="direction: ltr; line-height: 1; margin-left: 30pt; padding-left: 0pt;"&gt;&lt;span class="c2" style="color: black; font-family: Verdana; font-size: 10pt;"&gt;第15行：创建一个epoll对象。&lt;/span&gt;&lt;/li&gt;&lt;li class="c11" style="direction: ltr; line-height: 1; margin-left: 30pt; padding-left: 0pt;"&gt;&lt;span class="c2" style="color: black; font-family: Verdana; font-size: 10pt;"&gt;第16行：在服务端socket上面注册对读event的关注。一个读event随时会触发服务端socket去接收一个socket连接。&lt;/span&gt;&lt;/li&gt;&lt;li class="c11" style="direction: ltr; line-height: 1; margin-left: 30pt; padding-left: 0pt;"&gt;&lt;span class="c2" style="color: black; font-family: Verdana; font-size: 10pt;"&gt;第19行：字典connections映射文件描述符（整数）到其相应的网络连接对象。&lt;/span&gt;&lt;/li&gt;&lt;li class="c11" style="direction: ltr; line-height: 1; margin-left: 30pt; padding-left: 0pt;"&gt;&lt;span class="c2" style="color: black; font-family: Verdana; font-size: 10pt;"&gt;第21行：查询epoll对象，看是否有任何关注的event被触发。参数“1”表示，我们会等待1秒来看是否有event发生。如果有任何我们感兴趣的event发生在这次查询之前，这个查询就会带着这些event的列表立即返回。&lt;/span&gt;&lt;/li&gt;&lt;li class="c11" style="direction: ltr; line-height: 1; margin-left: 30pt; padding-left: 0pt;"&gt;&lt;span class="c2" style="color: black; font-family: Verdana; font-size: 10pt;"&gt;第22行：event作为一个序列（fileno，event code）的元组返回。fileno是文件描述符的代名词，始终是一个整数。&lt;/span&gt;&lt;/li&gt;&lt;li class="c11" style="direction: ltr; line-height: 1; margin-left: 30pt; padding-left: 0pt;"&gt;&lt;span class="c2" style="color: black; font-family: Verdana; font-size: 10pt;"&gt;第23行：如果一个读event在服务端sockt发生，就会有一个新的socket连接可能被创建。&lt;/span&gt;&lt;/li&gt;&lt;li class="c11" style="direction: ltr; line-height: 1; margin-left: 30pt; padding-left: 0pt;"&gt;&lt;span class="c2" style="color: black; font-family: Verdana; font-size: 10pt;"&gt;第25行：设置新的socket为非阻塞模式。&lt;/span&gt;&lt;/li&gt;&lt;li class="c11" style="direction: ltr; line-height: 1; margin-left: 30pt; padding-left: 0pt;"&gt;&lt;span class="c2" style="color: black; font-family: Verdana; font-size: 10pt;"&gt;第26行：为新的socket注册对读（EPOLLIN）event的关注。&lt;/span&gt;&lt;/li&gt;&lt;li class="c11" style="direction: ltr; line-height: 1; margin-left: 30pt; padding-left: 0pt;"&gt;&lt;span class="c2" style="color: black; font-family: Verdana; font-size: 10pt;"&gt;第31行：如果发生一个读event，就读取从客户端发送过来的新数据。&lt;/span&gt;&lt;/li&gt;&lt;li class="c11" style="direction: ltr; line-height: 1; margin-left: 30pt; padding-left: 0pt;"&gt;&lt;span class="c2" style="color: black; font-family: Verdana; font-size: 10pt;"&gt;第33行：一旦完成请求已收到，就注销对读event的关注，注册对写（EPOLLOUT）event的关注。写event发生的时候，会回复数据给客户端。&lt;/span&gt;&lt;/li&gt;&lt;li class="c11" style="direction: ltr; line-height: 1; margin-left: 30pt; padding-left: 0pt;"&gt;&lt;span class="c2" style="color: black; font-family: Verdana; font-size: 10pt;"&gt;第34行：打印完整的请求，证明虽然与客户端的通信是交错进行的，但数据可以作为一个整体来组装和处理。&lt;/span&gt;&lt;/li&gt;&lt;li class="c11" style="direction: ltr; line-height: 1; margin-left: 30pt; padding-left: 0pt;"&gt;&lt;span class="c2" style="color: black; font-family: Verdana; font-size: 10pt;"&gt;第35行：如果一个写event在一个客户端socket上面发生，它会接受新的数据以便发送到客户端。&lt;/span&gt;&lt;/li&gt;&lt;li class="c11" style="direction: ltr; line-height: 1; margin-left: 30pt; padding-left: 0pt;"&gt;&lt;span class="c2" style="color: black; font-family: Verdana; font-size: 10pt;"&gt;第36-38行：每次发送一部分响应数据，直到完整的响应数据都已经发送给操作系统等待传输给客户端。&lt;/span&gt;&lt;/li&gt;&lt;li class="c11" style="direction: ltr; line-height: 1; margin-left: 30pt; padding-left: 0pt;"&gt;&lt;span class="c2" style="color: black; font-family: Verdana; font-size: 10pt;"&gt;第39行：一旦完整的响应数据发送完成，就不再关注读或者写event。&lt;/span&gt;&lt;/li&gt;&lt;li class="c11" style="direction: ltr; line-height: 1; margin-left: 30pt; padding-left: 0pt;"&gt;&lt;span class="c2" style="color: black; font-family: Verdana; font-size: 10pt;"&gt;第40行：如果一个连接显式关闭，那么socket shutdown是可选的。本示例程序这样使用，是为了让客户端首先关闭。shutdown调用会通知客户端socket没有更多的数据应该被发送或接收，并会让功能正常的客户端关闭自己的socket连接。&lt;/span&gt;&lt;/li&gt;&lt;li class="c11" style="direction: ltr; line-height: 1; margin-left: 30pt; padding-left: 0pt;"&gt;&lt;span class="c2" style="color: black; font-family: Verdana; font-size: 10pt;"&gt;第41行：HUP（挂起）event表明客户端socket已经断开（即关闭），所以服务端也需要关闭。没有必要注册对HUP event的关注。在socket上面，它们总是会被epoll对象注册。&lt;/span&gt;&lt;/li&gt;&lt;li class="c11" style="direction: ltr; line-height: 1; margin-left: 30pt; padding-left: 0pt;"&gt;&lt;span class="c2" style="color: black; font-family: Verdana; font-size: 10pt;"&gt;第42行：注销对此socket连接的关注。&lt;/span&gt;&lt;/li&gt;&lt;li class="c11" style="direction: ltr; line-height: 1; margin-left: 30pt; padding-left: 0pt;"&gt;&lt;span class="c2" style="color: black; font-family: Verdana; font-size: 10pt;"&gt;第43行：关闭socket连接。&lt;/span&gt;&lt;/li&gt;&lt;li class="c11" style="direction: ltr; line-height: 1; margin-left: 30pt; padding-left: 0pt;"&gt;&lt;span class="c2" style="color: black; font-family: Verdana; font-size: 10pt;"&gt;第18-45行：使用try-catch，因为该示例程序最有可能被KeyboardInterrupt异常中断。&lt;/span&gt;&lt;/li&gt;&lt;li class="c11" style="direction: ltr; line-height: 1; margin-left: 30pt; padding-left: 0pt;"&gt;&lt;span class="c2" style="color: black; font-family: Verdana; font-size: 10pt;"&gt;第46-48行：打开的socket连接不需要关闭，因为Python会在程序结束的时候关闭。这里显式关闭是一个好的代码习惯。&lt;/span&gt;&lt;/li&gt;&lt;/ol&gt;&lt;div class="c19" style="direction: ltr; line-height: 1; margin: 0px; text-indent: 0pt;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="c19 c21" style="direction: ltr; line-height: 1; margin: 0px 48pt; text-indent: 0pt;"&gt;&lt;span class="c6" style="color: #20509b; font-family: Verdana; font-size: 10pt;"&gt;Example 3&lt;/span&gt;&lt;/div&gt;&lt;div class="c19 c21" style="direction: ltr; line-height: 1; margin: 0px 48pt; text-indent: 0pt;"&gt;&lt;span class="c1" style="color: black; font-family: Georgia; font-size: 11pt;"&gt;1 &amp;nbsp;&lt;/span&gt;&lt;span class="c0" style="color: #20509b; font-family: Georgia; font-size: 11pt; font-weight: bold;"&gt;import&lt;/span&gt;&lt;span class="c1" style="color: black; font-family: Georgia; font-size: 11pt;"&gt;&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;socket, select&lt;br /&gt;2&lt;br /&gt;3 &amp;nbsp;EOL1 = b&lt;/span&gt;&lt;span class="c4" style="color: #209b43; font-family: Georgia; font-size: 11pt;"&gt;'\n\n'&lt;/span&gt;&lt;span class="c1" style="color: black; font-family: Georgia; font-size: 11pt;"&gt;&lt;br /&gt;4 &amp;nbsp;EOL2 = b&lt;/span&gt;&lt;span class="c4" style="color: #209b43; font-family: Georgia; font-size: 11pt;"&gt;'\n\r\n'&lt;/span&gt;&lt;span class="c1" style="color: black; font-family: Georgia; font-size: 11pt;"&gt;&lt;br /&gt;5 &amp;nbsp;response &amp;nbsp;= b&lt;/span&gt;&lt;span class="c4" style="color: #209b43; font-family: Georgia; font-size: 11pt;"&gt;'HTTP/1.0 200 OK\r\nDate: Mon, 1 Jan 1996 01:01:01 GMT\r\n'&lt;/span&gt;&lt;span class="c1" style="color: black; font-family: Georgia; font-size: 11pt;"&gt;&lt;br /&gt;6 &amp;nbsp;response += b&lt;/span&gt;&lt;span class="c4" style="color: #209b43; font-family: Georgia; font-size: 11pt;"&gt;'Content-Type: text/plain\r\nContent-Length: 13\r\n\r\n'&lt;/span&gt;&lt;span class="c1" style="color: black; font-family: Georgia; font-size: 11pt;"&gt;&lt;br /&gt;7 &amp;nbsp;response += b&lt;/span&gt;&lt;span class="c4" style="color: #209b43; font-family: Georgia; font-size: 11pt;"&gt;'Hello, world!'&lt;/span&gt;&lt;span class="c1" style="color: black; font-family: Georgia; font-size: 11pt;"&gt;&lt;br /&gt;8&lt;br /&gt;9 &amp;nbsp;serversocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)&lt;br /&gt;10 &amp;nbsp;serversocket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)&lt;br /&gt;11 &amp;nbsp;serversocket.bind((&lt;/span&gt;&lt;span class="c4" style="color: #209b43; font-family: Georgia; font-size: 11pt;"&gt;'0.0.0.0'&lt;/span&gt;&lt;span class="c1" style="color: black; font-family: Georgia; font-size: 11pt;"&gt;, 8080))&lt;br /&gt;12 &amp;nbsp;serversocket.listen(1)&lt;br /&gt;13 &amp;nbsp;serversocket.setblocking(0)&lt;br /&gt;14&lt;br /&gt;15 &amp;nbsp;epoll = select.epoll()&lt;br /&gt;16 &amp;nbsp;epoll.register(serversocket.fileno(), select.EPOLLIN)&lt;br /&gt;17&lt;br /&gt;18 &amp;nbsp;&lt;/span&gt;&lt;span class="c0" style="color: #20509b; font-family: Georgia; font-size: 11pt; font-weight: bold;"&gt;try&lt;/span&gt;&lt;span class="c1" style="color: black; font-family: Georgia; font-size: 11pt;"&gt;:&lt;br /&gt;19 &amp;nbsp; &amp;nbsp; connections = {}; requests = {}; responses = {}&lt;br /&gt;20 &amp;nbsp; &amp;nbsp;&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span class="c0" style="color: #20509b; font-family: Georgia; font-size: 11pt; font-weight: bold;"&gt;while&lt;/span&gt;&lt;span class="c1" style="color: black; font-family: Georgia; font-size: 11pt;"&gt;&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span class="c0" style="color: #20509b; font-family: Georgia; font-size: 11pt; font-weight: bold;"&gt;True&lt;/span&gt;&lt;span class="c1" style="color: black; font-family: Georgia; font-size: 11pt;"&gt;:&lt;br /&gt;21 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;events = epoll.poll(1)&lt;br /&gt;22 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span class="c0" style="color: #20509b; font-family: Georgia; font-size: 11pt; font-weight: bold;"&gt;for&lt;/span&gt;&lt;span class="c1" style="color: black; font-family: Georgia; font-size: 11pt;"&gt;&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;fileno, event&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span class="c0" style="color: #20509b; font-family: Georgia; font-size: 11pt; font-weight: bold;"&gt;in&lt;/span&gt;&lt;span class="c1" style="color: black; font-family: Georgia; font-size: 11pt;"&gt;&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;events:&lt;br /&gt;23 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span class="c0" style="color: #20509b; font-family: Georgia; font-size: 11pt; font-weight: bold;"&gt;if&lt;/span&gt;&lt;span class="c1" style="color: black; font-family: Georgia; font-size: 11pt;"&gt;&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;fileno == serversocket.fileno():&lt;br /&gt;24 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;connection, address = serversocket.accept()&lt;br /&gt;25 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;connection.setblocking(0)&lt;br /&gt;26 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;epoll.register(connection.fileno(), select.EPOLLIN)&lt;br /&gt;27 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;connections[connection.fileno()] = connection&lt;br /&gt;28 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;requests[connection.fileno()] = b&lt;/span&gt;&lt;span class="c4" style="color: #209b43; font-family: Georgia; font-size: 11pt;"&gt;''&lt;/span&gt;&lt;span class="c1" style="color: black; font-family: Georgia; font-size: 11pt;"&gt;&lt;br /&gt;29 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;responses[connection.fileno()] = response&lt;br /&gt;30 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span class="c0" style="color: #20509b; font-family: Georgia; font-size: 11pt; font-weight: bold;"&gt;elif&lt;/span&gt;&lt;span class="c1" style="color: black; font-family: Georgia; font-size: 11pt;"&gt;&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;event &amp;amp; select.EPOLLIN:&lt;br /&gt;31 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;requests[fileno] += connections[fileno].recv(1024)&lt;br /&gt;32 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span class="c0" style="color: #20509b; font-family: Georgia; font-size: 11pt; font-weight: bold;"&gt;if&lt;/span&gt;&lt;span class="c1" style="color: black; font-family: Georgia; font-size: 11pt;"&gt;&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;EOL1&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span class="c0" style="color: #20509b; font-family: Georgia; font-size: 11pt; font-weight: bold;"&gt;in&lt;/span&gt;&lt;span class="c1" style="color: black; font-family: Georgia; font-size: 11pt;"&gt;&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;requests[fileno]&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span class="c0" style="color: #20509b; font-family: Georgia; font-size: 11pt; font-weight: bold;"&gt;or&lt;/span&gt;&lt;span class="c1" style="color: black; font-family: Georgia; font-size: 11pt;"&gt;&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;EOL2&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span class="c0" style="color: #20509b; font-family: Georgia; font-size: 11pt; font-weight: bold;"&gt;in&lt;/span&gt;&lt;span class="c1" style="color: black; font-family: Georgia; font-size: 11pt;"&gt;&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;requests[fileno]:&lt;br /&gt;33 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; epoll.modify(fileno, select.EPOLLOUT)&lt;br /&gt;34 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; print(&lt;/span&gt;&lt;span class="c4" style="color: #209b43; font-family: Georgia; font-size: 11pt;"&gt;'-'&lt;/span&gt;&lt;span class="c1" style="color: black; font-family: Georgia; font-size: 11pt;"&gt;*40 +&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span class="c4" style="color: #209b43; font-family: Georgia; font-size: 11pt;"&gt;'\n'&lt;/span&gt;&lt;span class="c1" style="color: black; font-family: Georgia; font-size: 11pt;"&gt;&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;+ requests[fileno].decode()[:-2])&lt;br /&gt;35 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span class="c0" style="color: #20509b; font-family: Georgia; font-size: 11pt; font-weight: bold;"&gt;elif&lt;/span&gt;&lt;span class="c1" style="color: black; font-family: Georgia; font-size: 11pt;"&gt;&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;event &amp;amp; select.EPOLLOUT:&lt;br /&gt;36 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;byteswritten = connections[fileno].send(responses[fileno])&lt;br /&gt;37 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;responses[fileno] = responses[fileno][byteswritten:]&lt;br /&gt;38 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span class="c0" style="color: #20509b; font-family: Georgia; font-size: 11pt; font-weight: bold;"&gt;if&lt;/span&gt;&lt;span class="c1" style="color: black; font-family: Georgia; font-size: 11pt;"&gt;&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;len(responses[fileno]) == 0:&lt;br /&gt;39 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; epoll.modify(fileno, 0)&lt;br /&gt;40 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; connections[fileno].shutdown(socket.SHUT_RDWR)&lt;br /&gt;41 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span class="c0" style="color: #20509b; font-family: Georgia; font-size: 11pt; font-weight: bold;"&gt;elif&lt;/span&gt;&lt;span class="c1" style="color: black; font-family: Georgia; font-size: 11pt;"&gt;&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;event &amp;amp; select.EPOLLHUP:&lt;br /&gt;42 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;epoll.unregister(fileno)&lt;br /&gt;43 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;connections[fileno].close()&lt;br /&gt;44 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span class="c0" style="color: #20509b; font-family: Georgia; font-size: 11pt; font-weight: bold;"&gt;del&lt;/span&gt;&lt;span class="c1" style="color: black; font-family: Georgia; font-size: 11pt;"&gt;&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;connections[fileno]&lt;br /&gt;45 &amp;nbsp;&lt;/span&gt;&lt;span class="c0" style="color: #20509b; font-family: Georgia; font-size: 11pt; font-weight: bold;"&gt;finally&lt;/span&gt;&lt;span class="c1" style="color: black; font-family: Georgia; font-size: 11pt;"&gt;:&lt;br /&gt;46 &amp;nbsp; &amp;nbsp; epoll.unregister(serversocket.fileno())&lt;br /&gt;47 &amp;nbsp; &amp;nbsp; epoll.close()&lt;br /&gt;48 &amp;nbsp; &amp;nbsp; serversocket.close()&lt;/span&gt;&lt;/div&gt;&lt;div class="c19 c21" style="direction: ltr; line-height: 1; margin: 0px 48pt; text-indent: 0pt;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="c7" style="direction: ltr; line-height: 1; margin: 0px; padding-bottom: 16pt; text-indent: 0pt;"&gt;&lt;span class="c2" style="color: black; font-family: Verdana; font-size: 10pt;"&gt;epoll有两种操作模式，称为&lt;/span&gt;&lt;span class="c2 c10" style="color: black; font-family: Verdana; font-size: 10pt; font-style: italic;"&gt;边沿触发&lt;/span&gt;&lt;span class="c2" style="color: black; font-family: Verdana; font-size: 10pt;"&gt;和&lt;/span&gt;&lt;span class="c2 c10" style="color: black; font-family: Verdana; font-size: 10pt; font-style: italic;"&gt;水平触发&lt;/span&gt;&lt;span class="c2" style="color: black; font-family: Verdana; font-size: 10pt;"&gt;&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;。在边沿触发模式中，epoll.poll（）在读或者写event在socket上面发生后，将只会返回一次event。调用epoll.poll()的程序必须处理所有和这个event相关的数据，随后的epoll.poll()调用不会再有这个event的通知。当一个特定event的数据耗尽时，进一步尝试操作socket将导致一个异常。相反，在水平触发模式下，重复调用epoll.poll（）会重复通知关注的event，直到与该event有关的所有数据都已被处理。在水平模式下通常没有异常。&lt;/span&gt;&lt;/div&gt;&lt;div class="c7" style="direction: ltr; line-height: 1; margin: 0px; padding-bottom: 16pt; text-indent: 0pt;"&gt;&lt;span class="c2" style="color: black; font-family: Verdana; font-size: 10pt;"&gt;例如，假设一个服务端socket已经为一个epoll对象注册了读event。在边沿触发模式下，程序需要一直accept()新的socket连接，直到一个socket.error的异常发生。而在水平触发模式下，一个accept()调用后，epoll对象会被服务端socket再次询问是否有新的event，以确定下一个accept()是否应该被调用。&lt;/span&gt;&lt;/div&gt;&lt;div class="c19 c20" style="direction: ltr; line-height: 1; margin: 0px; padding-bottom: 24pt; text-indent: 0pt;"&gt;&lt;span class="c2" style="color: black; font-family: Verdana; font-size: 10pt;"&gt;示例3使用水平触发模式，这是操作的默认模式。示例4演示了如何使用边沿触发模式。在示例4中，第25，36和45行引入循环，直到出现异常才退出（或者所有其他已知的数据都被处理）。第32，38和48行捕获预期的socket异常。最后，第16，28，41和51行添加EPOLLET掩码，用来设置为边沿触发模式。&lt;/span&gt;&lt;/div&gt;&lt;div class="c19 c21" style="direction: ltr; line-height: 1; margin: 0px 48pt; text-indent: 0pt;"&gt;&lt;span class="c6" style="color: #20509b; font-family: Verdana; font-size: 10pt;"&gt;Example 4&lt;/span&gt;&lt;/div&gt;&lt;div class="c19 c21" style="direction: ltr; line-height: 1; margin: 0px 48pt; text-indent: 0pt;"&gt;&lt;span class="c1" style="color: black; font-family: Georgia; font-size: 11pt;"&gt;1 &amp;nbsp;&lt;/span&gt;&lt;span class="c0" style="color: #20509b; font-family: Georgia; font-size: 11pt; font-weight: bold;"&gt;import&lt;/span&gt;&lt;span class="c1" style="color: black; font-family: Georgia; font-size: 11pt;"&gt;&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;socket, select&lt;br /&gt;2&lt;br /&gt;3 &amp;nbsp;EOL1 = b&lt;/span&gt;&lt;span class="c4" style="color: #209b43; font-family: Georgia; font-size: 11pt;"&gt;'\n\n'&lt;/span&gt;&lt;span class="c1" style="color: black; font-family: Georgia; font-size: 11pt;"&gt;&lt;br /&gt;4 &amp;nbsp;EOL2 = b&lt;/span&gt;&lt;span class="c4" style="color: #209b43; font-family: Georgia; font-size: 11pt;"&gt;'\n\r\n'&lt;/span&gt;&lt;span class="c1" style="color: black; font-family: Georgia; font-size: 11pt;"&gt;&lt;br /&gt;5 &amp;nbsp;response &amp;nbsp;= b&lt;/span&gt;&lt;span class="c4" style="color: #209b43; font-family: Georgia; font-size: 11pt;"&gt;'HTTP/1.0 200 OK\r\nDate: Mon, 1 Jan 1996 01:01:01 GMT\r\n'&lt;/span&gt;&lt;span class="c1" style="color: black; font-family: Georgia; font-size: 11pt;"&gt;&lt;br /&gt;6 &amp;nbsp;response += b&lt;/span&gt;&lt;span class="c4" style="color: #209b43; font-family: Georgia; font-size: 11pt;"&gt;'Content-Type: text/plain\r\nContent-Length: 13\r\n\r\n'&lt;/span&gt;&lt;span class="c1" style="color: black; font-family: Georgia; font-size: 11pt;"&gt;&lt;br /&gt;7 &amp;nbsp;response += b&lt;/span&gt;&lt;span class="c4" style="color: #209b43; font-family: Georgia; font-size: 11pt;"&gt;'Hello, world!'&lt;/span&gt;&lt;span class="c1" style="color: black; font-family: Georgia; font-size: 11pt;"&gt;&lt;br /&gt;8&lt;br /&gt;9 &amp;nbsp;serversocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)&lt;br /&gt;10 &amp;nbsp;serversocket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)&lt;br /&gt;11 &amp;nbsp;serversocket.bind((&lt;/span&gt;&lt;span class="c4" style="color: #209b43; font-family: Georgia; font-size: 11pt;"&gt;'0.0.0.0'&lt;/span&gt;&lt;span class="c1" style="color: black; font-family: Georgia; font-size: 11pt;"&gt;, 8080))&lt;br /&gt;12 &amp;nbsp;serversocket.listen(1)&lt;br /&gt;13 &amp;nbsp;serversocket.setblocking(0)&lt;br /&gt;14&lt;br /&gt;15 &amp;nbsp;epoll = select.epoll()&lt;br /&gt;16 &amp;nbsp;epoll.register(serversocket.fileno(), select.EPOLLIN | select.EPOLLET)&lt;br /&gt;17&lt;br /&gt;18 &amp;nbsp;&lt;/span&gt;&lt;span class="c0" style="color: #20509b; font-family: Georgia; font-size: 11pt; font-weight: bold;"&gt;try&lt;/span&gt;&lt;span class="c1" style="color: black; font-family: Georgia; font-size: 11pt;"&gt;:&lt;br /&gt;19 &amp;nbsp; &amp;nbsp; connections = {}; requests = {}; responses = {}&lt;br /&gt;20 &amp;nbsp; &amp;nbsp;&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span class="c0" style="color: #20509b; font-family: Georgia; font-size: 11pt; font-weight: bold;"&gt;while&lt;/span&gt;&lt;span class="c1" style="color: black; font-family: Georgia; font-size: 11pt;"&gt;&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span class="c0" style="color: #20509b; font-family: Georgia; font-size: 11pt; font-weight: bold;"&gt;True&lt;/span&gt;&lt;span class="c1" style="color: black; font-family: Georgia; font-size: 11pt;"&gt;:&lt;br /&gt;21 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;events = epoll.poll(1)&lt;br /&gt;22 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span class="c0" style="color: #20509b; font-family: Georgia; font-size: 11pt; font-weight: bold;"&gt;for&lt;/span&gt;&lt;span class="c1" style="color: black; font-family: Georgia; font-size: 11pt;"&gt;&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;fileno, event&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span class="c0" style="color: #20509b; font-family: Georgia; font-size: 11pt; font-weight: bold;"&gt;in&lt;/span&gt;&lt;span class="c1" style="color: black; font-family: Georgia; font-size: 11pt;"&gt;&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;events:&lt;br /&gt;23 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span class="c0" style="color: #20509b; font-family: Georgia; font-size: 11pt; font-weight: bold;"&gt;if&lt;/span&gt;&lt;span class="c1" style="color: black; font-family: Georgia; font-size: 11pt;"&gt;&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;fileno == serversocket.fileno():&lt;br /&gt;24 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span class="c0" style="color: #20509b; font-family: Georgia; font-size: 11pt; font-weight: bold;"&gt;try&lt;/span&gt;&lt;span class="c1" style="color: black; font-family: Georgia; font-size: 11pt;"&gt;:&lt;br /&gt;25 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span class="c0" style="color: #20509b; font-family: Georgia; font-size: 11pt; font-weight: bold;"&gt;while&lt;/span&gt;&lt;span class="c1" style="color: black; font-family: Georgia; font-size: 11pt;"&gt;&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span class="c0" style="color: #20509b; font-family: Georgia; font-size: 11pt; font-weight: bold;"&gt;True&lt;/span&gt;&lt;span class="c1" style="color: black; font-family: Georgia; font-size: 11pt;"&gt;:&lt;br /&gt;26 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;connection, address = serversocket.accept()&lt;br /&gt;27 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;connection.setblocking(0)&lt;br /&gt;28 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;epoll.register(connection.fileno(), select.EPOLLIN | select.EPOLLET)&lt;br /&gt;29 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;connections[connection.fileno()] = connection&lt;br /&gt;30 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;requests[connection.fileno()] = b&lt;/span&gt;&lt;span class="c4" style="color: #209b43; font-family: Georgia; font-size: 11pt;"&gt;''&lt;/span&gt;&lt;span class="c1" style="color: black; font-family: Georgia; font-size: 11pt;"&gt;&lt;br /&gt;31 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;responses[connection.fileno()] = response&lt;br /&gt;32 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span class="c0" style="color: #20509b; font-family: Georgia; font-size: 11pt; font-weight: bold;"&gt;except&lt;/span&gt;&lt;span class="c1" style="color: black; font-family: Georgia; font-size: 11pt;"&gt;&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;socket.error:&lt;br /&gt;33 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span class="c0" style="color: #20509b; font-family: Georgia; font-size: 11pt; font-weight: bold;"&gt;pass&lt;/span&gt;&lt;span class="c1" style="color: black; font-family: Georgia; font-size: 11pt;"&gt;&lt;br /&gt;34 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span class="c0" style="color: #20509b; font-family: Georgia; font-size: 11pt; font-weight: bold;"&gt;elif&lt;/span&gt;&lt;span class="c1" style="color: black; font-family: Georgia; font-size: 11pt;"&gt;&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;event &amp;amp; select.EPOLLIN:&lt;br /&gt;35 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span class="c0" style="color: #20509b; font-family: Georgia; font-size: 11pt; font-weight: bold;"&gt;try&lt;/span&gt;&lt;span class="c1" style="color: black; font-family: Georgia; font-size: 11pt;"&gt;:&lt;br /&gt;36 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span class="c0" style="color: #20509b; font-family: Georgia; font-size: 11pt; font-weight: bold;"&gt;while&lt;/span&gt;&lt;span class="c1" style="color: black; font-family: Georgia; font-size: 11pt;"&gt;&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span class="c0" style="color: #20509b; font-family: Georgia; font-size: 11pt; font-weight: bold;"&gt;True&lt;/span&gt;&lt;span class="c1" style="color: black; font-family: Georgia; font-size: 11pt;"&gt;:&lt;br /&gt;37 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;requests[fileno] += connections[fileno].recv(1024)&lt;br /&gt;38 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span class="c0" style="color: #20509b; font-family: Georgia; font-size: 11pt; font-weight: bold;"&gt;except&lt;/span&gt;&lt;span class="c1" style="color: black; font-family: Georgia; font-size: 11pt;"&gt;&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;socket.error:&lt;br /&gt;39 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span class="c0" style="color: #20509b; font-family: Georgia; font-size: 11pt; font-weight: bold;"&gt;pass&lt;/span&gt;&lt;span class="c1" style="color: black; font-family: Georgia; font-size: 11pt;"&gt;&lt;br /&gt;40 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span class="c0" style="color: #20509b; font-family: Georgia; font-size: 11pt; font-weight: bold;"&gt;if&lt;/span&gt;&lt;span class="c1" style="color: black; font-family: Georgia; font-size: 11pt;"&gt;&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;EOL1&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span class="c0" style="color: #20509b; font-family: Georgia; font-size: 11pt; font-weight: bold;"&gt;in&lt;/span&gt;&lt;span class="c1" style="color: black; font-family: Georgia; font-size: 11pt;"&gt;&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;requests[fileno]&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span class="c0" style="color: #20509b; font-family: Georgia; font-size: 11pt; font-weight: bold;"&gt;or&lt;/span&gt;&lt;span class="c1" style="color: black; font-family: Georgia; font-size: 11pt;"&gt;&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;EOL2&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span class="c0" style="color: #20509b; font-family: Georgia; font-size: 11pt; font-weight: bold;"&gt;in&lt;/span&gt;&lt;span class="c1" style="color: black; font-family: Georgia; font-size: 11pt;"&gt;&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;requests[fileno]:&lt;br /&gt;41 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; epoll.modify(fileno, select.EPOLLOUT | select.EPOLLET)&lt;br /&gt;42 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; print(&lt;/span&gt;&lt;span class="c4" style="color: #209b43; font-family: Georgia; font-size: 11pt;"&gt;'-'&lt;/span&gt;&lt;span class="c1" style="color: black; font-family: Georgia; font-size: 11pt;"&gt;*40 +&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span class="c4" style="color: #209b43; font-family: Georgia; font-size: 11pt;"&gt;'\n'&lt;/span&gt;&lt;span class="c1" style="color: black; font-family: Georgia; font-size: 11pt;"&gt;&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;+ requests[fileno].decode()[:-2])&lt;br /&gt;43 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span class="c0" style="color: #20509b; font-family: Georgia; font-size: 11pt; font-weight: bold;"&gt;elif&lt;/span&gt;&lt;span class="c1" style="color: black; font-family: Georgia; font-size: 11pt;"&gt;&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;event &amp;amp; select.EPOLLOUT:&lt;br /&gt;44 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span class="c0" style="color: #20509b; font-family: Georgia; font-size: 11pt; font-weight: bold;"&gt;try&lt;/span&gt;&lt;span class="c1" style="color: black; font-family: Georgia; font-size: 11pt;"&gt;:&lt;br /&gt;45 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span class="c0" style="color: #20509b; font-family: Georgia; font-size: 11pt; font-weight: bold;"&gt;while&lt;/span&gt;&lt;span class="c1" style="color: black; font-family: Georgia; font-size: 11pt;"&gt;&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;len(responses[fileno]) &amp;gt; 0:&lt;br /&gt;46 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;byteswritten = connections[fileno].send(responses[fileno])&lt;br /&gt;47 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;responses[fileno] = responses[fileno][byteswritten:]&lt;br /&gt;48 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span class="c0" style="color: #20509b; font-family: Georgia; font-size: 11pt; font-weight: bold;"&gt;except&lt;/span&gt;&lt;span class="c1" style="color: black; font-family: Georgia; font-size: 11pt;"&gt;&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;socket.error:&lt;br /&gt;49 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span class="c0" style="color: #20509b; font-family: Georgia; font-size: 11pt; font-weight: bold;"&gt;pass&lt;/span&gt;&lt;span class="c1" style="color: black; font-family: Georgia; font-size: 11pt;"&gt;&lt;br /&gt;50 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span class="c0" style="color: #20509b; font-family: Georgia; font-size: 11pt; font-weight: bold;"&gt;if&lt;/span&gt;&lt;span class="c1" style="color: black; font-family: Georgia; font-size: 11pt;"&gt;&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;len(responses[fileno]) == 0:&lt;br /&gt;51 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; epoll.modify(fileno, select.EPOLLET)&lt;br /&gt;52 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; connections[fileno].shutdown(socket.SHUT_RDWR)&lt;br /&gt;53 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span class="c0" style="color: #20509b; font-family: Georgia; font-size: 11pt; font-weight: bold;"&gt;elif&lt;/span&gt;&lt;span class="c1" style="color: black; font-family: Georgia; font-size: 11pt;"&gt;&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;event &amp;amp; select.EPOLLHUP:&lt;br /&gt;54 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;epoll.unregister(fileno)&lt;br /&gt;55 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;connections[fileno].close()&lt;br /&gt;56 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span class="c0" style="color: #20509b; font-family: Georgia; font-size: 11pt; font-weight: bold;"&gt;del&lt;/span&gt;&lt;span class="c1" style="color: black; font-family: Georgia; font-size: 11pt;"&gt;&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;connections[fileno]&lt;br /&gt;57 &amp;nbsp;&lt;/span&gt;&lt;span class="c0" style="color: #20509b; font-family: Georgia; font-size: 11pt; font-weight: bold;"&gt;finally&lt;/span&gt;&lt;span class="c1" style="color: black; font-family: Georgia; font-size: 11pt;"&gt;:&lt;br /&gt;58 &amp;nbsp; &amp;nbsp; epoll.unregister(serversocket.fileno())&lt;br /&gt;59 &amp;nbsp; &amp;nbsp; epoll.close()&lt;br /&gt;60 &amp;nbsp; &amp;nbsp; serversocket.close()&lt;/span&gt;&lt;/div&gt;&lt;div class="c19 c21" style="direction: ltr; line-height: 1; margin: 0px 48pt; text-indent: 0pt;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="c7" style="direction: ltr; line-height: 1; margin: 0px; padding-bottom: 16pt; text-indent: 0pt;"&gt;&lt;span class="c2" style="color: black; font-family: Verdana; font-size: 10pt;"&gt;这两种模式是类似的，水平触发模式常被用在移植使用select或者poll机制的应用程序时，而边沿触发模式可以用在当程序员不需要或不想要操作系统协助管理event状态时。&lt;/span&gt;&lt;/div&gt;&lt;div class="c18" style="direction: ltr; line-height: 1; margin: 0px; padding-bottom: 17.6pt; text-indent: 0pt;"&gt;&lt;span class="c2" style="color: black; font-family: Verdana; font-size: 10pt;"&gt;除了这两种操作模式，epoll对象也可以注册socket使用EPOLLONESHOTevent掩码。当使用这个选项时，注册的event只适用于一个epoll.poll()调用，调用之后它会自动从被监视的socket注册列表中移除。&lt;/span&gt;&lt;/div&gt;&lt;a href="https://docs.google.com/document/pub?id=1kH6JKRgAo6BDC3voKInN4TrSgqC0VVs9Op80xl5xGxw#" name="id.yg0cqu1qyw2x"&gt;&lt;/a&gt;&lt;div class="c17" style="direction: ltr; line-height: 1; margin: 0px; padding-bottom: 14.4pt; text-indent: 0pt;"&gt;&lt;a href="" name="h.9c4m549luf7"&gt;&lt;/a&gt;&lt;span class="c15" style="color: #20509b; font-family: Verdana; font-size: 17pt; font-weight: bold;"&gt;性能注意事项&lt;/span&gt;&lt;/div&gt;&lt;div class="c16" style="direction: ltr; line-height: 1; margin: 0px; padding-bottom: 8pt; text-indent: 0pt;"&gt;&lt;a href="" name="h.vzh1tqx3cd00"&gt;&lt;/a&gt;&lt;span class="c22" style="color: #20509b; font-family: Verdana; font-size: 14pt; font-weight: bold;"&gt;监听缓冲区队列大小&lt;/span&gt;&lt;/div&gt;&lt;div class="c7" style="direction: ltr; line-height: 1; margin: 0px; padding-bottom: 16pt; text-indent: 0pt;"&gt;&lt;span class="c2" style="color: black; font-family: Verdana; font-size: 10pt;"&gt;在示例1-4中，第12行都调用了serversocket.listen()方法。此方法的参数就是监听缓冲区队列的大小。它告诉操作系统可以接收多少TCP/IP连接，并放到缓冲区队列中等待Pytohn程序接收。Python程序每次在服务端socket上面调用accept()，就会有一个连接从缓冲区队列中移除，一个新的连接可以进入缓冲区队列。如果队列已满，新的连接都会被忽略，这会对网络连接的客户端造成不必要的延迟。在生产服务器上，通常要处理几十或几百个并发连接，所以值1通常是不够的。比如，当使用&lt;/span&gt;&lt;span class="c9" style="color: #9b2d20; font-family: Verdana; font-size: 10pt;"&gt;&lt;a href="http://www.google.com/url?q=http%3A%2F%2Fhttpd.apache.org%2Fdocs%2F2.0%2Fprograms%2Fab.html&amp;amp;sa=D&amp;amp;sntz=1&amp;amp;usg=AFQjCNG7xtRcfl5yoDPBXdTD_OpL6ERaHw"&gt;ab&lt;/a&gt;&lt;/span&gt;&lt;span class="c2" style="color: black; font-family: Verdana; font-size: 10pt;"&gt;模拟100个并发HTTP 1.0客户端，对上面的几个示例进行负载测试，如果缓冲区队列的值小于50，就会引起性能下降。&lt;/span&gt;&lt;/div&gt;&lt;div class="c16" style="direction: ltr; line-height: 1; margin: 0px; padding-bottom: 8pt; text-indent: 0pt;"&gt;&lt;a href="" name="h.t7qi1dqngixt"&gt;&lt;/a&gt;&lt;span class="c22" style="color: #20509b; font-family: Verdana; font-size: 14pt; font-weight: bold;"&gt;TCP选项&lt;/span&gt;&lt;/div&gt;&lt;div class="c19 c20" style="direction: ltr; line-height: 1; margin: 0px; padding-bottom: 24pt; text-indent: 0pt;"&gt;&lt;span class="c5" style="color: #000099; font-family: Verdana; font-size: 10pt; text-decoration: underline;"&gt;&lt;a href="http://www.google.com/url?q=http%3A%2F%2Fwww.baus.net%2Fon-tcp_cork&amp;amp;sa=D&amp;amp;sntz=1&amp;amp;usg=AFQjCNGj99pcsG7FWuggh3EzvssrQ7QRDA"&gt;TCP_CORK&lt;/a&gt;&lt;/span&gt;&lt;span class="c2" style="color: black; font-family: Verdana; font-size: 10pt;"&gt;选项可以用来“封存”消息，直到他们准备好发送。如示例5的第34行和第40行所示，这个选项对于使用&lt;/span&gt;&lt;span class="c5" style="color: #000099; font-family: Verdana; font-size: 10pt; text-decoration: underline;"&gt;&lt;a href="http://www.google.com/url?q=http%3A%2F%2Fen.wikipedia.org%2Fwiki%2FHTTP_pipelining&amp;amp;sa=D&amp;amp;sntz=1&amp;amp;usg=AFQjCNHC_dwCO2hlYoxtao0o8Q6_BhY3gw"&gt;HTTP/1.1流水线技术&lt;/a&gt;&lt;/span&gt;&lt;span class="c2" style="color: black; font-family: Verdana; font-size: 10pt;"&gt;的HTTP服务端来说，可能是一个很好的选择。&lt;/span&gt;&lt;/div&gt;&lt;div class="c12" style="direction: ltr; line-height: 1; margin: 0px 48pt; padding-bottom: 32pt; padding-top: 8pt; text-indent: 0pt;"&gt;&lt;span class="c6" style="color: #20509b; font-family: Verdana; font-size: 10pt;"&gt;Example 5&lt;/span&gt;&lt;/div&gt;&lt;div class="c12" style="direction: ltr; line-height: 1; margin: 0px 48pt; padding-bottom: 32pt; padding-top: 8pt; text-indent: 0pt;"&gt;&lt;span class="c1" style="color: black; font-family: Georgia; font-size: 11pt;"&gt;1 &amp;nbsp;&lt;/span&gt;&lt;span class="c0" style="color: #20509b; font-family: Georgia; font-size: 11pt; font-weight: bold;"&gt;import&lt;/span&gt;&lt;span class="c1" style="color: black; font-family: Georgia; font-size: 11pt;"&gt;&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;socket, select&lt;br /&gt;2&lt;br /&gt;3 &amp;nbsp;EOL1 = b&lt;/span&gt;&lt;span class="c4" style="color: #209b43; font-family: Georgia; font-size: 11pt;"&gt;'\n\n'&lt;/span&gt;&lt;span class="c1" style="color: black; font-family: Georgia; font-size: 11pt;"&gt;&lt;br /&gt;4 &amp;nbsp;EOL2 = b&lt;/span&gt;&lt;span class="c4" style="color: #209b43; font-family: Georgia; font-size: 11pt;"&gt;'\n\r\n'&lt;/span&gt;&lt;span class="c1" style="color: black; font-family: Georgia; font-size: 11pt;"&gt;&lt;br /&gt;5 &amp;nbsp;response &amp;nbsp;= b&lt;/span&gt;&lt;span class="c4" style="color: #209b43; font-family: Georgia; font-size: 11pt;"&gt;'HTTP/1.0 200 OK\r\nDate: Mon, 1 Jan 1996 01:01:01 GMT\r\n'&lt;/span&gt;&lt;span class="c1" style="color: black; font-family: Georgia; font-size: 11pt;"&gt;&lt;br /&gt;6 &amp;nbsp;response += b&lt;/span&gt;&lt;span class="c4" style="color: #209b43; font-family: Georgia; font-size: 11pt;"&gt;'Content-Type: text/plain\r\nContent-Length: 13\r\n\r\n'&lt;/span&gt;&lt;span class="c1" style="color: black; font-family: Georgia; font-size: 11pt;"&gt;&lt;br /&gt;7 &amp;nbsp;response += b&lt;/span&gt;&lt;span class="c4" style="color: #209b43; font-family: Georgia; font-size: 11pt;"&gt;'Hello, world!'&lt;/span&gt;&lt;span class="c1" style="color: black; font-family: Georgia; font-size: 11pt;"&gt;&lt;br /&gt;8&lt;br /&gt;9 &amp;nbsp;serversocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)&lt;br /&gt;10 &amp;nbsp;serversocket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)&lt;br /&gt;11 &amp;nbsp;serversocket.bind((&lt;/span&gt;&lt;span class="c4" style="color: #209b43; font-family: Georgia; font-size: 11pt;"&gt;'0.0.0.0'&lt;/span&gt;&lt;span class="c1" style="color: black; font-family: Georgia; font-size: 11pt;"&gt;, 8080))&lt;br /&gt;12 &amp;nbsp;serversocket.listen(1)&lt;br /&gt;13 &amp;nbsp;serversocket.setblocking(0)&lt;br /&gt;14&lt;br /&gt;15 &amp;nbsp;epoll = select.epoll()&lt;br /&gt;16 &amp;nbsp;epoll.register(serversocket.fileno(), select.EPOLLIN)&lt;br /&gt;17&lt;br /&gt;18&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span class="c0" style="color: #20509b; font-family: Georgia; font-size: 11pt; font-weight: bold;"&gt;try&lt;/span&gt;&lt;span class="c1" style="color: black; font-family: Georgia; font-size: 11pt;"&gt;:&lt;br /&gt;19 &amp;nbsp; &amp;nbsp; connections = {}; requests = {}; responses = {}&lt;br /&gt;20 &amp;nbsp; &amp;nbsp;&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span class="c0" style="color: #20509b; font-family: Georgia; font-size: 11pt; font-weight: bold;"&gt;while&lt;/span&gt;&lt;span class="c1" style="color: black; font-family: Georgia; font-size: 11pt;"&gt;&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span class="c0" style="color: #20509b; font-family: Georgia; font-size: 11pt; font-weight: bold;"&gt;True&lt;/span&gt;&lt;span class="c1" style="color: black; font-family: Georgia; font-size: 11pt;"&gt;:&lt;br /&gt;21 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;events = epoll.poll(1)&lt;br /&gt;22 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span class="c0" style="color: #20509b; font-family: Georgia; font-size: 11pt; font-weight: bold;"&gt;for&lt;/span&gt;&lt;span class="c1" style="color: black; font-family: Georgia; font-size: 11pt;"&gt;&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;fileno, event&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span class="c0" style="color: #20509b; font-family: Georgia; font-size: 11pt; font-weight: bold;"&gt;in&lt;/span&gt;&lt;span class="c1" style="color: black; font-family: Georgia; font-size: 11pt;"&gt;&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;events:&lt;br /&gt;23 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span class="c0" style="color: #20509b; font-family: Georgia; font-size: 11pt; font-weight: bold;"&gt;if&lt;/span&gt;&lt;span class="c1" style="color: black; font-family: Georgia; font-size: 11pt;"&gt;&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;fileno == serversocket.fileno():&lt;br /&gt;24 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;connection, address = serversocket.accept()&lt;br /&gt;25 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;connection.setblocking(0)&lt;br /&gt;26 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;epoll.register(connection.fileno(), select.EPOLLIN)&lt;br /&gt;27 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;connections[connection.fileno()] = connection&lt;br /&gt;28 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;requests[connection.fileno()] = b&lt;/span&gt;&lt;span class="c4" style="color: #209b43; font-family: Georgia; font-size: 11pt;"&gt;''&lt;/span&gt;&lt;span class="c1" style="color: black; font-family: Georgia; font-size: 11pt;"&gt;&lt;br /&gt;29 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;responses[connection.fileno()] = response&lt;br /&gt;30 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span class="c0" style="color: #20509b; font-family: Georgia; font-size: 11pt; font-weight: bold;"&gt;elif&lt;/span&gt;&lt;span class="c1" style="color: black; font-family: Georgia; font-size: 11pt;"&gt;&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;event &amp;amp; select.EPOLLIN:&lt;br /&gt;31 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;requests[fileno] += connections[fileno].recv(1024)&lt;br /&gt;32 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span class="c0" style="color: #20509b; font-family: Georgia; font-size: 11pt; font-weight: bold;"&gt;if&lt;/span&gt;&lt;span class="c1" style="color: black; font-family: Georgia; font-size: 11pt;"&gt;&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;EOL1&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span class="c0" style="color: #20509b; font-family: Georgia; font-size: 11pt; font-weight: bold;"&gt;in&lt;/span&gt;&lt;span class="c1" style="color: black; font-family: Georgia; font-size: 11pt;"&gt;&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;requests[fileno]&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span class="c0" style="color: #20509b; font-family: Georgia; font-size: 11pt; font-weight: bold;"&gt;or&lt;/span&gt;&lt;span class="c1" style="color: black; font-family: Georgia; font-size: 11pt;"&gt;&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;EOL2&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span class="c0" style="color: #20509b; font-family: Georgia; font-size: 11pt; font-weight: bold;"&gt;in&lt;/span&gt;&lt;span class="c1" style="color: black; font-family: Georgia; font-size: 11pt;"&gt;&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;requests[fileno]:&lt;br /&gt;33 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; epoll.modify(fileno, select.EPOLLOUT)&lt;br /&gt;34 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; connections[fileno].setsockopt(socket.IPPROTO_TCP, socket.TCP_CORK, 1)&lt;br /&gt;35 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; print(&lt;/span&gt;&lt;span class="c4" style="color: #209b43; font-family: Georgia; font-size: 11pt;"&gt;'-'&lt;/span&gt;&lt;span class="c1" style="color: black; font-family: Georgia; font-size: 11pt;"&gt;*40 +&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span class="c4" style="color: #209b43; font-family: Georgia; font-size: 11pt;"&gt;'\n'&lt;/span&gt;&lt;span class="c1" style="color: black; font-family: Georgia; font-size: 11pt;"&gt;&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;+ requests[fileno].decode()[:-2])&lt;br /&gt;36 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span class="c0" style="color: #20509b; font-family: Georgia; font-size: 11pt; font-weight: bold;"&gt;elif&lt;/span&gt;&lt;span class="c1" style="color: black; font-family: Georgia; font-size: 11pt;"&gt;&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;event &amp;amp; select.EPOLLOUT:&lt;br /&gt;37 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;byteswritten = connections[fileno].send(responses[fileno])&lt;br /&gt;38 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;responses[fileno] = responses[fileno][byteswritten:]&lt;br /&gt;39 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span class="c0" style="color: #20509b; font-family: Georgia; font-size: 11pt; font-weight: bold;"&gt;if&lt;/span&gt;&lt;span class="c1" style="color: black; font-family: Georgia; font-size: 11pt;"&gt;&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;len(responses[fileno]) == 0:&lt;br /&gt;40 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; connections[fileno].setsockopt(socket.IPPROTO_TCP, socket.TCP_CORK, 0)&lt;br /&gt;41 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; epoll.modify(fileno, 0)&lt;br /&gt;42 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; connections[fileno].shutdown(socket.SHUT_RDWR)&lt;br /&gt;43 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span class="c0" style="color: #20509b; font-family: Georgia; font-size: 11pt; font-weight: bold;"&gt;elif&lt;/span&gt;&lt;span class="c1" style="color: black; font-family: Georgia; font-size: 11pt;"&gt;&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;event &amp;amp; select.EPOLLHUP:&lt;br /&gt;44 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;epoll.unregister(fileno)&lt;br /&gt;45 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;connections[fileno].close()&lt;br /&gt;46 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span class="c0" style="color: #20509b; font-family: Georgia; font-size: 11pt; font-weight: bold;"&gt;del&lt;/span&gt;&lt;span class="c1" style="color: black; font-family: Georgia; font-size: 11pt;"&gt;&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;connections[fileno]&lt;br /&gt;47 &amp;nbsp;&lt;/span&gt;&lt;span class="c0" style="color: #20509b; font-family: Georgia; font-size: 11pt; font-weight: bold;"&gt;finally&lt;/span&gt;&lt;span class="c1" style="color: black; font-family: Georgia; font-size: 11pt;"&gt;:&lt;br /&gt;48 &amp;nbsp; &amp;nbsp; epoll.unregister(serversocket.fileno())&lt;br /&gt;49 &amp;nbsp; &amp;nbsp; epoll.close()&lt;br /&gt;50 &amp;nbsp; &amp;nbsp; serversocket.close()&lt;/span&gt;&lt;/div&gt;&lt;div class="c19 c20" style="direction: ltr; line-height: 1; margin: 0px; padding-bottom: 24pt; text-indent: 0pt;"&gt;&lt;span class="c2" style="color: black; font-family: Verdana; font-size: 10pt;"&gt;另一方面，&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span class="c5" style="color: #000099; font-family: Verdana; font-size: 10pt; text-decoration: underline;"&gt;&lt;a href="http://www.google.com/url?q=http%3A%2F%2Farticles.techrepublic.com.com%2F5100-10878_11-1050878.html&amp;amp;sa=D&amp;amp;sntz=1&amp;amp;usg=AFQjCNGFnQxhZ9P4LjSiE2OpY3PA6dNsjQ"&gt;TCP_NODELAY&lt;/a&gt;&lt;/span&gt;&lt;span class="c2" style="color: black; font-family: Verdana; font-size: 10pt;"&gt;选项可以用来告诉操作系统，任何传递给socket.send()的数据，不再缓存，要立即发送给客户端。如示例6的14行所示，这个选项对于使用一个SSH客户端或其他“实时”应用来说，可能是一个很好的选择。&lt;/span&gt;&lt;/div&gt;&lt;div class="c19 c21" style="direction: ltr; line-height: 1; margin: 0px 48pt; text-indent: 0pt;"&gt;&lt;span class="c6" style="color: #20509b; font-family: Verdana; font-size: 10pt;"&gt;Example 6&lt;/span&gt;&lt;/div&gt;&lt;div class="c19 c21" style="direction: ltr; line-height: 1; margin: 0px 48pt; text-indent: 0pt;"&gt;&lt;span class="c1" style="color: black; font-family: Georgia; font-size: 11pt;"&gt;1 &amp;nbsp;&lt;/span&gt;&lt;span class="c0" style="color: #20509b; font-family: Georgia; font-size: 11pt; font-weight: bold;"&gt;import&lt;/span&gt;&lt;span class="c1" style="color: black; font-family: Georgia; font-size: 11pt;"&gt;&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;socket, select&lt;br /&gt;2&lt;br /&gt;3 &amp;nbsp;EOL1 = b&lt;/span&gt;&lt;span class="c4" style="color: #209b43; font-family: Georgia; font-size: 11pt;"&gt;'\n\n'&lt;/span&gt;&lt;span class="c1" style="color: black; font-family: Georgia; font-size: 11pt;"&gt;&lt;br /&gt;4 &amp;nbsp;EOL2 = b&lt;/span&gt;&lt;span class="c4" style="color: #209b43; font-family: Georgia; font-size: 11pt;"&gt;'\n\r\n'&lt;/span&gt;&lt;span class="c1" style="color: black; font-family: Georgia; font-size: 11pt;"&gt;&lt;br /&gt;5 &amp;nbsp;response &amp;nbsp;= b&lt;/span&gt;&lt;span class="c4" style="color: #209b43; font-family: Georgia; font-size: 11pt;"&gt;'HTTP/1.0 200 OK\r\nDate: Mon, 1 Jan 1996 01:01:01 GMT\r\n'&lt;/span&gt;&lt;span class="c1" style="color: black; font-family: Georgia; font-size: 11pt;"&gt;&lt;br /&gt;6 &amp;nbsp;response += b&lt;/span&gt;&lt;span class="c4" style="color: #209b43; font-family: Georgia; font-size: 11pt;"&gt;'Content-Type: text/plain\r\nContent-Length: 13\r\n\r\n'&lt;/span&gt;&lt;span class="c1" style="color: black; font-family: Georgia; font-size: 11pt;"&gt;&lt;br /&gt;7 &amp;nbsp;response += b&lt;/span&gt;&lt;span class="c4" style="color: #209b43; font-family: Georgia; font-size: 11pt;"&gt;'Hello, world!'&lt;/span&gt;&lt;span class="c1" style="color: black; font-family: Georgia; font-size: 11pt;"&gt;&lt;br /&gt;8&lt;br /&gt;9 &amp;nbsp;serversocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)&lt;br /&gt;10 &amp;nbsp;serversocket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)&lt;br /&gt;11 &amp;nbsp;serversocket.bind((&lt;/span&gt;&lt;span class="c4" style="color: #209b43; font-family: Georgia; font-size: 11pt;"&gt;'0.0.0.0'&lt;/span&gt;&lt;span class="c1" style="color: black; font-family: Georgia; font-size: 11pt;"&gt;, 8080))&lt;br /&gt;12 &amp;nbsp;serversocket.listen(1)&lt;br /&gt;13 &amp;nbsp;serversocket.setblocking(0)&lt;br /&gt;14 &amp;nbsp;serversocket.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1)&lt;br /&gt;15&lt;br /&gt;16 &amp;nbsp;epoll = select.epoll()&lt;br /&gt;17 &amp;nbsp;epoll.register(serversocket.fileno(), select.EPOLLIN)&lt;br /&gt;18&lt;br /&gt;19&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span class="c0" style="color: #20509b; font-family: Georgia; font-size: 11pt; font-weight: bold;"&gt;try&lt;/span&gt;&lt;span class="c1" style="color: black; font-family: Georgia; font-size: 11pt;"&gt;:&lt;br /&gt;20 &amp;nbsp; &amp;nbsp; connections = {}; requests = {}; responses = {}&lt;br /&gt;21 &amp;nbsp; &amp;nbsp;&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span class="c0" style="color: #20509b; font-family: Georgia; font-size: 11pt; font-weight: bold;"&gt;while&lt;/span&gt;&lt;span class="c1" style="color: black; font-family: Georgia; font-size: 11pt;"&gt;&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span class="c0" style="color: #20509b; font-family: Georgia; font-size: 11pt; font-weight: bold;"&gt;True&lt;/span&gt;&lt;span class="c1" style="color: black; font-family: Georgia; font-size: 11pt;"&gt;:&lt;br /&gt;22 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;events = epoll.poll(1)&lt;br /&gt;23 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span class="c0" style="color: #20509b; font-family: Georgia; font-size: 11pt; font-weight: bold;"&gt;for&lt;/span&gt;&lt;span class="c1" style="color: black; font-family: Georgia; font-size: 11pt;"&gt;&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;fileno, event&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span class="c0" style="color: #20509b; font-family: Georgia; font-size: 11pt; font-weight: bold;"&gt;in&lt;/span&gt;&lt;span class="c1" style="color: black; font-family: Georgia; font-size: 11pt;"&gt;&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;events:&lt;br /&gt;24 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span class="c0" style="color: #20509b; font-family: Georgia; font-size: 11pt; font-weight: bold;"&gt;if&lt;/span&gt;&lt;span class="c1" style="color: black; font-family: Georgia; font-size: 11pt;"&gt;&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;fileno == serversocket.fileno():&lt;br /&gt;25 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;connection, address = serversocket.accept()&lt;br /&gt;26 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;connection.setblocking(0)&lt;br /&gt;27 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;epoll.register(connection.fileno(), select.EPOLLIN)&lt;br /&gt;28 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;connections[connection.fileno()] = connection&lt;br /&gt;29 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;requests[connection.fileno()] = b&lt;/span&gt;&lt;span class="c4" style="color: #209b43; font-family: Georgia; font-size: 11pt;"&gt;''&lt;/span&gt;&lt;span class="c1" style="color: black; font-family: Georgia; font-size: 11pt;"&gt;&lt;br /&gt;30 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;responses[connection.fileno()] = response&lt;br /&gt;31 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span class="c0" style="color: #20509b; font-family: Georgia; font-size: 11pt; font-weight: bold;"&gt;elif&lt;/span&gt;&lt;span class="c1" style="color: black; font-family: Georgia; font-size: 11pt;"&gt;&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;event &amp;amp; select.EPOLLIN:&lt;br /&gt;32 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;requests[fileno] += connections[fileno].recv(1024)&lt;br /&gt;33 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span class="c0" style="color: #20509b; font-family: Georgia; font-size: 11pt; font-weight: bold;"&gt;if&lt;/span&gt;&lt;span class="c1" style="color: black; font-family: Georgia; font-size: 11pt;"&gt;&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;EOL1&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span class="c0" style="color: #20509b; font-family: Georgia; font-size: 11pt; font-weight: bold;"&gt;in&lt;/span&gt;&lt;span class="c1" style="color: black; font-family: Georgia; font-size: 11pt;"&gt;&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;requests[fileno]&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span class="c0" style="color: #20509b; font-family: Georgia; font-size: 11pt; font-weight: bold;"&gt;or&lt;/span&gt;&lt;span class="c1" style="color: black; font-family: Georgia; font-size: 11pt;"&gt;&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;EOL2&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span class="c0" style="color: #20509b; font-family: Georgia; font-size: 11pt; font-weight: bold;"&gt;in&lt;/span&gt;&lt;span class="c1" style="color: black; font-family: Georgia; font-size: 11pt;"&gt;&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;requests[fileno]:&lt;br /&gt;34 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; epoll.modify(fileno, select.EPOLLOUT)&lt;br /&gt;35 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; print(&lt;/span&gt;&lt;span class="c4" style="color: #209b43; font-family: Georgia; font-size: 11pt;"&gt;'-'&lt;/span&gt;&lt;span class="c1" style="color: black; font-family: Georgia; font-size: 11pt;"&gt;*40 +&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span class="c4" style="color: #209b43; font-family: Georgia; font-size: 11pt;"&gt;'\n'&lt;/span&gt;&lt;span class="c1" style="color: black; font-family: Georgia; font-size: 11pt;"&gt;&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;+ requests[fileno].decode()[:-2])&lt;br /&gt;36 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span class="c0" style="color: #20509b; font-family: Georgia; font-size: 11pt; font-weight: bold;"&gt;elif&lt;/span&gt;&lt;span class="c1" style="color: black; font-family: Georgia; font-size: 11pt;"&gt;&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;event &amp;amp; select.EPOLLOUT:&lt;br /&gt;37 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;byteswritten = connections[fileno].send(responses[fileno])&lt;br /&gt;38 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;responses[fileno] = responses[fileno][byteswritten:]&lt;br /&gt;39 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span class="c0" style="color: #20509b; font-family: Georgia; font-size: 11pt; font-weight: bold;"&gt;if&lt;/span&gt;&lt;span class="c1" style="color: black; font-family: Georgia; font-size: 11pt;"&gt;&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;len(responses[fileno]) == 0:&lt;br /&gt;40 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; epoll.modify(fileno, 0)&lt;br /&gt;41 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; connections[fileno].shutdown(socket.SHUT_RDWR)&lt;br /&gt;42 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span class="c0" style="color: #20509b; font-family: Georgia; font-size: 11pt; font-weight: bold;"&gt;elif&lt;/span&gt;&lt;span class="c1" style="color: black; font-family: Georgia; font-size: 11pt;"&gt;&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;event &amp;amp; select.EPOLLHUP:&lt;br /&gt;43 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;epoll.unregister(fileno)&lt;br /&gt;44 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;connections[fileno].close()&lt;br /&gt;45 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span class="c0" style="color: #20509b; font-family: Georgia; font-size: 11pt; font-weight: bold;"&gt;del&lt;/span&gt;&lt;span class="c1" style="color: black; font-family: Georgia; font-size: 11pt;"&gt;&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;connections[fileno]&lt;br /&gt;46 &amp;nbsp;&lt;/span&gt;&lt;span class="c0" style="color: #20509b; font-family: Georgia; font-size: 11pt; font-weight: bold;"&gt;finally&lt;/span&gt;&lt;span class="c1" style="color: black; font-family: Georgia; font-size: 11pt;"&gt;:&lt;br /&gt;47 &amp;nbsp; &amp;nbsp; epoll.unregister(serversocket.fileno())&lt;br /&gt;48 &amp;nbsp; &amp;nbsp; epoll.close()&lt;br /&gt;49 &amp;nbsp; &amp;nbsp; serversocket.close()&lt;/span&gt;&lt;/div&gt;&lt;div class="c16" style="direction: ltr; line-height: 1; margin: 0px; padding-bottom: 8pt; text-indent: 0pt;"&gt;&lt;a href="" name="h.hm0nhuwzz7cj"&gt;&lt;/a&gt;&lt;/div&gt;&lt;a href="https://docs.google.com/document/pub?id=1kH6JKRgAo6BDC3voKInN4TrSgqC0VVs9Op80xl5xGxw#" name="id.lff525bi4x8o"&gt;&lt;/a&gt;&lt;div class="c16" style="direction: ltr; line-height: 1; margin: 0px; padding-bottom: 8pt; text-indent: 0pt;"&gt;&lt;a href="" name="h.n01rfstchnst"&gt;&lt;/a&gt;&lt;span class="c15" style="color: #20509b; font-family: Verdana; font-size: 17pt; font-weight: bold;"&gt;源代码&lt;/span&gt;&lt;/div&gt;&lt;div class="c19 c25" style="direction: ltr; line-height: 1; margin: 0px; padding-bottom: 33.6pt; text-indent: 0pt;"&gt;&lt;span class="c2" style="color: black; font-family: Verdana; font-size: 10pt;"&gt;此页面上的示例不受版权限制，这里提供&lt;/span&gt;&lt;span class="c5" style="color: #000099; font-family: Verdana; font-size: 10pt; text-decoration: underline;"&gt;&lt;a href="http://www.google.com/url?q=http%3A%2F%2Fscotdoyle.com%2Fpython-epoll-examples.tar.gz&amp;amp;sa=D&amp;amp;sntz=1&amp;amp;usg=AFQjCNGj_7emPC51_la_-A-aXVXjlf-smw"&gt;下载&lt;/a&gt;&lt;/span&gt;&lt;span class="c2" style="color: black; font-family: Verdana; font-size: 10pt;"&gt;&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;。&lt;/span&gt;&lt;/div&gt;&lt;/span&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5866936448448261654-3972792885069498271?l=moonbingbing.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://moonbingbing.blogspot.com/feeds/3972792885069498271/comments/default' title='帖子评论'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5866936448448261654&amp;postID=3972792885069498271' title='0 条评论'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5866936448448261654/posts/default/3972792885069498271'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5866936448448261654/posts/default/3972792885069498271'/><link rel='alternate' type='text/html' href='http://moonbingbing.blogspot.com/2010/11/pythonlinuxepoll.html' title='[翻译]在Python中如何使用Linux的epoll'/><author><name>wayne</name><uri>http://www.blogger.com/profile/08537956174550037355</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5866936448448261654.post-5840275983249942433</id><published>2010-05-31T17:26:00.001+08:00</published><updated>2010-05-31T17:26:12.175+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='mysql'/><title type='text'>MySQL enterprise Monitor的安装和使用</title><content type='html'>&amp;nbsp; 上次内部分享MySQL经验的时候，西山居的DBA建议试用一下MySQL enterprise Monitor，游戏部门已经购买，并且评价很高。&lt;br /&gt;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp; 抽空安装试用了一下，感觉挺好的，可以发现不少数据库存在的风险，推荐大家使用。&lt;br /&gt;&lt;br /&gt;&amp;nbsp; 官方的&lt;a href="https://enterprise.mysql.com/docs/monitor/2.2/en/"&gt;文档&lt;/a&gt;挺全的，这里记录一下安装的过程。&lt;br /&gt;&amp;nbsp;&amp;nbsp; 1、到&lt;a href="https://enterprise.mysql.com/"&gt;https://enterprise.mysql.com/&lt;/a&gt;去申请一个试用版。&lt;br /&gt;&amp;nbsp;&amp;nbsp; 2、安装监控访问管理端的程序（service manager and dashboard），这个我是安装在windows下的。一路next就行&lt;br /&gt;&amp;nbsp; 3、增加agent的MySQL权限：&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; grant select,replication client,show databases,super,process on *.* to ‘agent’@'127.0.0.1′ identified by ‘password’;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; grant create,insert on mysql.* to ‘agent’@'127.0.0.1′ identified by ‘password’;&lt;br /&gt;&amp;nbsp;4、安装agent端程序（mysqlmonitoragent），：&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; rpm -qa | grep -i lsb 看redhat-lsb-3.1-12.3.EL是否存在（数据库操作系统为centos5.4）&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 直接执行 mysqlmonitoragent-2.2.0.1705-linux-glibc2.3-x86-64bit-installer.bin --mode text即可。如果不需要agent采集SQL语句来分析，就不用开启MySQL Enterprise Agent Proxy Service。&lt;br /&gt;5、/etc/init.d/mysql-monitor-agent start 启动agent。可以查看/opt/mysql/enterprise/agent/mysql-monitor-agent.log来看是否正常。&lt;br /&gt;6、没问题的话，在server端的18080端口就可以看到数据库的监控情况了。&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5866936448448261654-5840275983249942433?l=moonbingbing.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://moonbingbing.blogspot.com/feeds/5840275983249942433/comments/default' title='帖子评论'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5866936448448261654&amp;postID=5840275983249942433' title='0 条评论'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5866936448448261654/posts/default/5840275983249942433'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5866936448448261654/posts/default/5840275983249942433'/><link rel='alternate' type='text/html' href='http://moonbingbing.blogspot.com/2010/05/mysql-enterprise-monitor.html' title='MySQL enterprise Monitor的安装和使用'/><author><name>wayne</name><uri>http://www.blogger.com/profile/08537956174550037355</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5866936448448261654.post-5153622963908466875</id><published>2010-05-12T10:15:00.013+08:00</published><updated>2010-12-27T14:09:35.303+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='mysql'/><title type='text'>MySQL Query Browser的SQL语句耗时提示</title><content type='html'>在MySQL Query Browser中执行一条SQL语句，会发现左下角有一行提示：&lt;br /&gt;&lt;br /&gt;N row(s) fetched in Time1 s(Time2 s)&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;以前没有在意里面两个时间的区别，最近数据库（IBM x3650）网卡故障，访问很慢，在排除软件问题的时候，发现这两个时间比较诡异，有时Time1比Time2大很多。google了下，&lt;a href="http://forums.mysql.com/read.php?108,51989,230038#msg-230038"&gt;这里&lt;/a&gt;可以看到sun数据库工程师的解释：&lt;span class="Apple-style-span" style="border-collapse: separate; color: black; font-family: 微软雅黑; font-size: small; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;"&gt;&lt;span class="Apple-style-span" style="border-collapse: collapse; font-family: arial,sans-serif;"&gt;&lt;div&gt;&lt;br /&gt;&lt;span xmlns="http://www.w3.org/1999/xhtml"&gt;&lt;span xmlns="http://www.w3.org/1999/xhtml"&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style="color: #76a5af;"&gt;query_time is the time the query needed to execute: &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: #76a5af;"&gt;   // Start query timer &lt;/span&gt;&lt;br /&gt;&lt;span style="color: #76a5af;"&gt;   timer_start(&amp;amp;timer); &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: #76a5af;"&gt;   if (sql) &lt;/span&gt;&lt;br /&gt;&lt;span style="color: #76a5af;"&gt;     r= myx_mysql_query(mysql, resultset-&amp;gt;query-&amp;gt;sql); &lt;/span&gt;&lt;br /&gt;&lt;span style="color: #76a5af;"&gt; #if MYSQL_VERSION_ID &amp;gt;= 50000 &lt;/span&gt;&lt;br /&gt;&lt;span style="color: #76a5af;"&gt;   else &lt;/span&gt;&lt;br /&gt;&lt;span style="color: #76a5af;"&gt;     r= mysql_next_result(mysql); &lt;/span&gt;&lt;br /&gt;&lt;span style="color: #76a5af;"&gt; #endif &lt;/span&gt;&lt;br /&gt;&lt;span style="color: #76a5af;"&gt;   // Stop query timer &lt;/span&gt;&lt;br /&gt;&lt;span style="color: #76a5af;"&gt;   resultset-&amp;gt;query_time= timer_stop(&amp;amp;timer); &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: #76a5af;"&gt; and fetch_time is what it took to get the result set transferred to the client. &lt;/span&gt;&lt;/div&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-size: small;"&gt;可以得知，Time1是服务器端把结果传回客户端的时间，Time2是数据库执行SQL语句的时间。&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5866936448448261654-5153622963908466875?l=moonbingbing.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://moonbingbing.blogspot.com/feeds/5153622963908466875/comments/default' title='帖子评论'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5866936448448261654&amp;postID=5153622963908466875' title='0 条评论'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5866936448448261654/posts/default/5153622963908466875'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5866936448448261654/posts/default/5153622963908466875'/><link rel='alternate' type='text/html' href='http://moonbingbing.blogspot.com/2010/05/mysql-query-browsersql.html' title='MySQL Query Browser的SQL语句耗时提示'/><author><name>wayne</name><uri>http://www.blogger.com/profile/08537956174550037355</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5866936448448261654.post-941392021126688371</id><published>2010-04-30T19:32:00.003+08:00</published><updated>2010-05-31T17:05:04.620+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='mysql'/><title type='text'>毒霸云查杀数据库架构和MySQL优化实践</title><content type='html'>&lt;div&gt;想写这个PPT很久了，毒霸的数据库规模和应用最大的就是云查杀这边，两三年间遇到的问题也挺多，有必要总结一下。这次参加2010数据库大会回来，要做内部分享，就抽了时间写了下（PPT是个提纲，等内部分享完了放录音出来）&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;a href="http://www.slideshare.net/moonbingbing/mercury-4148606"&gt;http://www.slideshare.net/moonbingbing/mercury-4148606&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5866936448448261654-941392021126688371?l=moonbingbing.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://moonbingbing.blogspot.com/feeds/941392021126688371/comments/default' title='帖子评论'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5866936448448261654&amp;postID=941392021126688371' title='0 条评论'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5866936448448261654/posts/default/941392021126688371'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5866936448448261654/posts/default/941392021126688371'/><link rel='alternate' type='text/html' href='http://moonbingbing.blogspot.com/2010/04/mysql.html' title='毒霸云查杀数据库架构和MySQL优化实践'/><author><name>wayne</name><uri>http://www.blogger.com/profile/08537956174550037355</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5866936448448261654.post-5190086442979662736</id><published>2010-04-14T20:43:00.003+08:00</published><updated>2010-06-01T11:00:55.145+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='mysql优化'/><title type='text'>[翻译]How to calculate a good InnoDB log file size</title><content type='html'>原文在&lt;a href="http://www.mysqlperformanceblog.com/2008/11/21/how-to-calculate-a-good-innodb-log-file-size/" target="_blank"&gt;这里&lt;/a&gt;&lt;br /&gt;&lt;div&gt;&lt;a href="http://www.mysqlperformanceblog.com/2008/11/21/how-to-calculate-a-good-innodb-log-file-size/" target="_blank"&gt;&lt;/a&gt;&lt;br /&gt;&lt;div&gt;Peter之前写了一篇文章：'&lt;a href="http://www.mysqlperformanceblog.com/2006/07/03/choosing-proper-innodb_log_file_size/" target="_blank"&gt;选择合适的InnoDB日志文件大小&lt;/a&gt;'。不是挑peter的刺儿，这篇文章其实讲了挺多东西，但就是没有告诉你怎么选择合适的日志文件大小！所以我想澄清这一点。&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;基本的一点是，你的日志文件大小应该满足&lt;span style="font-family: Verdana, Helvetica, sans-serif;"&gt;&lt;span style="line-height: 20px;"&gt;InnoDB优化自己的IO的需要，但是太大的话崩溃恢复时间就会变得很长。这一点peter已经讲的很清楚。怎么确定这个大小呢？我这里有一个相当不错的经验。&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style="font-family: Verdana, Helvetica, sans-serif;"&gt;&lt;span style="line-height: 20px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style="font-family: Verdana, Helvetica, sans-serif;"&gt;&lt;span style="line-height: 20px;"&gt;在大多数情况下，当别人给你一个公式来选择一个配置的时候，你应该对它持怀疑的态度。但是在这种情况下,你可以计算出一个合理的值，信不信由你。在你服务器的高峰期运行下面这些查询：&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style="font-family: Verdana, Helvetica, sans-serif;"&gt;&lt;span style="line-height: 20px;"&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;, Courier, monospace; font-size: 13px; white-space: nowrap;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;div&gt;&lt;div&gt;&lt;ol&gt;&lt;li style="color: #3a6a8b; font-family: &amp;quot;Courier New&amp;quot;, Courier, monospace; font-style: normal; font-weight: normal;"&gt;&lt;span style="font-size: small;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;, Courier, monospace; font-weight: normal;"&gt;&lt;span style="font-size: small;"&gt;mysql&amp;gt; pager grep sequence&lt;/span&gt;&lt;/div&gt;&lt;span style="font-size: small;"&gt;&lt;/span&gt;&lt;/li&gt;&lt;li style="color: #26536a; font-weight: bold;"&gt;&lt;span style="font-size: small;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;, Courier, monospace; font-weight: normal;"&gt;&lt;span style="font-size: small;"&gt;PAGER&amp;nbsp;&lt;span style="color: #993333; font-weight: bold;"&gt;SET&lt;/span&gt;&amp;nbsp;&lt;span style="color: #993333; font-weight: bold;"&gt;TO&lt;/span&gt;&amp;nbsp;&lt;span style="color: red;"&gt;'grep sequence'&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;span style="font-size: small;"&gt;&lt;/span&gt;&lt;/li&gt;&lt;li style="color: #3a6a8b; font-family: &amp;quot;Courier New&amp;quot;, Courier, monospace; font-style: normal; font-weight: normal;"&gt;&lt;span style="font-size: small;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;, Courier, monospace; font-weight: normal;"&gt;&lt;span style="font-size: small;"&gt;mysql&amp;gt;&amp;nbsp;&lt;span style="color: #993333; font-weight: bold;"&gt;SHOW&lt;/span&gt;&amp;nbsp;engine innodb&amp;nbsp;&lt;span style="color: #993333; font-weight: bold;"&gt;STATUS&lt;/span&gt;\G&amp;nbsp;&lt;span style="color: #993333; font-weight: bold;"&gt;SELECT&lt;/span&gt;&amp;nbsp;sleep&lt;span style="color: #006600; font-weight: bold;"&gt;(&lt;/span&gt;&lt;span style="color: maroon;"&gt;60&lt;/span&gt;&lt;span style="color: #006600; font-weight: bold;"&gt;)&lt;/span&gt;;&amp;nbsp;&lt;span style="color: #993333; font-weight: bold;"&gt;SHOW&lt;/span&gt;&amp;nbsp;engine innodb&amp;nbsp;&lt;span style="color: #993333; font-weight: bold;"&gt;STATUS&lt;/span&gt;\G&lt;/span&gt;&lt;/div&gt;&lt;span style="font-size: small;"&gt;&lt;/span&gt;&lt;/li&gt;&lt;li style="color: #26536a; font-weight: bold;"&gt;&lt;span style="font-size: small;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;, Courier, monospace; font-weight: normal;"&gt;&lt;span style="font-size: small;"&gt;Log sequence number&amp;nbsp;&lt;span style="color: maroon;"&gt;84&lt;/span&gt;&amp;nbsp;&lt;span style="color: maroon;"&gt;3836410803&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;span style="font-size: small;"&gt;&lt;/span&gt;&lt;/li&gt;&lt;li style="color: #3a6a8b; font-family: &amp;quot;Courier New&amp;quot;, Courier, monospace; font-style: normal; font-weight: normal;"&gt;&lt;span style="font-size: small;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;, Courier, monospace; font-weight: normal;"&gt;&lt;span style="font-size: small;"&gt;&lt;span style="color: maroon;"&gt;1&lt;/span&gt;&amp;nbsp;row&amp;nbsp;&lt;span style="color: #993333; font-weight: bold;"&gt;IN&lt;/span&gt;&amp;nbsp;&lt;span style="color: #993333; font-weight: bold;"&gt;SET&lt;/span&gt;&amp;nbsp;&lt;span style="color: #006600; font-weight: bold;"&gt;(&lt;/span&gt;&lt;span style="color: maroon;"&gt;0&lt;/span&gt;.&lt;span style="color: maroon;"&gt;06&lt;/span&gt;&amp;nbsp;sec&lt;span style="color: #006600; font-weight: bold;"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;span style="font-size: small;"&gt;&lt;/span&gt;&lt;/li&gt;&lt;li style="color: #26536a; font-weight: bold;"&gt;&lt;span style="font-size: small;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;, Courier, monospace; font-weight: normal;"&gt;&lt;/div&gt;&lt;span style="font-size: small;"&gt;&lt;/span&gt;&lt;/li&gt;&lt;li style="color: #3a6a8b; font-family: &amp;quot;Courier New&amp;quot;, Courier, monospace; font-style: normal; font-weight: normal;"&gt;&lt;span style="font-size: small;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;, Courier, monospace; font-weight: normal;"&gt;&lt;span style="font-size: small;"&gt;&lt;span style="color: maroon;"&gt;1&lt;/span&gt;&amp;nbsp;row&amp;nbsp;&lt;span style="color: #993333; font-weight: bold;"&gt;IN&lt;/span&gt;&amp;nbsp;&lt;span style="color: #993333; font-weight: bold;"&gt;SET&lt;/span&gt;&amp;nbsp;&lt;span style="color: #006600; font-weight: bold;"&gt;(&lt;/span&gt;&lt;span style="color: maroon;"&gt;1&lt;/span&gt;&amp;nbsp;min&amp;nbsp;&lt;span style="color: maroon;"&gt;0&lt;/span&gt;.&lt;span style="color: maroon;"&gt;00&lt;/span&gt;&amp;nbsp;sec&lt;span style="color: #006600; font-weight: bold;"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;span style="font-size: small;"&gt;&lt;/span&gt;&lt;/li&gt;&lt;li style="color: #26536a; font-weight: bold;"&gt;&lt;span style="font-size: small;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;, Courier, monospace; font-weight: normal;"&gt;&lt;/div&gt;&lt;span style="font-size: small;"&gt;&lt;/span&gt;&lt;/li&gt;&lt;li style="color: #3a6a8b; font-family: &amp;quot;Courier New&amp;quot;, Courier, monospace; font-style: normal; font-weight: normal;"&gt;&lt;span style="font-size: small;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;, Courier, monospace; font-weight: normal;"&gt;&lt;span style="font-size: small;"&gt;Log sequence number&amp;nbsp;&lt;span style="color: maroon;"&gt;84&lt;/span&gt;&amp;nbsp;&lt;span style="color: maroon;"&gt;3838334638&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;span style="font-size: small;"&gt;&lt;/span&gt;&lt;/li&gt;&lt;li style="color: #26536a; font-weight: bold;"&gt;&lt;span style="font-weight: normal;"&gt;&lt;span style="font-size: small;"&gt;&lt;span style="color: maroon;"&gt;1&lt;/span&gt;&amp;nbsp;row&amp;nbsp;&lt;span style="color: #993333; font-weight: bold;"&gt;IN&lt;/span&gt;&amp;nbsp;&lt;span style="color: #993333; font-weight: bold;"&gt;SET&lt;/span&gt;&amp;nbsp;&lt;span style="color: #006600; font-weight: bold;"&gt;(&lt;/span&gt;&lt;span style="color: maroon;"&gt;0&lt;/span&gt;.&lt;span style="color: maroon;"&gt;05&lt;/span&gt;&amp;nbsp;sec&lt;span style="color: #006600; font-weight: bold;"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;/ol&gt;&lt;div&gt;&lt;span style="font-size: small;"&gt;注意'log sequence number'，这个是已经写到事务日志中总的字节数。&lt;/span&gt;&lt;span style="font-size: small;"&gt;所以，现在你可以看到每分钟有多少MB写到日志文件中。&lt;/span&gt;&lt;span style="font-size: small;"&gt;（这种方法对MySQL的所有版本都有效。在5.0以上的版本中，可以用SHOW GLOBAL STATUS来观察Innodb_os_log_written的变化即可。最后有这种方法的介绍）&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;ol&gt;&lt;li style="color: #3a6a8b; font-family: &amp;quot;Courier New&amp;quot;, Courier, monospace; font-style: normal; font-weight: normal;"&gt;&lt;span style="font-size: small;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;, Courier, monospace; font-weight: normal;"&gt;&lt;span style="font-size: small;"&gt;mysql&amp;gt; &lt;span style="color: #993333; font-weight: bold;"&gt;SELECT&lt;/span&gt; &lt;span style="color: #006600; font-weight: bold;"&gt;(&lt;/span&gt;&lt;span style="color: maroon;"&gt;3838334638&lt;/span&gt; - &lt;span style="color: maroon;"&gt;3836410803&lt;/span&gt;&lt;span style="color: #006600; font-weight: bold;"&gt;)&lt;/span&gt; / &lt;span style="color: maroon;"&gt;1024&lt;/span&gt; / &lt;span style="color: maroon;"&gt;1024&lt;/span&gt; &lt;span style="color: #993333; font-weight: bold;"&gt;AS&lt;/span&gt; MB_per_min;&lt;/span&gt;&lt;/div&gt;&lt;span style="font-size: small;"&gt;&lt;/span&gt;&lt;/li&gt;&lt;li style="color: #26536a; font-weight: bold;"&gt;&lt;span style="font-size: small;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;, Courier, monospace; font-weight: normal;"&gt;&lt;span style="font-size: small;"&gt;+&lt;span style="color: grey; font-style: italic;"&gt;------------+&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;span style="font-size: small;"&gt;&lt;/span&gt;&lt;/li&gt;&lt;li style="color: #3a6a8b; font-family: &amp;quot;Courier New&amp;quot;, Courier, monospace; font-style: normal; font-weight: normal;"&gt;&lt;span style="font-size: small;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;, Courier, monospace; font-weight: normal;"&gt;&lt;span style="font-size: small;"&gt;| MB_per_min |&lt;/span&gt;&lt;/div&gt;&lt;span style="font-size: small;"&gt;&lt;/span&gt;&lt;/li&gt;&lt;li style="color: #26536a; font-weight: bold;"&gt;&lt;span style="font-size: small;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;, Courier, monospace; font-weight: normal;"&gt;&lt;span style="font-size: small;"&gt;+&lt;span style="color: grey; font-style: italic;"&gt;------------+&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;span style="font-size: small;"&gt;&lt;/span&gt;&lt;/li&gt;&lt;li style="color: #3a6a8b; font-family: &amp;quot;Courier New&amp;quot;, Courier, monospace; font-style: normal; font-weight: normal;"&gt;&lt;span style="font-size: small;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;, Courier, monospace; font-weight: normal;"&gt;&lt;span style="font-size: small;"&gt;| &lt;span style="color: maroon;"&gt;1&lt;/span&gt;.&lt;span style="color: maroon;"&gt;83471203&lt;/span&gt; |&lt;/span&gt;&lt;/div&gt;&lt;span style="font-size: small;"&gt;&lt;/span&gt;&lt;/li&gt;&lt;/ol&gt;&lt;span style="font-size: small;"&gt;&lt;/span&gt;&lt;span style="color: #26536a; font-weight: bold;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;, Courier, monospace; font-weight: normal;"&gt;&lt;span style="color: grey;"&gt;&lt;i&gt;&lt;br /&gt;&lt;span style="font-size: small;"&gt;&lt;/span&gt;&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;, Courier, monospace; font-weight: normal;"&gt;&lt;span style="background-color: white;"&gt;&lt;span style="color: black; font-size: small;"&gt;一个粗略的经验，你可以设置日志文件的大小，使它可以存放一个小时左右的日志。一小时的日志是足够应对InnoDB处理的大量数据,&lt;/span&gt;&lt;/span&gt;&lt;span style="background-color: white;"&gt;&lt;span style="color: black; font-size: small;"&gt;数据库就能在周期性的IO刷新和保存进度的过程中使用顺序写。以这样的速度,这个服务器会一共使用大约110MB的日志。为了好计算可以&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;, Courier, monospace; font-weight: normal;"&gt;&lt;span style="background-color: white;"&gt;&lt;span style="color: black; font-size: small;"&gt;把这个值约算到128M（2的倍数）。因为默认的日志文件有两个，所以除以二，你可以设置为：&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;, Courier, monospace; font-weight: normal;"&gt;&lt;span style="font-size: small;"&gt;&lt;/span&gt;&lt;span style="background-color: white;"&gt;&lt;span style="color: black;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;, Courier, monospace; font-weight: normal;"&gt;&lt;span style="font-size: small;"&gt;&amp;nbsp;innodb_log_file_size=64M &amp;nbsp;&lt;/span&gt;&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;, Courier, monospace; font-weight: normal;"&gt;&lt;span style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;, Courier, monospace; font-weight: normal;"&gt;&lt;span style="font-size: small;"&gt;这个值是不是有点儿出乎你意料的小？可能吧，我经常看到这个参数设置上G的。但是大部分都是设置错了。我上面用来计算这个参数的数据库不是个玩具，是一个负载挺大的数据库。在生产环境中日志文件的大小当然不能用默认的5M，但是也往往没有你想象中的那么大。&lt;/span&gt;&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;, Courier, monospace; font-weight: normal;"&gt;&lt;span style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;, Courier, monospace; font-weight: normal;"&gt;&lt;span style="font-size: small;"&gt;如果你有一个写操作很繁忙的数据库（可能你会插入很多数据量很大的），根据这个经验计算你得到的日志文件应该为好几G。&lt;/span&gt;&lt;span style="font-size: small;"&gt;这种情况下你可能想让日志文件小一点儿，不用GB来做文件结尾。但你同时要意识到：恢复时间不只和日志文件的大小有关，也和日志文件包含的条目数有关系。&lt;/span&gt;&lt;span style="font-size: small;"&gt;如果你的日志中，每个条目都很大，但是条目数并不多，那么它的恢复比你预料中的大日志恢复要快很多。&lt;/span&gt;&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;, Courier, monospace; font-weight: normal;"&gt;&lt;span style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;, Courier, monospace; font-weight: normal;"&gt;&lt;span style="font-size: small;"&gt;但是在我用这种方法的大多数情况下，我最后都发现合适的日志大小都比当时数据库已经配置好的要小得多。一方面是因为InnoDB日志经过很好的压缩;&lt;/span&gt;&lt;span style="font-size: small;"&gt;另一个原因是通常对设置日志大小的建议是错误的：根据innodb_buffer_pool_size来设置它的大小。（就是my.cnf里面的"Set innodb_log_file_size to 25 %of&amp;nbsp;innodb_buffer_pool_size"）&lt;/span&gt;&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;, Courier, monospace; font-weight: normal;"&gt;&lt;span style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;, Courier, monospace; font-weight: normal;"&gt;&lt;span style="font-size: small;"&gt;最后一个要注意的：很大的缓冲池或者异常繁忙的数据库可能需要更大（或者更小！）的日志大小。这就是公式的分解，需要更多的判断和经验。&lt;/span&gt;&lt;span style="font-size: small;"&gt;但是这个'经验法则'是一个很好的开端。&lt;/span&gt;&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;, Courier, monospace; font-weight: normal;"&gt;&lt;span style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;, Courier, monospace; font-weight: normal;"&gt;&lt;span style="font-size: small;"&gt;-------------------&lt;/span&gt;&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;, Courier, monospace; font-weight: normal;"&gt;&lt;span style="font-size: small;"&gt;附：怎么用Innodb_os_log_written来计算日志文件的大小。&lt;/span&gt;&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;, Courier, monospace; font-weight: normal;"&gt;&lt;div&gt;&lt;div&gt;&lt;span style="font-size: small;"&gt;mysql&amp;gt; SHOW GLOBAL STATUS &amp;nbsp;like 'Innodb_os_log_written';select sleep(60);SHOW GLOBAL STATUS &amp;nbsp;like 'Innodb_os_log_written';&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style="font-size: small;"&gt;+-----------------------+--------------+&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style="font-size: small;"&gt;| Variable_name &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; | Value &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;|&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style="font-size: small;"&gt;+-----------------------+--------------+&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style="font-size: small;"&gt;| Innodb_os_log_written | 291899526656 |&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style="font-size: small;"&gt;+-----------------------+--------------+&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style="font-size: small;"&gt;1 row in set (0.00 sec)&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style="font-size: small;"&gt;+-----------+&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style="font-size: small;"&gt;| sleep(60) |&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style="font-size: small;"&gt;+-----------+&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style="font-size: small;"&gt;| &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 0 |&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style="font-size: small;"&gt;+-----------+&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style="font-size: small;"&gt;1 row in set (1 min 0.08 sec)&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style="font-size: small;"&gt;+-----------------------+--------------+&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style="font-size: small;"&gt;| Variable_name &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; | Value &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;|&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style="font-size: small;"&gt;+-----------------------+--------------+&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style="font-size: small;"&gt;| Innodb_os_log_written | 291905601536 |&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style="font-size: small;"&gt;+-----------------------+--------------+&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style="font-size: small;"&gt;1 row in set (0.00 sec)&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;span style="font-size: small;"&gt;&lt;/span&gt;&lt;/div&gt;&lt;span style="font-size: small;"&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;span style="font-size: small;"&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5866936448448261654-5190086442979662736?l=moonbingbing.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://moonbingbing.blogspot.com/feeds/5190086442979662736/comments/default' title='帖子评论'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5866936448448261654&amp;postID=5190086442979662736' title='0 条评论'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5866936448448261654/posts/default/5190086442979662736'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5866936448448261654/posts/default/5190086442979662736'/><link rel='alternate' type='text/html' href='http://moonbingbing.blogspot.com/2010/04/how-to-calculate-good-innodb-log-file.html' title='[翻译]How to calculate a good InnoDB log file size'/><author><name>wayne</name><uri>http://www.blogger.com/profile/08537956174550037355</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5866936448448261654.post-8806904012422602823</id><published>2010-04-11T23:30:00.003+08:00</published><updated>2010-04-12T10:42:26.533+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='安全'/><title type='text'>开放的安全平台</title><content type='html'>国内杀软的竞争日趋白热化，瑞星已经是明日黄花，江民也面临被收购的命运，国外的巨头都在抢滩登陆，中小安全公司更是遍地开花。&lt;div&gt;现在最引人注目的就是云安全，每家都在宣传自己的云是多么的好，其实都差不多，听听就好了，不必太当真。&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;安全，是一个计算机用户都要面对的问题，每过几年这块蛋糕就有一次重新洗牌的机会。各个厂商在当下竞争的时候，也要关注下一步怎么走才能领先，不能被别人主导。&lt;/div&gt;&lt;div&gt;安全，对个人用户来说注定是要免费的，今年，2010，一定会全部免费。到时候，你靠什么赚钱？企业市场是国外杀软和瑞星的天下，其它专注个人用户的厂商靠什么活？这个问题在烧完投资人的钱前要想清楚，不然就会死的很惨了。&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;安全软件，作为一个可以一直常驻的软件，可以有千万活跃的软件，怎么去赚钱？是变成QQ那样风光还是迅雷那样尴尬。你可以选择去推广告，去赚流量，变身流氓软件也是办法；你也可以选择制定安全的标准，做一个开放的安全平台，为中小安全公司的发展助力。如果你相信'助人者助己'，本文对你就有点作用。&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;你可以像facebook，twitter开放自己的API，&lt;br /&gt;&lt;div&gt;&lt;a href="http://api.cloud_security.duba.net/file/need_upload/md5/0a0ce54dee6659e14024197f4f574960.xml/?u=uuid&amp;amp;s=checkcrc&amp;amp;c=channel" target="_blank"&gt;http://api.cloud_security.tt.com/file/need_upload/md5/0a0ce54dee6659e14024197f4f574960.xml/?u=uuid&amp;amp;s=checkcrc&amp;amp;c=channel&lt;/a&gt;&lt;div&gt;&lt;a href="http://api.cloud_security.duba.net/file/check_safe/fs/0,0,0,0,0,0,0,0,3035379690,22777,0,0,0,0,0,0.json/?u=uuid&amp;amp;s=checkcrc&amp;amp;c=channel&amp;amp;md5=0a0ce54dee6659e14024197f4f574960" target="_blank"&gt;http://api.cloud_security.tt.com/file/check_safe/fs/0,0,0,0,0,0,0,0,3,2,0,0,0,0,0,0.json/?u=uuid&amp;amp;s=checkcrc&amp;amp;c=channel&amp;amp;md5=0a0ce54dee6659e14024197f4f574960&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;这样，每一个互联网公司或者个人，只要他们有安全的需求，就可以通过这些开放的API来检测一个文件是否安全，而不是必须安装某个软件才行。通过这个平台，也可以更快更准确的收集到病毒样本，可以尽量的减少误报。同时，你也制定了安全的标准，成为行业的控制者。&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5866936448448261654-8806904012422602823?l=moonbingbing.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://moonbingbing.blogspot.com/feeds/8806904012422602823/comments/default' title='帖子评论'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5866936448448261654&amp;postID=8806904012422602823' title='0 条评论'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5866936448448261654/posts/default/8806904012422602823'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5866936448448261654/posts/default/8806904012422602823'/><link rel='alternate' type='text/html' href='http://moonbingbing.blogspot.com/2010/04/blog-post.html' title='开放的安全平台'/><author><name>wayne</name><uri>http://www.blogger.com/profile/08537956174550037355</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5866936448448261654.post-504325897721322250</id><published>2009-12-31T14:35:00.002+08:00</published><updated>2010-04-12T10:42:03.605+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='mysql'/><title type='text'>MySQL慢查询日志自动分割</title><content type='html'>MySQL的慢查询日志是揪出"数据库杀手"的好方法。美中不足的是，当我们解决了一个慢查询以后，通过&lt;span class="Apple-style-span" style="font-family: arial, sans-serif; color: rgb(0, 128, 0); line-height: 20px; "&gt;&lt;b&gt;&lt;a href="http://hackmysql.com/mysqlsla"&gt;mysqlsla&lt;/a&gt;&lt;/b&gt;&lt;/span&gt;再次分析慢查询日志，并不知道效果如何，因为默认是不会按照日期分割慢查询日志的。&lt;div&gt;&lt;br /&gt;&lt;div&gt;怎么处理？如果不是经常有慢查询，手工做一下即可。MySQL的&lt;a href="http://dev.mysql.com/doc/refman/5.1/en/log-file-maintenance.html"&gt;官方手册&lt;/a&gt;写的很清楚：&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;blockquote class="gmail_quote" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana, arial, helvetica, sans-serif; font-size: 13px; color: rgb(85, 85, 85); line-height: 23px; "&gt;&lt;p style="margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; outline-width: 0px; outline-style: initial; outline-color: initial; font-size: 14px; vertical-align: baseline; background-image: initial; background-repeat: initial; background-attachment: initial; -webkit-background-clip: initial; -webkit-background-origin: initial; background-color: transparent; line-height: 25px; font-family: sans-serif; display: block; max-width: 720px; background-position: initial initial; "&gt; For example, if the general and slow query logs are named &lt;code class="filename" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; outline-width: 0px; outline-style: initial; outline-color: initial; font-size: 13px; vertical-align: baseline; background-image: initial; background-repeat: initial; background-attachment: initial; -webkit-background-clip: initial; -webkit-background-origin: initial; background-color: white; color: rgb(153, 0, 0); font-weight: normal; font-family: monospace, fixed; background-position: initial initial; "&gt;mysql.log&lt;/code&gt; and &lt;code class="filename" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; outline-width: 0px; outline-style: initial; outline-color: initial; font-size: 13px; vertical-align: baseline; background-image: initial; background-repeat: initial; background-attachment: initial; -webkit-background-clip: initial; -webkit-background-origin: initial; background-color: white; color: rgb(153, 0, 0); font-weight: normal; font-family: monospace, fixed; background-position: initial initial; "&gt;mysql-slow.log&lt;/code&gt;, you can use a series of commands like this:&lt;/p&gt;&lt;pre class="programlisting" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 2px; padding-right: 2px; padding-bottom: 2px; padding-left: 2px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; outline-width: 0px; outline-style: initial; outline-color: initial; font-size: 13px; vertical-align: baseline; background-image: initial; background-repeat: initial; background-attachment: initial; -webkit-background-clip: initial; -webkit-background-origin: initial; background-color: rgb(238, 238, 238); color: black; font-family: monospace, fixed; display: block; max-width: 720px; line-height: 15px; background-position: initial initial; "&gt;shell&amp;gt; &lt;strong class="userinput" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; outline-width: 0px; outline-style: initial; outline-color: initial; font-size: 13px; vertical-align: baseline; background-image: initial; background-repeat: initial; background-attachment: initial; -webkit-background-clip: initial; -webkit-background-origin: initial; background-color: transparent; font-style: normal; font-weight: bold; background-position: initial initial; "&gt;&lt;code style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 1px; padding-right: 1px; padding-bottom: 1px; padding-left: 1px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; outline-width: 0px; outline-style: initial; outline-color: initial; font-size: 12px; vertical-align: baseline; background-image: initial; background-repeat: initial; background-attachment: initial; -webkit-background-clip: initial; -webkit-background-origin: initial; background-color: rgb(170, 170, 170); color: white; font-weight: normal; font-family: monospace, fixed; background-position: initial initial; "&gt;cd &lt;em class="replaceable" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; outline-width: 0px; outline-style: initial; outline-color: initial; font-size: 12px; vertical-align: baseline; background-image: initial; background-repeat: initial; background-attachment: initial; -webkit-background-clip: initial; -webkit-background-origin: initial; background-color: transparent; font-style: italic; font-weight: bold; background-position: initial initial; "&gt;&lt;code style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 1px; padding-right: 1px; padding-bottom: 1px; padding-left: 1px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; outline-width: 0px; outline-style: initial; outline-color: initial; font-size: 12px; vertical-align: baseline; background-image: initial; background-repeat: initial; background-attachment: initial; -webkit-background-clip: initial; -webkit-background-origin: initial; background-color: rgb(170, 170, 170); color: white; font-weight: normal; font-family: monospace, fixed; background-position: initial initial; "&gt;mysql-data-directory&lt;/code&gt;&lt;/em&gt;&lt;/code&gt;&lt;/strong&gt; shell&amp;gt; &lt;strong class="userinput" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; outline-width: 0px; outline-style: initial; outline-color: initial; font-size: 13px; vertical-align: baseline; background-image: initial; background-repeat: initial; background-attachment: initial; -webkit-background-clip: initial; -webkit-background-origin: initial; background-color: transparent; font-style: normal; font-weight: bold; background-position: initial initial; "&gt;&lt;code style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 1px; padding-right: 1px; padding-bottom: 1px; padding-left: 1px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; outline-width: 0px; outline-style: initial; outline-color: initial; font-size: 12px; vertical-align: baseline; background-image: initial; background-repeat: initial; background-attachment: initial; -webkit-background-clip: initial; -webkit-background-origin: initial; background-color: rgb(170, 170, 170); color: white; font-weight: normal; font-family: monospace, fixed; background-position: initial initial; "&gt;mv mysql.log mysql.old&lt;/code&gt;&lt;/strong&gt; shell&amp;gt; &lt;strong class="userinput" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; outline-width: 0px; outline-style: initial; outline-color: initial; font-size: 13px; vertical-align: baseline; background-image: initial; background-repeat: initial; background-attachment: initial; -webkit-background-clip: initial; -webkit-background-origin: initial; background-color: transparent; font-style: normal; font-weight: bold; background-position: initial initial; "&gt;&lt;code style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 1px; padding-right: 1px; padding-bottom: 1px; padding-left: 1px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; outline-width: 0px; outline-style: initial; outline-color: initial; font-size: 12px; vertical-align: baseline; background-image: initial; background-repeat: initial; background-attachment: initial; -webkit-background-clip: initial; -webkit-background-origin: initial; background-color: rgb(170, 170, 170); color: white; font-weight: normal; font-family: monospace, fixed; background-position: initial initial; "&gt;mv mysql-slow.log mysql-slow.old&lt;/code&gt;&lt;/strong&gt; shell&amp;gt; &lt;strong class="userinput" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; outline-width: 0px; outline-style: initial; outline-color: initial; font-size: 13px; vertical-align: baseline; background-image: initial; background-repeat: initial; background-attachment: initial; -webkit-background-clip: initial; -webkit-background-origin: initial; background-color: transparent; font-style: normal; font-weight: bold; background-position: initial initial; "&gt;&lt;code style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 1px; padding-right: 1px; padding-bottom: 1px; padding-left: 1px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; outline-width: 0px; outline-style: initial; outline-color: initial; font-size: 12px; vertical-align: baseline; background-image: initial; background-repeat: initial; background-attachment: initial; -webkit-background-clip: initial; -webkit-background-origin: initial; background-color: rgb(170, 170, 170); color: white; font-weight: normal; font-family: monospace, fixed; background-position: initial initial; "&gt;mysqladmin flush-logs&lt;/code&gt;&lt;/strong&gt; &lt;/pre&gt;&lt;p style="margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; outline-width: 0px; outline-style: initial; outline-color: initial; font-size: 14px; vertical-align: baseline; background-image: initial; background-repeat: initial; background-attachment: initial; -webkit-background-clip: initial; -webkit-background-origin: initial; background-color: transparent; line-height: 25px; font-family: sans-serif; display: block; max-width: 720px; background-position: initial initial; "&gt;At this point, you can make a backup of &lt;code class="filename" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; outline-width: 0px; outline-style: initial; outline-color: initial; font-size: 13px; vertical-align: baseline; background-image: initial; background-repeat: initial; background-attachment: initial; -webkit-background-clip: initial; -webkit-background-origin: initial; background-color: white; color: rgb(153, 0, 0); font-weight: normal; font-family: monospace, fixed; background-position: initial initial; "&gt;mysql.old&lt;/code&gt; and &lt;code class="filename" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; outline-width: 0px; outline-style: initial; outline-color: initial; font-size: 13px; vertical-align: baseline; background-image: initial; background-repeat: initial; background-attachment: initial; -webkit-background-clip: initial; -webkit-background-origin: initial; background-color: white; color: rgb(153, 0, 0); font-weight: normal; font-family: monospace, fixed; background-position: initial initial; "&gt;mysql-slow.log&lt;/code&gt; and then remove them from disk.&lt;/p&gt;&lt;/span&gt;&lt;/blockquote&gt;&lt;div&gt; 如果你的数据库慢查询太多，囧，可以考虑自动的方法（就是用&lt;span class="Apple-style-span" style="font-family: Georgia, &amp;#39;Times New Roman&amp;#39;, serif; font-size: 12px; color: rgb(51, 51, 51); font-weight: bold; line-height: 18px; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; "&gt;Logrotate&lt;span class="Apple-style-span" style="font-weight: normal;"&gt;来替你定时完成上面的几个命令，关键是怎么在执行mysqladmin不用输入数据库密码&lt;/span&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: arial; font-size: small; font-weight: normal; line-height: normal; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; "&gt;）,&lt;a href="http://www.question-defense.com/2009/12/20/configure-logrotate-to-rotate-and-flush-mysql-logs-without-a-password"&gt;参见这里&lt;/a&gt;（很详细）&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;担心哪一天不能访问了,在这里备份一下:)&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: Georgia, &amp;#39;Times New Roman&amp;#39;, serif; font-size: 12px; color: rgb(51, 51, 51); line-height: 18px; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; "&gt;&lt;p style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 1em; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; "&gt;If you have the resources (CPU + RAM) available on your server then its can be a great troubleshooting tool if you enable MySQL logging which includes server messages, SQL query logs, and slow query logs. If you do not have the resources I would suggest only enable minimal logging such as only server messages and the slow query log since enabling all queries to be written to a file can become expensive rather quickly. Below I discuss enabling three different types of MySQL logging, adding a MySQL configuration file to logrotate, and configuring root to run mysqladmin commands without having to type the password out each time.&lt;/p&gt;&lt;p style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 1em; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; "&gt;&lt;span id="more-4194" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 1em; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; "&gt;&lt;strong style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "&gt;Enable MySQL Logging:&lt;/strong&gt;&lt;/p&gt;&lt;p style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 1em; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; "&gt;First we are going to enable the various types of MySQL logging. I would keep an eye on the query log just in case it becomes to resource intensive. Below I will display the configuration command to enable each type of logging including creating the file and directory that MySQL will log to.&lt;/p&gt;&lt;ol style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 20px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; list-style-type: decimal; list-style-position: outside; list-style-image: none; "&gt;&lt;li style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 3px; margin-right: 0px; margin-bottom: 4px; margin-left: 5px; "&gt;&lt;strong style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "&gt;Modify The my.cnf MySQL Config File:&lt;/strong&gt; First lets add the statements to the MySQL configuration file which by default is typically /etc/my.cnf. There will probably be a minimal set of configuration items in this file if you have never modified it. Add the below lines which include comments above each one to explain what will be logged.&lt;p style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 1em; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; "&gt;&lt;strong style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "&gt;Configure my.cnf To Log Queries, Errors, Slow Queries:&lt;/strong&gt;&lt;/p&gt;&lt;div class="dp-highlighter" style="padding-top: 1px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 18px; margin-right: 0px; margin-bottom: 18px; margin-left: 0px; font-family: Consolas, &amp;#39;Courier New&amp;#39;, Courier, mono; font-size: 12px; background-color: rgb(231, 229, 220); width: 475px; overflow-x: auto; overflow-y: hidden; "&gt;&lt;div class="bar" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 45px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "&gt;&lt;div class="tools" style="padding-top: 3px; padding-right: 0px; padding-bottom: 10px; padding-left: 10px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 9px/normal Verdana, Geneva, Arial, Helvetica, sans-serif; color: silver; background-color: rgb(248, 248, 248); border-left-width: 3px; border-left-style: solid; border-left-color: rgb(108, 226, 108); width: 669px; "&gt;&lt;a href="http://www.question-defense.com/2009/12/20/configure-logrotate-to-rotate-and-flush-mysql-logs-without-a-password#" onclick="dp.sh.Toolbar.Command(&amp;#39;ViewSource&amp;#39;,this);return false;" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 10px; margin-bottom: 0px; margin-left: 0px; text-decoration: none; color: rgb(160, 160, 160); font-weight: bold; font-size: 9px; "&gt;view plain&lt;/a&gt;&lt;a href="http://www.question-defense.com/2009/12/20/configure-logrotate-to-rotate-and-flush-mysql-logs-without-a-password#" onclick="dp.sh.Toolbar.Command(&amp;#39;CopyToClipboard&amp;#39;,this);return false;" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 10px; margin-bottom: 0px; margin-left: 0px; text-decoration: none; color: rgb(160, 160, 160); font-weight: bold; font-size: 9px; "&gt;copy to clipboard&lt;/a&gt;&lt;a href="http://www.question-defense.com/2009/12/20/configure-logrotate-to-rotate-and-flush-mysql-logs-without-a-password#" onclick="dp.sh.Toolbar.Command(&amp;#39;PrintSource&amp;#39;,this);return false;" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 10px; margin-bottom: 0px; margin-left: 0px; text-decoration: none; color: rgb(160, 160, 160); font-weight: bold; font-size: 9px; "&gt;print&lt;/a&gt;&lt;a href="http://www.question-defense.com/2009/12/20/configure-logrotate-to-rotate-and-flush-mysql-logs-without-a-password#" onclick="dp.sh.Toolbar.Command(&amp;#39;About&amp;#39;,this);return false;" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 10px; margin-bottom: 0px; margin-left: 0px; text-decoration: none; color: rgb(160, 160, 160); font-weight: bold; font-size: 9px; "&gt;?&lt;/a&gt;&lt;/div&gt;&lt;/div&gt;&lt;ol start="1" class="dp-bash" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 1px; margin-left: 45px; list-style-type: decimal-leading-zero; list-style-position: initial; list-style-image: initial; background-color: rgb(255, 255, 255); color: rgb(92, 92, 92); white-space: nowrap; "&gt;&lt;li class="alt" style="padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 10px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; background-color: rgb(255, 255, 255) !important; border-top-width: 0px !important; border-top-style: initial !important; border-top-color: initial !important; border-bottom-width: 0px !important; border-bottom-style: initial !important; border-bottom-color: initial !important; border-left-width: 3px !important; border-left-style: solid !important; border-left-color: rgb(108, 226, 108) !important; line-height: 14px !important; border-right-width: 0px !important; border-right-style: initial !important; border-right-color: initial !important; "&gt; &lt;div class="alt" style="padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; background-color: rgb(255, 255, 255) !important; border-top-width: 0px !important; border-bottom-width: 0px !important; color: rgb(0, 0, 0) !important; border-right-width: 0px !important; border-left-width: 0px !important; border-style: initial !important; border-color: initial !important; border-style: initial !important; border-color: initial !important; width: 669px; "&gt;&lt;span class="comment" style="padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; border-top-width: 1px !important; border-right-width: 1px !important; border-bottom-width: 1px !important; border-left-width: 1px !important; border-top-color: transparent !important; border-right-color: transparent !important; border-bottom-color: transparent !important; border-left-color: transparent !important; border-top-style: solid !important; border-right-style: solid !important; border-bottom-style: solid !important; border-left-style: solid !important; background-image: initial !important; background-repeat: initial !important; background-attachment: initial !important; -webkit-background-clip: initial !important; -webkit-background-origin: initial !important; background-color: transparent !important; color: gray; background-position: initial initial !important; "&gt;# Will log MySQL Errors Including Startup Errors&lt;/span&gt;&lt;span style="padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; border-top-width: 1px !important; border-right-width: 1px !important; border-bottom-width: 1px !important; border-left-width: 1px !important; border-top-color: transparent !important; border-right-color: transparent !important; border-bottom-color: transparent !important; border-left-color: transparent !important; border-top-style: solid !important; border-right-style: solid !important; border-bottom-style: solid !important; border-left-style: solid !important; background-image: initial !important; background-repeat: initial !important; background-attachment: initial !important; -webkit-background-clip: initial !important; -webkit-background-origin: initial !important; background-color: transparent !important; background-position: initial initial !important; "&gt; &lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li class="" style="padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 10px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; border-left-width: 3px !important; border-left-style: solid !important; border-left-color: rgb(108, 226, 108) !important; background-color: rgb(248, 248, 248) !important; line-height: 14px !important; border-top-width: 0px !important; border-top-style: initial !important; border-top-color: initial !important; border-right-width: 0px !important; border-right-style: initial !important; border-right-color: initial !important; border-bottom-width: 0px !important; border-bottom-style: initial !important; border-bottom-color: initial !important; "&gt; &lt;div class="" style="padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; color: rgb(0, 0, 0) !important; background-color: rgb(248, 248, 248) !important; border-top-width: 0px !important; border-right-width: 0px !important; border-bottom-width: 0px !important; border-left-width: 0px !important; border-style: initial !important; border-color: initial !important; width: 669px; "&gt;log-&lt;span class="vars" style="padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; border-top-width: 1px !important; border-right-width: 1px !important; border-bottom-width: 1px !important; border-left-width: 1px !important; border-top-color: transparent !important; border-right-color: transparent !important; border-bottom-color: transparent !important; border-left-color: transparent !important; border-top-style: solid !important; border-right-style: solid !important; border-bottom-style: solid !important; border-left-style: solid !important; background-image: initial !important; background-repeat: initial !important; background-attachment: initial !important; -webkit-background-clip: initial !important; -webkit-background-origin: initial !important; background-color: transparent !important; color: blue; background-position: initial initial !important; "&gt;error=&lt;/span&gt;&lt;span style="padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; border-top-width: 1px !important; border-right-width: 1px !important; border-bottom-width: 1px !important; border-left-width: 1px !important; border-top-color: transparent !important; border-right-color: transparent !important; border-bottom-color: transparent !important; border-left-color: transparent !important; border-top-style: solid !important; border-right-style: solid !important; border-bottom-style: solid !important; border-left-style: solid !important; background-image: initial !important; background-repeat: initial !important; background-attachment: initial !important; -webkit-background-clip: initial !important; -webkit-background-origin: initial !important; background-color: transparent !important; background-position: initial initial !important; "&gt;/var/log/mysql/mysqld.log &lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li class="alt" style="padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 10px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; background-color: rgb(255, 255, 255) !important; border-top-width: 0px !important; border-top-style: initial !important; border-top-color: initial !important; border-bottom-width: 0px !important; border-bottom-style: initial !important; border-bottom-color: initial !important; border-left-width: 3px !important; border-left-style: solid !important; border-left-color: rgb(108, 226, 108) !important; line-height: 14px !important; border-right-width: 0px !important; border-right-style: initial !important; border-right-color: initial !important; "&gt; &lt;div class="alt" style="padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; background-color: rgb(255, 255, 255) !important; border-top-width: 0px !important; border-bottom-width: 0px !important; color: rgb(0, 0, 0) !important; border-right-width: 0px !important; border-left-width: 0px !important; border-style: initial !important; border-color: initial !important; border-style: initial !important; border-color: initial !important; width: 669px; "&gt;&lt;span class="comment" style="padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; border-top-width: 1px !important; border-right-width: 1px !important; border-bottom-width: 1px !important; border-left-width: 1px !important; border-top-color: transparent !important; border-right-color: transparent !important; border-bottom-color: transparent !important; border-left-color: transparent !important; border-top-style: solid !important; border-right-style: solid !important; border-bottom-style: solid !important; border-left-style: solid !important; background-image: initial !important; background-repeat: initial !important; background-attachment: initial !important; -webkit-background-clip: initial !important; -webkit-background-origin: initial !important; background-color: transparent !important; color: gray; background-position: initial initial !important; "&gt;# Will log MySQL queries, This log will grow quickly&lt;/span&gt;&lt;span style="padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; border-top-width: 1px !important; border-right-width: 1px !important; border-bottom-width: 1px !important; border-left-width: 1px !important; border-top-color: transparent !important; border-right-color: transparent !important; border-bottom-color: transparent !important; border-left-color: transparent !important; border-top-style: solid !important; border-right-style: solid !important; border-bottom-style: solid !important; border-left-style: solid !important; background-image: initial !important; background-repeat: initial !important; background-attachment: initial !important; -webkit-background-clip: initial !important; -webkit-background-origin: initial !important; background-color: transparent !important; background-position: initial initial !important; "&gt; &lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li class="" style="padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 10px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; border-left-width: 3px !important; border-left-style: solid !important; border-left-color: rgb(108, 226, 108) !important; background-color: rgb(248, 248, 248) !important; line-height: 14px !important; border-top-width: 0px !important; border-top-style: initial !important; border-top-color: initial !important; border-right-width: 0px !important; border-right-style: initial !important; border-right-color: initial !important; border-bottom-width: 0px !important; border-bottom-style: initial !important; border-bottom-color: initial !important; "&gt; &lt;div class="" style="padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; color: rgb(0, 0, 0) !important; background-color: rgb(248, 248, 248) !important; border-top-width: 0px !important; border-right-width: 0px !important; border-bottom-width: 0px !important; border-left-width: 0px !important; border-style: initial !important; border-color: initial !important; width: 669px; "&gt;&lt;span class="vars" style="padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; border-top-width: 1px !important; border-right-width: 1px !important; border-bottom-width: 1px !important; border-left-width: 1px !important; border-top-color: transparent !important; border-right-color: transparent !important; border-bottom-color: transparent !important; border-left-color: transparent !important; border-top-style: solid !important; border-right-style: solid !important; border-bottom-style: solid !important; border-left-style: solid !important; background-image: initial !important; background-repeat: initial !important; background-attachment: initial !important; -webkit-background-clip: initial !important; -webkit-background-origin: initial !important; background-color: transparent !important; color: blue; background-position: initial initial !important; "&gt;log=&lt;/span&gt;&lt;span style="padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; border-top-width: 1px !important; border-right-width: 1px !important; border-bottom-width: 1px !important; border-left-width: 1px !important; border-top-color: transparent !important; border-right-color: transparent !important; border-bottom-color: transparent !important; border-left-color: transparent !important; border-top-style: solid !important; border-right-style: solid !important; border-bottom-style: solid !important; border-left-style: solid !important; background-image: initial !important; background-repeat: initial !important; background-attachment: initial !important; -webkit-background-clip: initial !important; -webkit-background-origin: initial !important; background-color: transparent !important; background-position: initial initial !important; "&gt;/var/log/mysql/mysql.log &lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li class="alt" style="padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 10px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; background-color: rgb(255, 255, 255) !important; border-top-width: 0px !important; border-top-style: initial !important; border-top-color: initial !important; border-bottom-width: 0px !important; border-bottom-style: initial !important; border-bottom-color: initial !important; border-left-width: 3px !important; border-left-style: solid !important; border-left-color: rgb(108, 226, 108) !important; line-height: 14px !important; border-right-width: 0px !important; border-right-style: initial !important; border-right-color: initial !important; "&gt; &lt;div class="alt" style="padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; background-color: rgb(255, 255, 255) !important; border-top-width: 0px !important; border-bottom-width: 0px !important; color: rgb(0, 0, 0) !important; border-right-width: 0px !important; border-left-width: 0px !important; border-style: initial !important; border-color: initial !important; border-style: initial !important; border-color: initial !important; width: 669px; "&gt;&lt;span class="comment" style="padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; border-top-width: 1px !important; border-right-width: 1px !important; border-bottom-width: 1px !important; border-left-width: 1px !important; border-top-color: transparent !important; border-right-color: transparent !important; border-bottom-color: transparent !important; border-left-color: transparent !important; border-top-style: solid !important; border-right-style: solid !important; border-bottom-style: solid !important; border-left-style: solid !important; background-image: initial !important; background-repeat: initial !important; background-attachment: initial !important; -webkit-background-clip: initial !important; -webkit-background-origin: initial !important; background-color: transparent !important; color: gray; background-position: initial initial !important; "&gt;# Will log MySQL queries that take a long time (in this case over 1 second as specified below)&lt;/span&gt;&lt;span style="padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; border-top-width: 1px !important; border-right-width: 1px !important; border-bottom-width: 1px !important; border-left-width: 1px !important; border-top-color: transparent !important; border-right-color: transparent !important; border-bottom-color: transparent !important; border-left-color: transparent !important; border-top-style: solid !important; border-right-style: solid !important; border-bottom-style: solid !important; border-left-style: solid !important; background-image: initial !important; background-repeat: initial !important; background-attachment: initial !important; -webkit-background-clip: initial !important; -webkit-background-origin: initial !important; background-color: transparent !important; background-position: initial initial !important; "&gt; &lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li class="" style="padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 10px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; border-left-width: 3px !important; border-left-style: solid !important; border-left-color: rgb(108, 226, 108) !important; background-color: rgb(248, 248, 248) !important; line-height: 14px !important; border-top-width: 0px !important; border-top-style: initial !important; border-top-color: initial !important; border-right-width: 0px !important; border-right-style: initial !important; border-right-color: initial !important; border-bottom-width: 0px !important; border-bottom-style: initial !important; border-bottom-color: initial !important; "&gt; &lt;div class="" style="padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; color: rgb(0, 0, 0) !important; background-color: rgb(248, 248, 248) !important; border-top-width: 0px !important; border-right-width: 0px !important; border-bottom-width: 0px !important; border-left-width: 0px !important; border-style: initial !important; border-color: initial !important; width: 669px; "&gt;log-slow-queries = /var/log/mysql/mysql-slow.log &lt;/div&gt;&lt;/li&gt;&lt;li class="alt" style="padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 10px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; background-color: rgb(255, 255, 255) !important; border-top-width: 0px !important; border-top-style: initial !important; border-top-color: initial !important; border-bottom-width: 0px !important; border-bottom-style: initial !important; border-bottom-color: initial !important; border-left-width: 3px !important; border-left-style: solid !important; border-left-color: rgb(108, 226, 108) !important; line-height: 14px !important; border-right-width: 0px !important; border-right-style: initial !important; border-right-color: initial !important; "&gt; &lt;div class="alt" style="padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; background-color: rgb(255, 255, 255) !important; border-top-width: 0px !important; border-bottom-width: 0px !important; color: rgb(0, 0, 0) !important; border-right-width: 0px !important; border-left-width: 0px !important; border-style: initial !important; border-color: initial !important; border-style: initial !important; border-color: initial !important; width: 669px; "&gt;long_query_time = 1 &lt;/div&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/div&gt;&lt;p style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 1em; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; "&gt;The above configuration lines should go under the main section of MySQL which should be "[mysqld]" at the beginning of the file. The next section doesn't start until "[mysqld_safe]" so as you can see there are typically two sections and they are divided by these headings.&lt;/p&gt;&lt;/li&gt;&lt;li style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 3px; margin-right: 0px; margin-bottom: 4px; margin-left: 5px; "&gt;&lt;strong style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "&gt;Create MySQL Log Directory: &lt;/strong&gt;I like to try and split services up in the log directory so I can keep track of things easier so in this case we are going to do the same. In the command list below we will be creating a directory, creating blank files, and then making sure everything has the right permissions and is owned by the proper user which should be the "mysql".&lt;p style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 1em; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; "&gt;&lt;strong style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "&gt;Create MySQL Log Directory &amp;amp; Log Files:&lt;/strong&gt;&lt;/p&gt;&lt;div class="dp-highlighter" style="padding-top: 1px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 18px; margin-right: 0px; margin-bottom: 18px; margin-left: 0px; font-family: Consolas, &amp;#39;Courier New&amp;#39;, Courier, mono; font-size: 12px; background-color: rgb(231, 229, 220); width: 475px; overflow-x: auto; overflow-y: hidden; "&gt;&lt;div class="bar" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 45px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "&gt;&lt;div class="tools" style="padding-top: 3px; padding-right: 0px; padding-bottom: 10px; padding-left: 10px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 9px/normal Verdana, Geneva, Arial, Helvetica, sans-serif; color: silver; background-color: rgb(248, 248, 248); border-left-width: 3px; border-left-style: solid; border-left-color: rgb(108, 226, 108); width: 417px; "&gt;&lt;a href="http://www.question-defense.com/2009/12/20/configure-logrotate-to-rotate-and-flush-mysql-logs-without-a-password#" onclick="dp.sh.Toolbar.Command(&amp;#39;ViewSource&amp;#39;,this);return false;" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 10px; margin-bottom: 0px; margin-left: 0px; text-decoration: none; color: rgb(160, 160, 160); font-weight: bold; font-size: 9px; "&gt;view plain&lt;/a&gt;&lt;a href="http://www.question-defense.com/2009/12/20/configure-logrotate-to-rotate-and-flush-mysql-logs-without-a-password#" onclick="dp.sh.Toolbar.Command(&amp;#39;CopyToClipboard&amp;#39;,this);return false;" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 10px; margin-bottom: 0px; margin-left: 0px; text-decoration: none; color: rgb(160, 160, 160); font-weight: bold; font-size: 9px; "&gt;copy to clipboard&lt;/a&gt;&lt;a href="http://www.question-defense.com/2009/12/20/configure-logrotate-to-rotate-and-flush-mysql-logs-without-a-password#" onclick="dp.sh.Toolbar.Command(&amp;#39;PrintSource&amp;#39;,this);return false;" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 10px; margin-bottom: 0px; margin-left: 0px; text-decoration: none; color: rgb(160, 160, 160); font-weight: bold; font-size: 9px; "&gt;print&lt;/a&gt;&lt;a href="http://www.question-defense.com/2009/12/20/configure-logrotate-to-rotate-and-flush-mysql-logs-without-a-password#" onclick="dp.sh.Toolbar.Command(&amp;#39;About&amp;#39;,this);return false;" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 10px; margin-bottom: 0px; margin-left: 0px; text-decoration: none; color: rgb(160, 160, 160); font-weight: bold; font-size: 9px; "&gt;?&lt;/a&gt;&lt;/div&gt;&lt;/div&gt;&lt;ol start="1" class="dp-bash" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 1px; margin-left: 45px; list-style-type: decimal-leading-zero; list-style-position: initial; list-style-image: initial; background-color: rgb(255, 255, 255); color: rgb(92, 92, 92); white-space: nowrap; "&gt;&lt;li class="alt" style="padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 10px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; background-color: rgb(255, 255, 255) !important; border-top-width: 0px !important; border-top-style: initial !important; border-top-color: initial !important; border-bottom-width: 0px !important; border-bottom-style: initial !important; border-bottom-color: initial !important; border-left-width: 3px !important; border-left-style: solid !important; border-left-color: rgb(108, 226, 108) !important; line-height: 14px !important; border-right-width: 0px !important; border-right-style: initial !important; border-right-color: initial !important; "&gt; &lt;div class="alt" style="padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; background-color: rgb(255, 255, 255) !important; border-top-width: 0px !important; border-bottom-width: 0px !important; color: rgb(0, 0, 0) !important; border-right-width: 0px !important; border-left-width: 0px !important; border-style: initial !important; border-color: initial !important; border-style: initial !important; border-color: initial !important; width: 417px; "&gt;&lt;span class="delim" style="padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; border-top-width: 1px !important; border-right-width: 1px !important; border-bottom-width: 1px !important; border-left-width: 1px !important; border-top-color: transparent !important; border-right-color: transparent !important; border-bottom-color: transparent !important; border-left-color: transparent !important; border-top-style: solid !important; border-right-style: solid !important; border-bottom-style: solid !important; border-left-style: solid !important; background-image: initial !important; background-repeat: initial !important; background-attachment: initial !important; -webkit-background-clip: initial !important; -webkit-background-origin: initial !important; background-color: transparent !important; font-weight: bold; background-position: initial initial !important; "&gt;[&lt;/span&gt;&lt;span style="padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; border-top-width: 1px !important; border-right-width: 1px !important; border-bottom-width: 1px !important; border-left-width: 1px !important; border-top-color: transparent !important; border-right-color: transparent !important; border-bottom-color: transparent !important; border-left-color: transparent !important; border-top-style: solid !important; border-right-style: solid !important; border-bottom-style: solid !important; border-left-style: solid !important; background-image: initial !important; background-repeat: initial !important; background-attachment: initial !important; -webkit-background-clip: initial !important; -webkit-background-origin: initial !important; background-color: transparent !important; background-position: initial initial !important; "&gt;root@dev ~&lt;/span&gt;&lt;span class="delim" style="padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; border-top-width: 1px !important; border-right-width: 1px !important; border-bottom-width: 1px !important; border-left-width: 1px !important; border-top-color: transparent !important; border-right-color: transparent !important; border-bottom-color: transparent !important; border-left-color: transparent !important; border-top-style: solid !important; border-right-style: solid !important; border-bottom-style: solid !important; border-left-style: solid !important; background-image: initial !important; background-repeat: initial !important; background-attachment: initial !important; -webkit-background-clip: initial !important; -webkit-background-origin: initial !important; background-color: transparent !important; font-weight: bold; background-position: initial initial !important; "&gt;]&lt;/span&gt;&lt;span class="comment" style="padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; border-top-width: 1px !important; border-right-width: 1px !important; border-bottom-width: 1px !important; border-left-width: 1px !important; border-top-color: transparent !important; border-right-color: transparent !important; border-bottom-color: transparent !important; border-left-color: transparent !important; border-top-style: solid !important; border-right-style: solid !important; border-bottom-style: solid !important; border-left-style: solid !important; background-image: initial !important; background-repeat: initial !important; background-attachment: initial !important; -webkit-background-clip: initial !important; -webkit-background-origin: initial !important; background-color: transparent !important; color: gray; background-position: initial initial !important; "&gt;# mkdir /var/log/mysql&lt;/span&gt;&lt;span style="padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; border-top-width: 1px !important; border-right-width: 1px !important; border-bottom-width: 1px !important; border-left-width: 1px !important; border-top-color: transparent !important; border-right-color: transparent !important; border-bottom-color: transparent !important; border-left-color: transparent !important; border-top-style: solid !important; border-right-style: solid !important; border-bottom-style: solid !important; border-left-style: solid !important; background-image: initial !important; background-repeat: initial !important; background-attachment: initial !important; -webkit-background-clip: initial !important; -webkit-background-origin: initial !important; background-color: transparent !important; background-position: initial initial !important; "&gt; &lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li class="" style="padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 10px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; border-left-width: 3px !important; border-left-style: solid !important; border-left-color: rgb(108, 226, 108) !important; background-color: rgb(248, 248, 248) !important; line-height: 14px !important; border-top-width: 0px !important; border-top-style: initial !important; border-top-color: initial !important; border-right-width: 0px !important; border-right-style: initial !important; border-right-color: initial !important; border-bottom-width: 0px !important; border-bottom-style: initial !important; border-bottom-color: initial !important; "&gt; &lt;div class="" style="padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; color: rgb(0, 0, 0) !important; background-color: rgb(248, 248, 248) !important; border-top-width: 0px !important; border-right-width: 0px !important; border-bottom-width: 0px !important; border-left-width: 0px !important; border-style: initial !important; border-color: initial !important; width: 417px; "&gt;&lt;span class="delim" style="padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; border-top-width: 1px !important; border-right-width: 1px !important; border-bottom-width: 1px !important; border-left-width: 1px !important; border-top-color: transparent !important; border-right-color: transparent !important; border-bottom-color: transparent !important; border-left-color: transparent !important; border-top-style: solid !important; border-right-style: solid !important; border-bottom-style: solid !important; border-left-style: solid !important; background-image: initial !important; background-repeat: initial !important; background-attachment: initial !important; -webkit-background-clip: initial !important; -webkit-background-origin: initial !important; background-color: transparent !important; font-weight: bold; background-position: initial initial !important; "&gt;[&lt;/span&gt;&lt;span style="padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; border-top-width: 1px !important; border-right-width: 1px !important; border-bottom-width: 1px !important; border-left-width: 1px !important; border-top-color: transparent !important; border-right-color: transparent !important; border-bottom-color: transparent !important; border-left-color: transparent !important; border-top-style: solid !important; border-right-style: solid !important; border-bottom-style: solid !important; border-left-style: solid !important; background-image: initial !important; background-repeat: initial !important; background-attachment: initial !important; -webkit-background-clip: initial !important; -webkit-background-origin: initial !important; background-color: transparent !important; background-position: initial initial !important; "&gt;root@dev ~&lt;/span&gt;&lt;span class="delim" style="padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; border-top-width: 1px !important; border-right-width: 1px !important; border-bottom-width: 1px !important; border-left-width: 1px !important; border-top-color: transparent !important; border-right-color: transparent !important; border-bottom-color: transparent !important; border-left-color: transparent !important; border-top-style: solid !important; border-right-style: solid !important; border-bottom-style: solid !important; border-left-style: solid !important; background-image: initial !important; background-repeat: initial !important; background-attachment: initial !important; -webkit-background-clip: initial !important; -webkit-background-origin: initial !important; background-color: transparent !important; font-weight: bold; background-position: initial initial !important; "&gt;]&lt;/span&gt;&lt;span class="comment" style="padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; border-top-width: 1px !important; border-right-width: 1px !important; border-bottom-width: 1px !important; border-left-width: 1px !important; border-top-color: transparent !important; border-right-color: transparent !important; border-bottom-color: transparent !important; border-left-color: transparent !important; border-top-style: solid !important; border-right-style: solid !important; border-bottom-style: solid !important; border-left-style: solid !important; background-image: initial !important; background-repeat: initial !important; background-attachment: initial !important; -webkit-background-clip: initial !important; -webkit-background-origin: initial !important; background-color: transparent !important; color: gray; background-position: initial initial !important; "&gt;# touch /var/log/mysql/mysql.log&lt;/span&gt;&lt;span style="padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; border-top-width: 1px !important; border-right-width: 1px !important; border-bottom-width: 1px !important; border-left-width: 1px !important; border-top-color: transparent !important; border-right-color: transparent !important; border-bottom-color: transparent !important; border-left-color: transparent !important; border-top-style: solid !important; border-right-style: solid !important; border-bottom-style: solid !important; border-left-style: solid !important; background-image: initial !important; background-repeat: initial !important; background-attachment: initial !important; -webkit-background-clip: initial !important; -webkit-background-origin: initial !important; background-color: transparent !important; background-position: initial initial !important; "&gt; &lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li class="alt" style="padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 10px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; background-color: rgb(255, 255, 255) !important; border-top-width: 0px !important; border-top-style: initial !important; border-top-color: initial !important; border-bottom-width: 0px !important; border-bottom-style: initial !important; border-bottom-color: initial !important; border-left-width: 3px !important; border-left-style: solid !important; border-left-color: rgb(108, 226, 108) !important; line-height: 14px !important; border-right-width: 0px !important; border-right-style: initial !important; border-right-color: initial !important; "&gt; &lt;div class="alt" style="padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; background-color: rgb(255, 255, 255) !important; border-top-width: 0px !important; border-bottom-width: 0px !important; color: rgb(0, 0, 0) !important; border-right-width: 0px !important; border-left-width: 0px !important; border-style: initial !important; border-color: initial !important; border-style: initial !important; border-color: initial !important; width: 417px; "&gt;&lt;span class="delim" style="padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; border-top-width: 1px !important; border-right-width: 1px !important; border-bottom-width: 1px !important; border-left-width: 1px !important; border-top-color: transparent !important; border-right-color: transparent !important; border-bottom-color: transparent !important; border-left-color: transparent !important; border-top-style: solid !important; border-right-style: solid !important; border-bottom-style: solid !important; border-left-style: solid !important; background-image: initial !important; background-repeat: initial !important; background-attachment: initial !important; -webkit-background-clip: initial !important; -webkit-background-origin: initial !important; background-color: transparent !important; font-weight: bold; background-position: initial initial !important; "&gt;[&lt;/span&gt;&lt;span style="padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; border-top-width: 1px !important; border-right-width: 1px !important; border-bottom-width: 1px !important; border-left-width: 1px !important; border-top-color: transparent !important; border-right-color: transparent !important; border-bottom-color: transparent !important; border-left-color: transparent !important; border-top-style: solid !important; border-right-style: solid !important; border-bottom-style: solid !important; border-left-style: solid !important; background-image: initial !important; background-repeat: initial !important; background-attachment: initial !important; -webkit-background-clip: initial !important; -webkit-background-origin: initial !important; background-color: transparent !important; background-position: initial initial !important; "&gt;root@dev ~&lt;/span&gt;&lt;span class="delim" style="padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; border-top-width: 1px !important; border-right-width: 1px !important; border-bottom-width: 1px !important; border-left-width: 1px !important; border-top-color: transparent !important; border-right-color: transparent !important; border-bottom-color: transparent !important; border-left-color: transparent !important; border-top-style: solid !important; border-right-style: solid !important; border-bottom-style: solid !important; border-left-style: solid !important; background-image: initial !important; background-repeat: initial !important; background-attachment: initial !important; -webkit-background-clip: initial !important; -webkit-background-origin: initial !important; background-color: transparent !important; font-weight: bold; background-position: initial initial !important; "&gt;]&lt;/span&gt;&lt;span class="comment" style="padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; border-top-width: 1px !important; border-right-width: 1px !important; border-bottom-width: 1px !important; border-left-width: 1px !important; border-top-color: transparent !important; border-right-color: transparent !important; border-bottom-color: transparent !important; border-left-color: transparent !important; border-top-style: solid !important; border-right-style: solid !important; border-bottom-style: solid !important; border-left-style: solid !important; background-image: initial !important; background-repeat: initial !important; background-attachment: initial !important; -webkit-background-clip: initial !important; -webkit-background-origin: initial !important; background-color: transparent !important; color: gray; background-position: initial initial !important; "&gt;# touch /var/log/mysql/mysqld.log&lt;/span&gt;&lt;span style="padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; border-top-width: 1px !important; border-right-width: 1px !important; border-bottom-width: 1px !important; border-left-width: 1px !important; border-top-color: transparent !important; border-right-color: transparent !important; border-bottom-color: transparent !important; border-left-color: transparent !important; border-top-style: solid !important; border-right-style: solid !important; border-bottom-style: solid !important; border-left-style: solid !important; background-image: initial !important; background-repeat: initial !important; background-attachment: initial !important; -webkit-background-clip: initial !important; -webkit-background-origin: initial !important; background-color: transparent !important; background-position: initial initial !important; "&gt; &lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li class="" style="padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 10px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; border-left-width: 3px !important; border-left-style: solid !important; border-left-color: rgb(108, 226, 108) !important; background-color: rgb(248, 248, 248) !important; line-height: 14px !important; border-top-width: 0px !important; border-top-style: initial !important; border-top-color: initial !important; border-right-width: 0px !important; border-right-style: initial !important; border-right-color: initial !important; border-bottom-width: 0px !important; border-bottom-style: initial !important; border-bottom-color: initial !important; "&gt; &lt;div class="" style="padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; color: rgb(0, 0, 0) !important; background-color: rgb(248, 248, 248) !important; border-top-width: 0px !important; border-right-width: 0px !important; border-bottom-width: 0px !important; border-left-width: 0px !important; border-style: initial !important; border-color: initial !important; width: 417px; "&gt;&lt;span class="delim" style="padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; border-top-width: 1px !important; border-right-width: 1px !important; border-bottom-width: 1px !important; border-left-width: 1px !important; border-top-color: transparent !important; border-right-color: transparent !important; border-bottom-color: transparent !important; border-left-color: transparent !important; border-top-style: solid !important; border-right-style: solid !important; border-bottom-style: solid !important; border-left-style: solid !important; background-image: initial !important; background-repeat: initial !important; background-attachment: initial !important; -webkit-background-clip: initial !important; -webkit-background-origin: initial !important; background-color: transparent !important; font-weight: bold; background-position: initial initial !important; "&gt;[&lt;/span&gt;&lt;span style="padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; border-top-width: 1px !important; border-right-width: 1px !important; border-bottom-width: 1px !important; border-left-width: 1px !important; border-top-color: transparent !important; border-right-color: transparent !important; border-bottom-color: transparent !important; border-left-color: transparent !important; border-top-style: solid !important; border-right-style: solid !important; border-bottom-style: solid !important; border-left-style: solid !important; background-image: initial !important; background-repeat: initial !important; background-attachment: initial !important; -webkit-background-clip: initial !important; -webkit-background-origin: initial !important; background-color: transparent !important; background-position: initial initial !important; "&gt;root@dev ~&lt;/span&gt;&lt;span class="delim" style="padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; border-top-width: 1px !important; border-right-width: 1px !important; border-bottom-width: 1px !important; border-left-width: 1px !important; border-top-color: transparent !important; border-right-color: transparent !important; border-bottom-color: transparent !important; border-left-color: transparent !important; border-top-style: solid !important; border-right-style: solid !important; border-bottom-style: solid !important; border-left-style: solid !important; background-image: initial !important; background-repeat: initial !important; background-attachment: initial !important; -webkit-background-clip: initial !important; -webkit-background-origin: initial !important; background-color: transparent !important; font-weight: bold; background-position: initial initial !important; "&gt;]&lt;/span&gt;&lt;span class="comment" style="padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; border-top-width: 1px !important; border-right-width: 1px !important; border-bottom-width: 1px !important; border-left-width: 1px !important; border-top-color: transparent !important; border-right-color: transparent !important; border-bottom-color: transparent !important; border-left-color: transparent !important; border-top-style: solid !important; border-right-style: solid !important; border-bottom-style: solid !important; border-left-style: solid !important; background-image: initial !important; background-repeat: initial !important; background-attachment: initial !important; -webkit-background-clip: initial !important; -webkit-background-origin: initial !important; background-color: transparent !important; color: gray; background-position: initial initial !important; "&gt;# touch /var/log/mysql/mysql-slow.log&lt;/span&gt;&lt;span style="padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; border-top-width: 1px !important; border-right-width: 1px !important; border-bottom-width: 1px !important; border-left-width: 1px !important; border-top-color: transparent !important; border-right-color: transparent !important; border-bottom-color: transparent !important; border-left-color: transparent !important; border-top-style: solid !important; border-right-style: solid !important; border-bottom-style: solid !important; border-left-style: solid !important; background-image: initial !important; background-repeat: initial !important; background-attachment: initial !important; -webkit-background-clip: initial !important; -webkit-background-origin: initial !important; background-color: transparent !important; background-position: initial initial !important; "&gt; &lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li class="alt" style="padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 10px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; background-color: rgb(255, 255, 255) !important; border-top-width: 0px !important; border-top-style: initial !important; border-top-color: initial !important; border-bottom-width: 0px !important; border-bottom-style: initial !important; border-bottom-color: initial !important; border-left-width: 3px !important; border-left-style: solid !important; border-left-color: rgb(108, 226, 108) !important; line-height: 14px !important; border-right-width: 0px !important; border-right-style: initial !important; border-right-color: initial !important; "&gt; &lt;div class="alt" style="padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; background-color: rgb(255, 255, 255) !important; border-top-width: 0px !important; border-bottom-width: 0px !important; color: rgb(0, 0, 0) !important; border-right-width: 0px !important; border-left-width: 0px !important; border-style: initial !important; border-color: initial !important; border-style: initial !important; border-color: initial !important; width: 417px; "&gt;&lt;span class="delim" style="padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; border-top-width: 1px !important; border-right-width: 1px !important; border-bottom-width: 1px !important; border-left-width: 1px !important; border-top-color: transparent !important; border-right-color: transparent !important; border-bottom-color: transparent !important; border-left-color: transparent !important; border-top-style: solid !important; border-right-style: solid !important; border-bottom-style: solid !important; border-left-style: solid !important; background-image: initial !important; background-repeat: initial !important; background-attachment: initial !important; -webkit-background-clip: initial !important; -webkit-background-origin: initial !important; background-color: transparent !important; font-weight: bold; background-position: initial initial !important; "&gt;[&lt;/span&gt;&lt;span style="padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; border-top-width: 1px !important; border-right-width: 1px !important; border-bottom-width: 1px !important; border-left-width: 1px !important; border-top-color: transparent !important; border-right-color: transparent !important; border-bottom-color: transparent !important; border-left-color: transparent !important; border-top-style: solid !important; border-right-style: solid !important; border-bottom-style: solid !important; border-left-style: solid !important; background-image: initial !important; background-repeat: initial !important; background-attachment: initial !important; -webkit-background-clip: initial !important; -webkit-background-origin: initial !important; background-color: transparent !important; background-position: initial initial !important; "&gt;root@dev ~&lt;/span&gt;&lt;span class="delim" style="padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; border-top-width: 1px !important; border-right-width: 1px !important; border-bottom-width: 1px !important; border-left-width: 1px !important; border-top-color: transparent !important; border-right-color: transparent !important; border-bottom-color: transparent !important; border-left-color: transparent !important; border-top-style: solid !important; border-right-style: solid !important; border-bottom-style: solid !important; border-left-style: solid !important; background-image: initial !important; background-repeat: initial !important; background-attachment: initial !important; -webkit-background-clip: initial !important; -webkit-background-origin: initial !important; background-color: transparent !important; font-weight: bold; background-position: initial initial !important; "&gt;]&lt;/span&gt;&lt;span class="comment" style="padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; border-top-width: 1px !important; border-right-width: 1px !important; border-bottom-width: 1px !important; border-left-width: 1px !important; border-top-color: transparent !important; border-right-color: transparent !important; border-bottom-color: transparent !important; border-left-color: transparent !important; border-top-style: solid !important; border-right-style: solid !important; border-bottom-style: solid !important; border-left-style: solid !important; background-image: initial !important; background-repeat: initial !important; background-attachment: initial !important; -webkit-background-clip: initial !important; -webkit-background-origin: initial !important; background-color: transparent !important; color: gray; background-position: initial initial !important; "&gt;# chown -R mysql.mysql /var/log/mysql&lt;/span&gt;&lt;span style="padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; border-top-width: 1px !important; border-right-width: 1px !important; border-bottom-width: 1px !important; border-left-width: 1px !important; border-top-color: transparent !important; border-right-color: transparent !important; border-bottom-color: transparent !important; border-left-color: transparent !important; border-top-style: solid !important; border-right-style: solid !important; border-bottom-style: solid !important; border-left-style: solid !important; background-image: initial !important; background-repeat: initial !important; background-attachment: initial !important; -webkit-background-clip: initial !important; -webkit-background-origin: initial !important; background-color: transparent !important; background-position: initial initial !important; "&gt; &lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li class="" style="padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 10px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; border-left-width: 3px !important; border-left-style: solid !important; border-left-color: rgb(108, 226, 108) !important; background-color: rgb(248, 248, 248) !important; line-height: 14px !important; border-top-width: 0px !important; border-top-style: initial !important; border-top-color: initial !important; border-right-width: 0px !important; border-right-style: initial !important; border-right-color: initial !important; border-bottom-width: 0px !important; border-bottom-style: initial !important; border-bottom-color: initial !important; "&gt; &lt;div class="" style="padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; color: rgb(0, 0, 0) !important; background-color: rgb(248, 248, 248) !important; border-top-width: 0px !important; border-right-width: 0px !important; border-bottom-width: 0px !important; border-left-width: 0px !important; border-style: initial !important; border-color: initial !important; width: 417px; "&gt;&lt;span class="delim" style="padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; border-top-width: 1px !important; border-right-width: 1px !important; border-bottom-width: 1px !important; border-left-width: 1px !important; border-top-color: transparent !important; border-right-color: transparent !important; border-bottom-color: transparent !important; border-left-color: transparent !important; border-top-style: solid !important; border-right-style: solid !important; border-bottom-style: solid !important; border-left-style: solid !important; background-image: initial !important; background-repeat: initial !important; background-attachment: initial !important; -webkit-background-clip: initial !important; -webkit-background-origin: initial !important; background-color: transparent !important; font-weight: bold; background-position: initial initial !important; "&gt;[&lt;/span&gt;&lt;span style="padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; border-top-width: 1px !important; border-right-width: 1px !important; border-bottom-width: 1px !important; border-left-width: 1px !important; border-top-color: transparent !important; border-right-color: transparent !important; border-bottom-color: transparent !important; border-left-color: transparent !important; border-top-style: solid !important; border-right-style: solid !important; border-bottom-style: solid !important; border-left-style: solid !important; background-image: initial !important; background-repeat: initial !important; background-attachment: initial !important; -webkit-background-clip: initial !important; -webkit-background-origin: initial !important; background-color: transparent !important; background-position: initial initial !important; "&gt;root@dev ~&lt;/span&gt;&lt;span class="delim" style="padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; border-top-width: 1px !important; border-right-width: 1px !important; border-bottom-width: 1px !important; border-left-width: 1px !important; border-top-color: transparent !important; border-right-color: transparent !important; border-bottom-color: transparent !important; border-left-color: transparent !important; border-top-style: solid !important; border-right-style: solid !important; border-bottom-style: solid !important; border-left-style: solid !important; background-image: initial !important; background-repeat: initial !important; background-attachment: initial !important; -webkit-background-clip: initial !important; -webkit-background-origin: initial !important; background-color: transparent !important; font-weight: bold; background-position: initial initial !important; "&gt;]&lt;/span&gt;&lt;span class="comment" style="padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; border-top-width: 1px !important; border-right-width: 1px !important; border-bottom-width: 1px !important; border-left-width: 1px !important; border-top-color: transparent !important; border-right-color: transparent !important; border-bottom-color: transparent !important; border-left-color: transparent !important; border-top-style: solid !important; border-right-style: solid !important; border-bottom-style: solid !important; border-left-style: solid !important; background-image: initial !important; background-repeat: initial !important; background-attachment: initial !important; -webkit-background-clip: initial !important; -webkit-background-origin: initial !important; background-color: transparent !important; color: gray; background-position: initial initial !important; "&gt;# chmod -R 664 /var/log/mysql/&lt;/span&gt;&lt;span style="padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; border-top-width: 1px !important; border-right-width: 1px !important; border-bottom-width: 1px !important; border-left-width: 1px !important; border-top-color: transparent !important; border-right-color: transparent !important; border-bottom-color: transparent !important; border-left-color: transparent !important; border-top-style: solid !important; border-right-style: solid !important; border-bottom-style: solid !important; border-left-style: solid !important; background-image: initial !important; background-repeat: initial !important; background-attachment: initial !important; -webkit-background-clip: initial !important; -webkit-background-origin: initial !important; background-color: transparent !important; background-position: initial initial !important; "&gt; &lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/div&gt;&lt;p style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 1em; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; "&gt;So notice that all of the new files will be owned the mysql user in the mysql group and they will allow reading from all users and writing from the mysql user and members of the mysql group.&lt;/p&gt;&lt;/li&gt;&lt;li style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 3px; margin-right: 0px; margin-bottom: 4px; margin-left: 5px; "&gt;&lt;strong style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "&gt;Restart MySQL &amp;amp; Verify Logging:&lt;/strong&gt; Now lets restart MySQL and verify the logging is operational. You can restart MySQL by issuing the below command.&lt;p style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 1em; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; "&gt;&lt;strong style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "&gt;Restart MySQL:&lt;/strong&gt;&lt;/p&gt;&lt;div class="dp-highlighter" style="padding-top: 1px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 18px; margin-right: 0px; margin-bottom: 18px; margin-left: 0px; font-family: Consolas, &amp;#39;Courier New&amp;#39;, Courier, mono; font-size: 12px; background-color: rgb(231, 229, 220); width: 475px; overflow-x: auto; overflow-y: hidden; "&gt;&lt;div class="bar" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 45px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "&gt;&lt;div class="tools" style="padding-top: 3px; padding-right: 0px; padding-bottom: 10px; padding-left: 10px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 9px/normal Verdana, Geneva, Arial, Helvetica, sans-serif; color: silver; background-color: rgb(248, 248, 248); border-left-width: 3px; border-left-style: solid; border-left-color: rgb(108, 226, 108); width: 417px; "&gt;&lt;a href="http://www.question-defense.com/2009/12/20/configure-logrotate-to-rotate-and-flush-mysql-logs-without-a-password#" onclick="dp.sh.Toolbar.Command(&amp;#39;ViewSource&amp;#39;,this);return false;" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 10px; margin-bottom: 0px; margin-left: 0px; text-decoration: none; color: rgb(160, 160, 160); font-weight: bold; font-size: 9px; "&gt;view plain&lt;/a&gt;&lt;a href="http://www.question-defense.com/2009/12/20/configure-logrotate-to-rotate-and-flush-mysql-logs-without-a-password#" onclick="dp.sh.Toolbar.Command(&amp;#39;CopyToClipboard&amp;#39;,this);return false;" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 10px; margin-bottom: 0px; margin-left: 0px; text-decoration: none; color: rgb(160, 160, 160); font-weight: bold; font-size: 9px; "&gt;copy to clipboard&lt;/a&gt;&lt;a href="http://www.question-defense.com/2009/12/20/configure-logrotate-to-rotate-and-flush-mysql-logs-without-a-password#" onclick="dp.sh.Toolbar.Command(&amp;#39;PrintSource&amp;#39;,this);return false;" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 10px; margin-bottom: 0px; margin-left: 0px; text-decoration: none; color: rgb(160, 160, 160); font-weight: bold; font-size: 9px; "&gt;print&lt;/a&gt;&lt;a href="http://www.question-defense.com/2009/12/20/configure-logrotate-to-rotate-and-flush-mysql-logs-without-a-password#" onclick="dp.sh.Toolbar.Command(&amp;#39;About&amp;#39;,this);return false;" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 10px; margin-bottom: 0px; margin-left: 0px; text-decoration: none; color: rgb(160, 160, 160); font-weight: bold; font-size: 9px; "&gt;?&lt;/a&gt;&lt;/div&gt;&lt;/div&gt;&lt;ol start="1" class="dp-bash" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 1px; margin-left: 45px; list-style-type: decimal-leading-zero; list-style-position: initial; list-style-image: initial; background-color: rgb(255, 255, 255); color: rgb(92, 92, 92); white-space: nowrap; "&gt;&lt;li class="alt" style="padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 10px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; background-color: rgb(255, 255, 255) !important; border-top-width: 0px !important; border-top-style: initial !important; border-top-color: initial !important; border-bottom-width: 0px !important; border-bottom-style: initial !important; border-bottom-color: initial !important; border-left-width: 3px !important; border-left-style: solid !important; border-left-color: rgb(108, 226, 108) !important; line-height: 14px !important; border-right-width: 0px !important; border-right-style: initial !important; border-right-color: initial !important; "&gt; &lt;div class="alt" style="padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; background-color: rgb(255, 255, 255) !important; border-top-width: 0px !important; border-bottom-width: 0px !important; color: rgb(0, 0, 0) !important; border-right-width: 0px !important; border-left-width: 0px !important; border-style: initial !important; border-color: initial !important; border-style: initial !important; border-color: initial !important; width: 417px; "&gt;&lt;span class="delim" style="padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; border-top-width: 1px !important; border-right-width: 1px !important; border-bottom-width: 1px !important; border-left-width: 1px !important; border-top-color: transparent !important; border-right-color: transparent !important; border-bottom-color: transparent !important; border-left-color: transparent !important; border-top-style: solid !important; border-right-style: solid !important; border-bottom-style: solid !important; border-left-style: solid !important; background-image: initial !important; background-repeat: initial !important; background-attachment: initial !important; -webkit-background-clip: initial !important; -webkit-background-origin: initial !important; background-color: transparent !important; font-weight: bold; background-position: initial initial !important; "&gt;[&lt;/span&gt;&lt;span style="padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; border-top-width: 1px !important; border-right-width: 1px !important; border-bottom-width: 1px !important; border-left-width: 1px !important; border-top-color: transparent !important; border-right-color: transparent !important; border-bottom-color: transparent !important; border-left-color: transparent !important; border-top-style: solid !important; border-right-style: solid !important; border-bottom-style: solid !important; border-left-style: solid !important; background-image: initial !important; background-repeat: initial !important; background-attachment: initial !important; -webkit-background-clip: initial !important; -webkit-background-origin: initial !important; background-color: transparent !important; background-position: initial initial !important; "&gt;root@dev ~&lt;/span&gt;&lt;span class="delim" style="padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; border-top-width: 1px !important; border-right-width: 1px !important; border-bottom-width: 1px !important; border-left-width: 1px !important; border-top-color: transparent !important; border-right-color: transparent !important; border-bottom-color: transparent !important; border-left-color: transparent !important; border-top-style: solid !important; border-right-style: solid !important; border-bottom-style: solid !important; border-left-style: solid !important; background-image: initial !important; background-repeat: initial !important; background-attachment: initial !important; -webkit-background-clip: initial !important; -webkit-background-origin: initial !important; background-color: transparent !important; font-weight: bold; background-position: initial initial !important; "&gt;]&lt;/span&gt;&lt;span class="comment" style="padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; border-top-width: 1px !important; border-right-width: 1px !important; border-bottom-width: 1px !important; border-left-width: 1px !important; border-top-color: transparent !important; border-right-color: transparent !important; border-bottom-color: transparent !important; border-left-color: transparent !important; border-top-style: solid !important; border-right-style: solid !important; border-bottom-style: solid !important; border-left-style: solid !important; background-image: initial !important; background-repeat: initial !important; background-attachment: initial !important; -webkit-background-clip: initial !important; -webkit-background-origin: initial !important; background-color: transparent !important; color: gray; background-position: initial initial !important; "&gt;# /etc/init.d/mysqld restart&lt;/span&gt;&lt;span style="padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; border-top-width: 1px !important; border-right-width: 1px !important; border-bottom-width: 1px !important; border-left-width: 1px !important; border-top-color: transparent !important; border-right-color: transparent !important; border-bottom-color: transparent !important; border-left-color: transparent !important; border-top-style: solid !important; border-right-style: solid !important; border-bottom-style: solid !important; border-left-style: solid !important; background-image: initial !important; background-repeat: initial !important; background-attachment: initial !important; -webkit-background-clip: initial !important; -webkit-background-origin: initial !important; background-color: transparent !important; background-position: initial initial !important; "&gt; &lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li class="" style="padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 10px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; border-left-width: 3px !important; border-left-style: solid !important; border-left-color: rgb(108, 226, 108) !important; background-color: rgb(248, 248, 248) !important; line-height: 14px !important; border-top-width: 0px !important; border-top-style: initial !important; border-top-color: initial !important; border-right-width: 0px !important; border-right-style: initial !important; border-right-color: initial !important; border-bottom-width: 0px !important; border-bottom-style: initial !important; border-bottom-color: initial !important; "&gt; &lt;div class="" style="padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; color: rgb(0, 0, 0) !important; background-color: rgb(248, 248, 248) !important; border-top-width: 0px !important; border-right-width: 0px !important; border-bottom-width: 0px !important; border-left-width: 0px !important; border-style: initial !important; border-color: initial !important; width: 417px; "&gt;Stopping MySQL:  &lt;span class="delim" style="padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; border-top-width: 1px !important; border-right-width: 1px !important; border-bottom-width: 1px !important; border-left-width: 1px !important; border-top-color: transparent !important; border-right-color: transparent !important; border-bottom-color: transparent !important; border-left-color: transparent !important; border-top-style: solid !important; border-right-style: solid !important; border-bottom-style: solid !important; border-left-style: solid !important; background-image: initial !important; background-repeat: initial !important; background-attachment: initial !important; -webkit-background-clip: initial !important; -webkit-background-origin: initial !important; background-color: transparent !important; font-weight: bold; background-position: initial initial !important; "&gt;[&lt;/span&gt;&lt;span style="padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; border-top-width: 1px !important; border-right-width: 1px !important; border-bottom-width: 1px !important; border-left-width: 1px !important; border-top-color: transparent !important; border-right-color: transparent !important; border-bottom-color: transparent !important; border-left-color: transparent !important; border-top-style: solid !important; border-right-style: solid !important; border-bottom-style: solid !important; border-left-style: solid !important; background-image: initial !important; background-repeat: initial !important; background-attachment: initial !important; -webkit-background-clip: initial !important; -webkit-background-origin: initial !important; background-color: transparent !important; background-position: initial initial !important; "&gt;  OK  &lt;/span&gt;&lt;span class="delim" style="padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; border-top-width: 1px !important; border-right-width: 1px !important; border-bottom-width: 1px !important; border-left-width: 1px !important; border-top-color: transparent !important; border-right-color: transparent !important; border-bottom-color: transparent !important; border-left-color: transparent !important; border-top-style: solid !important; border-right-style: solid !important; border-bottom-style: solid !important; border-left-style: solid !important; background-image: initial !important; background-repeat: initial !important; background-attachment: initial !important; -webkit-background-clip: initial !important; -webkit-background-origin: initial !important; background-color: transparent !important; font-weight: bold; background-position: initial initial !important; "&gt;]&lt;/span&gt;&lt;span style="padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; border-top-width: 1px !important; border-right-width: 1px !important; border-bottom-width: 1px !important; border-left-width: 1px !important; border-top-color: transparent !important; border-right-color: transparent !important; border-bottom-color: transparent !important; border-left-color: transparent !important; border-top-style: solid !important; border-right-style: solid !important; border-bottom-style: solid !important; border-left-style: solid !important; background-image: initial !important; background-repeat: initial !important; background-attachment: initial !important; -webkit-background-clip: initial !important; -webkit-background-origin: initial !important; background-color: transparent !important; background-position: initial initial !important; "&gt; &lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li class="alt" style="padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 10px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; background-color: rgb(255, 255, 255) !important; border-top-width: 0px !important; border-top-style: initial !important; border-top-color: initial !important; border-bottom-width: 0px !important; border-bottom-style: initial !important; border-bottom-color: initial !important; border-left-width: 3px !important; border-left-style: solid !important; border-left-color: rgb(108, 226, 108) !important; line-height: 14px !important; border-right-width: 0px !important; border-right-style: initial !important; border-right-color: initial !important; "&gt; &lt;div class="alt" style="padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; background-color: rgb(255, 255, 255) !important; border-top-width: 0px !important; border-bottom-width: 0px !important; color: rgb(0, 0, 0) !important; border-right-width: 0px !important; border-left-width: 0px !important; border-style: initial !important; border-color: initial !important; border-style: initial !important; border-color: initial !important; width: 417px; "&gt;Starting MySQL:  &lt;span class="delim" style="padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; border-top-width: 1px !important; border-right-width: 1px !important; border-bottom-width: 1px !important; border-left-width: 1px !important; border-top-color: transparent !important; border-right-color: transparent !important; border-bottom-color: transparent !important; border-left-color: transparent !important; border-top-style: solid !important; border-right-style: solid !important; border-bottom-style: solid !important; border-left-style: solid !important; background-image: initial !important; background-repeat: initial !important; background-attachment: initial !important; -webkit-background-clip: initial !important; -webkit-background-origin: initial !important; background-color: transparent !important; font-weight: bold; background-position: initial initial !important; "&gt;[&lt;/span&gt;&lt;span style="padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; border-top-width: 1px !important; border-right-width: 1px !important; border-bottom-width: 1px !important; border-left-width: 1px !important; border-top-color: transparent !important; border-right-color: transparent !important; border-bottom-color: transparent !important; border-left-color: transparent !important; border-top-style: solid !important; border-right-style: solid !important; border-bottom-style: solid !important; border-left-style: solid !important; background-image: initial !important; background-repeat: initial !important; background-attachment: initial !important; -webkit-background-clip: initial !important; -webkit-background-origin: initial !important; background-color: transparent !important; background-position: initial initial !important; "&gt;  OK  &lt;/span&gt;&lt;span class="delim" style="padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; border-top-width: 1px !important; border-right-width: 1px !important; border-bottom-width: 1px !important; border-left-width: 1px !important; border-top-color: transparent !important; border-right-color: transparent !important; border-bottom-color: transparent !important; border-left-color: transparent !important; border-top-style: solid !important; border-right-style: solid !important; border-bottom-style: solid !important; border-left-style: solid !important; background-image: initial !important; background-repeat: initial !important; background-attachment: initial !important; -webkit-background-clip: initial !important; -webkit-background-origin: initial !important; background-color: transparent !important; font-weight: bold; background-position: initial initial !important; "&gt;]&lt;/span&gt;&lt;span style="padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; border-top-width: 1px !important; border-right-width: 1px !important; border-bottom-width: 1px !important; border-left-width: 1px !important; border-top-color: transparent !important; border-right-color: transparent !important; border-bottom-color: transparent !important; border-left-color: transparent !important; border-top-style: solid !important; border-right-style: solid !important; border-bottom-style: solid !important; border-left-style: solid !important; background-image: initial !important; background-repeat: initial !important; background-attachment: initial !important; -webkit-background-clip: initial !important; -webkit-background-origin: initial !important; background-color: transparent !important; background-position: initial initial !important; "&gt; &lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li class="" style="padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 10px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; border-left-width: 3px !important; border-left-style: solid !important; border-left-color: rgb(108, 226, 108) !important; background-color: rgb(248, 248, 248) !important; line-height: 14px !important; border-top-width: 0px !important; border-top-style: initial !important; border-top-color: initial !important; border-right-width: 0px !important; border-right-style: initial !important; border-right-color: initial !important; border-bottom-width: 0px !important; border-bottom-style: initial !important; border-bottom-color: initial !important; "&gt; &lt;div class="" style="padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; color: rgb(0, 0, 0) !important; background-color: rgb(248, 248, 248) !important; border-top-width: 0px !important; border-right-width: 0px !important; border-bottom-width: 0px !important; border-left-width: 0px !important; border-style: initial !important; border-color: initial !important; width: 417px; "&gt;&lt;span class="delim" style="padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; border-top-width: 1px !important; border-right-width: 1px !important; border-bottom-width: 1px !important; border-left-width: 1px !important; border-top-color: transparent !important; border-right-color: transparent !important; border-bottom-color: transparent !important; border-left-color: transparent !important; border-top-style: solid !important; border-right-style: solid !important; border-bottom-style: solid !important; border-left-style: solid !important; background-image: initial !important; background-repeat: initial !important; background-attachment: initial !important; -webkit-background-clip: initial !important; -webkit-background-origin: initial !important; background-color: transparent !important; font-weight: bold; background-position: initial initial !important; "&gt;[&lt;/span&gt;&lt;span style="padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; border-top-width: 1px !important; border-right-width: 1px !important; border-bottom-width: 1px !important; border-left-width: 1px !important; border-top-color: transparent !important; border-right-color: transparent !important; border-bottom-color: transparent !important; border-left-color: transparent !important; border-top-style: solid !important; border-right-style: solid !important; border-bottom-style: solid !important; border-left-style: solid !important; background-image: initial !important; background-repeat: initial !important; background-attachment: initial !important; -webkit-background-clip: initial !important; -webkit-background-origin: initial !important; background-color: transparent !important; background-position: initial initial !important; "&gt;root@dev ~&lt;/span&gt;&lt;span class="delim" style="padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; border-top-width: 1px !important; border-right-width: 1px !important; border-bottom-width: 1px !important; border-left-width: 1px !important; border-top-color: transparent !important; border-right-color: transparent !important; border-bottom-color: transparent !important; border-left-color: transparent !important; border-top-style: solid !important; border-right-style: solid !important; border-bottom-style: solid !important; border-left-style: solid !important; background-image: initial !important; background-repeat: initial !important; background-attachment: initial !important; -webkit-background-clip: initial !important; -webkit-background-origin: initial !important; background-color: transparent !important; font-weight: bold; background-position: initial initial !important; "&gt;]&lt;/span&gt;&lt;span class="comment" style="padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; border-top-width: 1px !important; border-right-width: 1px !important; border-bottom-width: 1px !important; border-left-width: 1px !important; border-top-color: transparent !important; border-right-color: transparent !important; border-bottom-color: transparent !important; border-left-color: transparent !important; border-top-style: solid !important; border-right-style: solid !important; border-bottom-style: solid !important; border-left-style: solid !important; background-image: initial !important; background-repeat: initial !important; background-attachment: initial !important; -webkit-background-clip: initial !important; -webkit-background-origin: initial !important; background-color: transparent !important; color: gray; background-position: initial initial !important; "&gt;#&lt;/span&gt;&lt;span style="padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; border-top-width: 1px !important; border-right-width: 1px !important; border-bottom-width: 1px !important; border-left-width: 1px !important; border-top-color: transparent !important; border-right-color: transparent !important; border-bottom-color: transparent !important; border-left-color: transparent !important; border-top-style: solid !important; border-right-style: solid !important; border-bottom-style: solid !important; border-left-style: solid !important; background-image: initial !important; background-repeat: initial !important; background-attachment: initial !important; -webkit-background-clip: initial !important; -webkit-background-origin: initial !important; background-color: transparent !important; background-position: initial initial !important; "&gt; &lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/div&gt;&lt;p style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 1em; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; "&gt;If MySQL fails to restart and this is a live server quickly make a backup of my.cnf, remove the changes,and start MySQL so your downtime is minimal. If you follow the directions above you should be fine but I wanted to mention just in case there were any issues with the restart. Now visit some web pages on your site to generate some of the MySQL queries to the database and then view the log files to verify logging is functional. You can view the log files in real time by using the tail command as displayed below.&lt;/p&gt;&lt;p style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 1em; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; "&gt;&lt;strong style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "&gt;View New MySQL Log Files In Real Time With Tail:&lt;/strong&gt;&lt;/p&gt;&lt;div class="dp-highlighter" style="padding-top: 1px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 18px; margin-right: 0px; margin-bottom: 18px; margin-left: 0px; font-family: Consolas, &amp;#39;Courier New&amp;#39;, Courier, mono; font-size: 12px; background-color: rgb(231, 229, 220); width: 475px; overflow-x: auto; overflow-y: hidden; "&gt;&lt;div class="bar" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 45px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "&gt;&lt;div class="tools" style="padding-top: 3px; padding-right: 0px; padding-bottom: 10px; padding-left: 10px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 9px/normal Verdana, Geneva, Arial, Helvetica, sans-serif; color: silver; background-color: rgb(248, 248, 248); border-left-width: 3px; border-left-style: solid; border-left-color: rgb(108, 226, 108); width: 417px; "&gt;&lt;a href="http://www.question-defense.com/2009/12/20/configure-logrotate-to-rotate-and-flush-mysql-logs-without-a-password#" onclick="dp.sh.Toolbar.Command(&amp;#39;ViewSource&amp;#39;,this);return false;" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 10px; margin-bottom: 0px; margin-left: 0px; text-decoration: none; color: rgb(160, 160, 160); font-weight: bold; font-size: 9px; "&gt;view plain&lt;/a&gt;&lt;a href="http://www.question-defense.com/2009/12/20/configure-logrotate-to-rotate-and-flush-mysql-logs-without-a-password#" onclick="dp.sh.Toolbar.Command(&amp;#39;CopyToClipboard&amp;#39;,this);return false;" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 10px; margin-bottom: 0px; margin-left: 0px; text-decoration: none; color: rgb(160, 160, 160); font-weight: bold; font-size: 9px; "&gt;copy to clipboard&lt;/a&gt;&lt;a href="http://www.question-defense.com/2009/12/20/configure-logrotate-to-rotate-and-flush-mysql-logs-without-a-password#" onclick="dp.sh.Toolbar.Command(&amp;#39;PrintSource&amp;#39;,this);return false;" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 10px; margin-bottom: 0px; margin-left: 0px; text-decoration: none; color: rgb(160, 160, 160); font-weight: bold; font-size: 9px; "&gt;print&lt;/a&gt;&lt;a href="http://www.question-defense.com/2009/12/20/configure-logrotate-to-rotate-and-flush-mysql-logs-without-a-password#" onclick="dp.sh.Toolbar.Command(&amp;#39;About&amp;#39;,this);return false;" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 10px; margin-bottom: 0px; margin-left: 0px; text-decoration: none; color: rgb(160, 160, 160); font-weight: bold; font-size: 9px; "&gt;?&lt;/a&gt;&lt;/div&gt;&lt;/div&gt;&lt;ol start="1" class="dp-bash" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 1px; margin-left: 45px; list-style-type: decimal-leading-zero; list-style-position: initial; list-style-image: initial; background-color: rgb(255, 255, 255); color: rgb(92, 92, 92); white-space: nowrap; "&gt;&lt;li class="alt" style="padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 10px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; background-color: rgb(255, 255, 255) !important; border-top-width: 0px !important; border-top-style: initial !important; border-top-color: initial !important; border-bottom-width: 0px !important; border-bottom-style: initial !important; border-bottom-color: initial !important; border-left-width: 3px !important; border-left-style: solid !important; border-left-color: rgb(108, 226, 108) !important; line-height: 14px !important; border-right-width: 0px !important; border-right-style: initial !important; border-right-color: initial !important; "&gt; &lt;div class="alt" style="padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; background-color: rgb(255, 255, 255) !important; border-top-width: 0px !important; border-bottom-width: 0px !important; color: rgb(0, 0, 0) !important; border-right-width: 0px !important; border-left-width: 0px !important; border-style: initial !important; border-color: initial !important; border-style: initial !important; border-color: initial !important; width: 417px; "&gt;&lt;span class="delim" style="padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; border-top-width: 1px !important; border-right-width: 1px !important; border-bottom-width: 1px !important; border-left-width: 1px !important; border-top-color: transparent !important; border-right-color: transparent !important; border-bottom-color: transparent !important; border-left-color: transparent !important; border-top-style: solid !important; border-right-style: solid !important; border-bottom-style: solid !important; border-left-style: solid !important; background-image: initial !important; background-repeat: initial !important; background-attachment: initial !important; -webkit-background-clip: initial !important; -webkit-background-origin: initial !important; background-color: transparent !important; font-weight: bold; background-position: initial initial !important; "&gt;[&lt;/span&gt;&lt;span style="padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; border-top-width: 1px !important; border-right-width: 1px !important; border-bottom-width: 1px !important; border-left-width: 1px !important; border-top-color: transparent !important; border-right-color: transparent !important; border-bottom-color: transparent !important; border-left-color: transparent !important; border-top-style: solid !important; border-right-style: solid !important; border-bottom-style: solid !important; border-left-style: solid !important; background-image: initial !important; background-repeat: initial !important; background-attachment: initial !important; -webkit-background-clip: initial !important; -webkit-background-origin: initial !important; background-color: transparent !important; background-position: initial initial !important; "&gt;root@dev mysql&lt;/span&gt;&lt;span class="delim" style="padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; border-top-width: 1px !important; border-right-width: 1px !important; border-bottom-width: 1px !important; border-left-width: 1px !important; border-top-color: transparent !important; border-right-color: transparent !important; border-bottom-color: transparent !important; border-left-color: transparent !important; border-top-style: solid !important; border-right-style: solid !important; border-bottom-style: solid !important; border-left-style: solid !important; background-image: initial !important; background-repeat: initial !important; background-attachment: initial !important; -webkit-background-clip: initial !important; -webkit-background-origin: initial !important; background-color: transparent !important; font-weight: bold; background-position: initial initial !important; "&gt;]&lt;/span&gt;&lt;span class="comment" style="padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; border-top-width: 1px !important; border-right-width: 1px !important; border-bottom-width: 1px !important; border-left-width: 1px !important; border-top-color: transparent !important; border-right-color: transparent !important; border-bottom-color: transparent !important; border-left-color: transparent !important; border-top-style: solid !important; border-right-style: solid !important; border-bottom-style: solid !important; border-left-style: solid !important; background-image: initial !important; background-repeat: initial !important; background-attachment: initial !important; -webkit-background-clip: initial !important; -webkit-background-origin: initial !important; background-color: transparent !important; color: gray; background-position: initial initial !important; "&gt;# tail -f mysql.log&lt;/span&gt;&lt;span style="padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; border-top-width: 1px !important; border-right-width: 1px !important; border-bottom-width: 1px !important; border-left-width: 1px !important; border-top-color: transparent !important; border-right-color: transparent !important; border-bottom-color: transparent !important; border-left-color: transparent !important; border-top-style: solid !important; border-right-style: solid !important; border-bottom-style: solid !important; border-left-style: solid !important; background-image: initial !important; background-repeat: initial !important; background-attachment: initial !important; -webkit-background-clip: initial !important; -webkit-background-origin: initial !important; background-color: transparent !important; background-position: initial initial !important; "&gt; &lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li class="" style="padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 10px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; border-left-width: 3px !important; border-left-style: solid !important; border-left-color: rgb(108, 226, 108) !important; background-color: rgb(248, 248, 248) !important; line-height: 14px !important; border-top-width: 0px !important; border-top-style: initial !important; border-top-color: initial !important; border-right-width: 0px !important; border-right-style: initial !important; border-right-color: initial !important; border-bottom-width: 0px !important; border-bottom-style: initial !important; border-bottom-color: initial !important; "&gt; &lt;div class="" style="padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; color: rgb(0, 0, 0) !important; background-color: rgb(248, 248, 248) !important; border-top-width: 0px !important; border-right-width: 0px !important; border-bottom-width: 0px !important; border-left-width: 0px !important; border-style: initial !important; border-color: initial !important; width: 417px; "&gt;FROM wp_posts WHERE MONTH&lt;span class="delim" style="padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; border-top-width: 1px !important; border-right-width: 1px !important; border-bottom-width: 1px !important; border-left-width: 1px !important; border-top-color: transparent !important; border-right-color: transparent !important; border-bottom-color: transparent !important; border-left-color: transparent !important; border-top-style: solid !important; border-right-style: solid !important; border-bottom-style: solid !important; border-left-style: solid !important; background-image: initial !important; background-repeat: initial !important; background-attachment: initial !important; -webkit-background-clip: initial !important; -webkit-background-origin: initial !important; background-color: transparent !important; font-weight: bold; background-position: initial initial !important; "&gt;(&lt;/span&gt;&lt;span style="padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; border-top-width: 1px !important; border-right-width: 1px !important; border-bottom-width: 1px !important; border-left-width: 1px !important; border-top-color: transparent !important; border-right-color: transparent !important; border-bottom-color: transparent !important; border-left-color: transparent !important; border-top-style: solid !important; border-right-style: solid !important; border-bottom-style: solid !important; border-left-style: solid !important; background-image: initial !important; background-repeat: initial !important; background-attachment: initial !important; -webkit-background-clip: initial !important; -webkit-background-origin: initial !important; background-color: transparent !important; background-position: initial initial !important; "&gt;post_date&lt;/span&gt;&lt;span class="delim" style="padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; border-top-width: 1px !important; border-right-width: 1px !important; border-bottom-width: 1px !important; border-left-width: 1px !important; border-top-color: transparent !important; border-right-color: transparent !important; border-bottom-color: transparent !important; border-left-color: transparent !important; border-top-style: solid !important; border-right-style: solid !important; border-bottom-style: solid !important; border-left-style: solid !important; background-image: initial !important; background-repeat: initial !important; background-attachment: initial !important; -webkit-background-clip: initial !important; -webkit-background-origin: initial !important; background-color: transparent !important; font-weight: bold; background-position: initial initial !important; "&gt;)&lt;/span&gt;&lt;span style="padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; border-top-width: 1px !important; border-right-width: 1px !important; border-bottom-width: 1px !important; border-left-width: 1px !important; border-top-color: transparent !important; border-right-color: transparent !important; border-bottom-color: transparent !important; border-left-color: transparent !important; border-top-style: solid !important; border-right-style: solid !important; border-bottom-style: solid !important; border-left-style: solid !important; background-image: initial !important; background-repeat: initial !important; background-attachment: initial !important; -webkit-background-clip: initial !important; -webkit-background-origin: initial !important; background-color: transparent !important; background-position: initial initial !important; "&gt; = &lt;/span&gt;&lt;span class="string" style="padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; border-top-width: 1px !important; border-right-width: 1px !important; border-bottom-width: 1px !important; border-left-width: 1px !important; border-top-color: transparent !important; border-right-color: transparent !important; border-bottom-color: transparent !important; border-left-color: transparent !important; border-top-style: solid !important; border-right-style: solid !important; border-bottom-style: solid !important; border-left-style: solid !important; background-image: initial !important; background-repeat: initial !important; background-attachment: initial !important; -webkit-background-clip: initial !important; -webkit-background-origin: initial !important; background-color: transparent !important; color: red; background-position: initial initial !important; "&gt;&amp;#39;12&amp;#39;&lt;/span&gt;&lt;span style="padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; border-top-width: 1px !important; border-right-width: 1px !important; border-bottom-width: 1px !important; border-left-width: 1px !important; border-top-color: transparent !important; border-right-color: transparent !important; border-bottom-color: transparent !important; border-left-color: transparent !important; border-top-style: solid !important; border-right-style: solid !important; border-bottom-style: solid !important; border-left-style: solid !important; background-image: initial !important; background-repeat: initial !important; background-attachment: initial !important; -webkit-background-clip: initial !important; -webkit-background-origin: initial !important; background-color: transparent !important; background-position: initial initial !important; "&gt; &lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li class="alt" style="padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 10px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; background-color: rgb(255, 255, 255) !important; border-top-width: 0px !important; border-top-style: initial !important; border-top-color: initial !important; border-bottom-width: 0px !important; border-bottom-style: initial !important; border-bottom-color: initial !important; border-left-width: 3px !important; border-left-style: solid !important; border-left-color: rgb(108, 226, 108) !important; line-height: 14px !important; border-right-width: 0px !important; border-right-style: initial !important; border-right-color: initial !important; "&gt; &lt;div class="alt" style="padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; background-color: rgb(255, 255, 255) !important; border-top-width: 0px !important; border-bottom-width: 0px !important; color: rgb(0, 0, 0) !important; border-right-width: 0px !important; border-left-width: 0px !important; border-style: initial !important; border-color: initial !important; border-style: initial !important; border-color: initial !important; width: 417px; "&gt;AND YEAR&lt;span class="delim" style="padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; border-top-width: 1px !important; border-right-width: 1px !important; border-bottom-width: 1px !important; border-left-width: 1px !important; border-top-color: transparent !important; border-right-color: transparent !important; border-bottom-color: transparent !important; border-left-color: transparent !important; border-top-style: solid !important; border-right-style: solid !important; border-bottom-style: solid !important; border-left-style: solid !important; background-image: initial !important; background-repeat: initial !important; background-attachment: initial !important; -webkit-background-clip: initial !important; -webkit-background-origin: initial !important; background-color: transparent !important; font-weight: bold; background-position: initial initial !important; "&gt;(&lt;/span&gt;&lt;span style="padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; border-top-width: 1px !important; border-right-width: 1px !important; border-bottom-width: 1px !important; border-left-width: 1px !important; border-top-color: transparent !important; border-right-color: transparent !important; border-bottom-color: transparent !important; border-left-color: transparent !important; border-top-style: solid !important; border-right-style: solid !important; border-bottom-style: solid !important; border-left-style: solid !important; background-image: initial !important; background-repeat: initial !important; background-attachment: initial !important; -webkit-background-clip: initial !important; -webkit-background-origin: initial !important; background-color: transparent !important; background-position: initial initial !important; "&gt;post_date&lt;/span&gt;&lt;span class="delim" style="padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; border-top-width: 1px !important; border-right-width: 1px !important; border-bottom-width: 1px !important; border-left-width: 1px !important; border-top-color: transparent !important; border-right-color: transparent !important; border-bottom-color: transparent !important; border-left-color: transparent !important; border-top-style: solid !important; border-right-style: solid !important; border-bottom-style: solid !important; border-left-style: solid !important; background-image: initial !important; background-repeat: initial !important; background-attachment: initial !important; -webkit-background-clip: initial !important; -webkit-background-origin: initial !important; background-color: transparent !important; font-weight: bold; background-position: initial initial !important; "&gt;)&lt;/span&gt;&lt;span style="padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; border-top-width: 1px !important; border-right-width: 1px !important; border-bottom-width: 1px !important; border-left-width: 1px !important; border-top-color: transparent !important; border-right-color: transparent !important; border-bottom-color: transparent !important; border-left-color: transparent !important; border-top-style: solid !important; border-right-style: solid !important; border-bottom-style: solid !important; border-left-style: solid !important; background-image: initial !important; background-repeat: initial !important; background-attachment: initial !important; -webkit-background-clip: initial !important; -webkit-background-origin: initial !important; background-color: transparent !important; background-position: initial initial !important; "&gt; = &lt;/span&gt;&lt;span class="string" style="padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; border-top-width: 1px !important; border-right-width: 1px !important; border-bottom-width: 1px !important; border-left-width: 1px !important; border-top-color: transparent !important; border-right-color: transparent !important; border-bottom-color: transparent !important; border-left-color: transparent !important; border-top-style: solid !important; border-right-style: solid !important; border-bottom-style: solid !important; border-left-style: solid !important; background-image: initial !important; background-repeat: initial !important; background-attachment: initial !important; -webkit-background-clip: initial !important; -webkit-background-origin: initial !important; background-color: transparent !important; color: red; background-position: initial initial !important; "&gt;&amp;#39;2009&amp;#39;&lt;/span&gt;&lt;span style="padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; border-top-width: 1px !important; border-right-width: 1px !important; border-bottom-width: 1px !important; border-left-width: 1px !important; border-top-color: transparent !important; border-right-color: transparent !important; border-bottom-color: transparent !important; border-left-color: transparent !important; border-top-style: solid !important; border-right-style: solid !important; border-bottom-style: solid !important; border-left-style: solid !important; background-image: initial !important; background-repeat: initial !important; background-attachment: initial !important; -webkit-background-clip: initial !important; -webkit-background-origin: initial !important; background-color: transparent !important; background-position: initial initial !important; "&gt; &lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li class="" style="padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 10px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; border-left-width: 3px !important; border-left-style: solid !important; border-left-color: rgb(108, 226, 108) !important; background-color: rgb(248, 248, 248) !important; line-height: 14px !important; border-top-width: 0px !important; border-top-style: initial !important; border-top-color: initial !important; border-right-width: 0px !important; border-right-style: initial !important; border-right-color: initial !important; border-bottom-width: 0px !important; border-bottom-style: initial !important; border-bottom-color: initial !important; "&gt; &lt;div class="" style="padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; color: rgb(0, 0, 0) !important; background-color: rgb(248, 248, 248) !important; border-top-width: 0px !important; border-right-width: 0px !important; border-bottom-width: 0px !important; border-left-width: 0px !important; border-style: initial !important; border-color: initial !important; width: 417px; "&gt;AND post_type = &lt;span class="string" style="padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; border-top-width: 1px !important; border-right-width: 1px !important; border-bottom-width: 1px !important; border-left-width: 1px !important; border-top-color: transparent !important; border-right-color: transparent !important; border-bottom-color: transparent !important; border-left-color: transparent !important; border-top-style: solid !important; border-right-style: solid !important; border-bottom-style: solid !important; border-left-style: solid !important; background-image: initial !important; background-repeat: initial !important; background-attachment: initial !important; -webkit-background-clip: initial !important; -webkit-background-origin: initial !important; background-color: transparent !important; color: red; background-position: initial initial !important; "&gt;&amp;#39;post&amp;#39;&lt;/span&gt;&lt;span style="padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; border-top-width: 1px !important; border-right-width: 1px !important; border-bottom-width: 1px !important; border-left-width: 1px !important; border-top-color: transparent !important; border-right-color: transparent !important; border-bottom-color: transparent !important; border-left-color: transparent !important; border-top-style: solid !important; border-right-style: solid !important; border-bottom-style: solid !important; border-left-style: solid !important; background-image: initial !important; background-repeat: initial !important; background-attachment: initial !important; -webkit-background-clip: initial !important; -webkit-background-origin: initial !important; background-color: transparent !important; background-position: initial initial !important; "&gt; AND post_status = &lt;/span&gt;&lt;span class="string" style="padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; border-top-width: 1px !important; border-right-width: 1px !important; border-bottom-width: 1px !important; border-left-width: 1px !important; border-top-color: transparent !important; border-right-color: transparent !important; border-bottom-color: transparent !important; border-left-color: transparent !important; border-top-style: solid !important; border-right-style: solid !important; border-bottom-style: solid !important; border-left-style: solid !important; background-image: initial !important; background-repeat: initial !important; background-attachment: initial !important; -webkit-background-clip: initial !important; -webkit-background-origin: initial !important; background-color: transparent !important; color: red; background-position: initial initial !important; "&gt;&amp;#39;publish&amp;#39;&lt;/span&gt;&lt;span style="padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; border-top-width: 1px !important; border-right-width: 1px !important; border-bottom-width: 1px !important; border-left-width: 1px !important; border-top-color: transparent !important; border-right-color: transparent !important; border-bottom-color: transparent !important; border-left-color: transparent !important; border-top-style: solid !important; border-right-style: solid !important; border-bottom-style: solid !important; border-left-style: solid !important; background-image: initial !important; background-repeat: initial !important; background-attachment: initial !important; -webkit-background-clip: initial !important; -webkit-background-origin: initial !important; background-color: transparent !important; background-position: initial initial !important; "&gt; &lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li class="alt" style="padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 10px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; background-color: rgb(255, 255, 255) !important; border-top-width: 0px !important; border-top-style: initial !important; border-top-color: initial !important; border-bottom-width: 0px !important; border-bottom-style: initial !important; border-bottom-color: initial !important; border-left-width: 3px !important; border-left-style: solid !important; border-left-color: rgb(108, 226, 108) !important; line-height: 14px !important; border-right-width: 0px !important; border-right-style: initial !important; border-right-color: initial !important; "&gt; &lt;div class="alt" style="padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; background-color: rgb(255, 255, 255) !important; border-top-width: 0px !important; border-bottom-width: 0px !important; color: rgb(0, 0, 0) !important; border-right-width: 0px !important; border-left-width: 0px !important; border-style: initial !important; border-color: initial !important; border-style: initial !important; border-color: initial !important; width: 417px; "&gt;AND post_date &amp;lt; &lt;span class="string" style="padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; border-top-width: 1px !important; border-right-width: 1px !important; border-bottom-width: 1px !important; border-left-width: 1px !important; border-top-color: transparent !important; border-right-color: transparent !important; border-bottom-color: transparent !important; border-left-color: transparent !important; border-top-style: solid !important; border-right-style: solid !important; border-bottom-style: solid !important; border-left-style: solid !important; background-image: initial !important; background-repeat: initial !important; background-attachment: initial !important; -webkit-background-clip: initial !important; -webkit-background-origin: initial !important; background-color: transparent !important; color: red; background-position: initial initial !important; "&gt;&amp;#39;2009-12-20 12:52:13&amp;#39;&lt;/span&gt;&lt;span style="padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; border-top-width: 1px !important; border-right-width: 1px !important; border-bottom-width: 1px !important; border-left-width: 1px !important; border-top-color: transparent !important; border-right-color: transparent !important; border-bottom-color: transparent !important; border-left-color: transparent !important; border-top-style: solid !important; border-right-style: solid !important; border-bottom-style: solid !important; border-left-style: solid !important; background-image: initial !important; background-repeat: initial !important; background-attachment: initial !important; -webkit-background-clip: initial !important; -webkit-background-origin: initial !important; background-color: transparent !important; background-position: initial initial !important; "&gt; &lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 3px; margin-right: 0px; margin-bottom: 4px; margin-left: 5px; "&gt;&lt;strong style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "&gt;Configure Root User MySQL Access:&lt;/strong&gt; Now in preparation for the logrotate mysql configuration file you want to add a file to the root users home directory so that user can flush the log files without having to use a username and password every single time. If you attempt to flush the MySQL logs before you add the below configuration file you will receive an error similar to the below.&lt;p style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 1em; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; "&gt;&lt;strong style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "&gt;Error When Running mysqladmin flush-logs Without A Password&lt;/strong&gt;:&lt;/p&gt;&lt;div class="dp-highlighter" style="padding-top: 1px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 18px; margin-right: 0px; margin-bottom: 18px; margin-left: 0px; font-family: Consolas, &amp;#39;Courier New&amp;#39;, Courier, mono; font-size: 12px; background-color: rgb(231, 229, 220); width: 475px; overflow-x: auto; overflow-y: hidden; "&gt;&lt;div class="bar" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 45px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "&gt;&lt;div class="tools" style="padding-top: 3px; padding-right: 0px; padding-bottom: 10px; padding-left: 10px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 9px/normal Verdana, Geneva, Arial, Helvetica, sans-serif; color: silver; background-color: rgb(248, 248, 248); border-left-width: 3px; border-left-style: solid; border-left-color: rgb(108, 226, 108); width: 516px; "&gt;&lt;a href="http://www.question-defense.com/2009/12/20/configure-logrotate-to-rotate-and-flush-mysql-logs-without-a-password#" onclick="dp.sh.Toolbar.Command(&amp;#39;ViewSource&amp;#39;,this);return false;" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 10px; margin-bottom: 0px; margin-left: 0px; text-decoration: none; color: rgb(160, 160, 160); font-weight: bold; font-size: 9px; "&gt;view plain&lt;/a&gt;&lt;a href="http://www.question-defense.com/2009/12/20/configure-logrotate-to-rotate-and-flush-mysql-logs-without-a-password#" onclick="dp.sh.Toolbar.Command(&amp;#39;CopyToClipboard&amp;#39;,this);return false;" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 10px; margin-bottom: 0px; margin-left: 0px; text-decoration: none; color: rgb(160, 160, 160); font-weight: bold; font-size: 9px; "&gt;copy to clipboard&lt;/a&gt;&lt;a href="http://www.question-defense.com/2009/12/20/configure-logrotate-to-rotate-and-flush-mysql-logs-without-a-password#" onclick="dp.sh.Toolbar.Command(&amp;#39;PrintSource&amp;#39;,this);return false;" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 10px; margin-bottom: 0px; margin-left: 0px; text-decoration: none; color: rgb(160, 160, 160); font-weight: bold; font-size: 9px; "&gt;print&lt;/a&gt;&lt;a href="http://www.question-defense.com/2009/12/20/configure-logrotate-to-rotate-and-flush-mysql-logs-without-a-password#" onclick="dp.sh.Toolbar.Command(&amp;#39;About&amp;#39;,this);return false;" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 10px; margin-bottom: 0px; margin-left: 0px; text-decoration: none; color: rgb(160, 160, 160); font-weight: bold; font-size: 9px; "&gt;?&lt;/a&gt;&lt;/div&gt;&lt;/div&gt;&lt;ol start="1" class="dp-bash" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 1px; margin-left: 45px; list-style-type: decimal-leading-zero; list-style-position: initial; list-style-image: initial; background-color: rgb(255, 255, 255); color: rgb(92, 92, 92); white-space: nowrap; "&gt;&lt;li class="alt" style="padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 10px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; background-color: rgb(255, 255, 255) !important; border-top-width: 0px !important; border-top-style: initial !important; border-top-color: initial !important; border-bottom-width: 0px !important; border-bottom-style: initial !important; border-bottom-color: initial !important; border-left-width: 3px !important; border-left-style: solid !important; border-left-color: rgb(108, 226, 108) !important; line-height: 14px !important; border-right-width: 0px !important; border-right-style: initial !important; border-right-color: initial !important; "&gt; &lt;div class="alt" style="padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; background-color: rgb(255, 255, 255) !important; border-top-width: 0px !important; border-bottom-width: 0px !important; color: rgb(0, 0, 0) !important; border-right-width: 0px !important; border-left-width: 0px !important; border-style: initial !important; border-color: initial !important; border-style: initial !important; border-color: initial !important; width: 516px; "&gt;&lt;span class="delim" style="padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; border-top-width: 1px !important; border-right-width: 1px !important; border-bottom-width: 1px !important; border-left-width: 1px !important; border-top-color: transparent !important; border-right-color: transparent !important; border-bottom-color: transparent !important; border-left-color: transparent !important; border-top-style: solid !important; border-right-style: solid !important; border-bottom-style: solid !important; border-left-style: solid !important; background-image: initial !important; background-repeat: initial !important; background-attachment: initial !important; -webkit-background-clip: initial !important; -webkit-background-origin: initial !important; background-color: transparent !important; font-weight: bold; background-position: initial initial !important; "&gt;[&lt;/span&gt;&lt;span style="padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; border-top-width: 1px !important; border-right-width: 1px !important; border-bottom-width: 1px !important; border-left-width: 1px !important; border-top-color: transparent !important; border-right-color: transparent !important; border-bottom-color: transparent !important; border-left-color: transparent !important; border-top-style: solid !important; border-right-style: solid !important; border-bottom-style: solid !important; border-left-style: solid !important; background-image: initial !important; background-repeat: initial !important; background-attachment: initial !important; -webkit-background-clip: initial !important; -webkit-background-origin: initial !important; background-color: transparent !important; background-position: initial initial !important; "&gt;root@dev ~&lt;/span&gt;&lt;span class="delim" style="padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; border-top-width: 1px !important; border-right-width: 1px !important; border-bottom-width: 1px !important; border-left-width: 1px !important; border-top-color: transparent !important; border-right-color: transparent !important; border-bottom-color: transparent !important; border-left-color: transparent !important; border-top-style: solid !important; border-right-style: solid !important; border-bottom-style: solid !important; border-left-style: solid !important; background-image: initial !important; background-repeat: initial !important; background-attachment: initial !important; -webkit-background-clip: initial !important; -webkit-background-origin: initial !important; background-color: transparent !important; font-weight: bold; background-position: initial initial !important; "&gt;]&lt;/span&gt;&lt;span class="comment" style="padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; border-top-width: 1px !important; border-right-width: 1px !important; border-bottom-width: 1px !important; border-left-width: 1px !important; border-top-color: transparent !important; border-right-color: transparent !important; border-bottom-color: transparent !important; border-left-color: transparent !important; border-top-style: solid !important; border-right-style: solid !important; border-bottom-style: solid !important; border-left-style: solid !important; background-image: initial !important; background-repeat: initial !important; background-attachment: initial !important; -webkit-background-clip: initial !important; -webkit-background-origin: initial !important; background-color: transparent !important; color: gray; background-position: initial initial !important; "&gt;# /usr/bin/mysqladmin flush-logs&lt;/span&gt;&lt;span style="padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; border-top-width: 1px !important; border-right-width: 1px !important; border-bottom-width: 1px !important; border-left-width: 1px !important; border-top-color: transparent !important; border-right-color: transparent !important; border-bottom-color: transparent !important; border-left-color: transparent !important; border-top-style: solid !important; border-right-style: solid !important; border-bottom-style: solid !important; border-left-style: solid !important; background-image: initial !important; background-repeat: initial !important; background-attachment: initial !important; -webkit-background-clip: initial !important; -webkit-background-origin: initial !important; background-color: transparent !important; background-position: initial initial !important; "&gt; &lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li class="" style="padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 10px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; border-left-width: 3px !important; border-left-style: solid !important; border-left-color: rgb(108, 226, 108) !important; background-color: rgb(248, 248, 248) !important; line-height: 14px !important; border-top-width: 0px !important; border-top-style: initial !important; border-top-color: initial !important; border-right-width: 0px !important; border-right-style: initial !important; border-right-color: initial !important; border-bottom-width: 0px !important; border-bottom-style: initial !important; border-bottom-color: initial !important; "&gt; &lt;div class="" style="padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; color: rgb(0, 0, 0) !important; background-color: rgb(248, 248, 248) !important; border-top-width: 0px !important; border-right-width: 0px !important; border-bottom-width: 0px !important; border-left-width: 0px !important; border-style: initial !important; border-color: initial !important; width: 516px; "&gt;/usr/bin/mysqladmin: connect to server at &lt;span class="string" style="padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; border-top-width: 1px !important; border-right-width: 1px !important; border-bottom-width: 1px !important; border-left-width: 1px !important; border-top-color: transparent !important; border-right-color: transparent !important; border-bottom-color: transparent !important; border-left-color: transparent !important; border-top-style: solid !important; border-right-style: solid !important; border-bottom-style: solid !important; border-left-style: solid !important; background-image: initial !important; background-repeat: initial !important; background-attachment: initial !important; -webkit-background-clip: initial !important; -webkit-background-origin: initial !important; background-color: transparent !important; color: red; background-position: initial initial !important; "&gt;&amp;#39;localhost&amp;#39;&lt;/span&gt;&lt;span style="padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; border-top-width: 1px !important; border-right-width: 1px !important; border-bottom-width: 1px !important; border-left-width: 1px !important; border-top-color: transparent !important; border-right-color: transparent !important; border-bottom-color: transparent !important; border-left-color: transparent !important; border-top-style: solid !important; border-right-style: solid !important; border-bottom-style: solid !important; border-left-style: solid !important; background-image: initial !important; background-repeat: initial !important; background-attachment: initial !important; -webkit-background-clip: initial !important; -webkit-background-origin: initial !important; background-color: transparent !important; background-position: initial initial !important; "&gt; failed &lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li class="alt" style="padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 10px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; background-color: rgb(255, 255, 255) !important; border-top-width: 0px !important; border-top-style: initial !important; border-top-color: initial !important; border-bottom-width: 0px !important; border-bottom-style: initial !important; border-bottom-color: initial !important; border-left-width: 3px !important; border-left-style: solid !important; border-left-color: rgb(108, 226, 108) !important; line-height: 14px !important; border-right-width: 0px !important; border-right-style: initial !important; border-right-color: initial !important; "&gt; &lt;div class="alt" style="padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; background-color: rgb(255, 255, 255) !important; border-top-width: 0px !important; border-bottom-width: 0px !important; color: rgb(0, 0, 0) !important; border-right-width: 0px !important; border-left-width: 0px !important; border-style: initial !important; border-color: initial !important; border-style: initial !important; border-color: initial !important; width: 516px; "&gt;error: &lt;span class="string" style="padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; border-top-width: 1px !important; border-right-width: 1px !important; border-bottom-width: 1px !important; border-left-width: 1px !important; border-top-color: transparent !important; border-right-color: transparent !important; border-bottom-color: transparent !important; border-left-color: transparent !important; border-top-style: solid !important; border-right-style: solid !important; border-bottom-style: solid !important; border-left-style: solid !important; background-image: initial !important; background-repeat: initial !important; background-attachment: initial !important; -webkit-background-clip: initial !important; -webkit-background-origin: initial !important; background-color: transparent !important; color: red; background-position: initial initial !important; "&gt;&amp;#39;Access denied for user &amp;#39;&lt;/span&gt;&lt;span style="padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; border-top-width: 1px !important; border-right-width: 1px !important; border-bottom-width: 1px !important; border-left-width: 1px !important; border-top-color: transparent !important; border-right-color: transparent !important; border-bottom-color: transparent !important; border-left-color: transparent !important; border-top-style: solid !important; border-right-style: solid !important; border-bottom-style: solid !important; border-left-style: solid !important; background-image: initial !important; background-repeat: initial !important; background-attachment: initial !important; -webkit-background-clip: initial !important; -webkit-background-origin: initial !important; background-color: transparent !important; background-position: initial initial !important; "&gt;root&lt;/span&gt;&lt;span class="string" style="padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; border-top-width: 1px !important; border-right-width: 1px !important; border-bottom-width: 1px !important; border-left-width: 1px !important; border-top-color: transparent !important; border-right-color: transparent !important; border-bottom-color: transparent !important; border-left-color: transparent !important; border-top-style: solid !important; border-right-style: solid !important; border-bottom-style: solid !important; border-left-style: solid !important; background-image: initial !important; background-repeat: initial !important; background-attachment: initial !important; -webkit-background-clip: initial !important; -webkit-background-origin: initial !important; background-color: transparent !important; color: red; background-position: initial initial !important; "&gt;&amp;#39;@&amp;#39;&lt;/span&gt;&lt;span style="padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; border-top-width: 1px !important; border-right-width: 1px !important; border-bottom-width: 1px !important; border-left-width: 1px !important; border-top-color: transparent !important; border-right-color: transparent !important; border-bottom-color: transparent !important; border-left-color: transparent !important; border-top-style: solid !important; border-right-style: solid !important; border-bottom-style: solid !important; border-left-style: solid !important; background-image: initial !important; background-repeat: initial !important; background-attachment: initial !important; -webkit-background-clip: initial !important; -webkit-background-origin: initial !important; background-color: transparent !important; background-position: initial initial !important; "&gt;localhost&lt;/span&gt;&lt;span class="string" style="padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; border-top-width: 1px !important; border-right-width: 1px !important; border-bottom-width: 1px !important; border-left-width: 1px !important; border-top-color: transparent !important; border-right-color: transparent !important; border-bottom-color: transparent !important; border-left-color: transparent !important; border-top-style: solid !important; border-right-style: solid !important; border-bottom-style: solid !important; border-left-style: solid !important; background-image: initial !important; background-repeat: initial !important; background-attachment: initial !important; -webkit-background-clip: initial !important; -webkit-background-origin: initial !important; background-color: transparent !important; color: red; background-position: initial initial !important; "&gt;&amp;#39; (using password: NO)&amp;#39;&lt;/span&gt;&lt;span style="padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; border-top-width: 1px !important; border-right-width: 1px !important; border-bottom-width: 1px !important; border-left-width: 1px !important; border-top-color: transparent !important; border-right-color: transparent !important; border-bottom-color: transparent !important; border-left-color: transparent !important; border-top-style: solid !important; border-right-style: solid !important; border-bottom-style: solid !important; border-left-style: solid !important; background-image: initial !important; background-repeat: initial !important; background-attachment: initial !important; -webkit-background-clip: initial !important; -webkit-background-origin: initial !important; background-color: transparent !important; background-position: initial initial !important; "&gt; &lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/div&gt;&lt;p style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 1em; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; "&gt;Use your favorite editor such as vi as the root user  to create a file by the name of .my.cnf in /root/. Add the contents below to this file but of make sure to modify the username and password in the example below to include a MySQL username and password that has access to run "mysqladmin flush-logs".&lt;/p&gt;&lt;p style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 1em; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; "&gt;&lt;strong style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "&gt;New /root/.my.cnf File:&lt;/strong&gt;&lt;/p&gt;&lt;div class="dp-highlighter" style="padding-top: 1px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 18px; margin-right: 0px; margin-bottom: 18px; margin-left: 0px; font-family: Consolas, &amp;#39;Courier New&amp;#39;, Courier, mono; font-size: 12px; background-color: rgb(231, 229, 220); width: 475px; overflow-x: auto; overflow-y: hidden; "&gt;&lt;div class="bar" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 45px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "&gt;&lt;div class="tools" style="padding-top: 3px; padding-right: 0px; padding-bottom: 10px; padding-left: 10px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 9px/normal Verdana, Geneva, Arial, Helvetica, sans-serif; color: silver; background-color: rgb(248, 248, 248); border-left-width: 3px; border-left-style: solid; border-left-color: rgb(108, 226, 108); width: 417px; "&gt;&lt;a href="http://www.question-defense.com/2009/12/20/configure-logrotate-to-rotate-and-flush-mysql-logs-without-a-password#" onclick="dp.sh.Toolbar.Command(&amp;#39;ViewSource&amp;#39;,this);return false;" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 10px; margin-bottom: 0px; margin-left: 0px; text-decoration: none; color: rgb(160, 160, 160); font-weight: bold; font-size: 9px; "&gt;view plain&lt;/a&gt;&lt;a href="http://www.question-defense.com/2009/12/20/configure-logrotate-to-rotate-and-flush-mysql-logs-without-a-password#" onclick="dp.sh.Toolbar.Command(&amp;#39;CopyToClipboard&amp;#39;,this);return false;" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 10px; margin-bottom: 0px; margin-left: 0px; text-decoration: none; color: rgb(160, 160, 160); font-weight: bold; font-size: 9px; "&gt;copy to clipboard&lt;/a&gt;&lt;a href="http://www.question-defense.com/2009/12/20/configure-logrotate-to-rotate-and-flush-mysql-logs-without-a-password#" onclick="dp.sh.Toolbar.Command(&amp;#39;PrintSource&amp;#39;,this);return false;" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 10px; margin-bottom: 0px; margin-left: 0px; text-decoration: none; color: rgb(160, 160, 160); font-weight: bold; font-size: 9px; "&gt;print&lt;/a&gt;&lt;a href="http://www.question-defense.com/2009/12/20/configure-logrotate-to-rotate-and-flush-mysql-logs-without-a-password#" onclick="dp.sh.Toolbar.Command(&amp;#39;About&amp;#39;,this);return false;" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 10px; margin-bottom: 0px; margin-left: 0px; text-decoration: none; color: rgb(160, 160, 160); font-weight: bold; font-size: 9px; "&gt;?&lt;/a&gt;&lt;/div&gt;&lt;/div&gt;&lt;ol start="1" class="dp-bash" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 1px; margin-left: 45px; list-style-type: decimal-leading-zero; list-style-position: initial; list-style-image: initial; background-color: rgb(255, 255, 255); color: rgb(92, 92, 92); white-space: nowrap; "&gt;&lt;li class="alt" style="padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 10px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; background-color: rgb(255, 255, 255) !important; border-top-width: 0px !important; border-top-style: initial !important; border-top-color: initial !important; border-bottom-width: 0px !important; border-bottom-style: initial !important; border-bottom-color: initial !important; border-left-width: 3px !important; border-left-style: solid !important; border-left-color: rgb(108, 226, 108) !important; line-height: 14px !important; border-right-width: 0px !important; border-right-style: initial !important; border-right-color: initial !important; "&gt; &lt;div class="alt" style="padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; background-color: rgb(255, 255, 255) !important; border-top-width: 0px !important; border-bottom-width: 0px !important; color: rgb(0, 0, 0) !important; border-right-width: 0px !important; border-left-width: 0px !important; border-style: initial !important; border-color: initial !important; border-style: initial !important; border-color: initial !important; width: 417px; "&gt;&lt;span class="delim" style="padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; border-top-width: 1px !important; border-right-width: 1px !important; border-bottom-width: 1px !important; border-left-width: 1px !important; border-top-color: transparent !important; border-right-color: transparent !important; border-bottom-color: transparent !important; border-left-color: transparent !important; border-top-style: solid !important; border-right-style: solid !important; border-bottom-style: solid !important; border-left-style: solid !important; background-image: initial !important; background-repeat: initial !important; background-attachment: initial !important; -webkit-background-clip: initial !important; -webkit-background-origin: initial !important; background-color: transparent !important; font-weight: bold; background-position: initial initial !important; "&gt;[&lt;/span&gt;&lt;span style="padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; border-top-width: 1px !important; border-right-width: 1px !important; border-bottom-width: 1px !important; border-left-width: 1px !important; border-top-color: transparent !important; border-right-color: transparent !important; border-bottom-color: transparent !important; border-left-color: transparent !important; border-top-style: solid !important; border-right-style: solid !important; border-bottom-style: solid !important; border-left-style: solid !important; background-image: initial !important; background-repeat: initial !important; background-attachment: initial !important; -webkit-background-clip: initial !important; -webkit-background-origin: initial !important; background-color: transparent !important; background-position: initial initial !important; "&gt;mysqladmin&lt;/span&gt;&lt;span class="delim" style="padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; border-top-width: 1px !important; border-right-width: 1px !important; border-bottom-width: 1px !important; border-left-width: 1px !important; border-top-color: transparent !important; border-right-color: transparent !important; border-bottom-color: transparent !important; border-left-color: transparent !important; border-top-style: solid !important; border-right-style: solid !important; border-bottom-style: solid !important; border-left-style: solid !important; background-image: initial !important; background-repeat: initial !important; background-attachment: initial !important; -webkit-background-clip: initial !important; -webkit-background-origin: initial !important; background-color: transparent !important; font-weight: bold; background-position: initial initial !important; "&gt;]&lt;/span&gt;&lt;span style="padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; border-top-width: 1px !important; border-right-width: 1px !important; border-bottom-width: 1px !important; border-left-width: 1px !important; border-top-color: transparent !important; border-right-color: transparent !important; border-bottom-color: transparent !important; border-left-color: transparent !important; border-top-style: solid !important; border-right-style: solid !important; border-bottom-style: solid !important; border-left-style: solid !important; background-image: initial !important; background-repeat: initial !important; background-attachment: initial !important; -webkit-background-clip: initial !important; -webkit-background-origin: initial !important; background-color: transparent !important; background-position: initial initial !important; "&gt; &lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li class="" style="padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 10px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; border-left-width: 3px !important; border-left-style: solid !important; border-left-color: rgb(108, 226, 108) !important; background-color: rgb(248, 248, 248) !important; line-height: 14px !important; border-top-width: 0px !important; border-top-style: initial !important; border-top-color: initial !important; border-right-width: 0px !important; border-right-style: initial !important; border-right-color: initial !important; border-bottom-width: 0px !important; border-bottom-style: initial !important; border-bottom-color: initial !important; "&gt; &lt;div class="" style="padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; color: rgb(0, 0, 0) !important; background-color: rgb(248, 248, 248) !important; border-top-width: 0px !important; border-right-width: 0px !important; border-bottom-width: 0px !important; border-left-width: 0px !important; border-style: initial !important; border-color: initial !important; width: 417px; "&gt;user               = root &lt;/div&gt;&lt;/li&gt;&lt;li class="alt" style="padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 10px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; background-color: rgb(255, 255, 255) !important; border-top-width: 0px !important; border-top-style: initial !important; border-top-color: initial !important; border-bottom-width: 0px !important; border-bottom-style: initial !important; border-bottom-color: initial !important; border-left-width: 3px !important; border-left-style: solid !important; border-left-color: rgb(108, 226, 108) !important; line-height: 14px !important; border-right-width: 0px !important; border-right-style: initial !important; border-right-color: initial !important; "&gt; &lt;div class="alt" style="padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; background-color: rgb(255, 255, 255) !important; border-top-width: 0px !important; border-bottom-width: 0px !important; color: rgb(0, 0, 0) !important; border-right-width: 0px !important; border-left-width: 0px !important; border-style: initial !important; border-color: initial !important; border-style: initial !important; border-color: initial !important; width: 417px; "&gt;password        = changeme &lt;/div&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/div&gt;&lt;p style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 1em; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; "&gt;Make sure that you set the proper permissions for the above file once you have created it so that no other users on the server can read the file contents and find out what the MySQL root password is. To set the proper permissions use the below command.&lt;/p&gt;&lt;p style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 1em; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; "&gt;&lt;strong style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "&gt;Set Permissions On /root/.my.cnf:&lt;/strong&gt;&lt;/p&gt;&lt;div class="dp-highlighter" style="padding-top: 1px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 18px; margin-right: 0px; margin-bottom: 18px; margin-left: 0px; font-family: Consolas, &amp;#39;Courier New&amp;#39;, Courier, mono; font-size: 12px; background-color: rgb(231, 229, 220); width: 475px; overflow-x: auto; overflow-y: hidden; "&gt;&lt;div class="bar" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 45px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "&gt;&lt;div class="tools" style="padding-top: 3px; padding-right: 0px; padding-bottom: 10px; padding-left: 10px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 9px/normal Verdana, Geneva, Arial, Helvetica, sans-serif; color: silver; background-color: rgb(248, 248, 248); border-left-width: 3px; border-left-style: solid; border-left-color: rgb(108, 226, 108); width: 417px; "&gt;&lt;a href="http://www.question-defense.com/2009/12/20/configure-logrotate-to-rotate-and-flush-mysql-logs-without-a-password#" onclick="dp.sh.Toolbar.Command(&amp;#39;ViewSource&amp;#39;,this);return false;" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 10px; margin-bottom: 0px; margin-left: 0px; text-decoration: none; color: rgb(160, 160, 160); font-weight: bold; font-size: 9px; "&gt;view plain&lt;/a&gt;&lt;a href="http://www.question-defense.com/2009/12/20/configure-logrotate-to-rotate-and-flush-mysql-logs-without-a-password#" onclick="dp.sh.Toolbar.Command(&amp;#39;CopyToClipboard&amp;#39;,this);return false;" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 10px; margin-bottom: 0px; margin-left: 0px; text-decoration: none; color: rgb(160, 160, 160); font-weight: bold; font-size: 9px; "&gt;copy to clipboard&lt;/a&gt;&lt;a href="http://www.question-defense.com/2009/12/20/configure-logrotate-to-rotate-and-flush-mysql-logs-without-a-password#" onclick="dp.sh.Toolbar.Command(&amp;#39;PrintSource&amp;#39;,this);return false;" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 10px; margin-bottom: 0px; margin-left: 0px; text-decoration: none; color: rgb(160, 160, 160); font-weight: bold; font-size: 9px; "&gt;print&lt;/a&gt;&lt;a href="http://www.question-defense.com/2009/12/20/configure-logrotate-to-rotate-and-flush-mysql-logs-without-a-password#" onclick="dp.sh.Toolbar.Command(&amp;#39;About&amp;#39;,this);return false;" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 10px; margin-bottom: 0px; margin-left: 0px; text-decoration: none; color: rgb(160, 160, 160); font-weight: bold; font-size: 9px; "&gt;?&lt;/a&gt;&lt;/div&gt;&lt;/div&gt;&lt;ol start="1" class="dp-bash" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 1px; margin-left: 45px; list-style-type: decimal-leading-zero; list-style-position: initial; list-style-image: initial; background-color: rgb(255, 255, 255); color: rgb(92, 92, 92); white-space: nowrap; "&gt;&lt;li class="alt" style="padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 10px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; background-color: rgb(255, 255, 255) !important; border-top-width: 0px !important; border-top-style: initial !important; border-top-color: initial !important; border-bottom-width: 0px !important; border-bottom-style: initial !important; border-bottom-color: initial !important; border-left-width: 3px !important; border-left-style: solid !important; border-left-color: rgb(108, 226, 108) !important; line-height: 14px !important; border-right-width: 0px !important; border-right-style: initial !important; border-right-color: initial !important; "&gt; &lt;div class="alt" style="padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; background-color: rgb(255, 255, 255) !important; border-top-width: 0px !important; border-bottom-width: 0px !important; color: rgb(0, 0, 0) !important; border-right-width: 0px !important; border-left-width: 0px !important; border-style: initial !important; border-color: initial !important; border-style: initial !important; border-color: initial !important; width: 417px; "&gt;&lt;span class="delim" style="padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; border-top-width: 1px !important; border-right-width: 1px !important; border-bottom-width: 1px !important; border-left-width: 1px !important; border-top-color: transparent !important; border-right-color: transparent !important; border-bottom-color: transparent !important; border-left-color: transparent !important; border-top-style: solid !important; border-right-style: solid !important; border-bottom-style: solid !important; border-left-style: solid !important; background-image: initial !important; background-repeat: initial !important; background-attachment: initial !important; -webkit-background-clip: initial !important; -webkit-background-origin: initial !important; background-color: transparent !important; font-weight: bold; background-position: initial initial !important; "&gt;[&lt;/span&gt;&lt;span style="padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; border-top-width: 1px !important; border-right-width: 1px !important; border-bottom-width: 1px !important; border-left-width: 1px !important; border-top-color: transparent !important; border-right-color: transparent !important; border-bottom-color: transparent !important; border-left-color: transparent !important; border-top-style: solid !important; border-right-style: solid !important; border-bottom-style: solid !important; border-left-style: solid !important; background-image: initial !important; background-repeat: initial !important; background-attachment: initial !important; -webkit-background-clip: initial !important; -webkit-background-origin: initial !important; background-color: transparent !important; background-position: initial initial !important; "&gt;root@dev ~&lt;/span&gt;&lt;span class="delim" style="padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; border-top-width: 1px !important; border-right-width: 1px !important; border-bottom-width: 1px !important; border-left-width: 1px !important; border-top-color: transparent !important; border-right-color: transparent !important; border-bottom-color: transparent !important; border-left-color: transparent !important; border-top-style: solid !important; border-right-style: solid !important; border-bottom-style: solid !important; border-left-style: solid !important; background-image: initial !important; background-repeat: initial !important; background-attachment: initial !important; -webkit-background-clip: initial !important; -webkit-background-origin: initial !important; background-color: transparent !important; font-weight: bold; background-position: initial initial !important; "&gt;]&lt;/span&gt;&lt;span class="comment" style="padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; border-top-width: 1px !important; border-right-width: 1px !important; border-bottom-width: 1px !important; border-left-width: 1px !important; border-top-color: transparent !important; border-right-color: transparent !important; border-bottom-color: transparent !important; border-left-color: transparent !important; border-top-style: solid !important; border-right-style: solid !important; border-bottom-style: solid !important; border-left-style: solid !important; background-image: initial !important; background-repeat: initial !important; background-attachment: initial !important; -webkit-background-clip: initial !important; -webkit-background-origin: initial !important; background-color: transparent !important; color: gray; background-position: initial initial !important; "&gt;# chmod 600 /root/.my.cnf&lt;/span&gt;&lt;span style="padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; border-top-width: 1px !important; border-right-width: 1px !important; border-bottom-width: 1px !important; border-left-width: 1px !important; border-top-color: transparent !important; border-right-color: transparent !important; border-bottom-color: transparent !important; border-left-color: transparent !important; border-top-style: solid !important; border-right-style: solid !important; border-bottom-style: solid !important; border-left-style: solid !important; background-image: initial !important; background-repeat: initial !important; background-attachment: initial !important; -webkit-background-clip: initial !important; -webkit-background-origin: initial !important; background-color: transparent !important; background-position: initial initial !important; "&gt; &lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/div&gt;&lt;p style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 1em; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; "&gt;Now you can run the "mysqladmin flush-logs" command as the root user without having to enter a username or password and without receiving an error.&lt;/p&gt;&lt;/li&gt;&lt;li style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 3px; margin-right: 0px; margin-bottom: 4px; margin-left: 5px; "&gt;&lt;strong style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "&gt;Add Logrotate MySQL Configuration File: &lt;/strong&gt;Now add the below configuration contents to a new file named "mysql" in the "/etc/logrotate.d/" directory.&lt;p style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 1em; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; "&gt;&lt;strong style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "&gt;The mysql Logrotate Configuration File Contents:&lt;/strong&gt;&lt;/p&gt;&lt;div class="dp-highlighter" style="padding-top: 1px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 18px; margin-right: 0px; margin-bottom: 18px; margin-left: 0px; font-family: Consolas, &amp;#39;Courier New&amp;#39;, Courier, mono; font-size: 12px; background-color: rgb(231, 229, 220); width: 475px; overflow-x: auto; overflow-y: hidden; "&gt;&lt;div class="bar" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 45px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "&gt;&lt;div class="tools" style="padding-top: 3px; padding-right: 0px; padding-bottom: 10px; padding-left: 10px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 9px/normal Verdana, Geneva, Arial, Helvetica, sans-serif; color: silver; background-color: rgb(248, 248, 248); border-left-width: 3px; border-left-style: solid; border-left-color: rgb(108, 226, 108); width: 417px; "&gt;&lt;a href="http://www.question-defense.com/2009/12/20/configure-logrotate-to-rotate-and-flush-mysql-logs-without-a-password#" onclick="dp.sh.Toolbar.Command(&amp;#39;ViewSource&amp;#39;,this);return false;" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 10px; margin-bottom: 0px; margin-left: 0px; text-decoration: none; color: rgb(160, 160, 160); font-weight: bold; font-size: 9px; "&gt;view plain&lt;/a&gt;&lt;a href="http://www.question-defense.com/2009/12/20/configure-logrotate-to-rotate-and-flush-mysql-logs-without-a-password#" onclick="dp.sh.Toolbar.Command(&amp;#39;CopyToClipboard&amp;#39;,this);return false;" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 10px; margin-bottom: 0px; margin-left: 0px; text-decoration: none; color: rgb(160, 160, 160); font-weight: bold; font-size: 9px; "&gt;copy to clipboard&lt;/a&gt;&lt;a href="http://www.question-defense.com/2009/12/20/configure-logrotate-to-rotate-and-flush-mysql-logs-without-a-password#" onclick="dp.sh.Toolbar.Command(&amp;#39;PrintSource&amp;#39;,this);return false;" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 10px; margin-bottom: 0px; margin-left: 0px; text-decoration: none; color: rgb(160, 160, 160); font-weight: bold; font-size: 9px; "&gt;print&lt;/a&gt;&lt;a href="http://www.question-defense.com/2009/12/20/configure-logrotate-to-rotate-and-flush-mysql-logs-without-a-password#" onclick="dp.sh.Toolbar.Command(&amp;#39;About&amp;#39;,this);return false;" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 10px; margin-bottom: 0px; margin-left: 0px; text-decoration: none; color: rgb(160, 160, 160); font-weight: bold; font-size: 9px; "&gt;?&lt;/a&gt;&lt;/div&gt;&lt;/div&gt;&lt;ol start="1" class="dp-bash" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 1px; margin-left: 45px; list-style-type: decimal-leading-zero; list-style-position: initial; list-style-image: initial; background-color: rgb(255, 255, 255); color: rgb(92, 92, 92); white-space: nowrap; "&gt;&lt;li class="alt" style="padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 10px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; background-color: rgb(255, 255, 255) !important; border-top-width: 0px !important; border-top-style: initial !important; border-top-color: initial !important; border-bottom-width: 0px !important; border-bottom-style: initial !important; border-bottom-color: initial !important; border-left-width: 3px !important; border-left-style: solid !important; border-left-color: rgb(108, 226, 108) !important; line-height: 14px !important; border-right-width: 0px !important; border-right-style: initial !important; border-right-color: initial !important; "&gt; &lt;div class="alt" style="padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; background-color: rgb(255, 255, 255) !important; border-top-width: 0px !important; border-bottom-width: 0px !important; color: rgb(0, 0, 0) !important; border-right-width: 0px !important; border-left-width: 0px !important; border-style: initial !important; border-color: initial !important; border-style: initial !important; border-color: initial !important; width: 417px; "&gt;&lt;span style="padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; border-top-width: 1px !important; border-right-width: 1px !important; border-bottom-width: 1px !important; border-left-width: 1px !important; border-top-color: transparent !important; border-right-color: transparent !important; border-bottom-color: transparent !important; border-left-color: transparent !important; border-top-style: solid !important; border-right-style: solid !important; border-bottom-style: solid !important; border-left-style: solid !important; background-image: initial !important; background-repeat: initial !important; background-attachment: initial !important; -webkit-background-clip: initial !important; -webkit-background-origin: initial !important; background-color: transparent !important; background-position: initial initial !important; "&gt;/var/log/mysql/*.log &lt;/span&gt;&lt;span class="delim" style="padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; border-top-width: 1px !important; border-right-width: 1px !important; border-bottom-width: 1px !important; border-left-width: 1px !important; border-top-color: transparent !important; border-right-color: transparent !important; border-bottom-color: transparent !important; border-left-color: transparent !important; border-top-style: solid !important; border-right-style: solid !important; border-bottom-style: solid !important; border-left-style: solid !important; background-image: initial !important; background-repeat: initial !important; background-attachment: initial !important; -webkit-background-clip: initial !important; -webkit-background-origin: initial !important; background-color: transparent !important; font-weight: bold; background-position: initial initial !important; "&gt;{&lt;/span&gt;&lt;span style="padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; border-top-width: 1px !important; border-right-width: 1px !important; border-bottom-width: 1px !important; border-left-width: 1px !important; border-top-color: transparent !important; border-right-color: transparent !important; border-bottom-color: transparent !important; border-left-color: transparent !important; border-top-style: solid !important; border-right-style: solid !important; border-bottom-style: solid !important; border-left-style: solid !important; background-image: initial !important; background-repeat: initial !important; background-attachment: initial !important; -webkit-background-clip: initial !important; -webkit-background-origin: initial !important; background-color: transparent !important; background-position: initial initial !important; "&gt; &lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li class="" style="padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 10px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; border-left-width: 3px !important; border-left-style: solid !important; border-left-color: rgb(108, 226, 108) !important; background-color: rgb(248, 248, 248) !important; line-height: 14px !important; border-top-width: 0px !important; border-top-style: initial !important; border-top-color: initial !important; border-right-width: 0px !important; border-right-style: initial !important; border-right-color: initial !important; border-bottom-width: 0px !important; border-bottom-style: initial !important; border-bottom-color: initial !important; "&gt; &lt;div class="" style="padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; color: rgb(0, 0, 0) !important; background-color: rgb(248, 248, 248) !important; border-top-width: 0px !important; border-right-width: 0px !important; border-bottom-width: 0px !important; border-left-width: 0px !important; border-style: initial !important; border-color: initial !important; width: 417px; "&gt;create 644 mysql mysql &lt;/div&gt;&lt;/li&gt;&lt;li class="alt" style="padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 10px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; background-color: rgb(255, 255, 255) !important; border-top-width: 0px !important; border-top-style: initial !important; border-top-color: initial !important; border-bottom-width: 0px !important; border-bottom-style: initial !important; border-bottom-color: initial !important; border-left-width: 3px !important; border-left-style: solid !important; border-left-color: rgb(108, 226, 108) !important; line-height: 14px !important; border-right-width: 0px !important; border-right-style: initial !important; border-right-color: initial !important; "&gt; &lt;div class="alt" style="padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; background-color: rgb(255, 255, 255) !important; border-top-width: 0px !important; border-bottom-width: 0px !important; color: rgb(0, 0, 0) !important; border-right-width: 0px !important; border-left-width: 0px !important; border-style: initial !important; border-color: initial !important; border-style: initial !important; border-color: initial !important; width: 417px; "&gt;notifempty &lt;/div&gt;&lt;/li&gt;&lt;li class="" style="padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 10px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; border-left-width: 3px !important; border-left-style: solid !important; border-left-color: rgb(108, 226, 108) !important; background-color: rgb(248, 248, 248) !important; line-height: 14px !important; border-top-width: 0px !important; border-top-style: initial !important; border-top-color: initial !important; border-right-width: 0px !important; border-right-style: initial !important; border-right-color: initial !important; border-bottom-width: 0px !important; border-bottom-style: initial !important; border-bottom-color: initial !important; "&gt; &lt;div class="" style="padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; color: rgb(0, 0, 0) !important; background-color: rgb(248, 248, 248) !important; border-top-width: 0px !important; border-right-width: 0px !important; border-bottom-width: 0px !important; border-left-width: 0px !important; border-style: initial !important; border-color: initial !important; width: 417px; "&gt;daily &lt;/div&gt;&lt;/li&gt;&lt;li class="alt" style="padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 10px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; background-color: rgb(255, 255, 255) !important; border-top-width: 0px !important; border-top-style: initial !important; border-top-color: initial !important; border-bottom-width: 0px !important; border-bottom-style: initial !important; border-bottom-color: initial !important; border-left-width: 3px !important; border-left-style: solid !important; border-left-color: rgb(108, 226, 108) !important; line-height: 14px !important; border-right-width: 0px !important; border-right-style: initial !important; border-right-color: initial !important; "&gt; &lt;div class="alt" style="padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; background-color: rgb(255, 255, 255) !important; border-top-width: 0px !important; border-bottom-width: 0px !important; color: rgb(0, 0, 0) !important; border-right-width: 0px !important; border-left-width: 0px !important; border-style: initial !important; border-color: initial !important; border-style: initial !important; border-color: initial !important; width: 417px; "&gt;rotate 5 &lt;/div&gt;&lt;/li&gt;&lt;li class="" style="padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 10px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; border-left-width: 3px !important; border-left-style: solid !important; border-left-color: rgb(108, 226, 108) !important; background-color: rgb(248, 248, 248) !important; line-height: 14px !important; border-top-width: 0px !important; border-top-style: initial !important; border-top-color: initial !important; border-right-width: 0px !important; border-right-style: initial !important; border-right-color: initial !important; border-bottom-width: 0px !important; border-bottom-style: initial !important; border-bottom-color: initial !important; "&gt; &lt;div class="" style="padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; color: rgb(0, 0, 0) !important; background-color: rgb(248, 248, 248) !important; border-top-width: 0px !important; border-right-width: 0px !important; border-bottom-width: 0px !important; border-left-width: 0px !important; border-style: initial !important; border-color: initial !important; width: 417px; "&gt;missingok &lt;/div&gt;&lt;/li&gt;&lt;li class="alt" style="padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 10px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; background-color: rgb(255, 255, 255) !important; border-top-width: 0px !important; border-top-style: initial !important; border-top-color: initial !important; border-bottom-width: 0px !important; border-bottom-style: initial !important; border-bottom-color: initial !important; border-left-width: 3px !important; border-left-style: solid !important; border-left-color: rgb(108, 226, 108) !important; line-height: 14px !important; border-right-width: 0px !important; border-right-style: initial !important; border-right-color: initial !important; "&gt; &lt;div class="alt" style="padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; background-color: rgb(255, 255, 255) !important; border-top-width: 0px !important; border-bottom-width: 0px !important; color: rgb(0, 0, 0) !important; border-right-width: 0px !important; border-left-width: 0px !important; border-style: initial !important; border-color: initial !important; border-style: initial !important; border-color: initial !important; width: 417px; "&gt;nocompress &lt;/div&gt;&lt;/li&gt;&lt;li class="" style="padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 10px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; border-left-width: 3px !important; border-left-style: solid !important; border-left-color: rgb(108, 226, 108) !important; background-color: rgb(248, 248, 248) !important; line-height: 14px !important; border-top-width: 0px !important; border-top-style: initial !important; border-top-color: initial !important; border-right-width: 0px !important; border-right-style: initial !important; border-right-color: initial !important; border-bottom-width: 0px !important; border-bottom-style: initial !important; border-bottom-color: initial !important; "&gt; &lt;div class="" style="padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; color: rgb(0, 0, 0) !important; background-color: rgb(248, 248, 248) !important; border-top-width: 0px !important; border-right-width: 0px !important; border-bottom-width: 0px !important; border-left-width: 0px !important; border-style: initial !important; border-color: initial !important; width: 417px; "&gt;postrotate &lt;/div&gt;&lt;/li&gt;&lt;li class="alt" style="padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 10px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; background-color: rgb(255, 255, 255) !important; border-top-width: 0px !important; border-top-style: initial !important; border-top-color: initial !important; border-bottom-width: 0px !important; border-bottom-style: initial !important; border-bottom-color: initial !important; border-left-width: 3px !important; border-left-style: solid !important; border-left-color: rgb(108, 226, 108) !important; line-height: 14px !important; border-right-width: 0px !important; border-right-style: initial !important; border-right-color: initial !important; "&gt; &lt;div class="alt" style="padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; background-color: rgb(255, 255, 255) !important; border-top-width: 0px !important; border-bottom-width: 0px !important; color: rgb(0, 0, 0) !important; border-right-width: 0px !important; border-left-width: 0px !important; border-style: initial !important; border-color: initial !important; border-style: initial !important; border-color: initial !important; width: 417px; "&gt;&lt;span class="comment" style="padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; border-top-width: 1px !important; border-right-width: 1px !important; border-bottom-width: 1px !important; border-left-width: 1px !important; border-top-color: transparent !important; border-right-color: transparent !important; border-bottom-color: transparent !important; border-left-color: transparent !important; border-top-style: solid !important; border-right-style: solid !important; border-bottom-style: solid !important; border-left-style: solid !important; background-image: initial !important; background-repeat: initial !important; background-attachment: initial !important; -webkit-background-clip: initial !important; -webkit-background-origin: initial !important; background-color: transparent !important; color: gray; background-position: initial initial !important; "&gt;# run if mysqld is running&lt;/span&gt;&lt;span style="padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; border-top-width: 1px !important; border-right-width: 1px !important; border-bottom-width: 1px !important; border-left-width: 1px !important; border-top-color: transparent !important; border-right-color: transparent !important; border-bottom-color: transparent !important; border-left-color: transparent !important; border-top-style: solid !important; border-right-style: solid !important; border-bottom-style: solid !important; border-left-style: solid !important; background-image: initial !important; background-repeat: initial !important; background-attachment: initial !important; -webkit-background-clip: initial !important; -webkit-background-origin: initial !important; background-color: transparent !important; background-position: initial initial !important; "&gt; &lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li class="" style="padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 10px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; border-left-width: 3px !important; border-left-style: solid !important; border-left-color: rgb(108, 226, 108) !important; background-color: rgb(248, 248, 248) !important; line-height: 14px !important; border-top-width: 0px !important; border-top-style: initial !important; border-top-color: initial !important; border-right-width: 0px !important; border-right-style: initial !important; border-right-color: initial !important; border-bottom-width: 0px !important; border-bottom-style: initial !important; border-bottom-color: initial !important; "&gt; &lt;div class="" style="padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; color: rgb(0, 0, 0) !important; background-color: rgb(248, 248, 248) !important; border-top-width: 0px !important; border-right-width: 0px !important; border-bottom-width: 0px !important; border-left-width: 0px !important; border-style: initial !important; border-color: initial !important; width: 417px; "&gt;&lt;span class="keyword" style="padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; border-top-width: 1px !important; border-right-width: 1px !important; border-bottom-width: 1px !important; border-left-width: 1px !important; border-top-color: transparent !important; border-right-color: transparent !important; border-bottom-color: transparent !important; border-left-color: transparent !important; border-top-style: solid !important; border-right-style: solid !important; border-bottom-style: solid !important; border-left-style: solid !important; background-image: initial !important; background-repeat: initial !important; background-attachment: initial !important; -webkit-background-clip: initial !important; -webkit-background-origin: initial !important; background-color: transparent !important; color: rgb(0, 102, 153); font-weight: bold; background-position: initial initial !important; "&gt;if&lt;/span&gt;&lt;span style="padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; border-top-width: 1px !important; border-right-width: 1px !important; border-bottom-width: 1px !important; border-left-width: 1px !important; border-top-color: transparent !important; border-right-color: transparent !important; border-bottom-color: transparent !important; border-left-color: transparent !important; border-top-style: solid !important; border-right-style: solid !important; border-bottom-style: solid !important; border-left-style: solid !important; background-image: initial !important; background-repeat: initial !important; background-attachment: initial !important; -webkit-background-clip: initial !important; -webkit-background-origin: initial !important; background-color: transparent !important; background-position: initial initial !important; "&gt; &lt;/span&gt;&lt;span class="builtin" style="padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; border-top-width: 1px !important; border-right-width: 1px !important; border-bottom-width: 1px !important; border-left-width: 1px !important; border-top-color: transparent !important; border-right-color: transparent !important; border-bottom-color: transparent !important; border-left-color: transparent !important; border-top-style: solid !important; border-right-style: solid !important; border-bottom-style: solid !important; border-left-style: solid !important; background-image: initial !important; background-repeat: initial !important; background-attachment: initial !important; -webkit-background-clip: initial !important; -webkit-background-origin: initial !important; background-color: transparent !important; color: maroon; font-weight: bold; background-position: initial initial !important; "&gt;test&lt;/span&gt;&lt;span class="flag" style="padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; border-top-width: 1px !important; border-right-width: 1px !important; border-bottom-width: 1px !important; border-left-width: 1px !important; border-top-color: transparent !important; border-right-color: transparent !important; border-bottom-color: transparent !important; border-left-color: transparent !important; border-top-style: solid !important; border-right-style: solid !important; border-bottom-style: solid !important; border-left-style: solid !important; background-image: initial !important; background-repeat: initial !important; background-attachment: initial !important; -webkit-background-clip: initial !important; -webkit-background-origin: initial !important; background-color: transparent !important; color: green; background-position: initial initial !important; "&gt; -n&lt;/span&gt;&lt;span style="padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; border-top-width: 1px !important; border-right-width: 1px !important; border-bottom-width: 1px !important; border-left-width: 1px !important; border-top-color: transparent !important; border-right-color: transparent !important; border-bottom-color: transparent !important; border-left-color: transparent !important; border-top-style: solid !important; border-right-style: solid !important; border-bottom-style: solid !important; border-left-style: solid !important; background-image: initial !important; background-repeat: initial !important; background-attachment: initial !important; -webkit-background-clip: initial !important; -webkit-background-origin: initial !important; background-color: transparent !important; background-position: initial initial !important; "&gt; &lt;/span&gt;&lt;span class="string" style="padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; border-top-width: 1px !important; border-right-width: 1px !important; border-bottom-width: 1px !important; border-left-width: 1px !important; border-top-color: transparent !important; border-right-color: transparent !important; border-bottom-color: transparent !important; border-left-color: transparent !important; border-top-style: solid !important; border-right-style: solid !important; border-bottom-style: solid !important; border-left-style: solid !important; background-image: initial !important; background-repeat: initial !important; background-attachment: initial !important; -webkit-background-clip: initial !important; -webkit-background-origin: initial !important; background-color: transparent !important; color: red; background-position: initial initial !important; "&gt;&amp;quot;`ps acx|grep mysqld`&amp;quot;&lt;/span&gt;&lt;span style="padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; border-top-width: 1px !important; border-right-width: 1px !important; border-bottom-width: 1px !important; border-left-width: 1px !important; border-top-color: transparent !important; border-right-color: transparent !important; border-bottom-color: transparent !important; border-left-color: transparent !important; border-top-style: solid !important; border-right-style: solid !important; border-bottom-style: solid !important; border-left-style: solid !important; background-image: initial !important; background-repeat: initial !important; background-attachment: initial !important; -webkit-background-clip: initial !important; -webkit-background-origin: initial !important; background-color: transparent !important; background-position: initial initial !important; "&gt;; &lt;/span&gt;&lt;span class="keyword" style="padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; border-top-width: 1px !important; border-right-width: 1px !important; border-bottom-width: 1px !important; border-left-width: 1px !important; border-top-color: transparent !important; border-right-color: transparent !important; border-bottom-color: transparent !important; border-left-color: transparent !important; border-top-style: solid !important; border-right-style: solid !important; border-bottom-style: solid !important; border-left-style: solid !important; background-image: initial !important; background-repeat: initial !important; background-attachment: initial !important; -webkit-background-clip: initial !important; -webkit-background-origin: initial !important; background-color: transparent !important; color: rgb(0, 102, 153); font-weight: bold; background-position: initial initial !important; "&gt;then&lt;/span&gt;&lt;span style="padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; border-top-width: 1px !important; border-right-width: 1px !important; border-bottom-width: 1px !important; border-left-width: 1px !important; border-top-color: transparent !important; border-right-color: transparent !important; border-bottom-color: transparent !important; border-left-color: transparent !important; border-top-style: solid !important; border-right-style: solid !important; border-bottom-style: solid !important; border-left-style: solid !important; background-image: initial !important; background-repeat: initial !important; background-attachment: initial !important; -webkit-background-clip: initial !important; -webkit-background-origin: initial !important; background-color: transparent !important; background-position: initial initial !important; "&gt; &lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li class="alt" style="padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 10px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; background-color: rgb(255, 255, 255) !important; border-top-width: 0px !important; border-top-style: initial !important; border-top-color: initial !important; border-bottom-width: 0px !important; border-bottom-style: initial !important; border-bottom-color: initial !important; border-left-width: 3px !important; border-left-style: solid !important; border-left-color: rgb(108, 226, 108) !important; line-height: 14px !important; border-right-width: 0px !important; border-right-style: initial !important; border-right-color: initial !important; "&gt; &lt;div class="alt" style="padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; background-color: rgb(255, 255, 255) !important; border-top-width: 0px !important; border-bottom-width: 0px !important; color: rgb(0, 0, 0) !important; border-right-width: 0px !important; border-left-width: 0px !important; border-style: initial !important; border-color: initial !important; border-style: initial !important; border-color: initial !important; width: 417px; "&gt;/usr/bin/mysqladmin flush-logs &lt;/div&gt;&lt;/li&gt;&lt;li class="" style="padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 10px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; border-left-width: 3px !important; border-left-style: solid !important; border-left-color: rgb(108, 226, 108) !important; background-color: rgb(248, 248, 248) !important; line-height: 14px !important; border-top-width: 0px !important; border-top-style: initial !important; border-top-color: initial !important; border-right-width: 0px !important; border-right-style: initial !important; border-right-color: initial !important; border-bottom-width: 0px !important; border-bottom-style: initial !important; border-bottom-color: initial !important; "&gt; &lt;div class="" style="padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; color: rgb(0, 0, 0) !important; background-color: rgb(248, 248, 248) !important; border-top-width: 0px !important; border-right-width: 0px !important; border-bottom-width: 0px !important; border-left-width: 0px !important; border-style: initial !important; border-color: initial !important; width: 417px; "&gt;&lt;span class="keyword" style="padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; border-top-width: 1px !important; border-right-width: 1px !important; border-bottom-width: 1px !important; border-left-width: 1px !important; border-top-color: transparent !important; border-right-color: transparent !important; border-bottom-color: transparent !important; border-left-color: transparent !important; border-top-style: solid !important; border-right-style: solid !important; border-bottom-style: solid !important; border-left-style: solid !important; background-image: initial !important; background-repeat: initial !important; background-attachment: initial !important; -webkit-background-clip: initial !important; -webkit-background-origin: initial !important; background-color: transparent !important; color: rgb(0, 102, 153); font-weight: bold; background-position: initial initial !important; "&gt;fi&lt;/span&gt;&lt;span style="padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; border-top-width: 1px !important; border-right-width: 1px !important; border-bottom-width: 1px !important; border-left-width: 1px !important; border-top-color: transparent !important; border-right-color: transparent !important; border-bottom-color: transparent !important; border-left-color: transparent !important; border-top-style: solid !important; border-right-style: solid !important; border-bottom-style: solid !important; border-left-style: solid !important; background-image: initial !important; background-repeat: initial !important; background-attachment: initial !important; -webkit-background-clip: initial !important; -webkit-background-origin: initial !important; background-color: transparent !important; background-position: initial initial !important; "&gt; &lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li class="alt" style="padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 10px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; background-color: rgb(255, 255, 255) !important; border-top-width: 0px !important; border-top-style: initial !important; border-top-color: initial !important; border-bottom-width: 0px !important; border-bottom-style: initial !important; border-bottom-color: initial !important; border-left-width: 3px !important; border-left-style: solid !important; border-left-color: rgb(108, 226, 108) !important; line-height: 14px !important; border-right-width: 0px !important; border-right-style: initial !important; border-right-color: initial !important; "&gt; &lt;div class="alt" style="padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; background-color: rgb(255, 255, 255) !important; border-top-width: 0px !important; border-bottom-width: 0px !important; color: rgb(0, 0, 0) !important; border-right-width: 0px !important; border-left-width: 0px !important; border-style: initial !important; border-color: initial !important; border-style: initial !important; border-color: initial !important; width: 417px; "&gt;endscript &lt;/div&gt;&lt;/li&gt;&lt;li class="" style="padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 10px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; border-left-width: 3px !important; border-left-style: solid !important; border-left-color: rgb(108, 226, 108) !important; background-color: rgb(248, 248, 248) !important; line-height: 14px !important; border-top-width: 0px !important; border-top-style: initial !important; border-top-color: initial !important; border-right-width: 0px !important; border-right-style: initial !important; border-right-color: initial !important; border-bottom-width: 0px !important; border-bottom-style: initial !important; border-bottom-color: initial !important; "&gt; &lt;div class="" style="padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; color: rgb(0, 0, 0) !important; background-color: rgb(248, 248, 248) !important; border-top-width: 0px !important; border-right-width: 0px !important; border-bottom-width: 0px !important; border-left-width: 0px !important; border-style: initial !important; border-color: initial !important; width: 417px; "&gt;&lt;span class="delim" style="padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; border-top-width: 1px !important; border-right-width: 1px !important; border-bottom-width: 1px !important; border-left-width: 1px !important; border-top-color: transparent !important; border-right-color: transparent !important; border-bottom-color: transparent !important; border-left-color: transparent !important; border-top-style: solid !important; border-right-style: solid !important; border-bottom-style: solid !important; border-left-style: solid !important; background-image: initial !important; background-repeat: initial !important; background-attachment: initial !important; -webkit-background-clip: initial !important; -webkit-background-origin: initial !important; background-color: transparent !important; font-weight: bold; background-position: initial initial !important; "&gt;}&lt;/span&gt;&lt;span style="padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; border-top-width: 1px !important; border-right-width: 1px !important; border-bottom-width: 1px !important; border-left-width: 1px !important; border-top-color: transparent !important; border-right-color: transparent !important; border-bottom-color: transparent !important; border-left-color: transparent !important; border-top-style: solid !important; border-right-style: solid !important; border-bottom-style: solid !important; border-left-style: solid !important; background-image: initial !important; background-repeat: initial !important; background-attachment: initial !important; -webkit-background-clip: initial !important; -webkit-background-origin: initial !important; background-color: transparent !important; background-position: initial initial !important; "&gt; &lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;/ol&gt;&lt;div style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "&gt;&lt;/div&gt;&lt;/div&gt;&lt;p style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 1em; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; "&gt;The basis of the file is that it will rotate any files in the MySQL directory that end with ".log". Once the files are rotated the new files will be generated by the mysql user with permissions of 644. The files will not be rotated by Logrotate unless they have contents. The files will be rotated daily and five copies will be retained. Logrotate is not going to panic if there is a file missing and when all is said and done the root user will run "mysqladmin flush-logs" to flush out the log files so logs will continue to write to the proper files.&lt;/p&gt;&lt;/li&gt;&lt;/ol&gt;&lt;p style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 1em; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; "&gt;You are now able to troubleshoot MySQL, web applications, and many other things much easier. Remember to keep an eye on mysql.log to make sure that the file does grow out of hand. Also be sure to check back on the log files after a couple days just to make sure that logrotate is functioning properly. If you don't have logrotate installed and configured yet you can check out the manpage &lt;a title="Logrotate Manpage" href="http://www.question-defense.com/documentation/linux-manpages/logrotate" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; text-decoration: none; color: rgb(46, 143, 198); font-weight: bold; "&gt;here&lt;/a&gt; on QD.&lt;/p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5866936448448261654-504325897721322250?l=moonbingbing.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://moonbingbing.blogspot.com/feeds/504325897721322250/comments/default' title='帖子评论'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5866936448448261654&amp;postID=504325897721322250' title='2 条评论'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5866936448448261654/posts/default/504325897721322250'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5866936448448261654/posts/default/504325897721322250'/><link rel='alternate' type='text/html' href='http://moonbingbing.blogspot.com/2009/12/mysql.html' title='MySQL慢查询日志自动分割'/><author><name>wayne</name><uri>http://www.blogger.com/profile/08537956174550037355</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5866936448448261654.post-2583609596780227408</id><published>2009-11-25T16:57:00.001+08:00</published><updated>2009-11-25T16:57:12.664+08:00</updated><title type='text'>[招聘]珠海金山招聘python开发工程师</title><content type='html'>部门发展的比较快，需要两名靠谱的同学加盟:)&lt;div&gt;职位要求为：&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial, sans-serif; font-size: 13px; border-collapse: collapse; "&gt;&lt;div&gt;&lt;blockquote class="gmail_quote" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex; "&gt; &lt;span style="font-family: Tahoma, Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 12px; line-height: 19px; "&gt;&lt;br&gt;职位：python开发工程师 &lt;br&gt;部门：金山互联网安全公司 安全技术研发中心 &lt;br&gt;工作地点：珠海 &lt;br&gt;&lt;br&gt;职位描述： &lt;br&gt;你是毒霸后台系统的开发者和维护者，为反病毒提供有力支持 &lt;br&gt; &lt;br&gt;职位要求: &lt;br&gt;a)基础要求 &lt;br&gt;0.良好的代码风格，较强的代码阅读理解能力和调试能力 &lt;br&gt;1.熟悉Linux系统使用 &lt;br&gt;2.熟练使用一种编程语言 &lt;br&gt;3.对数据敏感 &lt;br&gt;4.有较强的发现问题、分析问题与解决问题的能力 &lt;br&gt;5.善于沟通和表达，有良好的团队合作意识 &lt;br&gt;&lt;br&gt;b)符合以下者优先 &lt;br&gt;0.熟悉memcached,lighttpd,nginx,django,mysql,sqlite,postgresql中的2种以上 &lt;br&gt; 1.有Nginx和MySQL调优经验 &lt;br&gt;2.熟悉Python程序设计，了解常用库的使用 &lt;br&gt;3.了解存储系统 &lt;/span&gt;&lt;/blockquote&gt;&lt;/div&gt;&lt;/span&gt; &lt;div&gt;&lt;br&gt;&lt;/div&gt;&lt;div&gt;有意者直接联系我哈 moonbingbing at &lt;a href="http://gmail.com"&gt;gmail.com&lt;/a&gt;&lt;/div&gt;&lt;/div&gt; &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5866936448448261654-2583609596780227408?l=moonbingbing.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://moonbingbing.blogspot.com/feeds/2583609596780227408/comments/default' title='帖子评论'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5866936448448261654&amp;postID=2583609596780227408' title='0 条评论'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5866936448448261654/posts/default/2583609596780227408'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5866936448448261654/posts/default/2583609596780227408'/><link rel='alternate' type='text/html' href='http://moonbingbing.blogspot.com/2009/11/python.html' title='[招聘]珠海金山招聘python开发工程师'/><author><name>wayne</name><uri>http://www.blogger.com/profile/08537956174550037355</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5866936448448261654.post-5534216124193709769</id><published>2009-11-22T11:51:00.002+08:00</published><updated>2010-04-12T10:41:31.921+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='安全'/><title type='text'>安全行业最关键的半年</title><content type='html'>    一个多月前，360引导用户卸载毒霸的时候，就非常明确的感觉到360要对国内的传统杀软厂商下手了。&lt;div&gt;    当时觉得360需要半年左右的时间，来达到国内杀软第一的位置。现在看来，用不了那么久，不到两个月，就有接近2700w的用户量，比毒霸耕耘十年的市场还大。年前，360就会超过瑞星，成为中国最大的杀软厂商（企业市场还不会有啥变化）。&lt;/div&gt;&lt;div&gt;    当360两三年后，上市融资成功，也会成为腾讯、阿里巴巴这样的巨无霸。加上360安全卫士和360安全浏览器，其他安全厂商能喝口汤都不大容易。&lt;/div&gt;&lt;div&gt;    瑞星现在还有最大的客户端优势，还有企业市场来赚钱；腾讯还不屑于争夺安全这个不怎么赚钱的市场，但绝对警觉360这个痞子对手；毒霸只能背水一战！&lt;/div&gt;&lt;div&gt;    还有不少新兴的安全厂商还在觊觎'安全'这块儿蛋糕。&lt;/div&gt;&lt;div&gt;    安全行业最关键的半年已经开始了，爆发吧，小宇宙！&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5866936448448261654-5534216124193709769?l=moonbingbing.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://moonbingbing.blogspot.com/feeds/5534216124193709769/comments/default' title='帖子评论'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5866936448448261654&amp;postID=5534216124193709769' title='0 条评论'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5866936448448261654/posts/default/5534216124193709769'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5866936448448261654/posts/default/5534216124193709769'/><link rel='alternate' type='text/html' href='http://moonbingbing.blogspot.com/2009/11/blog-post.html' title='安全行业最关键的半年'/><author><name>wayne</name><uri>http://www.blogger.com/profile/08537956174550037355</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5866936448448261654.post-4434811453994794436</id><published>2009-11-20T13:45:00.003+08:00</published><updated>2010-04-12T11:37:30.793+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='mysql优化'/><category scheme='http://www.blogger.com/atom/ns#' term='mysql'/><title type='text'>MySQL性能调优简介</title><content type='html'>抽空总结了一下。参考了Peter Zaitsev April 22, 2009在Percona Performance Conference上面的演讲文档上面的很多东西，多谢这些大牛们。&lt;div style="width:425px;text-align:left" id="__ss_2541514"&gt;&lt;a style="font:14px Helvetica,Arial,Sans-serif;display:block;margin:12px 0 3px 0;text-decoration:underline;" href="http://www.slideshare.net/moonbingbing/mysql-2541514" title="MySQL调优"&gt;MySQL调优&lt;/a&gt;&lt;object style="margin:0px" width="425" height="355"&gt;&lt;param name="movie" value="http://static.slidesharecdn.com/swf/ssplayer2.swf?doc=mysql-091119190019-phpapp02&amp;stripped_title=mysql-2541514" /&gt;&lt;param name="allowFullScreen" value="true"/&gt;&lt;param name="allowScriptAccess" value="always"/&gt;&lt;embed src="http://static.slidesharecdn.com/swf/ssplayer2.swf?doc=mysql-091119190019-phpapp02&amp;stripped_title=mysql-2541514" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="355"&gt;&lt;/embed&gt;&lt;/object&gt;&lt;div style="font-size:11px;font-family:tahoma,arial;height:26px;padding-top:2px;"&gt;View more &lt;a style="text-decoration:underline;" href="http://www.slideshare.net/"&gt;presentations&lt;/a&gt; from &lt;a style="text-decoration:underline;" href="http://www.slideshare.net/moonbingbing"&gt;moonbingbing&lt;/a&gt;.&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5866936448448261654-4434811453994794436?l=moonbingbing.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://moonbingbing.blogspot.com/feeds/4434811453994794436/comments/default' title='帖子评论'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5866936448448261654&amp;postID=4434811453994794436' title='2 条评论'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5866936448448261654/posts/default/4434811453994794436'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5866936448448261654/posts/default/4434811453994794436'/><link rel='alternate' type='text/html' href='http://moonbingbing.blogspot.com/2009/11/mysql.html' title='MySQL性能调优简介'/><author><name>wayne</name><uri>http://www.blogger.com/profile/08537956174550037355</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5866936448448261654.post-1799668456340119989</id><published>2009-07-19T02:55:00.002+08:00</published><updated>2009-07-19T03:29:29.198+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='生活'/><title type='text'>休假</title><content type='html'>千言万语汇成一句话：休假。&lt;br /&gt;&lt;br /&gt;千言万语等休假回来再写&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5866936448448261654-1799668456340119989?l=moonbingbing.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://moonbingbing.blogspot.com/feeds/1799668456340119989/comments/default' title='帖子评论'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5866936448448261654&amp;postID=1799668456340119989' title='0 条评论'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5866936448448261654/posts/default/1799668456340119989'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5866936448448261654/posts/default/1799668456340119989'/><link rel='alternate' type='text/html' href='http://moonbingbing.blogspot.com/2009/07/blog-post.html' title='休假'/><author><name>wayne</name><uri>http://www.blogger.com/profile/08537956174550037355</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5866936448448261654.post-3001977103671574563</id><published>2009-06-14T23:52:00.002+08:00</published><updated>2009-06-15T00:15:32.939+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='生活'/><category scheme='http://www.blogger.com/atom/ns#' term='安全'/><title type='text'>绿坝：丑陋的云监控</title><content type='html'>实在不想把“云”和绿坝这样的软件联系起来，但它确实是云的一个实例。&lt;br /&gt;&lt;br /&gt;之前的监控是GFW，在你的电脑和网站之前架设一个检查站，监控关键字和过滤网址。随着互联网飞速发展，服务器的压力肯定越来越大，效果也越来越不明显。怎么办？“云”是很好的解决办法。&lt;br /&gt;&lt;br /&gt;让计算更靠近数据，让每一个客户端都是服务器的一朵云。绿坝生动的实现了“云”，从此GFW穿着保护儿童，打击色情的外衣，来到客户端，合法的监控你的一举一动：你敲的每一个文字，浏览过的每一个网页，写的每一份文档......感觉就像你洗澡，上厕所还有人通过摄像头实时监控一样。&lt;br /&gt;&lt;br /&gt;看着网上大家对绿坝的评价，大都从技术角度分析它有多么脆弱。对于绝大部分用户来讲，这样的技术已经够用，政府也不指望可以通过绿坝监控到所有客户端，还有GFW。所以谈论技术没有任何意义，绿坝的意义完全不在技术！&lt;br /&gt;&lt;br /&gt;巨大丑陋的乌云正笼罩在我们头顶。&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5866936448448261654-3001977103671574563?l=moonbingbing.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://moonbingbing.blogspot.com/feeds/3001977103671574563/comments/default' title='帖子评论'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5866936448448261654&amp;postID=3001977103671574563' title='0 条评论'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5866936448448261654/posts/default/3001977103671574563'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5866936448448261654/posts/default/3001977103671574563'/><link rel='alternate' type='text/html' href='http://moonbingbing.blogspot.com/2009/06/blog-post_318.html' title='绿坝：丑陋的云监控'/><author><name>wayne</name><uri>http://www.blogger.com/profile/08537956174550037355</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5866936448448261654.post-475214195169671134</id><published>2009-06-14T16:18:00.000+08:00</published><updated>2009-06-14T17:35:53.749+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='安全'/><category scheme='http://www.blogger.com/atom/ns#' term='珠海'/><title type='text'>杀软，你的用户在哪儿？</title><content type='html'>&lt;span style="color: rgb(153, 153, 0);"&gt;本人对产品和市场不熟悉，周末去北师大和电脑城逛了逛，只是根据常识和男人的第六感有感而发。&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;ul style="color: rgb(0, 0, 0);"&gt;&lt;li&gt;前言：&lt;/li&gt;&lt;/ul&gt;&lt;span style="color: rgb(153, 153, 0);"&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;我一直坚信一个不关心用户需求，觉得产品，市场和研发没有啥关系的程序员写不出好程序。是的，研发没有必要成为产品和市场方面的专家，但心里要一直有一幅清晰的用户需求（而不是只有bug列表）：我的程序是给千千万万个用户使用的，他们需要的产品是什么样子的，有哪些地方需要改进，用户是哪些人，他们是怎么看待自己程序的。&lt;br /&gt;&lt;br /&gt;正常情况下，这个需求画面，应该由产品和市场传导给研发的。更专业的做法，应该由第三方独立的咨询公司来完成产品和市场调查。更常见的情况是大家都没有这个画面，太囧了。&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;ul&gt;&lt;li&gt;用户调查&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;span style="color: rgb(153, 153, 0);"&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;北师大：随机找了10个学生，4男6女，全部都有电脑。3个用诺顿，3个瑞星，一个mcafee，一个卡巴，一个毒霸，还有一个没有安装杀软。都安装的有360。&lt;br /&gt;&lt;br /&gt;诺顿使用量高出乎我的意料，后来才发现是因为北师大机房使用的就是诺顿。&lt;br /&gt;&lt;br /&gt;瑞星都是电脑城装机时候安装的盗版。&lt;br /&gt;&lt;br /&gt;mcafee是买品牌机送的。&lt;br /&gt;&lt;br /&gt;卡巴是网上下载的破解版。&lt;br /&gt;&lt;br /&gt;毒霸是因为家里办宽带送的，后来用手机10块一月续费的。之所以不用盗版和不在taobao买便宜的是因为担心不安全。&lt;br /&gt;&lt;br /&gt;由此可以推测：诺顿走的是高端路线，城市包围农村，先抢占利润最大的企业市场，再通过企业市场影响个人用户市场，棋走高招；瑞星牢牢把控传统渠道和电脑城，农村包围城市，以最大化抢占个人市场来影响企业市场；mcafee更多的是OEM；卡巴借助泛滥的破解版本和360的推波助澜，不仅对网上渠道有很好的把控，对传统渠道也在悄悄的蚕食，不可小觑；毒霸借助OEM和手机支付迅速上位，但同时传统渠道丧失殆尽，用户认知度和忠诚度偏低，用户定位不清晰，浮躁冒进；360一定意义上面可以控制杀软的市场份额。&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;ul&gt;&lt;li&gt;传统渠道&lt;/li&gt;&lt;/ul&gt;电脑城：外墙杀软的广告都是卡巴和瑞星的。卖杀软的店铺里面最显眼的地方都是卡巴，偶尔可以看到江民，没有瑞星和毒霸的身影。&lt;br /&gt;&lt;br /&gt;推测：卡巴对传统渠道非常重视；瑞星比卡巴更明白潜规则；江民已是明日黄花；毒霸完全放弃传统渠道。&lt;br /&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;用户在哪儿？&lt;/li&gt;&lt;/ul&gt;每个杀软在中国都有自己的用户定位：诺顿是企业用户；卡巴是高端个人用户；瑞星是个人用户；mcafee是有钱的个人用户；毒霸是家庭用户。每个不同的用户定位，决定了市场，产品和研发。&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5866936448448261654-475214195169671134?l=moonbingbing.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://moonbingbing.blogspot.com/feeds/475214195169671134/comments/default' title='帖子评论'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5866936448448261654&amp;postID=475214195169671134' title='0 条评论'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5866936448448261654/posts/default/475214195169671134'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5866936448448261654/posts/default/475214195169671134'/><link rel='alternate' type='text/html' href='http://moonbingbing.blogspot.com/2009/06/blog-post_14.html' title='杀软，你的用户在哪儿？'/><author><name>wayne</name><uri>http://www.blogger.com/profile/08537956174550037355</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5866936448448261654.post-2765922930576634278</id><published>2009-06-14T11:37:00.003+08:00</published><updated>2009-06-14T12:08:41.633+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='生活'/><category scheme='http://www.blogger.com/atom/ns#' term='管理'/><title type='text'>细节反映成败</title><content type='html'>细节从来都决定不了成败，细节是成败的表征，是冰山浮在水面上最有价值的一角。&lt;br /&gt;&lt;br /&gt;当你对一个人，一个公司，一件事情有些踌躇的时候，就来看看细节吧。你不能指望一个约会经常迟到的人会恪守承诺；不能期望失去梦想，为下个季度财报而努力的公司能善待客户和员工；也不能期待一个横幅有错别字的市场宣传能奏效。&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 102, 0);"&gt;把kingsoft拼成kinsoft；www.duba.net写成www.duba.com；3888-&gt;03338-&gt;03888,到死都拼不对；&lt;/span&gt;&lt;a style="color: rgb(255, 102, 0);" href="http://bbs.duba.net/thread-22069171-1-1.html"&gt;毒霸变成独霸，还推向客户端去弹泡泡&lt;/a&gt;&lt;span style="color: rgb(255, 102, 0);"&gt;......&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;我们的技术并不差，那造成差距的根源在哪儿？我觉得是在心态，是对用户，对员工，对梦想的心态！有人觉得这个东西会影响千千万万的用户，我要做到最好吗？有人觉得员工是公司发展的源泉，要善待员工，留住好员工吗？有人还记得当初的梦想并为之奋斗吗？如果没有，就不要看着报表郁闷了，洗洗睡了吧。&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5866936448448261654-2765922930576634278?l=moonbingbing.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://moonbingbing.blogspot.com/feeds/2765922930576634278/comments/default' title='帖子评论'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5866936448448261654&amp;postID=2765922930576634278' title='0 条评论'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5866936448448261654/posts/default/2765922930576634278'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5866936448448261654/posts/default/2765922930576634278'/><link rel='alternate' type='text/html' href='http://moonbingbing.blogspot.com/2009/06/blog-post.html' title='细节反映成败'/><author><name>wayne</name><uri>http://www.blogger.com/profile/08537956174550037355</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5866936448448261654.post-6772268206631543191</id><published>2009-04-24T22:07:00.002+08:00</published><updated>2009-04-24T22:32:49.184+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='技术'/><title type='text'>怎么算是一个成功的项目？</title><content type='html'>成功的项目最明显的特征就是能赚钱或者能省钱，除了钱，我们还有很多评价结果的标准：&lt;br /&gt;&lt;ul&gt;&lt;li&gt;人的成长。&lt;/li&gt;&lt;li&gt;团队的成长。&lt;/li&gt;&lt;li&gt;技术探索和积累。&lt;/li&gt;&lt;/ul&gt;在我看来，如果人和团队在项目中成长起来，即使这个项目最后没有赚钱，这个项目也是成功的。最怕的是，老大们看错了方向，或者头脑一热，就去做项目，这样的项目就是彻头彻尾的失败了。&lt;br /&gt;&lt;br /&gt;反之，一个项目就算赚钱了，但是人和团队没有成长起来，这也不能算是成功的项目。&lt;br /&gt;&lt;br /&gt;成长，是一个很抽象的名词，很难去量化，有时候就是一种感觉，是一个蓦然回首才能看到的过程。&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5866936448448261654-6772268206631543191?l=moonbingbing.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://moonbingbing.blogspot.com/feeds/6772268206631543191/comments/default' title='帖子评论'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5866936448448261654&amp;postID=6772268206631543191' title='0 条评论'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5866936448448261654/posts/default/6772268206631543191'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5866936448448261654/posts/default/6772268206631543191'/><link rel='alternate' type='text/html' href='http://moonbingbing.blogspot.com/2009/04/blog-post_24.html' title='怎么算是一个成功的项目？'/><author><name>wayne</name><uri>http://www.blogger.com/profile/08537956174550037355</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5866936448448261654.post-2978654004179567641</id><published>2009-04-06T22:40:00.007+08:00</published><updated>2009-04-06T22:58:10.076+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='生活'/><title type='text'>笑过，哭过，我们都经历过..</title><content type='html'>在youku上面看到一个DV(2个多小时)，里面的每个人都能在我大学寝室的兄弟们身上看到影子，觉得很亲切。我的大学过的还算丰富多彩，如果，当然也只能如果，还能重新再上一遍大学，我会让自己胆子更大一些，眼界更开阔一些 :)&lt;br /&gt;&lt;br /&gt;&lt;embed src="http://player.youku.com/player.php/sid/XNzA0NDk5MzI=/v.swf" quality="high" allowscriptaccess="sameDomain" type="application/x-shockwave-flash" align="middle" height="400" width="450"&gt;&lt;/embed&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5866936448448261654-2978654004179567641?l=moonbingbing.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://moonbingbing.blogspot.com/feeds/2978654004179567641/comments/default' title='帖子评论'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5866936448448261654&amp;postID=2978654004179567641' title='0 条评论'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5866936448448261654/posts/default/2978654004179567641'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5866936448448261654/posts/default/2978654004179567641'/><link rel='alternate' type='text/html' href='http://moonbingbing.blogspot.com/2009/04/blog-post.html' title='笑过，哭过，我们都经历过..'/><author><name>wayne</name><uri>http://www.blogger.com/profile/08537956174550037355</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5866936448448261654.post-6371039748531967000</id><published>2009-03-31T21:03:00.006+08:00</published><updated>2009-04-01T00:02:07.920+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='技术'/><category scheme='http://www.blogger.com/atom/ns#' term='管理'/><title type='text'>运营运维比研发更重要</title><content type='html'>‘&lt;a href="http://baike.baidu.com/view/192499.html?fromTaglist"&gt;行百里者半九十&lt;/a&gt;’，就句话用来比喻产品的研发和运营运维非常恰当。&lt;br /&gt;&lt;br /&gt;研发是大家都非常重视的一环，开发量占整个过程的绝大部分，但是，良好的研发只是开了好头，如果忽视看似简单的产品运营和运维，再好的产品也得不到用户的认同。&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 153, 0);"&gt;&lt;span style="font-weight: bold;"&gt;有效&lt;/span&gt;的运营，可以及时收集用户的问题（将问题在萌芽期都处理掉），反馈给研发，推动，督促并监管问题的快速解决；&lt;span style="font-weight: bold;"&gt;稳定&lt;/span&gt;的运维，可以为用户提供持久可靠的服务，为研发优化，修改程序提供数据支持。&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;如果没有好的运营和运维，那么这样的情况是意料之中的：&lt;br /&gt;&lt;ul&gt;&lt;li&gt;出问题了，但是没有数据去查找原因。&lt;/li&gt;&lt;li&gt;问题的反馈总是从客户的抱怨声中传到研发的。&lt;br /&gt;&lt;/li&gt;&lt;li&gt;服务器端连两个九的可用性都不能保证。&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5866936448448261654-6371039748531967000?l=moonbingbing.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://moonbingbing.blogspot.com/feeds/6371039748531967000/comments/default' title='帖子评论'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5866936448448261654&amp;postID=6371039748531967000' title='0 条评论'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5866936448448261654/posts/default/6371039748531967000'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5866936448448261654/posts/default/6371039748531967000'/><link rel='alternate' type='text/html' href='http://moonbingbing.blogspot.com/2009/03/blog-post_31.html' title='运营运维比研发更重要'/><author><name>wayne</name><uri>http://www.blogger.com/profile/08537956174550037355</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5866936448448261654.post-5204048624954801471</id><published>2009-03-26T22:20:00.003+08:00</published><updated>2009-03-26T22:38:45.210+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='生活'/><title type='text'>五一长假惹谁了？</title><content type='html'>广东刚说要放假7天，今天国务院就说全国五一放假3天，禁止擅自调休。公司也赶快发邮件通知来响应国务院，广东的7天假一个字也没有提。&lt;br /&gt;&lt;br /&gt;本来想着这次五一出去玩可能不那么挤了，看来是肯定不挤了。&lt;br /&gt;&lt;br /&gt;我们还有年假可以休，那些没有年假，连周末休息都是奢望的人们，谁去保障你们的权利？冠冕堂皇的年假制度最终沦为合法剥削劳动者的借口。&lt;br /&gt;&lt;br /&gt;休假不是福利，是权利！应该由国家机器来保障。&lt;span style="color: rgb(0, 153, 0); font-weight: bold;"&gt;以前五一是有很多弊端，但它至少保障了很多人休假的权利。现在的休假模型当然比五一黄金周好，但却牺牲了弱势劳动者休假的权利。&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5866936448448261654-5204048624954801471?l=moonbingbing.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://moonbingbing.blogspot.com/feeds/5204048624954801471/comments/default' title='帖子评论'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5866936448448261654&amp;postID=5204048624954801471' title='0 条评论'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5866936448448261654/posts/default/5204048624954801471'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5866936448448261654/posts/default/5204048624954801471'/><link rel='alternate' type='text/html' href='http://moonbingbing.blogspot.com/2009/03/blog-post_26.html' title='五一长假惹谁了？'/><author><name>wayne</name><uri>http://www.blogger.com/profile/08537956174550037355</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5866936448448261654.post-8980726860053750533</id><published>2009-03-16T13:04:00.016+08:00</published><updated>2009-11-20T13:48:47.016+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='python'/><title type='text'>python tips</title><content type='html'>看别人代码的时候，总是会发现很多好玩儿的用法或者不太注意的库，比较零散，就记录在这儿吧。持续更新......&lt;br /&gt;&lt;br /&gt;1、用 ...and ... or ... 来替换 if....else...&lt;br /&gt;&lt;blockquote&gt;old:&lt;br /&gt;&lt;pre class="prettyprint"&gt;if flag:&lt;br /&gt;print 'yes'&lt;br /&gt;else:&lt;br /&gt;print 'no'&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;new:&lt;br /&gt;&lt;pre class="prettyprint"&gt;print flag and 'yes' or 'no'&lt;/pre&gt;&lt;/blockquote&gt;&lt;br /&gt;&lt;br /&gt;2、经常被字符串里面很多的%s搞糊涂？还不快试一下Template&lt;br /&gt;&lt;/code&gt;&lt;blockquote&gt;old:&lt;br /&gt;&lt;pre class="prettyprint"&gt;message = '%s is better than %s,and %s is worse than %s.so,%s is better than %s'&lt;br /&gt;print message %('a','b','c','b','a','c')&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;new:&lt;br /&gt;&lt;pre class="prettyprint"&gt;from string import Template&lt;br /&gt;message = Template( '$a is better than $b,and $c is worse than $b.so,$a is better than $c')&lt;br /&gt;print message.substitute(a='a',b='b',c='c')&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;/blockquote&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5866936448448261654-8980726860053750533?l=moonbingbing.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://moonbingbing.blogspot.com/feeds/8980726860053750533/comments/default' title='帖子评论'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5866936448448261654&amp;postID=8980726860053750533' title='0 条评论'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5866936448448261654/posts/default/8980726860053750533'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5866936448448261654/posts/default/8980726860053750533'/><link rel='alternate' type='text/html' href='http://moonbingbing.blogspot.com/2009/03/python-tips.html' title='python tips'/><author><name>wayne</name><uri>http://www.blogger.com/profile/08537956174550037355</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5866936448448261654.post-3137146461810395798</id><published>2009-03-15T00:31:00.003+08:00</published><updated>2009-03-15T00:47:17.635+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='生活'/><category scheme='http://www.blogger.com/atom/ns#' term='mysql'/><title type='text'>跳出框框看问题</title><content type='html'>今天看Bret Taylor写的FriendFeed使用MySQL的一些经验：&lt;a href="http://bret.appspot.com/entry/how-friendfeed-uses-mysql"&gt;How FriendFeed uses MySQL to store schema-less data &lt;/a&gt;，很有感触。&lt;br /&gt;&lt;br /&gt;FriendFeed遇到过的问题，我也遇到过苦恼过，因为想不到好的方法，最后不了了之。而FriendFeed并没有不了了之:&lt;span style="font-style: italic; color: rgb(153, 51, 0);"&gt;so we decided to look outside of the realm of RDBMS.  &lt;/span&gt;&lt;span style="color: rgb(153, 51, 0);"&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;就是&lt;/span&gt;&lt;span style="color: rgb(153, 51, 0);"&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;这种跳出框框的思维，让FriendFeed找到了一个非常适合自己的解决方案。&lt;/span&gt;&lt;/span&gt;&lt;span style="font-style: italic; color: rgb(153, 51, 0);"&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(153, 51, 0);"&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;现在看来，数据库的设计真的是一门艺术，需要创造性的思维。不要让书本上面所谓的金科玉律拴住我们的思维。&lt;/span&gt;&lt;/span&gt;&lt;span style="font-style: italic; color: rgb(153, 51, 0);"&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5866936448448261654-3137146461810395798?l=moonbingbing.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://moonbingbing.blogspot.com/feeds/3137146461810395798/comments/default' title='帖子评论'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5866936448448261654&amp;postID=3137146461810395798' title='1 条评论'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5866936448448261654/posts/default/3137146461810395798'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5866936448448261654/posts/default/3137146461810395798'/><link rel='alternate' type='text/html' href='http://moonbingbing.blogspot.com/2009/03/blog-post_15.html' title='跳出框框看问题'/><author><name>wayne</name><uri>http://www.blogger.com/profile/08537956174550037355</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5866936448448261654.post-8945300812600603816</id><published>2009-03-14T10:42:00.004+08:00</published><updated>2009-03-15T00:28:45.855+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='经济'/><category scheme='http://www.blogger.com/atom/ns#' term='管理'/><title type='text'>一直被模仿，从未被超越</title><content type='html'>为什么模仿者很难超越被模仿者？按说有了前人的探索和经验，模仿者应该更容易成功才对，但是现实中很少有模仿别人的公司做大作强，超过被模仿者的。&lt;br /&gt;&lt;br /&gt;原因笼统的说是因为‘&lt;span style="color: rgb(153, 102, 51);"&gt;知其然，不知其所以然&lt;/span&gt;’。在别人身后亦步亦趋，别人跌倒的地方你也不知道躲过去，别人&lt;span style="color: rgb(153, 51, 0);"&gt;积重难返&lt;/span&gt;的包袱你也照着背上......这样是肯定不能超越对方的。每个公司就像每个人一样，都有自己的个性，适合别人的不一定适合自己。&lt;br /&gt;&lt;br /&gt;做一个好的模仿者，必须要&lt;span style="color: rgb(153, 153, 0);"&gt;知己知彼，取其精华，去其糟粕&lt;/span&gt;。&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5866936448448261654-8945300812600603816?l=moonbingbing.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://moonbingbing.blogspot.com/feeds/8945300812600603816/comments/default' title='帖子评论'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5866936448448261654&amp;postID=8945300812600603816' title='0 条评论'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5866936448448261654/posts/default/8945300812600603816'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5866936448448261654/posts/default/8945300812600603816'/><link rel='alternate' type='text/html' href='http://moonbingbing.blogspot.com/2009/03/blog-post_14.html' title='一直被模仿，从未被超越'/><author><name>wayne</name><uri>http://www.blogger.com/profile/08537956174550037355</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5866936448448261654.post-6826383243052911999</id><published>2009-03-01T21:39:00.003+08:00</published><updated>2009-03-01T21:43:37.606+08:00</updated><title type='text'>大龄文艺女青年之歌</title><content type='html'>很有意思的一首歌&lt;br /&gt;&lt;object width="425" height="344"&gt;&lt;param name="movie" value="http://www.youtube.com/v/16pgRYEbo8w&amp;amp;hl=zh_CN&amp;amp;fs=1"&gt;&lt;param name="allowFullScreen" value="true"&gt;&lt;param name="allowscriptaccess" value="always"&gt;&lt;embed src="http://www.youtube.com/v/16pgRYEbo8w&amp;amp;hl=zh_CN&amp;amp;fs=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="344"&gt;&lt;/embed&gt;&lt;/object&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;词：邵夷贝&lt;br /&gt;曲：邵夷贝&lt;br /&gt;唱：邵夷贝&lt;/p&gt; &lt;p&gt;&lt;br /&gt;&lt;/p&gt; &lt;p&gt;王小姐三十一岁了&lt;br /&gt;朋友们见到了她&lt;br /&gt;都要问一个问题：&lt;br /&gt;你什么时候打算嫁呀？&lt;br /&gt;可是嫁人这一个问题&lt;br /&gt;又不是她一个人可以决定的&lt;br /&gt;她问她爸爸&lt;br /&gt;她问她妈妈&lt;br /&gt;他们都说你赶紧的&lt;br /&gt;你看 你看 你看人家那那那那那那那那那&lt;br /&gt;你看 你看 你看看那那那那&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt; &lt;p&gt;大龄文艺女青年&lt;br /&gt;该嫁一个什么样的人呢&lt;br /&gt;是不是也该找个搞艺术的&lt;br /&gt;这样就比较合适呢&lt;br /&gt;可是搞艺术的男青年&lt;br /&gt;有一部分只爱他的艺术&lt;br /&gt;还有极少部分搞艺术的男青年&lt;br /&gt;搞艺术是为了搞姑娘&lt;br /&gt;搞姑娘又不只搞她一个&lt;br /&gt;嫁给他干什么呢&lt;br /&gt;搞姑娘又不只搞她一个&lt;br /&gt;奶奶奶奶奶奶的&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt; &lt;p&gt;朋友们介绍了好几个&lt;br /&gt;有车子房子和孩子的&lt;br /&gt;他们说你该找个有钱的&lt;br /&gt;让他赞助你搞创作&lt;br /&gt;可是大款都不喜欢她&lt;br /&gt;他们只想娶会做饭的&lt;br /&gt;不会做饭的女青年&lt;br /&gt;只能去当第三者&lt;br /&gt;不会做饭的文艺女青年&lt;br /&gt;只能被他们潜规则&lt;br /&gt;奶奶奶奶奶奶的&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt; &lt;p&gt;这一首歌纯属雷同&lt;br /&gt;如有虚构纯属巧合&lt;br /&gt;请不要自觉对号入座&lt;br /&gt;然后发动群众封杀我&lt;br /&gt;你看 你看 你看她只会做西红柿炒鸡蛋&lt;br /&gt;你看 你看 还要就着方便面&lt;br /&gt;那是非常好吃的&lt;br /&gt;mia mia mia mia mia mia mia&lt;br /&gt;那是非常的好吃的&lt;br /&gt;mia mia mia mia mia mia mia&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5866936448448261654-6826383243052911999?l=moonbingbing.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://moonbingbing.blogspot.com/feeds/6826383243052911999/comments/default' title='帖子评论'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5866936448448261654&amp;postID=6826383243052911999' title='0 条评论'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5866936448448261654/posts/default/6826383243052911999'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5866936448448261654/posts/default/6826383243052911999'/><link rel='alternate' type='text/html' href='http://moonbingbing.blogspot.com/2009/03/blog-post.html' title='大龄文艺女青年之歌'/><author><name>wayne</name><uri>http://www.blogger.com/profile/08537956174550037355</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5866936448448261654.post-1747535687282317550</id><published>2009-02-25T21:34:00.005+08:00</published><updated>2009-02-25T22:02:11.900+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='mysql'/><title type='text'>MySQL备份数据的几种方法</title><content type='html'>部门一个大牛曾经说过：‘运营就是备份’。对于数据库的备份问题，很多时候是出事儿以后，大家才能认识到有多严重。。。数据文件不是放到盘柜就安全的，如果MySQL崩溃了，如果盘柜损坏了，如果有人误操作了，如果地震了......&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;备份分为完全备份和增量备份。&lt;/div&gt;&lt;div&gt;&lt;ul&gt;&lt;li&gt;完全备份是备份所有的数据库文件或者将数据库全部dump出来。前者适合比较大的数据库。&lt;br /&gt;&lt;/li&gt;&lt;li&gt;增量备份是定期备份二进制日志，备份前使用 flush logs 刷新日志。&lt;/li&gt;&lt;/ul&gt;&lt;div&gt;备份的时候如果不影响主库的运行，就叫做热备；如果flush table with read lock或者关闭数据库，就是冷备。&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;可以选择和主库实时同步，也可以选择延时同步。各有适合的场景。&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;如果已经有slave，那么再建另一个slave的时候，就没有必要从主库拷贝数据库文件了。只要暂停slave的服务，拷贝完文件后，修改my.cnf里面的server-id，以及在主库增加新增slave的replicuser权限，就可以了。&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;LVM的快照功能可以快速复制数据库文件。参见‘&lt;a href="http://qroom.blogspot.com/2007/04/lvm.html"&gt;使用LVM快速建立数据库的快照&lt;/a&gt;’ &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5866936448448261654-1747535687282317550?l=moonbingbing.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://moonbingbing.blogspot.com/feeds/1747535687282317550/comments/default' title='帖子评论'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5866936448448261654&amp;postID=1747535687282317550' title='0 条评论'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5866936448448261654/posts/default/1747535687282317550'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5866936448448261654/posts/default/1747535687282317550'/><link rel='alternate' type='text/html' href='http://moonbingbing.blogspot.com/2009/02/mysql.html' title='MySQL备份数据的几种方法'/><author><name>wayne</name><uri>http://www.blogger.com/profile/08537956174550037355</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5866936448448261654.post-5104277129821371923</id><published>2009-02-23T20:27:00.006+08:00</published><updated>2009-02-24T09:04:42.758+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='安全'/><title type='text'>有前途的网址认证</title><content type='html'>伴随着‘云安全’，文件认证火了一把。而网站/网址的安全认证大家也在暗自较劲。这个比文件的认证对用户的影响更为广泛。国外做的比较好的有&lt;a href="http://www.siteadvisor.com/"&gt;mcafee&lt;/a&gt;和&lt;a href="http://www.mywot.com/"&gt;web of trust&lt;/a&gt;（MySQL的创始人最近加入）；瑞星的&lt;a href="http://file.ikaka.com/"&gt;卡卡文件诊所&lt;/a&gt;有对网址的认证，不过功能太弱；&lt;a href="http://www.knownsec.com/"&gt;知道创宇&lt;/a&gt;也提供网站认证的服务，只是不能在网上查询，必须安装客户端软件，可以先去看一下他们的&lt;a href="http://www.scanw.com/blog/"&gt;blog&lt;/a&gt;，有每天挂马网站的简报。&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;木马、挂马网站、下载器、钓鱼网站，现在这些因特网最大的威胁将随着网址认证的推广逐渐失去生存的土壤。&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;如果一个搜索引擎（比如百度）有了网址认证，&lt;span class="Apple-style-span" style="font-weight: bold;"&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 153, 0);"&gt;那么完全可以按照这个网站的安全级别（是否有漏洞，SQL注入，挂马，低俗等）来排名&lt;/span&gt;&lt;/span&gt;。搜索结果会提示这个网站可能存在的威胁（和google一样）。&lt;span class="Apple-style-span" style="color: rgb(51, 102, 255);"&gt;如果你想提高排名，需要花钱来得知你的网站有哪些漏洞（这个就是google没有做的）。就这样做就能趋‘竞价排名’的利，而避其害了。&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5866936448448261654-5104277129821371923?l=moonbingbing.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://moonbingbing.blogspot.com/feeds/5104277129821371923/comments/default' title='帖子评论'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5866936448448261654&amp;postID=5104277129821371923' title='0 条评论'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5866936448448261654/posts/default/5104277129821371923'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5866936448448261654/posts/default/5104277129821371923'/><link rel='alternate' type='text/html' href='http://moonbingbing.blogspot.com/2009/02/blog-post.html' title='有前途的网址认证'/><author><name>wayne</name><uri>http://www.blogger.com/profile/08537956174550037355</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5866936448448261654.post-8887027787430376291</id><published>2009-02-09T13:45:00.004+08:00</published><updated>2009-02-09T23:29:56.485+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='存储'/><title type='text'>希捷的SAS硬盘也有问题？</title><content type='html'>今天早上发现一台联想R525报警，RAID10的一块硬盘offline。该服务器没有搬动过，offline的硬盘可以rebuild成功。&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;硬盘型号是ST3146855SS，146G。&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;以后绕着希捷走&lt;br /&gt;&lt;br /&gt;ps：下午这块硬盘又报unconf bad，只能通知联想换硬盘。还好刚开始用，没有什么重要的数据和应用。&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5866936448448261654-8887027787430376291?l=moonbingbing.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://moonbingbing.blogspot.com/feeds/8887027787430376291/comments/default' title='帖子评论'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5866936448448261654&amp;postID=8887027787430376291' title='0 条评论'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5866936448448261654/posts/default/8887027787430376291'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5866936448448261654/posts/default/8887027787430376291'/><link rel='alternate' type='text/html' href='http://moonbingbing.blogspot.com/2009/02/sas.html' title='希捷的SAS硬盘也有问题？'/><author><name>wayne</name><uri>http://www.blogger.com/profile/08537956174550037355</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5866936448448261654.post-2124302327226355305</id><published>2009-02-04T19:38:00.008+08:00</published><updated>2009-02-06T23:45:34.457+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='mysql'/><title type='text'>用master-slave实现mysql延时备份</title><content type='html'>master-slave不仅可以实现mysql的实时备份，也可以实现延时备份，而且这样实现的备份很灵活。&lt;br /&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;使用非常著名的maatkit工具集里面的&lt;a href="http://www.maatkit.org/doc/mk-slave-delay.html"&gt;mk-slave-delay&lt;/a&gt;，可以让salve落后master指定的时间。用法很简单，自己看文档。&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;延时备份为什么是必要的？&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 102, 102); font-weight: bold;"&gt;binlog里面记录的都是有写操作的sql语句&lt;/span&gt;&lt;span style="font-weight: bold;"&gt;。&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;如果你delete了一条几个月前insert的记录，那么你要先找到那条insert的sql语句；如果批量delete或者drop了一张表，那就够你痛苦的了。当然，找回数据的前提是：&lt;span style="font-weight: bold;"&gt;binlog完整&lt;/span&gt;。如果drop了一张表，那么从create talbe开始，所有执行过的写操作全部重演一次。对于写频繁的表，这是不可忍受的。&lt;br /&gt;&lt;br /&gt;延时备份可以让你恢复到一段时间之前，然后你再用日志恢复到那条语句前就可以了。&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5866936448448261654-2124302327226355305?l=moonbingbing.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://moonbingbing.blogspot.com/feeds/2124302327226355305/comments/default' title='帖子评论'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5866936448448261654&amp;postID=2124302327226355305' title='0 条评论'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5866936448448261654/posts/default/2124302327226355305'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5866936448448261654/posts/default/2124302327226355305'/><link rel='alternate' type='text/html' href='http://moonbingbing.blogspot.com/2009/02/master-slavemysql.html' title='用master-slave实现mysql延时备份'/><author><name>wayne</name><uri>http://www.blogger.com/profile/08537956174550037355</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5866936448448261654.post-2375633489925638412</id><published>2009-01-19T22:05:00.005+08:00</published><updated>2009-01-19T22:17:49.730+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='存储'/><title type='text'>［重要］希捷硬盘缺陷</title><content type='html'>参见新闻：&lt;br /&gt;http://www.cnbeta.com/articles/75219.htm&lt;br /&gt;http://www.it007.com/A/2009-1/Art_27968.html&lt;br /&gt;&lt;blockquote&gt;&lt;br /&gt;最近其7200.11系列容量为1TB的硬盘又出现了新的问题。出现此问题的硬盘产地大部分为泰国，原因疑为固件缺陷所致。在故障出现时，硬盘无法自行引导系统，甚至无法读取或写入任何数据。而硬盘上保存的数据甚至可能会全部丢失，如果这些数据非常重要，用户或许只能寄希望于数据恢复公司把它们从故障的硬盘中恢复出来。&lt;br /&gt;&lt;br /&gt;&lt;/blockquote&gt;没有什么比随时可能丢失数据或者系统莫名其妙蓝屏死机更让SA头痛的了。而希捷全都做到了。有缺陷的硬盘基本涵盖了希捷的主要产品，以后谁还敢用它的硬盘？服务器什么最贵？不是硬件，而是数据！伟大的希捷做到了，不管你做RAID几，它都会在一夜之间让你写辞职报告，卷铺盖走人。&lt;br /&gt;&lt;br /&gt;贵的不一定好，但是便宜肯定没有好货，而且便宜的东西机会成本非常的高，一点儿都不划算！&lt;br /&gt;&lt;br /&gt;现在明白为啥重要的数据用磁带机备份了。&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5866936448448261654-2375633489925638412?l=moonbingbing.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://moonbingbing.blogspot.com/feeds/2375633489925638412/comments/default' title='帖子评论'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5866936448448261654&amp;postID=2375633489925638412' title='2 条评论'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5866936448448261654/posts/default/2375633489925638412'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5866936448448261654/posts/default/2375633489925638412'/><link rel='alternate' type='text/html' href='http://moonbingbing.blogspot.com/2009/01/blog-post_19.html' title='［重要］希捷硬盘缺陷'/><author><name>wayne</name><uri>http://www.blogger.com/profile/08537956174550037355</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5866936448448261654.post-4079645488404401182</id><published>2009-01-12T22:32:00.007+08:00</published><updated>2009-02-07T10:05:26.906+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='生活'/><category scheme='http://www.blogger.com/atom/ns#' term='管理'/><title type='text'>当当网＝上当</title><content type='html'>新年的第一篇博客，本来不想写这个比较愤青的标题。只是如鲠在喉，不吐不快。&lt;br /&gt;&lt;br /&gt;去年12月30号的时候帮妹妹买了一本书，因为那个大学比较偏僻，不能选择货到付款。谁知道一直到今天，状态还是‘正在配货’。真正让人恼火的不是时间太长，而是当当根本不重视客户的感受，根本就不积极去解决问题。&lt;br /&gt;&lt;br /&gt;打电话给当当，只听到当当在把责任推卸给整理库房，承诺马上处理，但一直没有回应；发邮件，一直没有人理。&lt;br /&gt;&lt;br /&gt;大家都是人，都会犯错，这个没有问题。但是，&lt;span style="color: rgb(0, 102, 0); font-weight: bold;"&gt;不愿面对问题，不敢承担责任，不能兑现承诺&lt;/span&gt;，当当，这像是一个能成功的企业做的吗？这样的企业，不值得给他留一点儿面子和退路。&lt;br /&gt;&lt;br /&gt;－－－－－－－－－－－－－－－－－－－－－－－－&lt;br /&gt;&lt;br /&gt;如果只是在这里愤青一把，这个博客就没有含量了......从这里面能吸取什么教训呢？我看有以下几点：&lt;br /&gt;&lt;ul&gt;&lt;li&gt;主动收集用户的牢骚。&lt;a href="http://money.163.com/09/0112/09/4VETCS64002524TH.html"&gt;美国一家航空公司，一个客户在twitter上面发出一些疑问，很快就收到该公司的邮件回复。&lt;/a&gt; &lt;span style="color: rgb(0, 102, 0); font-weight: bold;"&gt;有抱怨和投诉的客户，是这个公司的一笔财富。&lt;/span&gt;那些整天想着怎么去删除负面信息的公司，是活不长久的。&lt;/li&gt;&lt;/ul&gt;&lt;ul&gt;&lt;li&gt;要有及时有效的反馈。反馈必须要及时，&lt;span style="color: rgb(0, 102, 0); font-weight: bold;"&gt;及时表示对人的尊重&lt;/span&gt;，没有人有那么多时间配你玩儿。反馈必须要有效，无效的反馈，比如当当客服统一口径的‘库房问题’，&lt;span style="color: rgb(0, 102, 0); font-weight: bold;"&gt;谈不到用户真正关心的问题，这种反馈让人反感&lt;/span&gt;。&lt;/li&gt;&lt;/ul&gt;&lt;ul&gt;&lt;li&gt;要有应急预案。今天当当出了这么大的事故，别光看笑话，生闷气，你知道明天类似的事情不会发生在你身上吗？是要事先做好准备，还是到时候手忙脚乱？你自己选择。&lt;/li&gt;&lt;/ul&gt;&lt;ul&gt;&lt;li&gt;敢于承担责任。出了问题了，怎么办？怎么向用户解释？你有很多选择，但是推卸责任到其他人身上，不敢说‘这是我的错，对不起’，绝对不是明智的选择。如果你觉得欺骗用户很高明，那么，我确定肯定以及一定，你下次还会犯同样的错。&lt;/li&gt;&lt;/ul&gt;看看金山，这几点也没有做好。&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5866936448448261654-4079645488404401182?l=moonbingbing.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://moonbingbing.blogspot.com/feeds/4079645488404401182/comments/default' title='帖子评论'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5866936448448261654&amp;postID=4079645488404401182' title='1 条评论'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5866936448448261654/posts/default/4079645488404401182'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5866936448448261654/posts/default/4079645488404401182'/><link rel='alternate' type='text/html' href='http://moonbingbing.blogspot.com/2009/01/blog-post.html' title='当当网＝上当'/><author><name>wayne</name><uri>http://www.blogger.com/profile/08537956174550037355</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5866936448448261654.post-3832289133482262306</id><published>2008-12-23T13:54:00.007+08:00</published><updated>2008-12-24T13:32:42.803+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='mysql优化'/><category scheme='http://www.blogger.com/atom/ns#' term='mysql'/><title type='text'>什么时候该增加MySQL数据库的内存？</title><content type='html'>除了优化好数据库配置文件外，更换/增加MySQL数据库服务器的硬件，是提高数据库性能最直接有效的方法。&lt;br /&gt;&lt;br /&gt;这里先从最便宜的内存入手。（服务器内存和硬盘价格一般是台式机的5倍左右）&lt;br /&gt;&lt;br /&gt;最便捷的方法是使用&lt;a href="http://hackmysql.com/mysqlreport"&gt;mysqlreport&lt;/a&gt;，来&lt;span style="font-weight: bold;"&gt;持续关注&lt;/span&gt;报告里面‘Key’和‘InnoDB Buffer Pool’这两个部分。如果你的my.cnf参数设置正确，但是Read hit一直低于99%，那么就要考虑增加内存了。&lt;br /&gt;&lt;br /&gt;那么Read hit是怎么计算出来的呢？为什么要持续关注？在MySQL的命令行下：&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;mysql&gt; show status like 'key_read%';&lt;br /&gt;+-------------------+------------+&lt;br /&gt;| Variable_name     | Value      |&lt;br /&gt;+-------------------+------------+&lt;br /&gt;| Key_read_requests | 3041374401 |&lt;br /&gt;| Key_reads         | 60959876   |&lt;br /&gt;+-------------------+------------+&lt;br /&gt;2 rows in set (0.02 sec)&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 153, 0);"&gt;key_efficiency(Read hit) = 1 - (Key_reads / Key_read_requests) = 97.995647100207184%&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;mysql&gt; show status like 'Innodb_buffer_pool_read%';&lt;br /&gt;+-----------------------------------+------------+&lt;br /&gt;| Variable_name                     | Value      |&lt;br /&gt;+-----------------------------------+------------+&lt;br /&gt;| Innodb_buffer_pool_read_ahead_rnd | 1660545    |&lt;br /&gt;| Innodb_buffer_pool_read_ahead_seq | 576767     |&lt;br /&gt;| Innodb_buffer_pool_read_requests  | 2080081461 |&lt;br /&gt;| Innodb_buffer_pool_reads          | 292415839  |&lt;br /&gt;+-----------------------------------+------------+&lt;br /&gt;4 rows in set (0.02 sec)&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 153, 0);"&gt;key_efficiency（Read hit）= 1 - (Innodb_buffer_pool_reads / Innodb_buffer_pool_read_requests) = 85.942096764834353%&lt;/span&gt;&lt;/blockquote&gt;&lt;blockquote&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 153, 0);"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/blockquote&gt;从文档里面找出这几个参数的意义：&lt;br /&gt;&lt;span&gt;&lt;span&gt; &lt;/span&gt;&lt;/span&gt;&lt;ul&gt;&lt;li&gt;&lt;span&gt;Key_read_requests:从缓存读键的数据块的请求数。&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt; &lt;ul&gt;&lt;li&gt;&lt;span&gt;&lt;span&gt; &lt;/span&gt;&lt;/span&gt;&lt;span&gt;Key_reads:从硬盘读取键的数据块的次数&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul&gt;&lt;li&gt;Innodb_buffer_pool_read_ahead_rnd:&lt;span&gt;InnoDB&lt;/span&gt;初始化的“&lt;span class="quote"&gt;随机&lt;/span&gt;”&lt;span&gt;read-ah&lt;/span&gt;&lt;span&gt;eads&lt;/span&gt;&lt;span&gt;数。当查询以随&lt;/span&gt;机顺序扫描表的一大部分时发生。&lt;/li&gt;&lt;/ul&gt; &lt;ul&gt;&lt;li&gt;&lt;span&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span&gt;Innodb_buffer_pool_read_ahead_s&lt;/span&gt;&lt;span&gt;eq:&lt;span&gt;InnoDB&lt;/span&gt;&lt;span&gt;初始化的顺序&lt;span&gt;read-aheads&lt;/span&gt;数。当&lt;/span&gt;&lt;span&gt;InnoDB&lt;/span&gt;执行顺序全表扫描时发生。&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt; &lt;ul&gt;&lt;li&gt;&lt;span&gt;&lt;/span&gt;&lt;span&gt;Innodb_buffer_pool_read_requests:&lt;span&gt;InnoDB&lt;/span&gt;已经完成的逻辑读请求数。&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt; &lt;ul&gt;&lt;li&gt;&lt;span&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span&gt;Innodb_buffer_pool_&lt;/span&gt;&lt;span&gt;reads:不能满足&lt;span&gt;InnoDB&lt;/span&gt;必须单页读取的缓冲池中的逻辑读数量。&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;div&gt;这几个都是时刻在变化的，一两次的查询并不能暴露问题。&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5866936448448261654-3832289133482262306?l=moonbingbing.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://moonbingbing.blogspot.com/feeds/3832289133482262306/comments/default' title='帖子评论'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5866936448448261654&amp;postID=3832289133482262306' title='0 条评论'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5866936448448261654/posts/default/3832289133482262306'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5866936448448261654/posts/default/3832289133482262306'/><link rel='alternate' type='text/html' href='http://moonbingbing.blogspot.com/2008/12/mysql_23.html' title='什么时候该增加MySQL数据库的内存？'/><author><name>wayne</name><uri>http://www.blogger.com/profile/08537956174550037355</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5866936448448261654.post-4477516004076293418</id><published>2008-12-21T15:44:00.004+08:00</published><updated>2008-12-23T20:20:32.243+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='生活'/><title type='text'>人人为我，我为人人</title><content type='html'>开源软件为什么在中国走的这么艰辛？我觉得这个和BT，电驴在中国走下坡路的原因是一样的：&lt;span style="font-weight: bold;"&gt;可以人人为我，不能我为人人&lt;/span&gt;。&lt;br /&gt;&lt;br /&gt;国内用到开源代码的软件太多了，可是大家用的都很‘低调’：怕别人知道自己用了开源代码，改了bug怕别人知道，有了bug又埋怨开源的质量。&lt;br /&gt;&lt;br /&gt;中国大陆忽视知识产权，不仅仅表现在盗版横行，也表现在软件行业中对开源代码的‘单向’使用和篡改版权。&lt;br /&gt;&lt;br /&gt;只有‘人人为我，我为人人’，中国的软件才能真正拥抱开源，才能让世界了解中国软件。这个不仅仅适用于软件，其他的都是这个道理。&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5866936448448261654-4477516004076293418?l=moonbingbing.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://moonbingbing.blogspot.com/feeds/4477516004076293418/comments/default' title='帖子评论'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5866936448448261654&amp;postID=4477516004076293418' title='0 条评论'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5866936448448261654/posts/default/4477516004076293418'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5866936448448261654/posts/default/4477516004076293418'/><link rel='alternate' type='text/html' href='http://moonbingbing.blogspot.com/2008/12/blog-post.html' title='人人为我，我为人人'/><author><name>wayne</name><uri>http://www.blogger.com/profile/08537956174550037355</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5866936448448261654.post-2783815195870138917</id><published>2008-12-17T18:43:00.005+08:00</published><updated>2008-12-17T18:57:28.980+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='旅游'/><title type='text'>2007年泛珠三角大学生计算机作品大赛之黄果树瀑布</title><content type='html'>今天梁老师在论坛上面把一年前去贵州的照片贴了出来，还有一篇很有文采的游记。可以去这里看&lt;a href="http://acmfan.cn/viewthread.php?tid=388&amp;amp;page=1&amp;amp;extra=page%3D1"&gt;详情&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;这里贴几张图吧，不舞文弄墨了。&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_euuQjbOccPk/SUjaicquvSI/AAAAAAAAAKs/Ddai5HyKTa0/s1600-h/1.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 300px;" src="http://2.bp.blogspot.com/_euuQjbOccPk/SUjaicquvSI/AAAAAAAAAKs/Ddai5HyKTa0/s400/1.jpg" alt="" id="BLOGGER_PHOTO_ID_5280710848437730594" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_euuQjbOccPk/SUjaid60eFI/AAAAAAAAAK0/XxBLRlXgid0/s1600-h/2.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 300px;" src="http://4.bp.blogspot.com/_euuQjbOccPk/SUjaid60eFI/AAAAAAAAAK0/XxBLRlXgid0/s400/2.jpg" alt="" id="BLOGGER_PHOTO_ID_5280710848773650514" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_euuQjbOccPk/SUjainniCwI/AAAAAAAAAK8/1DBqctCKt3E/s1600-h/3.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 300px;" src="http://3.bp.blogspot.com/_euuQjbOccPk/SUjainniCwI/AAAAAAAAAK8/1DBqctCKt3E/s400/3.jpg" alt="" id="BLOGGER_PHOTO_ID_5280710851377105666" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_euuQjbOccPk/SUjai2uZRFI/AAAAAAAAALM/9z5fGDJZcTw/s1600-h/5.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 300px;" src="http://3.bp.blogspot.com/_euuQjbOccPk/SUjai2uZRFI/AAAAAAAAALM/9z5fGDJZcTw/s400/5.jpg" alt="" id="BLOGGER_PHOTO_ID_5280710855432422482" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_euuQjbOccPk/SUjZ6VA-n_I/AAAAAAAAAKk/4zDsNF2TyrE/s1600-h/7.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 300px;" src="http://2.bp.blogspot.com/_euuQjbOccPk/SUjZ6VA-n_I/AAAAAAAAAKk/4zDsNF2TyrE/s400/7.jpg" alt="" id="BLOGGER_PHOTO_ID_5280710159188795378" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_euuQjbOccPk/SUjai1p3aMI/AAAAAAAAALE/vfH4stJnAqc/s1600-h/4.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 300px;" src="http://1.bp.blogspot.com/_euuQjbOccPk/SUjai1p3aMI/AAAAAAAAALE/vfH4stJnAqc/s400/4.jpg" alt="" id="BLOGGER_PHOTO_ID_5280710855144990914" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_euuQjbOccPk/SUjZ6YK5RLI/AAAAAAAAAKc/OjDyvh2M-Ww/s1600-h/6.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 300px;" src="http://1.bp.blogspot.com/_euuQjbOccPk/SUjZ6YK5RLI/AAAAAAAAAKc/OjDyvh2M-Ww/s400/6.jpg" alt="" id="BLOGGER_PHOTO_ID_5280710160035693746" border="0" /&gt;&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5866936448448261654-2783815195870138917?l=moonbingbing.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://moonbingbing.blogspot.com/feeds/2783815195870138917/comments/default' title='帖子评论'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5866936448448261654&amp;postID=2783815195870138917' title='0 条评论'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5866936448448261654/posts/default/2783815195870138917'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5866936448448261654/posts/default/2783815195870138917'/><link rel='alternate' type='text/html' href='http://moonbingbing.blogspot.com/2008/12/2007.html' title='2007年泛珠三角大学生计算机作品大赛之黄果树瀑布'/><author><name>wayne</name><uri>http://www.blogger.com/profile/08537956174550037355</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_euuQjbOccPk/SUjaicquvSI/AAAAAAAAAKs/Ddai5HyKTa0/s72-c/1.jpg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5866936448448261654.post-2264622424431435435</id><published>2008-12-07T16:50:00.007+08:00</published><updated>2008-12-23T14:19:30.397+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='mysql优化'/><category scheme='http://www.blogger.com/atom/ns#' term='mysql'/><title type='text'>MySQL海量数据优化</title><content type='html'>经常见到有人对MySQL处理海量数据（几百万,几千万的数据就不要往海量上面扯了）的能力持怀疑的态度，根据我的经验，MySQL处理单表亿级数据没有任何问题。&lt;br /&gt;&lt;br /&gt;数据库最重要的是安全稳定，速度其次。&lt;span style="color: rgb(0, 102, 0); font-weight: bold;"&gt;在做任何优化之前，你都必须做好最坏的打算，一定要有备份和应急方案！&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;要有一个稳定安全的数据库，你必须：&lt;br /&gt;&lt;ul&gt;&lt;li&gt;至少要有一个热备&lt;/li&gt;&lt;/ul&gt;&lt;ul&gt;&lt;li&gt;UPS&lt;/li&gt;&lt;/ul&gt;&lt;ul&gt;&lt;li&gt;做合适的RAID。RAID0＋1，RAID5或者RAID6&lt;/li&gt;&lt;/ul&gt;如果可以，最好：&lt;br /&gt;&lt;ul&gt;&lt;li&gt;使用xfs而不是ext3。哪天reboot后，你发现磁盘检查要半天，还不能停止，哭都来不及&lt;/li&gt;&lt;/ul&gt;&lt;ul&gt;&lt;li&gt;将数据库数据放入盘柜。更安全，访问更快&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;现在切入正题，开始优化：&lt;br /&gt;&lt;ul&gt;&lt;li&gt;使用64位系统。这是老生常谈了，只要谈优化就少不了这个。不仅MySQL的性能有提升，内存也能使用超过4G。&lt;/li&gt;&lt;/ul&gt;&lt;ul&gt;&lt;li&gt;选择合适的引擎。一般来讲，innodb适合写频繁的表，myisam适合读频繁的表。&lt;/li&gt;&lt;/ul&gt;&lt;ul&gt;&lt;li&gt;建立正确的索引。推荐&lt;a href="http://www.phpe.net/articles/323.shtml"&gt;这篇文章&lt;/a&gt;。虽然比较老了，但很经典。&lt;/li&gt;&lt;/ul&gt;&lt;ul&gt;&lt;li&gt;优化my.cnf里面的参数。主要关心和buffer有关的参数，innodb_buffer_pool_size之类的 &lt;/li&gt;&lt;/ul&gt;&lt;ul&gt;&lt;li&gt;使用memcache。可以把访问频繁，不经常改动的小表放入memcache；程序对数据库的读操作之前最好访问一下memcache。&lt;/li&gt;&lt;/ul&gt;&lt;ul&gt;&lt;li&gt;打开slow_query_log选项。解决出现的慢查询语句。&lt;/li&gt;&lt;/ul&gt;&lt;ul&gt;&lt;li&gt;优化sql语句。&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul&gt;&lt;li&gt;使用SAS而不是SATA。数据库对硬盘要求很高，很多时候，换个快的硬盘就能有立竿见影的效果。&lt;/li&gt;&lt;/ul&gt;&lt;span style="font-weight: bold;"&gt;优化不可能一蹴而就，它是一个长期持续的过程&lt;/span&gt;，比如一些参数要在长期的运行中观察测试才能得到一个最优的值。&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;ps:&lt;a href="http://forge.mysql.com/wiki/Top10SQLPerformanceTips"&gt;这篇文章&lt;/a&gt;不要错过&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5866936448448261654-2264622424431435435?l=moonbingbing.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://moonbingbing.blogspot.com/feeds/2264622424431435435/comments/default' title='帖子评论'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5866936448448261654&amp;postID=2264622424431435435' title='0 条评论'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5866936448448261654/posts/default/2264622424431435435'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5866936448448261654/posts/default/2264622424431435435'/><link rel='alternate' type='text/html' href='http://moonbingbing.blogspot.com/2008/12/mysql.html' title='MySQL海量数据优化'/><author><name>wayne</name><uri>http://www.blogger.com/profile/08537956174550037355</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5866936448448261654.post-8849223319539930272</id><published>2008-11-22T11:43:00.004+08:00</published><upd
