﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>BlogJava-陈于喆的技术博客-随笔分类-mysql</title><link>http://www.blogjava.net/dongbule/category/46019.html</link><description>构建高性能门户网</description><language>zh-cn</language><lastBuildDate>Wed, 01 Dec 2010 21:57:22 GMT</lastBuildDate><pubDate>Wed, 01 Dec 2010 21:57:22 GMT</pubDate><ttl>60</ttl><item><title>安装配置整理之 mysql</title><link>http://www.blogjava.net/dongbule/archive/2010/11/30/339394.html</link><dc:creator>陈于喆</dc:creator><author>陈于喆</author><pubDate>Tue, 30 Nov 2010 07:21:00 GMT</pubDate><guid>http://www.blogjava.net/dongbule/archive/2010/11/30/339394.html</guid><wfw:comment>http://www.blogjava.net/dongbule/comments/339394.html</wfw:comment><comments>http://www.blogjava.net/dongbule/archive/2010/11/30/339394.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/dongbule/comments/commentRss/339394.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/dongbule/services/trackbacks/339394.html</trackback:ping><description><![CDATA[mysql的官方网站是 http://www.mysql.com<br />
<br />
tar zxvf mysql-5.1.50.tar.gz<br />
<br />
cd mysql-5.1.50<br />
<br />
./configure --prefix=/usr/local/mysql --with-charset=gbk --with-extra-charset=all --enable-hread-safe-client <br />
--enable-local-infile --with-low-memory&nbsp; <br />
<br />
make &amp;&amp; make install<br />
<br />
chmod +w /usr/local/mysql<br />
<br />
chown -R mysql:mysql /usr/local/mysql<br />
<br />
cp support-files/my-medium.cnf /etc/my.cnf<br />
<br />
/usr/local/mysql/bin/mysql_install_db --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --user=mysql<br />
<br />
/bin/sh /usr/local/mysql/bin/mysqld_safe --defaults-file=/etc/my.cnf<br />
<img src ="http://www.blogjava.net/dongbule/aggbug/339394.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/dongbule/" target="_blank">陈于喆</a> 2010-11-30 15:21 <a href="http://www.blogjava.net/dongbule/archive/2010/11/30/339394.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>MySQL定期分析检查与优化表</title><link>http://www.blogjava.net/dongbule/archive/2010/10/10/334176.html</link><dc:creator>陈于喆</dc:creator><author>陈于喆</author><pubDate>Sun, 10 Oct 2010 06:55:00 GMT</pubDate><guid>http://www.blogjava.net/dongbule/archive/2010/10/10/334176.html</guid><wfw:comment>http://www.blogjava.net/dongbule/comments/334176.html</wfw:comment><comments>http://www.blogjava.net/dongbule/archive/2010/10/10/334176.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://www.blogjava.net/dongbule/comments/commentRss/334176.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/dongbule/services/trackbacks/334176.html</trackback:ping><description><![CDATA[<br />
听DBA的人说，相比oracle，MySQL就是一个玩具级别的数据库，在网易门户中，DBA基本很少去管理到MySQL的东西，所以我们产品使用到的MySQL的一些配置和优化还是需要我们开发人员自己动手，下面就简单介绍一下实用的定期优化方法<br />
<br />
<strong>定期分析表<br />
<br />
</strong>
<div style="background-color: rgb(238, 238, 238); font-size: 13px; border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; width: 98%;"><!--<br />
<br />
Code highlighting produced by Actipro CodeHighlighter (freeware)<br />
http://www.CodeHighlighter.com/<br />
<br />
--><span style="color: rgb(0, 0, 0);">ANALYZE&nbsp;[LOCAL&nbsp;|&nbsp;NO_WRITE_TO_BINLOG]&nbsp;TABLE&nbsp;tbl_name&nbsp;[,&nbsp;tbl_name]</span></div>
<br />
本语句用于分析和存储表的关键字分布。在分析期间，使用一个读取锁定对表进行锁定。这对于MyISAM, BDB和InnoDB表有作用。对于MyISAM表，本语句与使用myisamchk -a相当。<br />
<br />
MySQL使用已存储的关键字分布来决定，当您对除常数以外的对象执行联合时，表按什么顺序进行联合。
<br />
<br />
<div style="background-color: rgb(238, 238, 238); font-size: 13px; border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; width: 98%;"><!--<br />
<br />
Code highlighting produced by Actipro CodeHighlighter (freeware)<br />
http://www.CodeHighlighter.com/<br />
<br />
--><span style="color: rgb(0, 0, 0);">mysql&gt;&nbsp;analyze&nbsp;table&nbsp;a;<br />
+--------+---------+----------+-----------------------------+<br />
|&nbsp;Table&nbsp;&nbsp;|&nbsp;Op&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;Msg_type&nbsp;|&nbsp;Msg_text&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;|<br />
+--------+---------+----------+-----------------------------+<br />
|&nbsp;test.a&nbsp;|&nbsp;analyze&nbsp;|&nbsp;status&nbsp;&nbsp;&nbsp;|&nbsp;Table&nbsp;is&nbsp;already&nbsp;up&nbsp;to&nbsp;date&nbsp;|&nbsp;<br />
+--------+---------+----------+-----------------------------+<br />
1&nbsp;row&nbsp;in&nbsp;set&nbsp;(0.00&nbsp;sec)</span></div>
<br />
<strong>定期检查表<br />
<br />
</strong>
<div style="background-color: rgb(238, 238, 238); font-size: 13px; border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; width: 98%;"><!--<br />
<br />
Code highlighting produced by Actipro CodeHighlighter (freeware)<br />
http://www.CodeHighlighter.com/<br />
<br />
--><span style="color: rgb(0, 0, 0);">CHECK&nbsp;TABLE&nbsp;tbl_name&nbsp;[,&nbsp;tbl_name]&nbsp;<img src="http://www.blogjava.net/Images/dot.gif" alt="" />&nbsp;[option]&nbsp;<img src="http://www.blogjava.net/Images/dot.gif" alt="" /><br />
<br />
option&nbsp;=&nbsp;{QUICK&nbsp;|&nbsp;FAST&nbsp;|&nbsp;MEDIUM&nbsp;|&nbsp;EXTENDED&nbsp;|&nbsp;CHANGED}</span></div>
<strong><br />
</strong>检查一个或多个表是否有错误。CHECK TABLE对MyISAM和InnoDB表有作用。对于MyISAM表，关键字统计数据被更新。<br />
<br />
<div style="background-color: rgb(238, 238, 238); font-size: 13px; border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; width: 98%;"><!--<br />
<br />
Code highlighting produced by Actipro CodeHighlighter (freeware)<br />
http://www.CodeHighlighter.com/<br />
<br />
--><span style="color: rgb(0, 0, 0);">mysql&gt;&nbsp;check&nbsp;table&nbsp;a;<br />
+--------+-------+----------+----------+<br />
|&nbsp;Table&nbsp;&nbsp;|&nbsp;Op&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;Msg_type&nbsp;|&nbsp;Msg_text&nbsp;|<br />
+--------+-------+----------+----------+<br />
|&nbsp;test.a&nbsp;|&nbsp;check&nbsp;|&nbsp;status&nbsp;&nbsp;&nbsp;|&nbsp;OK&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;<br />
+--------+-------+----------+----------+<br />
1&nbsp;row&nbsp;in&nbsp;set&nbsp;(0.00&nbsp;sec)</span></div>
<br />
CHECK TABLE也可以检查视图是否有错误，比如在视图定义中被引用的表已不存在。<br />
我们为上面的表a创建一个视图
<br />
<br />
<div style="background-color: rgb(238, 238, 238); font-size: 13px; border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; width: 98%;"><!--<br />
<br />
Code highlighting produced by Actipro CodeHighlighter (freeware)<br />
http://www.CodeHighlighter.com/<br />
<br />
--><span style="color: rgb(0, 0, 0);">mysql&gt;&nbsp;create&nbsp;view&nbsp;a_view&nbsp;as&nbsp;select&nbsp;*&nbsp;from&nbsp;a;<br />
Query&nbsp;OK,&nbsp;0&nbsp;rows&nbsp;affected&nbsp;(0.02&nbsp;sec)</span></div>
<br />
然后CHECK一下该视图，发现没有问题<br />
<br />
<div style="background-color: rgb(238, 238, 238); font-size: 13px; border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; width: 98%;"><!--<br />
<br />
Code highlighting produced by Actipro CodeHighlighter (freeware)<br />
http://www.CodeHighlighter.com/<br />
<br />
--><span style="color: rgb(0, 0, 0);">mysql&gt;&nbsp;check&nbsp;table&nbsp;a_view;<br />
+-------------+-------+----------+----------+<br />
|&nbsp;Table&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;Op&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;Msg_type&nbsp;|&nbsp;Msg_text&nbsp;|<br />
+-------------+-------+----------+----------+<br />
|&nbsp;test.a_view&nbsp;|&nbsp;check&nbsp;|&nbsp;status&nbsp;&nbsp;&nbsp;|&nbsp;OK&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;<br />
+-------------+-------+----------+----------+<br />
1&nbsp;row&nbsp;in&nbsp;set&nbsp;(0.00&nbsp;sec)</span></div>
<br />
现在删掉视图依赖的表<br />
<br />
<div style="background-color: rgb(238, 238, 238); font-size: 13px; border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; width: 98%;"><!--<br />
<br />
Code highlighting produced by Actipro CodeHighlighter (freeware)<br />
http://www.CodeHighlighter.com/<br />
<br />
--><span style="color: rgb(0, 0, 0);">mysql&gt;&nbsp;drop&nbsp;table&nbsp;a;<br />
Query&nbsp;OK,&nbsp;0&nbsp;rows&nbsp;affected&nbsp;(0.01&nbsp;sec)</span></div>
<br />
再CHECK一下刚才的视图，发现报错了<br />
<br />
<div style="background-color: rgb(238, 238, 238); font-size: 13px; border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; width: 98%;"><!--<br />
<br />
Code highlighting produced by Actipro CodeHighlighter (freeware)<br />
http://www.CodeHighlighter.com/<br />
<br />
--><span style="color: rgb(0, 0, 0);">mysql&gt;&nbsp;check&nbsp;table&nbsp;a_view\G;<br />
***************************&nbsp;1.&nbsp;row&nbsp;***************************<br />
&nbsp;&nbsp;&nbsp;Table:&nbsp;test.a_view<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Op:&nbsp;check<br />
Msg_type:&nbsp;Error<br />
Msg_text:&nbsp;Table&nbsp;'test.a'&nbsp;doesn't&nbsp;exist<br />
***************************&nbsp;2.&nbsp;row&nbsp;***************************<br />
&nbsp;&nbsp;&nbsp;Table:&nbsp;test.a_view<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Op:&nbsp;check<br />
Msg_type:&nbsp;Error<br />
Msg_text:&nbsp;View&nbsp;'test.a_view'&nbsp;references&nbsp;invalid&nbsp;table(s)&nbsp;or&nbsp;column(s)&nbsp;or&nbsp;function(s)&nbsp;or&nbsp;definer/invoker&nbsp;of&nbsp;view&nbsp;lack&nbsp;rights&nbsp;to&nbsp;use&nbsp;them<br />
***************************&nbsp;3.&nbsp;row&nbsp;***************************<br />
&nbsp;&nbsp;&nbsp;Table:&nbsp;test.a_view<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Op:&nbsp;check<br />
Msg_type:&nbsp;error<br />
Msg_text:&nbsp;Corrupt<br />
3&nbsp;rows&nbsp;in&nbsp;set&nbsp;(0.00&nbsp;sec)<br />
<br />
ERROR:&nbsp;<br />
No&nbsp;query&nbsp;specified</span></div>
<br />
<strong>定期优化表<br />
<br />
</strong>
<div style="background-color: rgb(238, 238, 238); font-size: 13px; border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; width: 98%;"><!--<br />
<br />
Code highlighting produced by Actipro CodeHighlighter (freeware)<br />
http://www.CodeHighlighter.com/<br />
<br />
--><span style="color: rgb(0, 0, 0);">OPTIMIZE&nbsp;[LOCAL&nbsp;|&nbsp;NO_WRITE_TO_BINLOG]&nbsp;TABLE&nbsp;tbl_name&nbsp;[,&nbsp;tbl_name]&nbsp;</span></div>
<strong></strong><br />
如果您已经删除了表的一大部分，或者如果您已经对含有可变长度行的表（含有VARCHAR, BLOB或TEXT列的表）进行了很多更改，则应使用OPTIMIZE TABLE。被删除的记录被保持在链接清单中，后续的INSERT操作会重新使用旧的记录位置。您可以使用OPTIMIZE TABLE来重新利用未使用的空间，并整理数据文件的碎片。<br />
在多数的设置中，您根本不需要运行OPTIMIZE TABLE。即使您对可变长度的行进行了大量的更新，您也不需要经常运行，每周一次或每月一次即可，只对特定的表运行。<br />
OPTIMIZE TABLE只对MyISAM, BDB和InnoDB表起作用。<br />
对于MyISAM表，OPTIMIZE TABLE按如下方式操作：<br />
如果表已经删除或分解了行，则修复表。<br />
如果未对索引页进行分类，则进行分类。<br />
如果表的统计数据没有更新（并且通过对索引进行分类不能实现修复），则进行更新。
<br />
<br />
<div style="background-color: rgb(238, 238, 238); font-size: 13px; border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; width: 98%;"><!--<br />
<br />
Code highlighting produced by Actipro CodeHighlighter (freeware)<br />
http://www.CodeHighlighter.com/<br />
<br />
--><span style="color: rgb(0, 0, 0);">mysql&gt;&nbsp;OPTIMIZE&nbsp;table&nbsp;a;<br />
+--------+----------+----------+-----------------------------+<br />
|&nbsp;Table&nbsp;&nbsp;|&nbsp;Op&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;Msg_type&nbsp;|&nbsp;Msg_text&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;|<br />
+--------+----------+----------+-----------------------------+<br />
|&nbsp;test.a&nbsp;|&nbsp;optimize&nbsp;|&nbsp;status&nbsp;&nbsp;&nbsp;|&nbsp;Table&nbsp;is&nbsp;already&nbsp;up&nbsp;to&nbsp;date&nbsp;|&nbsp;<br />
+--------+----------+----------+-----------------------------+<br />
1&nbsp;row&nbsp;in&nbsp;set&nbsp;(0.00&nbsp;sec)<br />
</span></div>
<br />
****<br />
以上某些的段落是直接摘自MySQL的中文手册，详细可以直接查看MySQL的帮助手册，这里只是简单指出几种定期优化的方式，需要注意的是无论是ANALYZE，CHECK还是OPTIMIZE在执行期间将对表进行锁定，因此请注意这些操作要在数据库不繁忙的时候执行<br />
<p>****<br />
参考<br />
《MySQL 5.1参考手册》</p>
<p><br />
</p>
----------------------------------------<br />
<br />
by 陈于喆 <br />
QQ:34174409<br />
Mail: chenyz@corp.netease.com <br />
<br />
<img src ="http://www.blogjava.net/dongbule/aggbug/334176.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/dongbule/" target="_blank">陈于喆</a> 2010-10-10 14:55 <a href="http://www.blogjava.net/dongbule/archive/2010/10/10/334176.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>对MyIsam存储引擎表损坏的处理</title><link>http://www.blogjava.net/dongbule/archive/2010/10/10/334174.html</link><dc:creator>陈于喆</dc:creator><author>陈于喆</author><pubDate>Sun, 10 Oct 2010 06:11:00 GMT</pubDate><guid>http://www.blogjava.net/dongbule/archive/2010/10/10/334174.html</guid><wfw:comment>http://www.blogjava.net/dongbule/comments/334174.html</wfw:comment><comments>http://www.blogjava.net/dongbule/archive/2010/10/10/334174.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/dongbule/comments/commentRss/334174.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/dongbule/services/trackbacks/334174.html</trackback:ping><description><![CDATA[<br />
如果你的MyIsam表存在大量高并发的读写，那么就可能出现坏表的现象，这是因为MyIsam存储引擎所决定的，一张损坏的表的症状可能是以前某些错误<br />
<br />
<div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); width: 98%; font-size: 13px;"><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" alt="" align="top" /><span style="color: rgb(128, 128, 128);">*</span><span style="color: rgb(0, 0, 0);">.frm&nbsp;被锁定不能更改<br />
<img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" alt="" align="top" />找不到</span><span style="color: rgb(128, 128, 128);">*</span><span style="color: rgb(0, 0, 0);">.MYI<br />
<img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" alt="" align="top" />文件意外结束<br />
<img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" alt="" align="top" />记录文件损坏<br />
<img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" alt="" align="top" /><img src="http://www.blogjava.net/Images/dot.gif" alt="" /></span></div>
<br />
<strong>处理1</strong><br />
使用MySQL自带的myisamchk的工具进行修复，myisamchk不仅可以检查和修复MyIsam表，还可以进行优化和分析表，实际上，它集成了mysql中的check,repair,analyze,optimize的功能，下面是用myisamchk进行修复<br />
<br />
<div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); width: 98%; font-size: 13px;"><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" alt="" align="top" /><span style="color: rgb(0, 0, 0);">myisamchk&nbsp;</span><span style="color: rgb(128, 128, 128);">-</span><span style="color: rgb(0, 0, 0);">r&nbsp;tablename</span></div>
<br />
其中-r参数的含义是recover，在以往的应用，这语句几乎可以解决上面所述碰到的问题，如果还不行，可以使用<br />
<br />
<div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); width: 98%; font-size: 13px;"><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" alt="" align="top" /><span style="color: rgb(0, 0, 0);">myisamchk&nbsp;</span><span style="color: rgb(128, 128, 128);">-</span><span style="color: rgb(0, 0, 0);">o&nbsp;tablename</span></div>
<br />
其中-o参数的含义是--safe-recover，可以进行更安全的修复<br />
<br />
<strong>处理2</strong><br />
使用MySql的CHECK TABLE和REPAIR TABLE命令来进行修复，CHECK TABLE检查表是否损坏，REPAIR TABLE用来对表坏进行修复<br />
<br />
<div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); width: 98%; font-size: 13px;"><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" alt="" align="top" /><span style="color: rgb(0, 0, 255);">CHECK</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(0, 0, 255);">TABLE</span><span style="color: rgb(0, 0, 0);">&nbsp;tablename&nbsp;</span><span style="color: rgb(255, 0, 0);">[</span><span style="color: rgb(255, 0, 0);">option</span><span style="color: rgb(255, 0, 0);">]</span><span style="color: rgb(0, 0, 0);"><br />
<img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" alt="" align="top" /><br />
<img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" alt="" align="top" />REPAIR&nbsp;</span><span style="color: rgb(255, 0, 0);">[</span><span style="color: rgb(255, 0, 0);">option</span><span style="color: rgb(255, 0, 0);">]</span><span style="color: rgb(0, 0, 0);">&nbsp;tablename</span></div>
<br />
具体的参数可以参看MySQL的帮助文档<br />
<br />
一般来说第一种方法可以解决大多数的问题，如果采用这两种方法依然无法解决可以与我联系，QQ是34174409<br />
<br />
----------------------------------------<br />
<br />
by 陈于喆 <br />
QQ:34174409<br />
Mail: chenyz@corp.netease.com <br />
<br />
<img src ="http://www.blogjava.net/dongbule/aggbug/334174.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/dongbule/" target="_blank">陈于喆</a> 2010-10-10 14:11 <a href="http://www.blogjava.net/dongbule/archive/2010/10/10/334174.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>浅析MySql二进制日志的应用</title><link>http://www.blogjava.net/dongbule/archive/2010/09/04/331050.html</link><dc:creator>陈于喆</dc:creator><author>陈于喆</author><pubDate>Sat, 04 Sep 2010 10:55:00 GMT</pubDate><guid>http://www.blogjava.net/dongbule/archive/2010/09/04/331050.html</guid><wfw:comment>http://www.blogjava.net/dongbule/comments/331050.html</wfw:comment><comments>http://www.blogjava.net/dongbule/archive/2010/09/04/331050.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/dongbule/comments/commentRss/331050.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/dongbule/services/trackbacks/331050.html</trackback:ping><description><![CDATA[mysql有4种不同的日志，分别是二进制日志，查询日志，慢查询日志和错误日志，这些日记记录着数据库工作的方方面面，可以帮助我们了解数据库的不同方面的踪迹，下面先介绍二进制日志的作用和使用方法，并利用二进制日志对数据库进行各种维护和优化,其他日志也会在后面陆续会做详细的介绍。<br />
<span style="font-size: 18pt;"><br />
二进制日志（bin-log日志）</span><br />
在<a href="http://www.blogjava.net/dongbule/archive/2010/08/22/329602.html">上一篇介绍mysql主从配置的blog</a>中，已经提过bin-log日志的作用和使用，bin-log日志记录了所有的DDL和DML的语句，但不包括查询的语句，语句以事件的方式保存，描述了数据的更改过程，此日志对发生灾难时数据恢复起到了极为重要的作用。<br />
<br />
<strong>开启</strong><br />
mysql默认是没有开发bin-log日志，首先我们需要开启bin-log日志，在my.cnf中修改<br />
<br />
<img alt="" src="http://www.blogjava.net/images/blogjava_net/dongbule/mysql二进制日志/1.jpg" width="345" height="40" /><br />
<br />
指定了bin-log日志的路径，开启日志后需要myssqladmin flush log才生效,重启后我们发现在刚才设定的路径新增了log文件，这就是我们需要的二进制日志<br />
<br />
<img src="http://www.blogjava.net/images/blogjava_net/dongbule/mysql二进制日志/2.jpg" alt="" border="0" /><br />
<br />
由于日志是以二进制方式存储的，不能直接读取，需要使用mysql自带的mysqlbinlog工具来进行查看<br />
语法如下：<br />
<br />
<div style="background-color: rgb(238, 238, 238); font-size: 13px; border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; width: 98%;"><!--<br />
<br />
Code highlighting produced by Actipro CodeHighlighter (freeware)<br />
http://www.CodeHighlighter.com/<br />
<br />
--><span style="color: rgb(0, 0, 0);">#mysqlbinlog&nbsp;mysql</span><span style="color: rgb(128, 128, 128);">-</span><span style="color: rgb(0, 0, 0);">bin.</span><span style="color: rgb(128, 0, 0); font-weight: bold;">000002</span></div>
<br />
现在我们尝试向test1表插入数据<br />
<br />
<img alt="" src="http://www.blogjava.net/images/blogjava_net/dongbule/mysql二进制日志/3.jpg" border="0" /><br />
<br />
然后使用mysqlbinlog工具进行日志查看<br />
<br />
<div style="background-color: rgb(238, 238, 238); font-size: 13px; border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; width: 98%;"><!--<br />
<br />
Code highlighting produced by Actipro CodeHighlighter (freeware)<br />
http://www.CodeHighlighter.com/<br />
<br />
--><span style="color: rgb(0, 0, 0);">#mysqlbinlog&nbsp;mysql</span><span style="color: rgb(128, 128, 128);">-</span><span style="color: rgb(0, 0, 0);">bin.</span><span style="color: rgb(128, 0, 0); font-weight: bold;">000002</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(128, 128, 128);">-</span><span style="color: rgb(0, 0, 0);">d&nbsp;test</span></div>
<br />
<img src="http://www.blogjava.net/images/blogjava_net/dongbule/mysql二进制日志/4.jpg" alt="" border="0" /><br />
<br />
<strong>清理</strong><br />
<br />
如果每天都会生成大量的二进制日志，这些日志长时间不清理的话，将会对磁盘空间带来很大的浪费，所以定期清理日志是DBA维护mysql的一个重要工作<br />
<br />
1)<strong>RESET MASTER</strong><br />
在上面查看日志存放的文件夹中，二进制日志命名的格式是以mysql-bin.*，*代表日志的序号,序号是递增的,其中还有mysql-bin.index是日志的索引文件,记录了日志的最大序号<br />
我们执行RESET MASTER命名删除全部日志<br />
<br />
<img src="http://www.blogjava.net/images/blogjava_net/dongbule/mysql二进制日志/5.jpg" alt="" border="0" /><br />
<br />
查看删除后的日志<br />
<br />
<img src="http://www.blogjava.net/images/blogjava_net/dongbule/mysql二进制日志/6.jpg" alt="" border="0" /><br />
<br />
可以看到,以前的日志全部被清空,新的日志从00001开始<br />
<br />
2)<strong>PURGE MASTER LOGS TO</strong> &amp; <strong>PURGE MASTER LOGS BEFORE</strong><br />
执行PURGE MASTER LOGS TO 'mysql-bin.******'命令，是将'******'编号之前的所有日志进行删除<br />
执行PURGE MASTER LOGS BEFORE 'yyyy-mm-dd hh:mm:ss'命令，是将在'yyyy-mm-dd hh:mm:ss'时间之前的所有日志进行删除<br />
<br />
3)-<strong>EXPIRE_LOGS_DAYS</strong><br />
此参数是设置日志的过期天数，过期的日志将会被自动删除，这有利于减少我们管理日志的工作量，需要修改my.cnf<br />
<br />
<img src="http://www.blogjava.net/images/blogjava_net/dongbule/mysql二进制日志/7.jpg" alt="" border="0" /><br />
<br />
这里我们设定保存日志为3天，3天之后过期的日志将被自动删除<br />
<br />
<strong>恢复</strong><br />
<br />
bin-log是记录着mysql所有事件的操作，当mysql发生灾难性错误时，可以通过bin-log做完整恢复，基于时间点的恢复，和基于位置的恢复<br />
<u><br />
</u><strong>完整恢复</strong>，假定我们每天凌晨2点都会使用mysqldump备份数据库，但在第二天早上9点由于数据库出现了故障，数据无法访问，需要恢复数据，先使用昨天凌晨备份的文件进行恢复到凌晨2点的状态，在使用mysqlbinlog恢复自mysqldump备份以来的binlog<br />
mysql localhost mysql-bin.000001 | mysql -uroot -p<br />
这样数据库就可以完全的恢复到崩溃前的完全状态<br />
<br />
<strong>基于时间点的恢复</strong>，由于误操作，比如说删除了一张表，这时使用上面讲的完全恢复是没有用的，因为日志里面还存在误操作的语句，，我们需要的是恢复到误操作前的状态，然后跳过误操作的语句，再恢复后面操作的语句，假定我们删除了一张表的误操作发生在10:00这个时间点，我们可以使用下面的语句用备份和binlog将数据恢复到故障前<br />
<br />
<div style="background-color: rgb(238, 238, 238); font-size: 13px; border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; width: 98%;"><!--<br />
<br />
Code highlighting produced by Actipro CodeHighlighter (freeware)<br />
http://www.CodeHighlighter.com/<br />
<br />
--><span style="color: rgb(0, 0, 0);">mysqlbinlog&nbsp;</span><span style="color: rgb(0, 128, 128);">--</span><span style="color: rgb(0, 128, 128);">stop-date='2010-09-04&nbsp;9:59:59'&nbsp;/var/log/mysql-bin.000001&nbsp;|&nbsp;mysql&nbsp;-uroot&nbsp;-p</span></div>
<br />
然后跳过误操作的时间点，继续执行后面的binlog<br />
<br />
<div style="background-color: rgb(238, 238, 238); font-size: 13px; border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; width: 98%;"><!--<br />
<br />
Code highlighting produced by Actipro CodeHighlighter (freeware)<br />
http://www.CodeHighlighter.com/<br />
<br />
--><span style="color: rgb(0, 0, 0);">mysqlbinlog&nbsp;</span><span style="color: rgb(0, 128, 128);">--</span><span style="color: rgb(0, 128, 128);">start-date='2010-09-04&nbsp;10:01:00'&nbsp;/var/log/mysql-bin.000001&nbsp;|&nbsp;mysql&nbsp;-uroot&nbsp;-p</span></div>
<br />
其中--stop-date='2010-09-04 9:59:59' 和 --start-date='2010-09-04 10:01:00' 其中的时间是你误操作的时间点，当然了，这个时间点你需要你自己计算的，而且这个时间点还可以涉及到的不只是误操作，还可以有正确的操作也被跳过去了。<br />
<br />
<strong>基于位置恢复</strong>，由于上面提到的，使用基于时间点的恢复可能出现，在一个时间点里面可能存在误操作和其他正确的操作，所以我们需要一种更为精确的恢复方式<br />
使用mysqlbinlog查看二进制，可看到<br />
<br />
<img src="http://www.blogjava.net/images/blogjava_net/dongbule/mysql二进制日志/8.jpg" alt="" border="0" /><br />
<br />
其中drop tables test1这个误操作的end_log_pos为8879917，几下这个id,得出它前后操作的id分别为8879916,8879918<br />
我们将进行位置恢复操作<br />
<div style="background-color: rgb(238, 238, 238); font-size: 13px; border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; width: 98%;"><!--<br />
<br />
Code highlighting produced by Actipro CodeHighlighter (freeware)<br />
http://www.CodeHighlighter.com/<br />
<br />
--><span style="color: rgb(0, 0, 0);">mysqlbinlog&nbsp;</span><span style="color: rgb(0, 128, 128);">--</span><span style="color: rgb(0, 128, 128);">stop-position='8879916'&nbsp;/var/log/mysql-bin.000001&nbsp;|&nbsp;mysql&nbsp;-uroot&nbsp;-p</span><span style="color: rgb(0, 128, 128);"><br />
</span><span style="color: rgb(0, 0, 0);"><br />
mysqlbinlog&nbsp;</span><span style="color: rgb(0, 128, 128);">--</span><span style="color: rgb(0, 128, 128);">start-position='8879918'&nbsp;/var/log/mysql-bin.000001&nbsp;|&nbsp;mysql&nbsp;-uroot&nbsp;-p</span></div>
<br />
第一行是恢复到停止位置位置的所以事务，第二性是恢复从给定的起始位置知道二进制日志结束所有事物。<br />
<br />
<strong>主从复制</strong><br />
mysql的复制是指将主数据库的DDL和DML操作通过二进制日志传到从服务器上，然后在从服务器上对这些日志做重新执行的操作，从而使得从服务器和主服务器保持数据的同步，通过二进制日志进行主从复制的可以看前一篇《<a href="http://www.blogjava.net/dongbule/archive/2010/08/22/329602.html">MySQL 主从复制配置</a>》<br />
<br />
----------------------------------------<br />
<br />
by 陈于喆 <br />
Mail: chenyz@corp.netease.com
<br />
<br />
<img src ="http://www.blogjava.net/dongbule/aggbug/331050.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/dongbule/" target="_blank">陈于喆</a> 2010-09-04 18:55 <a href="http://www.blogjava.net/dongbule/archive/2010/09/04/331050.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>MySQL主从复制的一些错误处理和日常维护</title><link>http://www.blogjava.net/dongbule/archive/2010/08/23/329714.html</link><dc:creator>陈于喆</dc:creator><author>陈于喆</author><pubDate>Mon, 23 Aug 2010 13:35:00 GMT</pubDate><guid>http://www.blogjava.net/dongbule/archive/2010/08/23/329714.html</guid><wfw:comment>http://www.blogjava.net/dongbule/comments/329714.html</wfw:comment><comments>http://www.blogjava.net/dongbule/archive/2010/08/23/329714.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/dongbule/comments/commentRss/329714.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/dongbule/services/trackbacks/329714.html</trackback:ping><description><![CDATA[检查从服务器一般使用show slave status命令来检查<br />
<br />
<div style="background-color: rgb(238, 238, 238); font-size: 13px; border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; width: 98%;"><!--<br />
<br />
Code highlighting produced by Actipro CodeHighlighter (freeware)<br />
http://www.CodeHighlighter.com/<br />
<br />
--><span style="color: rgb(0, 0, 0);">mysql</span><span style="color: rgb(128, 128, 128);">&gt;</span><span style="color: rgb(0, 0, 0);">&nbsp;SHOW&nbsp;SLAVE&nbsp;STATUS\G<br />
</span><span style="color: rgb(128, 128, 128);">***************************</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(128, 0, 0); font-weight: bold;">1</span><span style="color: rgb(0, 0, 0);">.&nbsp;row&nbsp;</span><span style="color: rgb(128, 128, 128);">***************************</span><span style="color: rgb(0, 0, 0);"><br />
Slave_IO_State:&nbsp;Waiting&nbsp;</span><span style="color: rgb(0, 0, 255);">for</span><span style="color: rgb(0, 0, 0);">&nbsp;master&nbsp;</span><span style="color: rgb(0, 0, 255);">to</span><span style="color: rgb(0, 0, 0);">&nbsp;send&nbsp;event<br />
Master_Host:&nbsp;</span><span style="color: rgb(128, 0, 0); font-weight: bold;">192.168</span><span style="color: rgb(0, 0, 0);">.</span><span style="color: rgb(128, 0, 0); font-weight: bold;">0.100</span><span style="color: rgb(0, 0, 0);"><br />
Master_User:&nbsp;root<br />
Master_Port:&nbsp;</span><span style="color: rgb(128, 0, 0); font-weight: bold;">3306</span><span style="color: rgb(0, 0, 0);"><br />
Connect_Retry:&nbsp;</span><span style="color: rgb(128, 0, 0); font-weight: bold;">3</span><span style="color: rgb(0, 0, 0);"><br />
&nbsp;Master_Log_File:&nbsp;mysql</span><span style="color: rgb(128, 128, 128);">-</span><span style="color: rgb(0, 0, 0);">bin.</span><span style="color: rgb(128, 0, 0); font-weight: bold;">003</span><span style="color: rgb(0, 0, 0);"><br />
&nbsp;Read_Master_Log_Pos:&nbsp;</span><span style="color: rgb(128, 0, 0); font-weight: bold;">79</span><span style="color: rgb(0, 0, 0);"><br />
Relay_Log_File:&nbsp;mysql&nbsp;</span><span style="color: rgb(128, 128, 128);">-</span><span style="color: rgb(0, 0, 0);">relay</span><span style="color: rgb(128, 128, 128);">-</span><span style="color: rgb(0, 0, 0);">bin.&nbsp;</span><span style="color: rgb(128, 0, 0); font-weight: bold;">003</span><span style="color: rgb(0, 0, 0);"><br />
Relay_Log_Pos:&nbsp;</span><span style="color: rgb(128, 0, 0); font-weight: bold;">548</span><span style="color: rgb(0, 0, 0);"><br />
Relay_Master_Log_File:&nbsp;mysql&nbsp;</span><span style="color: rgb(128, 128, 128);">-</span><span style="color: rgb(0, 0, 0);">bin.&nbsp;</span><span style="color: rgb(128, 0, 0); font-weight: bold;">003</span><span style="color: rgb(0, 0, 0);"><br />
Slave_IO_Running:&nbsp;Yes<br />
Slave_SQL_Running:&nbsp;Yes<br />
Replicate_Do_DB:<br />
Replicate_Ignore_DB:<br />
Last_Errno:&nbsp;</span><span style="color: rgb(128, 0, 0); font-weight: bold;">0</span><span style="color: rgb(0, 0, 0);"><br />
&#8230;..</span></div>
<br />
在上面这些信息中我们主要关注的是Slave_IO_Running和Slave_SQL_Running<br />
Slave_IO_Running:从服务器正从主服务器上读取BINLOG日志,并写入从服务器的中继日志<br />
Slave_SQL_Running:进程正在读取从服务器的BINLOG中继日志，并转化为SQL执行<br />
以前有一个进程是no状态，表示复制的进程停止，在Last_Errno会看到是什么情况<br />
<br />
有时候因为主服务器的更新过于频繁,造成了从服务器更新速度较慢,当然问题是多种多样,有可能是网络搭建的结构不好或者硬件的性能较差,从而使得主从服务器之间的差距越来越大,最终对某些应用产生了影响,在这种情况下,我们需要定期进行主从服务器的数据同步,具体步骤如下<br />
在主服务器上<br />
<br />
<div style="background-color: rgb(238, 238, 238); font-size: 13px; border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; width: 98%;"><!--<br />
<br />
Code highlighting produced by Actipro CodeHighlighter (freeware)<br />
http://www.CodeHighlighter.com/<br />
<br />
--><span style="color: rgb(0, 0, 0);">mysql</span><span style="color: rgb(128, 128, 128);">&gt;</span><span style="color: rgb(0, 0, 0);">&nbsp;FLUSH&nbsp;TABLES&nbsp;</span><span style="color: rgb(0, 0, 255);">WITH</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(0, 0, 255);">READ</span><span style="color: rgb(0, 0, 0);">&nbsp;LOCK;<br />
Query&nbsp;OK,&nbsp;</span><span style="color: rgb(128, 0, 0); font-weight: bold;">0</span><span style="color: rgb(0, 0, 0);">&nbsp;rows&nbsp;affected&nbsp;(</span><span style="color: rgb(128, 0, 0); font-weight: bold;">0.03</span><span style="color: rgb(0, 0, 0);">&nbsp;sec)<br />
mysql</span><span style="color: rgb(128, 128, 128);">&gt;</span><span style="color: rgb(0, 0, 0);">&nbsp;show&nbsp;master&nbsp;status\G;<br />
</span><span style="color: rgb(128, 128, 128);">***************************</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(128, 0, 0); font-weight: bold;">1</span><span style="color: rgb(0, 0, 0);">.&nbsp;row&nbsp;</span><span style="color: rgb(128, 128, 128);">***************************</span><span style="color: rgb(0, 0, 0);"><br />
</span><span style="color: rgb(0, 0, 255);">File</span><span style="color: rgb(0, 0, 0);">:&nbsp;mysql</span><span style="color: rgb(128, 128, 128);">-</span><span style="color: rgb(0, 0, 0);">bin.</span><span style="color: rgb(128, 0, 0); font-weight: bold;">000004</span><span style="color: rgb(0, 0, 0);"><br />
Position:&nbsp;</span><span style="color: rgb(128, 0, 0); font-weight: bold;">102</span><span style="color: rgb(0, 0, 0);"><br />
Binlog_Do_DB:<br />
Binlog_Ignore_DB:<br />
</span><span style="color: rgb(128, 0, 0); font-weight: bold;">1</span><span style="color: rgb(0, 0, 0);">&nbsp;row&nbsp;</span><span style="color: rgb(128, 128, 128);">in</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(0, 0, 255);">set</span><span style="color: rgb(0, 0, 0);">&nbsp;(</span><span style="color: rgb(128, 0, 0); font-weight: bold;">0.00</span><span style="color: rgb(0, 0, 0);">&nbsp;sec)</span></div>
<br />
记录出日志的名字和偏移量,这些是从服务器复制的目的目标<br />
<br />
在从服务器上,使用MASTER_POS_WAIT()函数得到复制坐标值<br />
<br />
<div style="background-color: rgb(238, 238, 238); font-size: 13px; border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; width: 98%;"><!--<br />
<br />
Code highlighting produced by Actipro CodeHighlighter (freeware)<br />
http://www.CodeHighlighter.com/<br />
<br />
--><span style="color: rgb(0, 0, 0);">mysql</span><span style="color: rgb(128, 128, 128);">&gt;</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(0, 0, 255);">select</span><span style="color: rgb(0, 0, 0);">&nbsp;master_pos_wait(</span><span style="color: rgb(255, 0, 0);">'</span><span style="color: rgb(255, 0, 0);">mysql-bin.000004</span><span style="color: rgb(255, 0, 0);">'</span><span style="color: rgb(0, 0, 0);">,</span><span style="color: rgb(255, 0, 0);">'</span><span style="color: rgb(255, 0, 0);">102</span><span style="color: rgb(255, 0, 0);">'</span><span style="color: rgb(0, 0, 0);">);<br />
</span><span style="color: rgb(128, 128, 128);">+</span><span style="color: rgb(0, 128, 128);">--</span><span style="color: rgb(0, 128, 128);">-----------------------------------------+</span><span style="color: rgb(0, 128, 128);"><br />
</span><span style="color: rgb(128, 128, 128);">|</span><span style="color: rgb(0, 0, 0);">&nbsp;master_pos_wait(</span><span style="color: rgb(255, 0, 0);">'</span><span style="color: rgb(255, 0, 0);">mysql-bin.000004</span><span style="color: rgb(255, 0, 0);">'</span><span style="color: rgb(0, 0, 0);">,</span><span style="color: rgb(255, 0, 0);">'</span><span style="color: rgb(255, 0, 0);">102</span><span style="color: rgb(255, 0, 0);">'</span><span style="color: rgb(0, 0, 0);">)&nbsp;</span><span style="color: rgb(128, 128, 128);">|</span><span style="color: rgb(0, 0, 0);"><br />
</span><span style="color: rgb(128, 128, 128);">+</span><span style="color: rgb(0, 128, 128);">--</span><span style="color: rgb(0, 128, 128);">-----------------------------------------+</span><span style="color: rgb(0, 128, 128);"><br />
</span><span style="color: rgb(128, 128, 128);">|</span><span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(128, 0, 0); font-weight: bold;">0</span><span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(128, 128, 128);">|</span><span style="color: rgb(0, 0, 0);"><br />
</span><span style="color: rgb(128, 128, 128);">+</span><span style="color: rgb(0, 128, 128);">--</span><span style="color: rgb(0, 128, 128);">-----------------------------------------+</span><span style="color: rgb(0, 128, 128);"><br />
</span><span style="color: rgb(128, 0, 0); font-weight: bold;">1</span><span style="color: rgb(0, 0, 0);">&nbsp;row&nbsp;</span><span style="color: rgb(128, 128, 128);">in</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(0, 0, 255);">set</span><span style="color: rgb(0, 0, 0);">&nbsp;(</span><span style="color: rgb(128, 0, 0); font-weight: bold;">0.00</span><span style="color: rgb(0, 0, 0);">&nbsp;sec)</span></div>
这个select 语句会阻塞直到从服务器达到指定日志文件和偏移量后,返回0,如果是-1,则表示超时推出,查询是0时,表示从服务器与主服务器已经同步<br />
<br />
在某些情况下,会出现从服务器更新失败,首先需要确定是否从服务器的表与主服务器的不同造成的,如果是表结构造成的,则需要修改从服务器的表和主服务器一致,然后重新运行start slave<br />
如果不是表结构不同造成的更新失败，则需要确认手动更新是否安全，然后忽视来自主服务器的更新失败语句，跳过来来自主服务器的语句，命令为SET GLOBAL SQL_SLAVE_SKIP_COUNTER=n,其中,n=1表示来自主服务器的更新语句不使用AUTO_INCREMENT或LAST_INSERT_ID(),n=2时则反之,原因是使用AUTO_INCREMENT或LAST_INSERT_ID的语句需要从二进制日志中取得两个事件.<br />
----------------------------------------<br />
<br />
by 陈于喆 <br />
Mail: chenyz@corp.netease.com
<br />
<br />
<br />
<br />
<img src ="http://www.blogjava.net/dongbule/aggbug/329714.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/dongbule/" target="_blank">陈于喆</a> 2010-08-23 21:35 <a href="http://www.blogjava.net/dongbule/archive/2010/08/23/329714.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>mysql4.0迁移到5.0的passowd()函数问题</title><link>http://www.blogjava.net/dongbule/archive/2010/08/23/329628.html</link><dc:creator>陈于喆</dc:creator><author>陈于喆</author><pubDate>Mon, 23 Aug 2010 02:41:00 GMT</pubDate><guid>http://www.blogjava.net/dongbule/archive/2010/08/23/329628.html</guid><wfw:comment>http://www.blogjava.net/dongbule/comments/329628.html</wfw:comment><comments>http://www.blogjava.net/dongbule/archive/2010/08/23/329628.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/dongbule/comments/commentRss/329628.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/dongbule/services/trackbacks/329628.html</trackback:ping><description><![CDATA[前天迁移了一个老系统,用的mysql是4.0要迁移到5.0的环境下,发现了一个问题,在password()函数上发生错误,查一查原来password()函数在mysql5.0已经发生了变换
<br />
在mysql4.0下<br />
<br />
<div style="background-color: rgb(238, 238, 238); font-size: 13px; border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; width: 98%;"><!--<br />
<br />
Code highlighting produced by Actipro CodeHighlighter (freeware)<br />
http://www.CodeHighlighter.com/<br />
<br />
--><span style="color: rgb(0, 0, 0);">mysql</span><span style="color: rgb(128, 128, 128);">&gt;</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(0, 0, 255);">select</span><span style="color: rgb(0, 0, 0);">&nbsp;password(</span><span style="color: rgb(255, 0, 0);">'</span><span style="color: rgb(255, 0, 0);">abc</span><span style="color: rgb(255, 0, 0);">'</span><span style="color: rgb(0, 0, 0);">);&nbsp;<br />
</span><span style="color: rgb(128, 128, 128);">+</span><span style="color: rgb(0, 128, 128);">--</span><span style="color: rgb(0, 128, 128);">----------------+&nbsp;</span><span style="color: rgb(0, 128, 128);"><br />
</span><span style="color: rgb(128, 128, 128);">|</span><span style="color: rgb(0, 0, 0);">&nbsp;password(</span><span style="color: rgb(255, 0, 0);">'</span><span style="color: rgb(255, 0, 0);">abc</span><span style="color: rgb(255, 0, 0);">'</span><span style="color: rgb(0, 0, 0);">)&nbsp;&nbsp;</span><span style="color: rgb(128, 128, 128);">|</span><span style="color: rgb(0, 0, 0);">&nbsp;<br />
</span><span style="color: rgb(128, 128, 128);">+</span><span style="color: rgb(0, 128, 128);">--</span><span style="color: rgb(0, 128, 128);">----------------+&nbsp;</span><span style="color: rgb(0, 128, 128);"><br />
</span><span style="color: rgb(128, 128, 128);">|</span><span style="color: rgb(0, 0, 0);">&nbsp;7cd2b5942be28759&nbsp;</span><span style="color: rgb(128, 128, 128);">|</span><span style="color: rgb(0, 0, 0);">&nbsp;<br />
</span><span style="color: rgb(128, 128, 128);">+</span><span style="color: rgb(0, 128, 128);">--</span><span style="color: rgb(0, 128, 128);">----------------+&nbsp; <br />
</span></div>
<br />
而在mysql5.0下
<br />
<br />
<div style="background-color: rgb(238, 238, 238); font-size: 13px; border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; width: 98%;"><!--<br />
<br />
Code highlighting produced by Actipro CodeHighlighter (freeware)<br />
http://www.CodeHighlighter.com/<br />
<br />
--><span style="color: rgb(0, 0, 255);">select</span><span style="color: rgb(0, 0, 0);">&nbsp;password(</span><span style="color: rgb(255, 0, 0);">'</span><span style="color: rgb(255, 0, 0);">abc</span><span style="color: rgb(255, 0, 0);">'</span><span style="color: rgb(0, 0, 0);">);&nbsp;&nbsp;<br />
</span><span style="color: rgb(128, 128, 128);">+</span><span style="color: rgb(0, 128, 128);">--</span><span style="color: rgb(0, 128, 128);">-----------------------------------------+&nbsp;&nbsp;</span><span style="color: rgb(0, 128, 128);"><br />
</span><span style="color: rgb(128, 128, 128);">|</span><span style="color: rgb(0, 0, 0);">&nbsp;password(</span><span style="color: rgb(255, 0, 0);">'</span><span style="color: rgb(255, 0, 0);">abc</span><span style="color: rgb(255, 0, 0);">'</span><span style="color: rgb(0, 0, 0);">)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(128, 128, 128);">|</span><span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;<br />
</span><span style="color: rgb(128, 128, 128);">+</span><span style="color: rgb(0, 128, 128);">--</span><span style="color: rgb(0, 128, 128);">-----------------------------------------+&nbsp;&nbsp;</span><span style="color: rgb(0, 128, 128);"><br />
</span><span style="color: rgb(128, 128, 128);">|</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(128, 128, 128);">*</span><span style="color: rgb(0, 0, 0);">0D3CED9BEC10A777AEC23CCC353A8C08A633045E&nbsp;</span><span style="color: rgb(128, 128, 128);">|</span><span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;<br />
</span><span style="color: rgb(128, 128, 128);">+</span><span style="color: rgb(0, 128, 128);">--</span><span style="color: rgb(0, 128, 128);">-----------------------------------------+&nbsp; <br />
</span></div>
<br />
经查资料,在mysql5.0下使用old_passord()函数就可以得到与4.0一样的效果
<br />
<br />
<div style="background-color: rgb(238, 238, 238); font-size: 13px; border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; width: 98%;"><!--<br />
<br />
Code highlighting produced by Actipro CodeHighlighter (freeware)<br />
http://www.CodeHighlighter.com/<br />
<br />
--><span style="color: rgb(0, 0, 255);">select</span><span style="color: rgb(0, 0, 0);">&nbsp;old_password(</span><span style="color: rgb(255, 0, 0);">'</span><span style="color: rgb(255, 0, 0);">abc</span><span style="color: rgb(255, 0, 0);">'</span><span style="color: rgb(0, 0, 0);">);&nbsp;&nbsp;<br />
</span><span style="color: rgb(128, 128, 128);">+</span><span style="color: rgb(0, 128, 128);">--</span><span style="color: rgb(0, 128, 128);">-------------------+&nbsp;&nbsp;</span><span style="color: rgb(0, 128, 128);"><br />
</span><span style="color: rgb(128, 128, 128);">|</span><span style="color: rgb(0, 0, 0);">&nbsp;old_password(</span><span style="color: rgb(255, 0, 0);">'</span><span style="color: rgb(255, 0, 0);">abc</span><span style="color: rgb(255, 0, 0);">'</span><span style="color: rgb(0, 0, 0);">)&nbsp;</span><span style="color: rgb(128, 128, 128);">|</span><span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;<br />
</span><span style="color: rgb(128, 128, 128);">+</span><span style="color: rgb(0, 128, 128);">--</span><span style="color: rgb(0, 128, 128);">-------------------+&nbsp;&nbsp;</span><span style="color: rgb(0, 128, 128);"><br />
</span><span style="color: rgb(128, 128, 128);">|</span><span style="color: rgb(0, 0, 0);">&nbsp;7cd2b5942be28759&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(128, 128, 128);">|</span><span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;<br />
</span><span style="color: rgb(128, 128, 128);">+</span><span style="color: rgb(0, 128, 128);">--</span><span style="color: rgb(0, 128, 128);">-------------------+&nbsp; <br />
</span></div>
<br />
<br />
但只要需要改动到程序,再进行查资料
<br />
<br />
两个函数都可以用password() 函数调用，
<br />
控制开关由/etc/mysql/my.cnf中的old_passwords变量设定：
<br />
设置为&#8220;0&#8221; ,调用新的password函数，
<br />
设置为&#8221;1&#8243;，就调用旧的password函数。
<br />
<br />
问题最终解决,不用修改程序
<br />
<br />
----------------------------------------<br />
<br />
陈于喆 <br />
Mail: chenyz@corp.netease.com
<br />
<img src ="http://www.blogjava.net/dongbule/aggbug/329628.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/dongbule/" target="_blank">陈于喆</a> 2010-08-23 10:41 <a href="http://www.blogjava.net/dongbule/archive/2010/08/23/329628.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>MySQL主从复制几个重要的启动选项</title><link>http://www.blogjava.net/dongbule/archive/2010/08/22/329603.html</link><dc:creator>陈于喆</dc:creator><author>陈于喆</author><pubDate>Sun, 22 Aug 2010 15:30:00 GMT</pubDate><guid>http://www.blogjava.net/dongbule/archive/2010/08/22/329603.html</guid><wfw:comment>http://www.blogjava.net/dongbule/comments/329603.html</wfw:comment><comments>http://www.blogjava.net/dongbule/archive/2010/08/22/329603.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/dongbule/comments/commentRss/329603.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/dongbule/services/trackbacks/329603.html</trackback:ping><description><![CDATA[<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="ProgId" content="Word.Document" />
<meta name="Generator" content="Microsoft Word 11" />
<meta name="Originator" content="Microsoft Word 11" />
<link rel="File-List" href="file:///C:%5CDOCUME%7E1%5CADMINI%7E1%5CLOCALS%7E1%5CTemp%5Cmsohtml1%5C16%5Cclip_filelist.xml" /><!--[if gte mso 9]><xml>
<w:WordDocument>
<w:View>Normal</w:View>
<w:Zoom>0</w:Zoom>
<w:PunctuationKerning/>
<w:DrawingGridVerticalSpacing>7.8 磅</w:DrawingGridVerticalSpacing>
<w:DisplayHorizontalDrawingGridEvery>0</w:DisplayHorizontalDrawingGridEvery>
<w:DisplayVerticalDrawingGridEvery>2</w:DisplayVerticalDrawingGridEvery>
<w:ValidateAgainstSchemas/>
<w:SaveIfXMLInvalid>false</w:SaveIfXMLInvalid>
<w:IgnoreMixedContent>false</w:IgnoreMixedContent>
<w:AlwaysShowPlaceholderText>false</w:AlwaysShowPlaceholderText>
<w:Compatibility>
<w:SpaceForUL/>
<w:BalanceSingleByteDoubleByteWidth/>
<w:DoNotLeaveBackslashAlone/>
<w:ULTrailSpace/>
<w:DoNotExpandShiftReturn/>
<w:AdjustLineHeightInTable/>
<w:BreakWrappedTables/>
<w:SnapToGridInCell/>
<w:WrapTextWithPunct/>
<w:UseAsianBreakRules/>
<w:DontGrowAutofit/>
<w:UseFELayout/>
</w:Compatibility>
<w:BrowserLevel>MicrosoftInternetExplorer4</w:BrowserLevel>
</w:WordDocument>
</xml><![endif]--><!--[if gte mso 9]><xml>
<w:LatentStyles deflockedstate="false" latentstylecount="156">
</w:LatentStyles>
</xml><![endif]--><style>
<!-- /* Font Definitions */
@font-face
{font-family:宋体;
panose-1:2 1 6 0 3 1 1 1 1 1;
mso-font-alt:SimSun;
mso-font-charset:134;
mso-generic-font-family:auto;
mso-font-pitch:variable;
mso-font-signature:3 135135232 16 0 262145 0;}
@font-face
{font-family:"\@宋体";
panose-1:2 1 6 0 3 1 1 1 1 1;
mso-font-charset:134;
mso-generic-font-family:auto;
mso-font-pitch:variable;
mso-font-signature:3 135135232 16 0 262145 0;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{mso-style-parent:"";
margin:0cm;
margin-bottom:.0001pt;
text-align:justify;
text-justify:inter-ideograph;
mso-pagination:none;
font-size:10.5pt;
mso-bidi-font-size:12.0pt;
font-family:"Times New Roman";
mso-fareast-font-family:宋体;
mso-font-kerning:1.0pt;}
/* Page Definitions */
@page
{mso-page-border-surround-header:no;
mso-page-border-surround-footer:no;}
@page Section1
{size:595.3pt 841.9pt;
margin:72.0pt 90.0pt 72.0pt 90.0pt;
mso-header-margin:42.55pt;
mso-footer-margin:49.6pt;
mso-paper-source:0;
layout-grid:15.6pt;}
div.Section1
{page:Section1;}
/* List Definitions */
@list l0
{mso-list-id:1490370181;
mso-list-type:hybrid;
mso-list-template-ids:1888769624 1071167276 67698713 67698715 67698703 67698713 67698715 67698703 67698713 67698715;}
@list l0:level1
{mso-level-text:"\(%1\)";
mso-level-tab-stop:18.0pt;
mso-level-number-position:left;
margin-left:18.0pt;
text-indent:-18.0pt;}
ol
{margin-bottom:0cm;}
ul
{margin-bottom:0cm;}
-->
</style><!--[if gte mso 10]>
<style>
/* Style Definitions */
table.MsoNormalTable
{mso-style-name:普通表格;
mso-tstyle-rowband-size:0;
mso-tstyle-colband-size:0;
mso-style-noshow:yes;
mso-style-parent:"";
mso-padding-alt:0cm 5.4pt 0cm 5.4pt;
mso-para-margin:0cm;
mso-para-margin-bottom:.0001pt;
mso-pagination:widow-orphan;
font-size:10.0pt;
font-family:"Times New Roman";
mso-ansi-language:#0400;
mso-fareast-language:#0400;
mso-bidi-language:#0400;}
</style>
<![endif]-->
<p class="MsoNormal" style="text-align: center;" align="center"><strong><span style="font-size: 12pt;" lang="EN-US"><br />
</span></strong><strong></strong><strong><span style="font-size: 12pt;" lang="EN-US"><o:p></o:p></span></strong></p>
<p class="MsoNormal"><span style="font-size: 11pt; font-family: 宋体;">在上一篇</span><span style="font-size: 11pt;" lang="EN-US">MySQL</span><span style="font-size: 11pt; font-family: 宋体;">主从复制配置</span><span style="font-size: 11pt;"> </span><span style="font-size: 11pt; font-family: 宋体;">已经介绍过几个启动时的复制参数</span><span style="font-size: 11pt;" lang="EN-US">,</span><span style="font-size: 11pt; font-family: 宋体;">下面再介绍几个常用的启动选项</span><span style="font-size: 11pt;" lang="EN-US">,<o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left: 18pt; text-indent: -18pt;"><!--[if !supportLists]--><strong><span style="font-size: 11pt;" lang="EN-US"><span>(1)<span style="font: 7pt &quot;Times New Roman&quot;;">&nbsp;&nbsp; </span></span></span></strong><!--[endif]--><span style="font-size: 11pt;" lang="EN-US"><strong>log-slave-updates</strong><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 11pt;" lang="EN-US">log-slave-updates</span><span style="font-size: 11pt; font-family: 宋体;">这个参数用来配置从服务器的更新是否写入二进制日志，这个选项默认是不打开的，但是，如果这个从服务器</span><span style="font-size: 11pt;" lang="EN-US">B</span><span style="font-size: 11pt; font-family: 宋体;">是服务器</span><span style="font-size: 11pt;" lang="EN-US">A</span><span style="font-size: 11pt; font-family: 宋体;">的从服务器，同时还作为服务器</span><span style="font-size: 11pt;" lang="EN-US">C</span><span style="font-size: 11pt; font-family: 宋体;">的主服务器，那么就需要开发这个选项，这样它的从服务器</span><span style="font-size: 11pt;" lang="EN-US">C</span><span style="font-size: 11pt; font-family: 宋体;">才能获得它的二进制日志进行同步操作</span><span style="font-size: 11pt;" lang="EN-US"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 11pt;" lang="EN-US"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal" style="margin-left: 18pt; text-indent: -18pt;"><!--[if !supportLists]--><strong><span style="font-size: 11pt;" lang="EN-US"><span>(2)<span style="font: 7pt &quot;Times New Roman&quot;;">&nbsp;&nbsp; </span></span></span></strong><!--[endif]--><span style="font-size: 11pt;" lang="EN-US"><strong>master-connect-retry</strong><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 11pt;" lang="EN-US">master-connect-retry</span><span style="font-size: 11pt; font-family: 宋体;">这个参数是用来设置在和主服务器连接丢失的时候，重试的时间间隔，默认是</span><span style="font-size: 11pt;" lang="EN-US">60</span><span style="font-size: 11pt; font-family: 宋体;">秒</span><span style="font-size: 11pt;" lang="EN-US"><o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left: 18pt;"><span style="font-size: 11pt;" lang="EN-US"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal" style="margin-left: 18pt; text-indent: -18pt;"><!--[if !supportLists]--><strong><span style="font-size: 11pt;" lang="EN-US"><span>(3)<span style="font: 7pt &quot;Times New Roman&quot;;">&nbsp;&nbsp; </span></span></span></strong><!--[endif]--><span style="font-size: 11pt;" lang="EN-US"><strong>read-only</strong><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 11pt;" lang="EN-US">read-only</span><span style="font-size: 11pt; font-family: 宋体;">是用来限制普通用户对从数据库的更新操作，以确保从数据库的安全性，不过如果是超级用户依然可以对从数据库进行更新操作</span><span style="font-size: 11pt;" lang="EN-US"><o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left: 18pt;"><span style="font-size: 11pt;" lang="EN-US"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal" style="margin-left: 18pt; text-indent: -18pt;"><!--[if !supportLists]--><strong><span style="font-size: 11pt;" lang="EN-US"><span>(4)<span style="font: 7pt &quot;Times New Roman&quot;;">&nbsp;&nbsp; </span></span></span></strong><!--[endif]--><span style="font-size: 11pt;" lang="EN-US"><strong>slave-skip-errors</strong><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 11pt; font-family: 宋体;">在复制过程中，由于各种的原因，从服务器可能会遇到执行</span><span style="font-size: 11pt;" lang="EN-US">BINLOG</span><span style="font-size: 11pt; font-family: 宋体;">中的</span><span style="font-size: 11pt;" lang="EN-US">SQL</span><span style="font-size: 11pt; font-family: 宋体;">出错的情况，在默认情况下，服务器会停止复制进程，不再进行同步，等到用户自行来处理。</span><span style="font-size: 11pt;" lang="EN-US"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 11pt;" lang="EN-US">Slave-skip-errors</span><span style="font-size: 11pt; font-family: 宋体;">的作用就是用来定义复制过程中从服务器可以自动跳过的错误号，当复制过程中遇到定义的错误号，就可以自动跳过，直接执行后面的</span><span style="font-size: 11pt;" lang="EN-US">SQL</span><span style="font-size: 11pt; font-family: 宋体;">语句。</span></p>
<p class="MsoNormal"><br />
<span style="font-size: 11pt;" lang="EN-US"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 11pt; background: none repeat scroll 0% 0% rgb(217, 217, 217);" lang="EN-US">--slave-skip-errors=[err1,err2,&#8230;&#8230;.|ALL]</span></p>
<p class="MsoNormal"><br />
<span style="font-size: 11pt; background: none repeat scroll 0% 0% rgb(217, 217, 217);" lang="EN-US"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 11pt; font-family: 宋体;">但必须注意的是，启动这个参数，如果处理不当，很可能造成主从数据库的数据不同步，在应用中需要根据实际情况，如果对数据完整性要求不是很严格，那么这个选项确实可以减轻维护的成本</span><span style="font-size: 11pt;" lang="EN-US"><o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left: 18pt;"><span style="font-size: 11pt;" lang="EN-US"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal" style="margin-left: 18pt;"><span style="font-size: 11pt;" lang="EN-US"><o:p>&nbsp;</o:p></span></p>
<img src ="http://www.blogjava.net/dongbule/aggbug/329603.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/dongbule/" target="_blank">陈于喆</a> 2010-08-22 23:30 <a href="http://www.blogjava.net/dongbule/archive/2010/08/22/329603.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>MySQL主从复制配置</title><link>http://www.blogjava.net/dongbule/archive/2010/08/22/329602.html</link><dc:creator>陈于喆</dc:creator><author>陈于喆</author><pubDate>Sun, 22 Aug 2010 15:28:00 GMT</pubDate><guid>http://www.blogjava.net/dongbule/archive/2010/08/22/329602.html</guid><wfw:comment>http://www.blogjava.net/dongbule/comments/329602.html</wfw:comment><comments>http://www.blogjava.net/dongbule/archive/2010/08/22/329602.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/dongbule/comments/commentRss/329602.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/dongbule/services/trackbacks/329602.html</trackback:ping><description><![CDATA[<span style="font-size: 10pt;">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="ProgId" content="Word.Document" />
<meta name="Generator" content="Microsoft Word 11" />
<meta name="Originator" content="Microsoft Word 11" />
<link rel="File-List" href="file:///C:%5CDOCUME%7E1%5CADMINI%7E1%5CLOCALS%7E1%5CTemp%5Cmsohtml1%5C11%5Cclip_filelist.xml" /><!--[if gte mso 9]><xml>
<w:WordDocument>
<w:View>Normal</w:View>
<w:Zoom>0</w:Zoom>
<w:PunctuationKerning/>
<w:DrawingGridVerticalSpacing>7.8 磅</w:DrawingGridVerticalSpacing>
<w:DisplayHorizontalDrawingGridEvery>0</w:DisplayHorizontalDrawingGridEvery>
<w:DisplayVerticalDrawingGridEvery>2</w:DisplayVerticalDrawingGridEvery>
<w:ValidateAgainstSchemas/>
<w:SaveIfXMLInvalid>false</w:SaveIfXMLInvalid>
<w:IgnoreMixedContent>false</w:IgnoreMixedContent>
<w:AlwaysShowPlaceholderText>false</w:AlwaysShowPlaceholderText>
<w:Compatibility>
<w:SpaceForUL/>
<w:BalanceSingleByteDoubleByteWidth/>
<w:DoNotLeaveBackslashAlone/>
<w:ULTrailSpace/>
<w:DoNotExpandShiftReturn/>
<w:AdjustLineHeightInTable/>
<w:BreakWrappedTables/>
<w:SnapToGridInCell/>
<w:WrapTextWithPunct/>
<w:UseAsianBreakRules/>
<w:DontGrowAutofit/>
<w:UseFELayout/>
</w:Compatibility>
<w:BrowserLevel>MicrosoftInternetExplorer4</w:BrowserLevel>
</w:WordDocument>
</xml><![endif]--><!--[if gte mso 9]><xml>
<w:LatentStyles deflockedstate="false" latentstylecount="156">
</w:LatentStyles>
</xml><![endif]--><style>
<!-- /* Font Definitions */
@font-face
{font-family:宋体;
panose-1:2 1 6 0 3 1 1 1 1 1;
mso-font-alt:SimSun;
mso-font-charset:134;
mso-generic-font-family:auto;
mso-font-pitch:variable;
mso-font-signature:3 135135232 16 0 262145 0;}
@font-face
{font-family:"\@宋体";
panose-1:2 1 6 0 3 1 1 1 1 1;
mso-font-charset:134;
mso-generic-font-family:auto;
mso-font-pitch:variable;
mso-font-signature:3 135135232 16 0 262145 0;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{mso-style-parent:"";
margin:0cm;
margin-bottom:.0001pt;
text-align:justify;
text-justify:inter-ideograph;
mso-pagination:none;
font-size:10.5pt;
mso-bidi-font-size:12.0pt;
font-family:"Times New Roman";
mso-fareast-font-family:宋体;
mso-font-kerning:1.0pt;}
/* Page Definitions */
@page
{mso-page-border-surround-header:no;
mso-page-border-surround-footer:no;}
@page Section1
{size:612.0pt 792.0pt;
margin:72.0pt 90.0pt 72.0pt 90.0pt;
mso-header-margin:36.0pt;
mso-footer-margin:36.0pt;
mso-paper-source:0;}
div.Section1
{page:Section1;}
-->
</style><!--[if gte mso 10]>
<style>
/* Style Definitions */
table.MsoNormalTable
{mso-style-name:普通表格;
mso-tstyle-rowband-size:0;
mso-tstyle-colband-size:0;
mso-style-noshow:yes;
mso-style-parent:"";
mso-padding-alt:0cm 5.4pt 0cm 5.4pt;
mso-para-margin:0cm;
mso-para-margin-bottom:.0001pt;
mso-pagination:widow-orphan;
font-size:10.0pt;
font-family:"Times New Roman";
mso-ansi-language:#0400;
mso-fareast-language:#0400;
mso-bidi-language:#0400;}
</style>
<![endif]-->
<p class="MsoNormal"><span style="font-size: 11pt; font-family: Arial; color: black;" lang="EN-US">Mysql</span><span style="font-size: 11pt; font-family: 宋体; color: black;">的主从复制至少是需要两个</span><span style="font-size: 11pt; font-family: Arial; color: black;" lang="EN-US">Mysql</span><span style="font-size: 11pt; font-family: 宋体; color: black;">的服务，当然</span><span style="font-size: 11pt; font-family: Arial; color: black;" lang="EN-US">Mysql</span><span style="font-size: 11pt; font-family: 宋体; color: black;">的服务是可以分布在不同的服务器上，也可以在一台服务器上启动多个服务。</span><span style="font-size: 11pt; font-family: Arial; color: black;" lang="EN-US"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 11pt; font-family: Arial; color: black;" lang="EN-US">(1)</span><span style="font-size: 11pt; font-family: 宋体; color: black;">首先确保主从服务器上的</span><span style="font-size: 11pt; font-family: Arial; color: black;" lang="EN-US">Mysql</span><span style="font-size: 11pt; font-family: 宋体; color: black;">版本相同</span><span style="font-size: 11pt; font-family: Arial; color: black;" lang="EN-US"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 11pt; font-family: Arial; color: black;" lang="EN-US">(2)</span><span style="font-size: 11pt; font-family: 宋体; color: black;">在主服务器上</span><span style="font-size: 11pt; font-family: Arial; color: black;" lang="EN-US">,</span><span style="font-size: 11pt; font-family: 宋体; color: black;">设置一个从数据库的账户</span><span style="font-size: 11pt; font-family: Arial; color: black;" lang="EN-US">,</span><span style="font-size: 11pt; font-family: 宋体; color: black;">使用</span><span style="font-size: 11pt; font-family: Arial; color: black;" lang="EN-US">REPLICATION SLAVE</span><span style="font-size: 11pt; font-family: 宋体; color: black;">赋予权限</span><span style="font-size: 11pt; font-family: Arial; color: black;" lang="EN-US">,</span><span style="font-size: 11pt; font-family: 宋体; color: black;">如</span><span style="font-size: 11pt; font-family: Arial; color: black;" lang="EN-US">:</span></p>
<p class="MsoNormal"><br />
<span style="font-size: 12pt; font-family: 宋体;" lang="EN-US"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 11pt; font-family: Arial; color: black; background: none repeat scroll 0% 0% rgb(224, 224, 224);" lang="EN-US">mysql&gt; GRANT
REPLICATION SLAVE ON *.* TO 'slave001'@'192.168.0.99' IDENTIFIED BY</span><span style="font-size: 12pt; font-family: 宋体; background: none repeat scroll 0% 0% rgb(224, 224, 224);" lang="EN-US"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 11pt; font-family: Arial; color: black; background: none repeat scroll 0% 0% rgb(224, 224, 224);" lang="EN-US">'123456';</span><span style="font-size: 12pt; font-family: 宋体; background: none repeat scroll 0% 0% rgb(224, 224, 224);" lang="EN-US"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 11pt; font-family: Arial; color: black; background: none repeat scroll 0% 0% rgb(224, 224, 224);" lang="EN-US">Query OK, 0 rows affected
(0.13 sec)</span></p>
<p class="MsoNormal"><br />
<span style="font-size: 11pt; font-family: Arial; color: black;" lang="EN-US"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 11pt; font-family: Arial; color: black;" lang="EN-US">(3)</span><span style="font-size: 11pt; font-family: 宋体; color: black;">修改主数据库的配置文件</span><span style="font-size: 11pt; font-family: Arial; color: black;" lang="EN-US">my.cnf,</span><span style="font-size: 11pt; font-family: 宋体; color: black;">开启</span><span style="font-size: 11pt; font-family: Arial; color: black;" lang="EN-US">BINLOG</span><span style="font-size: 11pt; font-family: 宋体; color: black;">，并设置</span><span style="font-size: 11pt; font-family: Arial; color: black;" lang="EN-US">server-id</span><span style="font-size: 11pt; font-family: 宋体; color: black;">的值，修改之后必须重启</span><span style="font-size: 11pt; font-family: Arial; color: black;" lang="EN-US">Mysql</span><span style="font-size: 11pt; font-family: 宋体; color: black;">服务</span></p>
<p class="MsoNormal"><br />
<span style="font-size: 12pt; font-family: 宋体;" lang="EN-US"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 11pt; font-family: Arial; color: black; background: none repeat scroll 0% 0% rgb(217, 217, 217);" lang="EN-US">[mysqld]</span><span style="font-size: 12pt; font-family: 宋体; background: none repeat scroll 0% 0% rgb(217, 217, 217);" lang="EN-US"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 11pt; font-family: Arial; color: black; background: none repeat scroll 0% 0% rgb(217, 217, 217);" lang="EN-US">log-bin = /home/mysql/log/mysql-bin.log</span><span style="font-size: 12pt; font-family: 宋体; background: none repeat scroll 0% 0% rgb(217, 217, 217);" lang="EN-US"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 11pt; font-family: Arial; color: black; background: none repeat scroll 0% 0% rgb(217, 217, 217);" lang="EN-US">server-id=1</span></p>
<p class="MsoNormal"><br />
<span style="font-size: 11pt; font-family: Arial; color: black;" lang="EN-US"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 11pt; font-family: Arial; color: black;" lang="EN-US">(4)</span><span style="font-size: 11pt; font-family: 宋体; color: black;">之后可以得到主服务器当前二进制日志名和偏移量，这个操作的目的是为了在从数据库启动后，从这个点开始进行数据的恢复</span></p>
<p class="MsoNormal"><br />
<span style="font-size: 11pt; font-family: Arial; color: black;" lang="EN-US"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 11pt; font-family: Arial; color: black; background: none repeat scroll 0% 0% rgb(217, 217, 217);" lang="EN-US">mysql&gt; show master status\G;<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 11pt; font-family: Arial; color: black; background: none repeat scroll 0% 0% rgb(217, 217, 217);" lang="EN-US">*************************** 1. row
***************************<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 11pt; font-family: Arial; color: black; background: none repeat scroll 0% 0% rgb(217, 217, 217);" lang="EN-US">File: mysql-bin.000003<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 11pt; font-family: Arial; color: black; background: none repeat scroll 0% 0% rgb(217, 217, 217);" lang="EN-US">Position: 243<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 11pt; font-family: Arial; color: black; background: none repeat scroll 0% 0% rgb(217, 217, 217);" lang="EN-US">Binlog_Do_DB:<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 11pt; font-family: Arial; color: black; background: none repeat scroll 0% 0% rgb(217, 217, 217);" lang="EN-US">Binlog_Ignore_DB:<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 11pt; font-family: Arial; color: black; background: none repeat scroll 0% 0% rgb(217, 217, 217);" lang="EN-US">1 row in set (0.00 sec)</span></p>
<p class="MsoNormal"><br />
<span style="font-size: 11pt; font-family: Arial; color: black; background: none repeat scroll 0% 0% rgb(217, 217, 217);" lang="EN-US"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 11pt; font-family: Arial; color: black;" lang="EN-US">(5)</span><span style="font-size: 11pt; font-family: 宋体; color: black;">好了，现在可以停止主数据的的更新操作，并生成主数据库的备份，我们可以通过</span><span style="font-size: 11pt; font-family: Arial; color: black;" lang="EN-US">mysqldump</span><span style="font-size: 11pt; font-family: 宋体; color: black;">到处数据到从数据库，当然了，你也可以直接用</span><span style="font-size: 11pt; font-family: Arial; color: black;" lang="EN-US">cp</span><span style="font-size: 11pt; font-family: 宋体; color: black;">命令将数据文件复制到从数据库去</span><span style="font-size: 11pt; font-family: Arial; color: black;" lang="EN-US"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 11pt; font-family: 宋体; color: black;">注意在导出数据之前先对主数据库进行</span><span style="font-size: 11pt; font-family: Arial; color: black;" lang="EN-US">READ
LOCK</span><span style="font-size: 11pt; font-family: 宋体; color: black;">，以保证数据的一致性</span></p>
<p class="MsoNormal"><br />
<span style="font-size: 11pt; font-family: Arial; color: black;" lang="EN-US"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 11pt; font-family: Arial; color: black; background: none repeat scroll 0% 0% rgb(217, 217, 217);" lang="EN-US">mysql&gt; flush tables with read lock;<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 11pt; font-family: Arial; color: black; background: none repeat scroll 0% 0% rgb(217, 217, 217);" lang="EN-US">Query OK, 0 rows affected (0.19 sec)</span></p>
<p class="MsoNormal"><br />
<span style="font-size: 11pt; font-family: Arial; color: black; background: none repeat scroll 0% 0% rgb(217, 217, 217);" lang="EN-US"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 11pt; font-family: 宋体; color: black;">之后是</span><span style="font-size: 11pt; font-family: Arial; color: black;" lang="EN-US">mysqldump</span></p>
<p class="MsoNormal"><br />
<span style="font-size: 11pt; font-family: Arial; color: black;" lang="EN-US"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 11pt; font-family: Arial; color: black; background: none repeat scroll 0% 0% rgb(217, 217, 217);" lang="EN-US">mysqldump -h127.0.0.1 -p3306 -uroot -p test &gt;
/home/chenyz/test.sql</span></p>
<p class="MsoNormal"><br />
<span style="font-size: 11pt; font-family: Arial; color: black; background: none repeat scroll 0% 0% rgb(217, 217, 217);" lang="EN-US"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 11pt; font-family: 宋体; color: black;">最好在主数据库备份完毕，恢复写操作</span></p>
<p class="MsoNormal"><br />
<span style="font-size: 11pt; font-family: Arial; color: black;" lang="EN-US"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 11pt; font-family: Arial; color: black; background: none repeat scroll 0% 0% rgb(217, 217, 217);" lang="EN-US">mysql&gt; unlock tables;<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 11pt; font-family: Arial; color: black; background: none repeat scroll 0% 0% rgb(217, 217, 217);" lang="EN-US">Query OK, 0 rows affected (0.28 sec)</span></p>
<p class="MsoNormal"><br />
<span style="font-size: 11pt; font-family: Arial; color: black; background: none repeat scroll 0% 0% rgb(217, 217, 217);" lang="EN-US"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 11pt; font-family: Arial; color: black;" lang="EN-US">(6)</span><span style="font-size: 11pt; font-family: 宋体; color: black;">将刚才主数据备份的</span><span style="font-size: 11pt; font-family: Arial; color: black;" lang="EN-US">test.sql</span><span style="font-size: 11pt; font-family: 宋体; color: black;">复制到从数据库，进行导入</span><span style="font-size: 11pt; font-family: Arial; color: black;" lang="EN-US"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 11pt; font-family: Arial; color: black;" lang="EN-US">(7)</span><span style="font-size: 11pt; font-family: 宋体; color: black;">接着修改从数据库的</span><span style="font-size: 11pt; font-family: Arial; color: black;" lang="EN-US">my.cnf,</span><span style="font-size: 11pt; font-family: 宋体; color: black;">增加</span><span style="font-size: 11pt; font-family: Arial; color: black;" lang="EN-US">server-id</span><span style="font-size: 11pt; font-family: 宋体; color: black;">参数</span><span style="font-size: 11pt; font-family: Arial; color: black;" lang="EN-US">,</span><span style="font-size: 11pt; font-family: 宋体; color: black;">指定复制使用的用户</span><span style="font-size: 11pt; font-family: Arial; color: black;" lang="EN-US">,</span><span style="font-size: 11pt; font-family: 宋体; color: black;">主数据库服务器的</span><span style="font-size: 11pt; font-family: Arial; color: black;" lang="EN-US">ip,</span><span style="font-size: 11pt; font-family: 宋体; color: black;">端口以及开始执行复制日志的文件和位置</span></p>
<p class="MsoNormal"><br />
<span style="font-size: 11pt; font-family: Arial; color: black;" lang="EN-US"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 11pt; font-family: Arial; color: black; background: none repeat scroll 0% 0% rgb(217, 217, 217);" lang="EN-US">[mysqld]</span><span style="font-size: 12pt; font-family: 宋体; background: none repeat scroll 0% 0% rgb(217, 217, 217);" lang="EN-US"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 11pt; font-family: Arial; color: black; background: none repeat scroll 0% 0% rgb(217, 217, 217);" lang="EN-US">server-id=2<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 11pt; font-family: Arial; color: black; background: none repeat scroll 0% 0% rgb(217, 217, 217);" lang="EN-US">log_bin&nbsp;= /var/log/mysql/mysql-bin.log<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 11pt; font-family: Arial; color: black; background: none repeat scroll 0% 0% rgb(217, 217, 217);" lang="EN-US">master-host =192.168.1.100<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 11pt; font-family: Arial; color: black; background: none repeat scroll 0% 0% rgb(217, 217, 217);" lang="EN-US">master-user=test<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 11pt; font-family: Arial; color: black; background: none repeat scroll 0% 0% rgb(217, 217, 217);" lang="EN-US">master-pass=123456<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 11pt; font-family: Arial; color: black; background: none repeat scroll 0% 0% rgb(217, 217, 217);" lang="EN-US">master-port&nbsp;=3306<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 11pt; font-family: Arial; color: black; background: none repeat scroll 0% 0% rgb(217, 217, 217);" lang="EN-US">master-connect-retry=60<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 11pt; font-family: Arial; color: black; background: none repeat scroll 0% 0% rgb(217, 217, 217);" lang="EN-US">replicate-do-db =test <br />
</span></p>
<p class="MsoNormal"><br />
<span style="font-size: 11pt; font-family: Arial; color: black; background: none repeat scroll 0% 0% rgb(217, 217, 217);" lang="EN-US"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 11pt; font-family: Arial; color: black;" lang="EN-US">(8)</span><span style="font-size: 11pt; font-family: 宋体; color: black;">在从服务器上</span><span style="font-size: 11pt; font-family: Arial; color: black;" lang="EN-US">,</span><span style="font-size: 11pt; font-family: 宋体; color: black;">启动</span><span style="font-size: 11pt; font-family: Arial; color: black;" lang="EN-US">slave</span><span style="font-size: 11pt; font-family: 宋体; color: black;">进程</span></p>
<p class="MsoNormal"><br />
<span style="font-size: 11pt; font-family: Arial; color: black;" lang="EN-US"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 11pt; font-family: Arial; color: black; background: none repeat scroll 0% 0% rgb(217, 217, 217);" lang="EN-US">mysql&gt; start slave;</span></p>
<p class="MsoNormal"><br />
<span style="font-size: 11pt; font-family: Arial; color: black; background: none repeat scroll 0% 0% rgb(217, 217, 217);" lang="EN-US"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 11pt; font-family: Arial; color: black;" lang="EN-US">(9)</span><span style="font-size: 11pt; font-family: 宋体; color: black;">在从服务器进行</span><span style="font-size: 11pt; font-family: Arial; color: black;" lang="EN-US">show salve status</span><span style="font-size: 11pt; font-family: 宋体; color: black;">验证</span></p>
<p class="MsoNormal"><br />
<span style="font-size: 11pt; font-family: Arial; color: black;" lang="EN-US"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 11pt; font-family: Arial; color: black; background: none repeat scroll 0% 0% rgb(217, 217, 217);" lang="EN-US">mysql&gt; SHOW SLAVE STATUS\G<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 11pt; font-family: Arial; color: black; background: none repeat scroll 0% 0% rgb(217, 217, 217);" lang="EN-US">*************************** 1. row
***************************<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 11pt; font-family: Arial; color: black; background: none repeat scroll 0% 0% rgb(217, 217, 217);" lang="EN-US">Slave_IO_State: Waiting for master to send event<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 11pt; font-family: Arial; color: black; background: none repeat scroll 0% 0% rgb(217, 217, 217);" lang="EN-US">Master_Host: localhost<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 11pt; font-family: Arial; color: black; background: none repeat scroll 0% 0% rgb(217, 217, 217);" lang="EN-US">Master_User: root<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 11pt; font-family: Arial; color: black; background: none repeat scroll 0% 0% rgb(217, 217, 217);" lang="EN-US">Master_Port: 3306<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 11pt; font-family: Arial; color: black; background: none repeat scroll 0% 0% rgb(217, 217, 217);" lang="EN-US">Connect_Retry: 3<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 11pt; font-family: Arial; color: black; background: none repeat scroll 0% 0% rgb(217, 217, 217);" lang="EN-US">Master_Log_File: mysql-bin.003<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 11pt; font-family: Arial; color: black; background: none repeat scroll 0% 0% rgb(217, 217, 217);" lang="EN-US">Read_Master_Log_Pos: 79<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 11pt; font-family: Arial; color: black; background: none repeat scroll 0% 0% rgb(217, 217, 217);" lang="EN-US">Relay_Log_File: gbichot-relay-bin.003<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 11pt; font-family: Arial; color: black; background: none repeat scroll 0% 0% rgb(217, 217, 217);" lang="EN-US">Relay_Log_Pos: 548<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 11pt; font-family: Arial; color: black; background: none repeat scroll 0% 0% rgb(217, 217, 217);" lang="EN-US">Relay_Master_Log_File: mysql-bin .003<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 11pt; font-family: Arial; color: black; background: none repeat scroll 0% 0% rgb(217, 217, 217);" lang="EN-US">Slave_IO_Running: Yes<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 11pt; font-family: Arial; color: black; background: none repeat scroll 0% 0% rgb(217, 217, 217);" lang="EN-US">Slave_SQL_Running: Yes</span></p>
<p class="MsoNormal"><br />
<span style="font-size: 11pt; font-family: Arial; color: black; background: none repeat scroll 0% 0% rgb(217, 217, 217);" lang="EN-US"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 11pt; font-family: Arial; color: black;" lang="EN-US">(10)</span><span style="font-size: 11pt; font-family: 宋体; color: black;">好了</span><span style="font-size: 11pt; font-family: Arial; color: black;" lang="EN-US">,</span><span style="font-size: 11pt; font-family: 宋体; color: black;">现在可以在我们的主服务器做一些更新的操作</span><span style="font-size: 11pt; font-family: Arial; color: black;" lang="EN-US">,</span><span style="font-size: 11pt; font-family: 宋体; color: black;">然后在从服务器查看是否已经更新</span></p>
<p class="MsoNormal">----------------------------------------<br />
<br />
陈于喆 <br />
Mail: chenyz@corp.netease.com
<br />
<br />
<span style="font-size: 11pt; font-family: Arial; color: black;" lang="EN-US"><o:p></o:p></span></p>
</span>
<img src ="http://www.blogjava.net/dongbule/aggbug/329602.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/dongbule/" target="_blank">陈于喆</a> 2010-08-22 23:28 <a href="http://www.blogjava.net/dongbule/archive/2010/08/22/329602.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>