<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Seateng Blog &#187; Mysql</title>
	<atom:link href="http://blog.seateng.cn/tags/mysql/feed" rel="self" type="application/rss+xml" />
	<link>http://blog.seateng.cn</link>
	<description>[spawn(fun()-&#62;Browser ! {self(), share(X)}end) &#124;&#124; X &#60;- [&#34;Web开发&#34;, &#34;网站构架&#34;, &#34;分布式开发&#34;]]</description>
	<lastBuildDate>Tue, 06 Dec 2011 09:25:58 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1</generator>
		<item>
		<title>动态 Mysql 日志分析</title>
		<link>http://blog.seateng.cn/archives/2009/06/mysql-server-log.html</link>
		<comments>http://blog.seateng.cn/archives/2009/06/mysql-server-log.html#comments</comments>
		<pubDate>Sat, 27 Jun 2009 04:35:54 +0000</pubDate>
		<dc:creator>Seateng</dc:creator>
				<category><![CDATA[Database]]></category>
		<category><![CDATA[Mysql]]></category>

		<guid isPermaLink="false">http://blog.seateng.cn/?p=169</guid>
		<description><![CDATA[Mysql 一共记录 4 种日志 1. The Error Log 2. The General Query Log 3. The Binary Log 4. The Slow Query Log 从MySQL5.1.6开始，General Query Log和Slow Query Log开始可以写到文件或者数据库表中，并且日志的开关，保存方式的修改，都是Global级别动态修改。 也就是说不需要重启服务器动态生效了。 日志保存到数据库表 root@mysql-server>SET GLOBAL log_output=TABLE; 日志保存到文件 root@mysql-server>SET GLOBAL log_output=FILE; root@mysql-server>SET GLOBAL general_log_file=&#8217;/tmp/general.log&#8217;; root@mysql-server>SET GLOBAL general_log=on; root@mysql-server>SET GLOBAL slow_query_log_file=&#8217;/tmp/slow.log&#8217;; root@mysql-server>SET GLOBAL slow_query_log=on; 保存到数据表则是在mysql.general_log和mysql.slow_log 默认ENGINE为CSV SET @old_log_state = @@global.general_log; SET [...]]]></description>
			<content:encoded><![CDATA[<p>Mysql 一共记录 4 种日志<br />
1. The Error Log<br />
2. The General Query Log<br />
3. The Binary Log<br />
4. The Slow Query Log<br />
从MySQL5.1.6开始，General Query Log和Slow Query Log开始可以写到文件或者数据库表中，并且日志的开关，保存方式的修改，都是Global级别动态修改。<br />
也就是说不需要重启服务器动态生效了。<br />
日志保存到数据库表<br />
root@mysql-server>SET GLOBAL log_output=TABLE;<br />
日志保存到文件<br />
root@mysql-server>SET GLOBAL log_output=FILE;<br />
root@mysql-server>SET GLOBAL general_log_file=&#8217;/tmp/general.log&#8217;;<br />
root@mysql-server>SET GLOBAL general_log=on;<br />
root@mysql-server>SET GLOBAL slow_query_log_file=&#8217;/tmp/slow.log&#8217;;<br />
root@mysql-server>SET GLOBAL slow_query_log=on;<br />
保存到数据表则是在mysql.general_log和mysql.slow_log 默认ENGINE为CSV<br />
SET @old_log_state = @@global.general_log;<br />
SET GLOBAL general_log = &#8216;OFF&#8217;;<br />
ALTER TABLE mysql.general_log ENGINE = MyISAM;<br />
SET GLOBAL general_log = @old_log_state;<br />
可以动态修改日志保存表引擎。<br />
具体的一些配置用法可以参考<a href="http://dev.mysql.com/doc/refman/5.1/en/log-tables.html" target="_blank">Mysql Doc</a>就不再累赘。</p>
<p>利用这个功能，脑子里就有了个数据库服务器定时监控系统的雏形。大概的功能是可以在指定的时间段内(而非实时)开启被监控数据库服务器的日志功能，获取并保存日志，出报表给DBA分析，起到抽样日志分析的作用，这样的好处是只需监控数据库的高压时间就可以找到系统的短板。</p>
<p>最近在Mysql圈子里看到挺多人研究<a href="https://launchpad.net/percona-xtrabackup" target="_blank">XtraBackup</a>(开源MySQL在线热备份工具)顺便在这里也啰嗦下，有兴趣的自己研究吧。XtraBackup <a href="http://www.percona.com/mysql/xtrabackup/0.7/" target="_blank">下载地址</a>，</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.seateng.cn/archives/2009/06/mysql-server-log.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

