dz̸MySQLÂý²éѯÈÕÖ¾¼°microslow patch(msl patch)
mysql(°üÀ¨ËùÓÐ5.*ϵÁÐ,5.1.21֮ǰ)µÄÂý²éѯÈÕ־ĬÈÏÊÇÒÔÃëΪµ¥Î»µÄ,¿ÉÒÔͨ¹ýset [session|global] long_query_time=1Õâ¸ö×îµÍÒ²¾ÍÊÇ¿ÉÒÔÉèÖõ½1Ãë,¶ÔÓÚ0.5,0.005Ö®Àà¾ÍÎÞÄÜΪÁ¦ÁË,Õâʱºò¿ÉÒÔÓÐmicroslow patch(msl patch)²¹¶¡À´Íê³ÉÕâÒ»¹¤×÷,Õâ¸ö¹¦Äܵĺô¦×ÔÈ»²»ÑÔ¶øÓ÷.
ÔÚmysql5.1.21¼°ÒÔºó°æ±¾¿ÉÒÔͨ¹ýset [session|global] long_query_time=0.01µÈÀ´ÉèÖüǼ0.01ÃëÒÔÉϵÄsqlÓï¾ä.
ÔÚ5.1.6Ö®ºóϵÁвúÆ·Öл¹ÓÐ--log-output=[FILE|TABLE|NONE]ÌØÐÔ,Õâ¸öÊÇÑ¡Ôñgeneral_logºÍslow_logµÄ´æ´¢·½Ê½,Îļþ,Êý¾Ý±í,»¹ÊDz»¼Ç¼,5.1.6-5.1.20ĬÈÏÊÇÊý¾Ý±í(mysql.slow_log±í),ÆäÓàĬÈÏÊÇÎļþ.
--log-queries-not-using-indexesÒ²ÊÇ5.1µÄÐÂÑ¡Ïî,¿ÉÒÔûÓÐʹÓÃindexµÄsqlÓï¾ä¼Ç¼µ½Âý²éѯÈÕÖ¾ÖÐ
--log-slow-admin-statements¸ÃÃüÁîÑ¡Ïî¿ÉÒÔ½«OPTIMIZE TABLE, ANALYZE TABLE, ÒÔ¼°ALTER TABLE µÈ¹ÜÀí²Ù×÷дµÀÂý²éѯÈÕÖ¾ÖÐ.
ÔÚ5.0ϵÁвúÆ·¿ÉÒÔͨ¹ý°²×°microslow patch(msl patch)À´¸Ä½øÂý²éѯÈÕÖ¾.
ÕâЩѡÏî¿ÉÒÔ¼ÓÔÚÆô¶¯ÃüÁîÉÏÒ²¿ÉÒԼǼÔÚmy.cnfÀïÃæ
ÖÁÓڲ鿴ÈÕÖ¾,¿ÉÒÔÖ±½Ó²é¿´Ò²¿ÉÒÔʹÓù¤¾ß,¶ÔÓڱȽ϶àµÄÈÕÖ¾»¹ÊÇÈÕÖ¾·½±ãЩ.³£¼ûµÄ¹¤¾ßÓÐmysql×Ô´øµÄmysqldumpslowÒÔ¼°µÚÈý·½¹¤¾ßmysqlslaµÈ.
msl patchÊÇͨ¹ýÐÞ¸ÄmysqlÔ´´úÂëµÄ·½Ê½À´ÔöÇ¿mysqlµÄ¹¦ÄÜ,ËùÒÔÖ»ÄÜÊÇÔ´Âë°²×°²Å¿ÉÒÔÀ©Õ¹Õâ¸ö¹¦ÄÜ,ÆäÔÚwww.mysqlperformanceblog.comÉÏÓÐÏêϸ½éÉÜ(ÆäʵӢÓïºÜ¼òµ¥,ºÙºÙ)
ÓÐƪÎÄÕÂÏêϸ˵Ã÷ÁËmicroslow patchµÄ°²×°ºÍʹÓÃÕª¼¸¸öÑ¡Ïî·ÅÔÚÕâ·½±ãÒÔºó²é¿´
Configuration
There are several parameters related to slow log you can set with patch applied. All filter-type options work in conjunction meaning that in order for query to be logged it must match long_query_time AND min_examined_row_limit AND log_slow_filter.
log-slow-queries[=name]
Log slow queries to this log file. Defaults logging to hostname-slow.log file. Must be enabled to activate other slow log options.
This is the most important one as it enables the logging. If you don’t specify it in my.cnf file, the remaining part of the configuration will not matter, because the log file won&
Ïà¹ØÎĵµ£º
È¥mysqlµÄ¹Ù·½ÍøÕ¾ÏÂÔØodbc connector(http://dev.mysql.com/downloads/connector/odbc/3.51.html)
ÏÂÔصÄÊÇmysql-connector-odbc-noinstall-3.51.rar
½âѹºóÖ±½ÓÔËÐÐÎļþ¼ÐÖÐµÄ Install.bat Åú´¦ÀíÎļþ
mysql-connectorÓкü¸ÖÖ£¬Ñ¡ÔñÒ»¸ö×Ô¼ºÏ²»¶µÄ¼´¿É¡£
ÔÚxpÖдò¿ªODBCÊý¾ÝÔ´¹ÜÀíÆ÷£¨¿ØÖÆÃæ°å£¡·¹ÜÀí¹¤¾ß£¡·ODBCÊ ......
½â¾öÂÒÂë×îºÃµÄ·½·¨ÊÇÔÚÏîÄ¿Éè¼ÆÖ®³õ£¬Í³Ò»ËùÓеÄ×Ö·û¼¯£¬ÀýÈçÒ³Ãæ¡¢request¶ÔÏóÒÔ¼°Êý¾Ý¿âµÈµÈ¡£
Ò»¡¢
¼¸ÖÖ³£¼ûµÄÂÒÂëÏÖÏó£º
1¡¢Ò³ÃæÂÒÂë
µ¥´¿µÄÒ³ÃæÂÒÂëÊǺܺýâ¾öµÄ£¬Ö»ÒªÐÞ¸ÄÍ·²¿ÊʺϵÄ×Ö·û¼¯¼´¿É£¬Èç¹ûÒ³ÃæÖÐÎÄÏÔʾÂÒÂ룬Äã¿ÉÒÔ°Ñ×Ö·û¼¯ÐÞ¸ÄΪ£ºgb2312»ògbk¡£
2¡¢
Ò³ÃæÖ®¼ä´«µÝµÄ²Î ......
»·¾³:
Tomcat6.0.18
Mysql: 5.1.36
Windwos XP sp2
×î½üÐèÒªÓõ½Tomcat+mysqlÁ¬½Ó³ØµÄÅäÖÃ,½ñÌìÔÚÍøÉϲéÁ˺öà×ÊÁÏ,ÀÏ×ÊÁÏÌ«¶à,¶ÔÓÚÒÔÉϵÄÀÏ°æ±¾tomcat¿ÉÄÜÓÐÓÃ,±¾ÈËûÓвâÊÔ¹ý,Õýȷд³ötomcat6.0ÅäÖõÄÎļäºÜÉÙ!ºÃ¶à×ÊÁÏÉÏÃæµÄÅäÖöÔÓÚÏÖÔÚаæµÄ¼¸ºõ¶¼ÊÇÓÐÎÊÌâµÄ,Ê®´íÆß°Ë!½ñÌì°ÑÎÒÅäÖõÄÕýÈ··½·¨Ð´ÏÂÀ´,¹©´ó¼Ò²Î¿¼ ......
ÎÒµÄmysql×°ÔÚ/usr/local/mysqlĿ¼ÏÂÆô
¶¯Åöµ½¹ýºÜ¶àÎÊÌâ¡£×î³£¼ûµÄÊÇ£º
ERROR 2002: Can't connect to local MySQL server through socket
'/tmp/mysql.sock' (111)
½â¾ö°ì·¨£º
[root@test mysql]# /usr/local/mysql/bin/mysqladmin -u root /
> -S /var/lib/mysql/mysql.sock password 'your.passwd'
......
Èç¹ûÄãÊǸöÈü³µÊÖ£¬²¢ÇÒ°´Ò»Ï°´Å¥¾ÍÄܹ»Á¢¼´¸ü»»ÒýÇæ¶ø²»ÐèÒª°Ñ³µ¿ªµ½³µ¿âÀïÈ¥»»£¬ÄÇ»áÊÇʲô¸Ð¾õÄØ£¿MySQLÊý¾Ý¿âΪ¿ª·¢ÈËÔ±Ëù×öµÄ¾ÍºÃÏñÊÇ°´°´Å¥»»ÒýÇ棻ËüÈÃÄãÑ¡ÔñÊý¾Ý¿âÒýÇ棬²¢¸øÄãÒ»Ìõ¼òµ¥µÄ;¾¶À´Çл»Ëü¡£
MySQLµÄ×Ô´øÒýÇæ¿Ï¶¨Êǹ»ÓÃÁË£¬µ«ÊÇÔÚÓÐЩÇé¿öÏ£¬ÆäËûµÄÒýÇæ¿ÉÄÜÒª±ÈÊÖÍ·ËùÓøüÊʺÏÍê³ÉÈÎÎñ¡£Èç¹ûÔ¸ ......