<?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>夜行人 &#187; MySQL</title>
	<atom:link href="http://www.187299.com/archives/tag/mysql/feed" rel="self" type="application/rss+xml" />
	<link>http://www.187299.com</link>
	<description>寻觅生命中的那一片浅草......</description>
	<lastBuildDate>Wed, 16 Nov 2011 11:25:49 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>MySQL报错：my_global.h151615 error new No such file or directory</title>
		<link>http://www.187299.com/archives/1665</link>
		<comments>http://www.187299.com/archives/1665#comments</comments>
		<pubDate>Mon, 13 Sep 2010 09:42:40 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[MySQL]]></category>

		<guid isPermaLink="false">http://www.187299.com/?p=1665</guid>
		<description><![CDATA[今天安装MySQL,在make的时候报错，错误信息如下： In file included from mysys_priv.h:16, from my_new.cc:21: ../include/my_global.h:1516:15: error: new: No such file or directory make[1]: *** [my_new.o] Error 1 make[1]: Leaving directory `/... ]]></description>
			<content:encoded><![CDATA[<p>今天安装MySQL,在make的时候报错，错误信息如下：</p>
<p>In file included from mysys_priv.h:16,<br />
from my_new.cc:21:<br />
../include/my_global.h:1516:15: error: new: No such file or directory<br />
make[1]: *** [my_new.o] Error 1<br />
make[1]: Leaving directory `/opt/mysql-5.1.45-10/mysys'<br />
make: *** [all-recursive] Error 1</p>
<p>检查了操作系统版本等情况，都没问题，configure时也没报错，可以正常产生Makefile</p>
<p>将有问题服(假设是A机)的config.log和另外一台正常服(假设是B机)的config.log做对比</p>
<p>发现A机，有2处比较严重的报错</p>
<p>conftest.c:181:21: error: termcap.h: No such file or directory<br />
conftest.cpp:314:20: error: cxxabi.h: No such file or directory</p>
<p>在B机上<br />
updatedb</p>
<p>for i in `locate termcap.h`; do rpm -qf $i; done |uniq<br />
输出：<br />
libtermcap-devel-2.0.8-46.1<br />
ncurses-devel-5.5-24.20060715<br />
dev86-0.16.17-2.2</p>
<p>for i in `locate cxxabi.h`; do rpm -qf $i; done |uniq<br />
输出：</p>
<p>libstdc++-devel-4.1.2-48.el5<br />
libstdc++44-devel-4.4.0-6.el5<br />
xulrunner-devel-1.9.0.18-1.el5_4</p>
<p>到A机上用rpm -qa查询libtermcap-devel，ncurses-devel，dev86，libstdc++-devel，libstdc++44，xulrunner-devel的安装情况<br />
发现libtermcap-devel，dev86，libstdc++-devel没有安装</p>
<p>yum -y install libtermcap-devel dev86 libstdc++-devel</p>
<p>然后再make，就没有报错了</p>
]]></content:encoded>
			<wfw:commentRss>http://www.187299.com/archives/1665/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MySQL调优脚本tuning-primer.sh使用说明</title>
		<link>http://www.187299.com/archives/1653</link>
		<comments>http://www.187299.com/archives/1653#comments</comments>
		<pubDate>Tue, 07 Sep 2010 08:32:25 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[MySQL]]></category>

		<guid isPermaLink="false">http://www.187299.com/?p=1653</guid>
		<description><![CDATA[大名鼎鼎的MySQL调优脚本tuning-primer.sh官方下载地址：http://forge.mysql.com/projects/project.php?id=44 -&#62; https://launchpad.net/mysql-tuning-primer, 直接下载地址： http://launchpad.net/mysql-tuning-primer/trunk/1.5-r5/+download... ]]></description>
			<content:encoded><![CDATA[<p>大名鼎鼎的MySQL调优脚本tuning-primer.sh官方下载地址：http://forge.mysql.com/projects/project.php?id=44  -&gt; <a href="https://launchpad.net/mysql-tuning-primer" target="_blank"><span style="color: #0066cc;">https://launchpad.net/mysql-tuning-primer</span></a>, 直接下载地址： <a href="http://launchpad.net/mysql-tuning-primer/trunk/1.5-r5/+download/tuning-primer.sh" target="_blank"><span style="color: #0066cc;">http://launchpad.net/mysql-tuning-primer/trunk/1.5-r5/+download/tuning-primer.sh</span></a></p>
<p>该脚本使用 “SHOW STATUS LIKE…” 和 “SHOW VARIABLES LIKE…”  命令获得MySQL相关变量和运行状态。然后根据推荐的调优参数对当前的MySQL数据库进行测试。最后根据不同颜色的标识来提醒用户需要注意的各个参数设置。该版本兼容  MySQL 3.23 和更高版本（包含 5.1）</p>
<p>当前版本会处理如下这些推荐的参数：</p>
<div><a onclick="copycode('p755code1');" href="javascript:;"><span style="color: #0066cc;">[Copy  to clipboard]</span></a><a onclick="javascript:showCodeTxt('p755code1'); return false;" href="javascript:;"><span style="color: #0066cc;">View Code</span></a></div>
<div>
<table>
<tbody>
<tr id="p7551">
<td>
<pre>1
2
3
4
5
6
7
8
9
10
11
12</pre>
</td>
<td id="p755code1">
<pre> Slow Query Log （慢查询日志）
 Max Connections （最大连接数）
 Worker Threads （工作线程）
 <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Akey+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky">Key</a> Buffer （<a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Akey+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky">Key</a> 缓冲）
 Query Cache （查询缓存）
 Sort Buffer （排序缓存）
 Joins （连接）
 Temp Tables （临时表）
 Table (Open &amp;amp; Definition) Cache （表缓存）
 Table Locking （表锁定）
 Table Scans (read_buffer) （表扫描，读缓冲）
 Innodb Status （Innodb 状态）</pre>
</td>
</tr>
</tbody>
</table>
</div>
<p>tuning-primer.sh 有如下运行参数:</p>
<div><a onclick="copycode('p755code2');" href="javascript:;"><span style="color: #0066cc;">[Copy  to clipboard]</span></a><a onclick="javascript:showCodeTxt('p755code2'); return false;" href="javascript:;"><span style="color: #0066cc;">View Code</span></a></div>
<div>
<table>
<tbody>
<tr id="p7552">
<td>
<pre>1
2
3
4
5
6
7</pre>
</td>
<td id="p755code2">
<pre>Usage: ./tuning-primer.sh [ mode ]
all            运行所有检测(默认值)
prompt         显示提示信息
mem, memory    运行有关内存使用方面的检测
disk, file     运行有关I/O性能和文件处理限制方面的检测
innodb         运行InnoDB检测
misc           其它</pre>
</td>
</tr>
</tbody>
</table>
</div>
<p>脚本支持my.cnf文件，可以把user, password, host,  socket等连接参数放在~/.my.cnf文件里，如果使用了自定义的socket文件，请修改tuning-primer.sh文件中关于socket文件位置的变量。</p>
<p><strong>运行 tuning-primer.sh显示说明 </strong></p>
<div>
<table border="1">
<colgroup> </colgroup>
<tbody>
<tr>
<td valign="center"><strong>SLOW QUERIES</strong></td>
<td valign="center"><strong>慢查询检查</strong></td>
</tr>
<tr>
<td valign="center">SLOW QUERIESThe slow query log is enabled.</td>
<td valign="center">说明我已经启用了慢查询记录功能。也就是参数<br />
slow_query_log = 1</td>
</tr>
<tr>
<td valign="center">Current long_query_time = 5.000000 sec.</td>
<td valign="center">慢查询的阀值时间。也就是参数<br />
long_query_time = 5</td>
</tr>
<tr>
<td valign="center">You have 17 out of 638844 that take longer than 5.000000 sec.  to complete</td>
<td valign="center">说明慢查询日志中记录了17条查询时间超过5秒的语句。<br />
slow_query_log_file=/data/ats_db/mysql-slow.log设置慢查询日志路径。使用mysqldumpslow命令查询慢日志</td>
</tr>
<tr>
<td valign="center"><strong>Your long_query_time seems to be fine</strong></td>
<td valign="center">慢查询阀值时间设置得在推荐的范围内</td>
</tr>
<tr>
<td colspan="2" valign="center"></td>
</tr>
<tr>
<td valign="center"><strong>BINARY UPDATE LOG</strong></td>
<td valign="center"><strong>更新二进制日志文件</strong></td>
</tr>
<tr>
<td valign="center">The binary update log is enabled</td>
<td valign="center">这项说明启用了bin-log日志功能。参数<br />
log-bin =  /data/ats_db/mysql-bin</td>
</tr>
<tr>
<td valign="center"><strong>Binlog sync is not enabled, you could loose binlog  records during a server crash</strong></td>
<td valign="center">没有启用 sync_binlog 选项。也即是将二进制日志实时写入到磁盘通过  sync_binlog=1来指定</td>
</tr>
<tr>
<td colspan="2" valign="center"></td>
</tr>
<tr>
<td valign="center"><strong>WORKER THREADS</strong></td>
<td valign="center"><strong>工作线程</strong></td>
</tr>
<tr>
<td valign="center">Current thread_cache_size = 8</td>
<td valign="center">当前线程缓存大小。<br />
thread_concurrency = 8</td>
</tr>
<tr>
<td valign="center">Current threads_cached = 7</td>
<td valign="center">Show status like ‘threads_cached’</td>
</tr>
<tr>
<td valign="center">Current threads_per_sec = 0</td>
<td valign="center">脚本先执行Show status like ‘Threads_cached’查看当前的线程创建情况，然后sleep  1后在执行相同的命令，最终后者减去前者的数就是每秒线程创建数。</td>
</tr>
<tr>
<td valign="center">Historic threads_per_sec = 0</td>
<td valign="center">该值是使用Threads_cached /uptime获得的。</td>
</tr>
<tr>
<td valign="center"><strong>Your thread_cache_size is fine</strong></td>
<td valign="center"></td>
</tr>
<tr>
<td colspan="2" valign="center"></td>
</tr>
<tr>
<td valign="center"><strong>MAX CONNECTIONS</strong></td>
<td valign="center"><strong>最大连接数</strong></td>
</tr>
<tr>
<td valign="center">Current max_connections = 1024</td>
<td valign="center">当前配置文件中设置的并发连接数</td>
</tr>
<tr>
<td valign="center">Current threads_connected = 2</td>
<td valign="center">当前线程连接诶数。<br />
show status like ‘Threads_connected’</td>
</tr>
<tr>
<td valign="center">Historic max_used_connections = 4</td>
<td valign="center">show status like ‘Max_used_connections’;</td>
</tr>
<tr>
<td valign="center">The number of used connections is 0% of the configured  maximum.</td>
<td valign="center">这个值使用 Max_used_connections*100/ max_connections得出。</td>
</tr>
<tr>
<td valign="center"><strong>You are using less than 10% of your configured  max_connections. </strong><strong>Lowering max_connections could help to avoid  an over-allocation of memory </strong><strong>See “MEMORY USAGE” section to make sure you are not  over-allocating</strong></td>
<td valign="center">Max_used_connections的值不足max_connections值的10%。设置合适的max_connections值有助于节省内存。</td>
</tr>
<tr>
<td colspan="2" valign="center"></td>
</tr>
<tr>
<td valign="center"><strong>MEMORY USAGE</strong></td>
<td valign="center"><strong>内存使用</strong></td>
</tr>
<tr>
<td valign="center">Max Memory Ever Allocated : 841 M</td>
<td valign="center"><strong>Max Memory Ever Allocated</strong> =  <strong>max_memory</strong></td>
</tr>
<tr>
<td valign="center">Configured Max Per-thread Buffers : 28.40 G</td>
<td valign="center"><strong>Configured Max Per-thread Buffers </strong>=  <strong>per_thread_buffers</strong></td>
</tr>
<tr>
<td valign="center">Configured Max Global Buffers : 586 M</td>
<td valign="center"><strong>Configured Max Global Buffers</strong> =  <strong>per_thread_max_buffers</strong></td>
</tr>
<tr>
<td valign="center">Configured Max Memory Limit : 28.97 G</td>
<td valign="center"><strong>Configured Max Memory Limit</strong> =  <strong>total_memory<br />
</strong>这一项很重要，他是将各个缓存的大小累加，然后同max_connections相乘，从而得出当达到max_connections后需要分配的内存有多少。我这里由于max_connections写得很大，造成了最大内存限制超过了真实内存很多，所以建议不要随意增大max_connections的值。减小  max_connections的值，最终保证最大内存限制在真实内存的90%以下。</td>
</tr>
<tr>
<td valign="center">Physical Memory : 7.79 G</td>
<td valign="center">实际物理内存</td>
</tr>
<tr>
<td valign="center">Max memory limit exceeds 90% of physical memory</td>
<td valign="center"></td>
</tr>
<tr>
<td colspan="2" valign="center"><strong>per_thread_buffers<br />
</strong>(read_buffer_size+read_rnd_buffer_size  +sort_buffer_size+thread_stack+<br />
join_buffer_size+binlog_cache_size)*max_connections<strong>per_thread_max_buffers<br />
</strong>(read_buffer_size+read_rnd_buffer_size  +sort_buffer_size+thread_stack<br />
+join_buffer_size+binlog_cache_size)*max_used_connections<strong>global_buffers<br />
</strong>innodb_buffer_pool_size+innodb_additional_mem_pool_size+innodb_log_buffer_size+<br />
key_buffer_size+query_cache_size<strong>max_memory</strong>=global_buffers+per_thread_max_buffers</p>
<p><strong>total_memory</strong>=global_buffers+per_thread_buffers</td>
</tr>
<tr>
<td colspan="2" valign="center"></td>
</tr>
<tr>
<td valign="center"><strong>KEY BUFFER</strong></td>
<td valign="center"><strong>Key 缓冲</strong></td>
</tr>
<tr>
<td valign="center">Current MyISAM index space = 222 K</td>
<td valign="center">当前数据库MyISAM表中索引占用磁盘空间</td>
</tr>
<tr>
<td valign="center">Current key_buffer_size = 512 M</td>
<td valign="center">MySQL配置文件中key_buffer_size 设置的大小</td>
</tr>
<tr>
<td valign="center">Key cache miss rate is 1 : 3316</td>
<td valign="center">Key_read_requests/ Key_reads  这里说明3316次读取请求中有1次丢失(也就是说1次读取磁盘)</td>
</tr>
<tr>
<td valign="center">Key buffer free ratio = 81 %</td>
<td valign="center">key_blocks_unused * key_cache_block_size / key_buffer_size *  100</td>
</tr>
<tr>
<td valign="center"><strong>Your key_buffer_size seems to be fine</strong></td>
<td valign="center"></td>
</tr>
<tr>
<td colspan="2" valign="center"></td>
</tr>
<tr>
<td valign="center"><strong>QUERY CACHE</strong></td>
<td valign="center"><strong>Query 缓存</strong></td>
</tr>
<tr>
<td valign="center"><strong>Query cache is enabled</strong></td>
<td valign="center">该项说明 我们指定了query_cache_size  的值。如果query_cache_size=0的话这里给出的提示是：<br />
Query cache is supported but not  enabled<br />
Perhaps you should set the query_cache_size</td>
</tr>
<tr>
<td valign="center">Current query_cache_size = 64 M</td>
<td valign="center">当前系统query_cache_size 值大小 [F]</td>
</tr>
<tr>
<td valign="center">Current query_cache_used = 1 M</td>
<td valign="center"><strong>query_cache_used  =query_cache_size</strong>-<strong>qcache_free_memory </strong></td>
</tr>
<tr>
<td valign="center">Current query_cache_limit = 128 M</td>
<td valign="center">变量 query_cache_limit 大小</td>
</tr>
<tr>
<td valign="center">Current Query cache Memory fill ratio = 1.79 %</td>
<td valign="center"><strong>query_cache_used/</strong>query_cache_size  *100%</td>
</tr>
<tr>
<td valign="center">Current query_cache_min_res_unit = 4 K</td>
<td valign="center"><strong>show variables like  ‘query_cache_min_res_unit’;</strong></td>
</tr>
<tr>
<td valign="center"><strong>Your query_cache_size seems to be too high.<br />
Perhaps  you can use these resources elsewhere</strong></td>
<td valign="center">这项给出的结论是query_cache_size的值设置的有些过高。其比对标准是 “Query cache Memory  fill ratio”的值如果小于&lt;25%就会给出这个提示。可以将这些资源应用到其他的地方</td>
</tr>
<tr>
<td valign="center"><strong>MySQL won’t cache query results that are larger than  query_cache_limit in size</strong></td>
<td valign="center">MySQL不会将大于query_cache_limit的查询结果进行缓存</td>
</tr>
<tr>
<td colspan="2" valign="center">show status like ‘Qcache%’;Qcache_free_blocks         10<br />
Qcache_free_memory        65891984<br />
Qcache_hits             14437<br />
Qcache_inserts            707<br />
Qcache_lowmem_prunes     0<br />
Qcache_not_cached        216<br />
Qcache_queries_in_cache     540<br />
Qcache_total_blocks        1191</td>
</tr>
<tr>
<td colspan="2" valign="center"></td>
</tr>
<tr>
<td valign="center"><strong>SORT OPERATIONS</strong></td>
<td valign="center"><strong>SORT 选项</strong></td>
</tr>
<tr>
<td valign="center">Current sort_buffer_size = 6 M</td>
<td valign="center">show variables like ’sort_buffer%’;</td>
</tr>
<tr>
<td valign="center">Current read_rnd_buffer_size = 16 M</td>
<td valign="center">show variables like ‘read_rnd_buffer_size%’;</td>
</tr>
<tr>
<td valign="center">Sort buffer seems to be fine</td>
<td valign="center"></td>
</tr>
<tr>
<td colspan="2" valign="center"></td>
</tr>
<tr>
<td valign="center"><strong>JOINS</strong></td>
<td valign="center"><strong>JOINS</strong></td>
</tr>
<tr>
<td valign="center">Current join_buffer_size = 132.00 K</td>
<td valign="center"><strong>show variables like  ‘join_buffer_size%’;</strong><strong>join_buffer_size</strong>=<strong> join_buffer_size</strong>+4kb</td>
</tr>
<tr>
<td valign="center">You have had 6 queries where a join could not use an index  properly</td>
<td valign="center">这里的6是通过 <strong>show status like ‘Select_full_join’; </strong>获得的</td>
</tr>
<tr>
<td valign="center">You should enable “log-queries-not-using-indexes”<br />
Then look  for non indexed joins in the slow query log.<br />
If you are unable to optimize  your queries you may want to increase your<br />
join_buffer_size to accommodate  larger joins in one pass.Note! This script will still suggest raising the  join_buffer_size when<br />
ANY joins not using indexes are found.</td>
<td valign="center">你需要启用 “<strong>log-queries-not-using-indexes</strong>”  然后在慢查询日志中看是否有取消索引的joins语句。如果不优化查询语句的话，则需要增大<strong>join_buffer_size</strong>。</td>
</tr>
<tr>
<td colspan="2" valign="center"></td>
</tr>
<tr>
<td valign="center"><strong>OPEN FILES LIMIT</strong></td>
<td valign="center"><strong>文件打开数限制</strong></td>
</tr>
<tr>
<td valign="center">Current open_files_limit = 1234 files</td>
<td valign="center"><strong>show variables like  ‘open_files_limit%’;</strong></td>
</tr>
<tr>
<td valign="center">The open_files_limit should typically be set to at least  2x-3xthat of table_cache if you have heavy MyISAM usage.</td>
<td valign="center">如果系统中有很多的MyISAM类型的表，则建议将open_files_limit  设置为2X~3X的table_open_cache<br />
<strong>show status like  ‘Open_files’;</strong><strong>open_files_ratio</strong>=  open_files*100/open_files_limit<br />
如果<strong>open_files_ratio </strong>超过75%  则需要加大open_files_limit</td>
</tr>
<tr>
<td valign="center"><strong>Your open_files_limit value seems to be  fine</strong></td>
<td valign="center"></td>
</tr>
<tr>
<td colspan="2" valign="center"></td>
</tr>
<tr>
<td valign="center"><strong>TABLE CACHE</strong></td>
<td valign="center"><strong>TABLE 缓存</strong></td>
</tr>
<tr>
<td valign="center">Current table_open_cache = 512 tables</td>
<td valign="center">show variables like ‘table_open_cache’;</td>
</tr>
<tr>
<td valign="center">Current table_definition_cache = 256 tables</td>
<td valign="center">show variables like ‘ table_definition_cache ‘;</td>
</tr>
<tr>
<td valign="center">You have a total of 368 tables</td>
<td valign="center">SELECTCOUNT(*) FROM INFORMATION_SCHEMA.TABLES WHERE  TABLE_TYPE=’BASE TABLE’</td>
</tr>
<tr>
<td valign="center">You have <strong>371</strong> open tables.</td>
<td valign="center">show status like ‘Open_tables’;</td>
</tr>
<tr>
<td valign="center"><strong>The table_cache value seems to be fine</strong></td>
<td valign="center"><strong>Open_tables</strong> /<strong>table_open_cache*100%</strong> &lt; 95%</td>
</tr>
<tr>
<td valign="center"><strong>You should probably increase your  table_definition_cache value.</strong></td>
<td valign="center"><strong>table_cache_hit_rate</strong> =open_tables*100/opened_tables</td>
</tr>
<tr>
<td colspan="2" valign="center"></td>
</tr>
<tr>
<td valign="center"><strong>TEMP TABLES</strong></td>
<td valign="center"><strong>临时表</strong></td>
</tr>
<tr>
<td valign="center">Current max_heap_table_size = 16 M</td>
<td valign="center">show variables like ‘max_heap_table_size’;</td>
</tr>
<tr>
<td valign="center">Current tmp_table_size = 16 M</td>
<td valign="center">show variables like ‘tmp_table_size’;</td>
</tr>
<tr>
<td valign="center">Of 285 temp tables, 11% were created on disk</td>
<td valign="center">Created_tmp_tables=285created_tmp_disk_tables*100/<br />
(created_tmp_tables+created_tmp_disk_tables)=11%</td>
</tr>
<tr>
<td valign="center"><strong>Created disk tmp tables ratio seems fine</strong></td>
<td valign="center"></td>
</tr>
<tr>
<td colspan="2" valign="center"></td>
</tr>
<tr>
<td valign="center"><strong>TABLE SCANS</strong></td>
<td valign="center"><strong>扫描表</strong></td>
</tr>
<tr>
<td valign="center">Current read_buffer_size = 6 M</td>
<td valign="center">show variables like ‘read_buffer_size’;</td>
</tr>
<tr>
<td valign="center">Current table scan ratio = 9 : 1</td>
<td valign="center"><strong>read_rnd_next</strong> =show global status like  ‘Handler_read_rnd_next’;<br />
<strong>com_select</strong>= show global status like  ‘Com_select’;<br />
<strong>full_table_scans</strong>=read_rnd_next/com_select<br />
<strong>Current  table scan ratio</strong> = full_table_scans :  1″<br />
如果表扫描率超过4000，说明进行了太多表扫描，很有可能索引没有建好，增加read_buffer_size值会有一些好处，但最好不要超过8MB。</td>
</tr>
<tr>
<td valign="center"><strong>read_buffer_size seems to be fine</strong></td>
<td valign="center"></td>
</tr>
<tr>
<td colspan="2" valign="center"></td>
</tr>
<tr>
<td valign="center"><strong>TABLE LOCKING</strong></td>
<td valign="center"><strong>TABLE LOCKING</strong></td>
</tr>
<tr>
<td valign="center">Current Lock Wait ratio = 0 : 5617</td>
<td valign="center">show global status like’Table_locks_waited’;<br />
show global  status like‘Questions’;<br />
如果 Table_locks_waited=0<br />
Current Lock Wait ratio = 0:  Questions</td>
</tr>
<tr>
<td valign="center"><strong>Your table locking seems to be fine</strong></td>
<td valign="center"></td>
</tr>
</tbody>
</table>
</div>
<div></div>
<div></div>
<div>转载自：http://blog.chinaunix.net/u3/117634/showart_2291084.html</div>
]]></content:encoded>
			<wfw:commentRss>http://www.187299.com/archives/1653/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MySQL：how to ignore errors loading a dump</title>
		<link>http://www.187299.com/archives/1642</link>
		<comments>http://www.187299.com/archives/1642#comments</comments>
		<pubDate>Mon, 09 Aug 2010 05:29:27 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[MySQL]]></category>

		<guid isPermaLink="false">http://www.187299.com/?p=1642</guid>
		<description><![CDATA[When we load a dump sql file using the following command: mysql -uroot -pdbpassword test &#60; /data/mysql.sql the procedure will stop as it detects an error. How to make procedure ignore the errors and continue anyway? There are two kinds of methond can... ]]></description>
			<content:encoded><![CDATA[<p>When we load a dump sql file using the following command:<br />
mysql -uroot -pdbpassword test &lt; /data/mysql.sql<br />
the procedure will stop as it detects an error.<br />
How to make procedure ignore the errors and continue anyway?<br />
There are two kinds of methond can do that.</p>
<p>The first one:use "-f" option<br />
mysql -uroot -pdbpassword -f test &lt; /data/mysql.sql</p>
<p>The second one:access into mysql,and use the "source" command.<br />
mysql -uroot -pdbpassword test<br />
source /data/mysql.sql<br />
exit</p>
<p>References:</p>
<p>http://forums.mysql.com/read.php?28,78316,78316</p>
]]></content:encoded>
			<wfw:commentRss>http://www.187299.com/archives/1642/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>使用mysqldump線上備份InnoDB</title>
		<link>http://www.187299.com/archives/1493</link>
		<comments>http://www.187299.com/archives/1493#comments</comments>
		<pubDate>Fri, 05 Mar 2010 03:08:20 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[MySQL]]></category>

		<guid isPermaLink="false">http://www.187299.com/?p=1493</guid>
		<description><![CDATA[用 mysqldump 做線上即時備份，通常 InnoDB 的資料只有出現1~2筆，如果要儘可能把完整的資料匯出，可以加上 --single-transaction，備份前 mysqldump 會先執行 BEGIN ，取得 READ LOCK 後，便能確定資料在執... ]]></description>
			<content:encoded><![CDATA[<p>用 mysqldump 做線上即時備份，通常 InnoDB 的資料只有出現1~2筆，如果要儘可能把完整的資料匯出，可以加上 --single-transaction，備份前 mysqldump 會先執行 BEGIN ，取得 READ LOCK 後，便能確定資料在執行 mysqldump 的過程中不會受到其它連線對 InnoDB 存取的干擾，也能 Dump 出較完整的資料。(使用此參數需有 READ LOCK 權限)</p>
<p>mysqldump --single-transaction --all-databases &gt; all_db.sql</p>
<p>注意:<br />
1.表單較大時可以加上 --quick<br />
2.MySQL Cluster 不支援 --single-transaction</p>
<p>然而使用 --single-transaction 時最好搭配 --flush-logs 及 --master-data 來維持 Binary Log 的完整性。(使用這二個參數皆需有 RELOAD 權限)</p>
<p>mysqldump --single-transaction --flush-logs --master-data --all-databases &gt; all_db.sql</p>
<p>Binary Log 採用的是遞增備份，--flush-logs 便是把目前的 Binary Log 給 flush 出來 (若目前 MASTER_LOG_FILE 已經到 mysql-bin.000005，產生出來的檔案便是 mysql-bin.000006)，完成之後才進行 Dump 的作業。</p>
<p>而 --master-data (預設值為1) 則是在 Dump 出來的 SQL 語法中加入下面這一行，以記錄目前 Dump 的時間點。</p>
<p>CHANGE MASTER TO MASTER_LOG_FILE=mysql-bin.000006',MASTER_LOG_POS=4;</p>
<p>如果在未來執行匯入時 SQL 語法時， MySQL 便能很清楚的知道這次 Dump 出來的 SQL 在 Binary Log 中是屬於哪個位置。</p>
<p>註: 若不需理會 Binary Log 的位置時 (例如進行完整備份作業)，只要將 --master-data 設為 2 便會將 CHANGE MASTER 給註解起來純供參考用。</p>
<p>转载自：<a href="http://www.neo.com.tw/archives/1122" target="_blank">http://www.neo.com.tw/archives/1122 </a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.187299.com/archives/1493/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MySQL – Got a packet bigger than ‘max_allowed_packet’</title>
		<link>http://www.187299.com/archives/1448</link>
		<comments>http://www.187299.com/archives/1448#comments</comments>
		<pubDate>Mon, 25 Jan 2010 02:40:54 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[MySQL]]></category>

		<guid isPermaLink="false">http://www.187299.com/?p=1448</guid>
		<description><![CDATA[The default maximum allowed packget size is 1MB, so if you store some large binaries in your database you might get some problems. All you need to do is re-set the maximum size to a larger number. Macintosh:trunk jennyfong$ mysql -uroot database_name &#6... ]]></description>
			<content:encoded><![CDATA[<p>The default maximum allowed packget size is 1MB, so if you store some large binaries in your database you might get some problems. All you need to do is re-set the maximum size to a larger number.</p>
<p>Macintosh:trunk jennyfong$ mysql -uroot database_name &lt; database_backup.sql</p>
<p>ERROR 1153 (08S01) at line 2365: Got a packet bigger than 'max_allowed_packet' bytes<br />
Macintosh:trunk jennyfong$ mysql -uroot<br />
Welcome to the MySQL monitor.  Commands end with ; or \g.<br />
Your MySQL connection id is 25<br />
Server version: 5.0.86 MySQL Community Server (GPL)</p>
<p>Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.</p>
<p>mysql&gt; set global net_buffer_length=10000000;<br />
Query OK, 0 rows affected, 1 warning (0.00 sec)</p>
<p>mysql&gt; set global max_allowed_packet=1000000000;<br />
Query OK, 0 rows affected (0.00 sec)</p>
<p>mysql&gt; exit<br />
Bye<br />
Macintosh:trunk jennyfong$ mysql -uroot database_name &lt; database_backup.sql</p>
<p>show variables like 'max_allowed_packet';</p>
]]></content:encoded>
			<wfw:commentRss>http://www.187299.com/archives/1448/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>install_xtrabackup-1.0_on_CentOS_5.4</title>
		<link>http://www.187299.com/archives/1436</link>
		<comments>http://www.187299.com/archives/1436#comments</comments>
		<pubDate>Wed, 06 Jan 2010 13:11:10 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[MySQL]]></category>

		<guid isPermaLink="false">http://www.187299.com/?p=1436</guid>
		<description><![CDATA[wget http://www.percona.com/mysql/xtrabackup/1.0/source/xtrabackup-1.0-56.rhel5.src.rpm mkdir -p /usr/src/redhat/SOURCES/ rpm -i xtrabackup-1.0-56.rhel5.src.rpm cd /usr/src/redhat/SOURCES/ tar xf xtrabackup-1.0.tar.gz cd xtrabackup-1.0 ./configure make c... ]]></description>
			<content:encoded><![CDATA[<p>wget http://www.percona.com/mysql/xtrabackup/1.0/source/xtrabackup-1.0-56.rhel5.src.rpm<br />
mkdir -p /usr/src/redhat/SOURCES/<br />
rpm -i xtrabackup-1.0-56.rhel5.src.rpm<br />
cd /usr/src/redhat/SOURCES/<br />
tar xf xtrabackup-1.0.tar.gz<br />
cd xtrabackup-1.0<br />
./configure<br />
make<br />
cd innobase/xtrabackup/<br />
make<br />
make install</p>
<p>/usr/bin/innobackupex-1.5.1 --help</p>
]]></content:encoded>
			<wfw:commentRss>http://www.187299.com/archives/1436/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Got error 28 from storage engine 解决方法</title>
		<link>http://www.187299.com/archives/1380</link>
		<comments>http://www.187299.com/archives/1380#comments</comments>
		<pubDate>Tue, 08 Dec 2009 11:10:25 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[MySQL]]></category>

		<guid isPermaLink="false">http://www.187299.com/?p=1380</guid>
		<description><![CDATA[今天碰到数据库出错 Got error 28 from storage engine 查了一下，数据库文件所在的盘应该没事，应该是数据库用的临时目录空间不够 引用 磁盘临时空间不够导致。 解决办法： 清空/tmp目录，或者修... ]]></description>
			<content:encoded><![CDATA[<p>今天碰到数据库出错</p>
<p>Got error 28 from storage engine</p>
<p>查了一下，数据库文件所在的盘应该没事，应该是数据库用的临时目录空间不够</p>
<p>引用<br />
磁盘临时空间不够导致。<br />
解决办法：<br />
清空/tmp目录，或者修改my.cnf中的tmpdir参数，指向具有足够空间目录</p>
<p>上面的说法应该比较清楚，还有一个类似的：</p>
<p>引用<br />
mysql报以下错的解决方法</p>
<p>ERROR 1030 (HY000): Got error 28 from storage engine</p>
<p>出现此问题的原因：临时空间不够，无法执行此SQL语句</p>
<p>解决方法：将tmpdir指向一个硬盘空间很大的目录即可</p>
<p>原创内容如转载请注明：来自 阿权的书房<br />
本帖地址：<a href="http://www.aslibra.com/blog/read.php/794.htm" target="_blank">http://www.aslibra.com/blog/read.php/794.htm</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.187299.com/archives/1380/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Windows下mysqlimport批量txt文件</title>
		<link>http://www.187299.com/archives/1369</link>
		<comments>http://www.187299.com/archives/1369#comments</comments>
		<pubDate>Sat, 05 Dec 2009 04:54:41 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[MySQL]]></category>

		<guid isPermaLink="false">http://www.187299.com/?p=1369</guid>
		<description><![CDATA[在Linux上把MySQL库导出为sql和txt，在Linux上是很容易导入 mysql -u root -ppassword dbname &#60; db_struc.sql mysqlimport –local -uroot -ppassword dbname `find . -name “*.txt”` Windows下麻烦了，没有find，又不支持*.txt 后... ]]></description>
			<content:encoded><![CDATA[<p>在Linux上把MySQL库导出为sql和txt，在Linux上是很容易导入</p>
<p>mysql -u root -ppassword  dbname &lt; db_struc.sql</p>
<p>mysqlimport –local -uroot -ppassword dbname `find . -name “*.txt”`</p>
<p>Windows下麻烦了，没有find，又不支持*.txt</p>
<p>后来想到办法，建了个bat文件</p>
<p>用替换的方法将文件修改为</p>
<p>mysqlimport -uroot -ppassword dbname d:\dump\table1.txt</p>
<p>mysqlimport -uroot -ppassword dbname d:\dump\table2.txt</p>
<p>进入cmd<br />
c:<br />
cd "\Documents and Settings\user\桌面\test_2011-03-10\2011-03-10"<br />
创建数据库test<br />
"F:\Program Files\xampp\xampp\mysql\bin\mysql.exe" -uroot -pmanypassword<br />
CREATE DATABASE IF NOT EXISTS test DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;<br />
exit</p>
<p>导入数据结构<br />
"F:\Program Files\xampp\xampp\mysql\bin\mysql.exe" -uroot -pmanypassword test &lt; test_db_struc.sql<br />
获取所有表的txt文件名<br />
dir /b *.txt &gt; c:\import.bat<br />
现在的格式是<br />
test_data.txt<br />
test_data_a.txt</p>
<p>然后用editplus打开，替换成这样的格式<br />
"F:\Program Files\xampp\xampp\mysql\bin\mysqlimport.exe" --local -uroot -pmanypassword test test_data.txt<br />
"F:\Program Files\xampp\xampp\mysql\bin\mysqlimport.exe" --local -uroot -pmanypassword test test_data_a.txt</p>
<p>把import.bat放到c:\Documents and Settings\user\桌面\test_2011-03-10\2011-03-10<br />
执行，数据就导进去了</p>
]]></content:encoded>
			<wfw:commentRss>http://www.187299.com/archives/1369/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>mysql_drop_user错误</title>
		<link>http://www.187299.com/archives/1366</link>
		<comments>http://www.187299.com/archives/1366#comments</comments>
		<pubDate>Sat, 28 Nov 2009 05:20:28 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[MySQL]]></category>

		<guid isPermaLink="false">http://www.187299.com/?p=1366</guid>
		<description><![CDATA[mysql&#62; drop user 'test_s99'@'%'; ERROR 1268 (HY000): Can't drop one or more of the requested users revoke all on test_s99.* from 'test_s99'@'localhost'; drop user 'test_s99'@'localhost'; The DROP USER statement removes one or more MySQL accounts. To ... ]]></description>
			<content:encoded><![CDATA[<p>mysql&gt; drop user 'test_s99'@'%';<br />
ERROR 1268 (HY000): Can't drop one or more of the requested users</p>
<p>revoke all on test_s99.* from 'test_s99'@'localhost';<br />
drop user 'test_s99'@'localhost';</p>
<p>The DROP USER statement removes one or more MySQL accounts. To use it, you must have the DELETE privilege for the mysql database. Each account is named using the same format as for the GRANT  statement; for example, 'jeffrey'@'localhost'. If you specify only the user name part of the account name, a host name part of '%' is used. For additional information about specifying account names, see Section 12.5.1.2, “GRANT Syntax”.</p>
<p>DROP USER was added in MySQL 4.1.1. In MySQL 4.1, it serves only to remove account rows from the user table for accounts that have no privileges. To remove a MySQL account completely (including all of its privileges), you should use the following procedure, performing the steps in the order shown:</p>
<p>1.</p>
<p>Use SHOW GRANTS to determine what privileges the account has. See Section 12.5.5.12, “SHOW GRANTS Syntax”.<br />
2.</p>
<p>Use REVOKE to revoke the privileges displayed by SHOW GRANTS. This removes rows for the account from all the grant tables except the user table, and revokes any global privileges listed in the user table. See Section 12.5.1.2, “GRANT Syntax”.<br />
3.</p>
<p>Delete the account by using DROP USER to remove the user table row.</p>
<p>In MySQL 5.0.2 and up, DROP USER removes the account row in the user table and also revokes the privileges held by the account. It is not necessary to use DROP USER in conjunction with REVOKE.<br />
Important</p>
<p>DROP USER does not automatically close any open user sessions. Rather, in the event that a user with an open session is dropped, the statement does not take effect until that user's session is closed. Once the session is closed, the user is dropped, and that user's next attempt to log in will fail. This is by design.</p>
<p>Before MySQL 4.1.1, DROP USER is not available. You should first revoke the account privileges using SHOW GRANTS and REVOKE as just described. Then delete the user table row and flush the grant tables as shown here:</p>
<p><a href="http://dev.mysql.com/doc/refman/4.1/en/drop-user.html" target="_blank">http://dev.mysql.com/doc/refman/4.1/en/drop-user.html</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.187299.com/archives/1366/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>mysql时区的修正</title>
		<link>http://www.187299.com/archives/1313</link>
		<comments>http://www.187299.com/archives/1313#comments</comments>
		<pubDate>Sat, 07 Nov 2009 03:22:23 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[MySQL]]></category>

		<guid isPermaLink="false">http://www.187299.com/?p=1313</guid>
		<description><![CDATA[昨天暴风的技术人员找我要核对充值数据，说是时间对不上；我检查了之后发现二服的数据库的时间有问题，我使用from_unixtime()这个方法查看1257868800这个时间戳顯示的不是2009-11-11，而是2009-11-1... ]]></description>
			<content:encoded><![CDATA[<p>昨天暴风的技术人员找我要核对充值数据，说是时间对不上；我检查了之后发现二服的数据库的时间有问题，我使用from_unixtime()这个方法查看1257868800这个时间戳顯示的不是2009-11-11，而是2009-11-10  11:00:00，时间差了十三个小时。而后台显示那里是用from_unixtime()这个方法来显示时间格式的，所以所有的订单数据都对不上他们那边系统记录的时间。据说是因为装MYSQL的时候的时间不对，导致后来MYSQL的时区就不对了，后来系统虽然把时区改过来了，但是MYSQL的时区还是在装机的时候的那个时区，显示就错误了。</p>
<p>知道了原因之后就能解决了，上网搜索了一下，找到了解决的方法。现在把我的解决方式记录一下。</p>
<p>先检查MYSQL的时区，打开一台MYSQL时区正确的机器，然后打开有问题的机器，确认是时区错误。</p>
<p>先打开时区正确的机器：进入MYSQL，在命令行输入：mysql -uroot -p****(root的密码)，进去之后输入show variables  like ‘%time_zone%’;然后回车，得到如下的显示：</p>
<p>+——————+——–+<br />
| Variable_name    | Value  |<br />
+——————+——–+<br />
|  system_time_zone | CST    |<br />
| time_zone        | SYSTEM  |<br />
+——————+——–+<br />
2 rows in set (0.00 sec)</p>
<p>然后再输入select from_unixtime(1257868800);回车，得到如下结果：</p>
<p>+—————————+<br />
| from_unixtime(1257868800) |<br />
+—————————+<br />
| 2009-11-11  00:00:00       |<br />
+—————————+<br />
1 row in set (0.00 sec)</p>
<p>好了，再去有问题有机器上执行相同的操作发现执行show variables like ‘%time_zone%’;得到的结果是：</p>
<p>+——————+——–+<br />
| Variable_name    | Value  |<br />
+——————+——–+<br />
|  system_time_zone | EDT    |<br />
| time_zone        | SYSTEM  |<br />
+——————+——–+<br />
2 rows in set (0.01 sec)</p>
<p>执行select from_unixtime(1257868800);得到的结果是：</p>
<p>+—————————+<br />
| from_unixtime(1257868800) |<br />
+—————————+<br />
| 2009-11-10  11:00:00       |<br />
+—————————+<br />
1 row in set (0.00 sec)</p>
<p>时间差了十三个小时。怎么样把时区调回我们想要的呢？虽然网上说可以在命令行下执行set time_zone =  ‘+8:00′;之后就设置了时区，但是这样的操作没有对全司有效。只是在执行这个之后再在命令行下执行其它的操作可以得到正确的数据。但是在phpmyadmin下得到的结果还是错的。所以要修改MYSQL的配置文件来达到修改全局变量的目的。</p>
<p>先去找到mysql的配置文件my.cnf，一般在/etc/my.cnf下面，可以cd /etc 然后find  my.cnf找找，看能不能找到。找到之后就修改它，用VI打开：vi  /etc/my.cnf，打开之后查找[mysqld]，在VI输入“/”然后输入[mysqld],就定位到[mysqld]所在的位置，在它的下面加上default-time-zone  = ‘+8:00′这一行，然后保存退出，重新启动MYSQL，使时区生效。这个时候再去MYSQL下查看刚才的那两条命令，就会发现时区都设置正确了。</p>
<p>到此，时区不对的问题就解决了。</p>
<p>转载自：<a href="http://www.codeo4.cn/?p=318" target="_blank">http://www.codeo4.cn/?p=318</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.187299.com/archives/1313/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

