Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

MySQLÐÔÄܼà¿ØС֪ʶ (ת)

 ÒýÓÃhttp://hi.baidu.com/mygf/blog/item/b9f55d60049a2ed58cb10d64.html
2009-10-24 00:23
Ò»£¬»ñÈ¡mysqlÓû§ÏµĽø³Ì×ÜÊý
ps -ef | awk '{print $1}' | grep "mysql" | grep -v "grep" | wc-1
¶þ£¬Ö÷»úÐÔÄÜ״̬
# uptime
[root@ ~]# uptime
13:05:52 up 53 days, 52 min, 1 user, load average: 0.00, 0.00, 0.00
Èý£¬CPUʹÓÃÂÊ
# top
»ò
# vmstat
ËÄ£¬´ÅÅÌIOÁ¿
# vmstat »ò # iostat
Î壬swap½ø³öÁ¿[ÄÚ´æ]
# free
Áù£¬Êý¾Ý¿âÐÔÄÜ״̬
(1)QPS(ÿÃëQueryÁ¿)
QPS = Questions(or Queries) / seconds
mysql > show /*50000 global */ status like 'Question';
(2)TPS(ÿÃëÊÂÎñÁ¿)
TPS = (Com_commit + Com_rollback) / seconds
mysql > show status like 'Com_commit';
mysql > show status like 'Com_rollback';
(3)key Buffer ÃüÖÐÂÊ
key_buffer_read_hits = (1-key_reads / key_read_requests) * 100%
key_buffer_write_hits = (1-key_writes / key_write_requests) * 100%
mysql> show status like 'Key%';
(4)InnoDB BufferÃüÖÐÂÊ
innodb_buffer_read_hits = (1 - innodb_buffer_pool_reads / innodb_buffer_pool_read_requests) * 100%
mysql> show status like 'innodb_buffer_pool_read%';
(5)Query CacheÃüÖÐÂÊ
Query_cache_hits = (Qcahce_hits / (Qcache_hits + Qcache_inserts )) * 100%;
mysql> show status like 'Qcache%';
(6)Table Cache״̬Á¿
mysql> show status like 'open%';
(7)Thread Cache ÃüÖÐÂÊ
Thread_cache_hits = (1 - Threads_created / connections ) * 100%
mysql> show status like 'Thread%';
mysql> show status like 'Connections';
(8)Ëø¶¨×´Ì¬
mysql> show status like '%lock%';
(9)¸´ÖÆÑÓʱÁ¿
mysql > show slave status
(10) Tmp Table ×´¿ö(ÁÙʱ±í×´¿ö)
mysql > show status like 'Create_tmp%';
(11) Binlog Cache ʹÓÃ×´¿ö
mysql > show status like 'Binlog_cache%';
(12) Innodb_log_waits Á¿
mysql > show status like 'innodb_log_waits';
¿ªÔ´¼à¿ØÈí¼þ
Ò»£¬RRDTool
¶þ£¬Nagios
Èý£¬MRTG
ËÄ£¬Cacti


Ïà¹ØÎĵµ£º

mysql ÖРʱ¼äºÍÈÕÆÚº¯Êý

Ò»¡¢MySQL »ñµÃµ±Ç°ÈÕÆÚʱ¼ä º¯Êý
select now();
+---------------------+
| now()               |
+---------------------+
| 2008-08-08 22:20:46 |
+---------------------+
³ýÁË now() º¯ÊýÄÜ»ñµÃµ±Ç°µÄÈÕÆÚʱ¼äÍ⣬MySQL Öл¹ÓÐÏÂÃæµÄ ......

¸ã¶¨MySQLÊý¾Ý¿âÖÐÎÄÄ£ºý¼ìË÷ÎÊÌâ

ÔÚ MySQLÏ£¬ÔÚ½øÐÐÖÐÎÄÄ£ºý¼ìË÷ʱ£¬¾­³£»á·µ»ØһЩÓëÖ®²»Ïà¹ØµÄ¼Ç¼£¬Èç²éÕÒ "%a%" ʱ£¬·µ»ØµÄ¿ÉÄÜÓÐÖÐÎÄ×Ö·û£¬È´Ã»ÓÐa×Ö·û´æÔÚ¡£±¾ÈËÒÔÇ°Ò²ÔøÓöµ½¹ýÀàËÆÎÊÌ⣬¾­ÏêϸÔĶÁMySQLµÄManual£¬·¢ÏÖ¿ÉÒÔÓÐÒ»ÖÖ·½·¨ºÜ·½±ãµÄ½â¾ö²¢µÃµ½ÂúÒâµÄ½á¹û¡£
¡¡¡¡Àý×Ó£º
¡¡¡¡Ï£Íûͨ¹ý“±êÌ┶ÔÐÂÎÅ¿â½øÐмìË÷£¬¹Ø¼ü×Ö¿ÉÄÜ°üº¬Ê ......

mysqlÖÐÓÃÃüÁîÐ޸ıí½á¹¹µÄ·½·¨

ALTER [IGNORE] TABLE tbl_name alter_spec [, alter_spec …]
alter_specification:
       ADD [COLUMN] create_definition [FIRST | AFTER column_name ]
   or ADD INDEX [index_name] (index_col_name,…)
   or ADD PRIMARY KEY (index_col_name,&hell ......

MySQL È«ÎļìË÷ ʵÏÖÖÐÎļìË÷

ͨ¹ýMySQLÄÚÖÃÈ«ÎļìË÷ʵÏÖÖÐÎĵÄÏà¹Ø¼ìË÷
¹Ø¼ü×Ö£ºMySQL È«ÎļìË÷ È«ÎÄË÷Òý ÖÐÎÄ·Ö´Ê ¶þÔª·Ö´Ê ÇøλÂë ÏàËƶÈ
×¢£º±¾ÎÄʹÓõÄMySQL°æ±¾Îª£ºMySQL 4.0.x
ÔÚMySQL4ÖУ¬ÊÇÒѾ­¿ªÊ¼Ö§³ÖÈ«ÎļìË÷£¨Ë÷Òý£©µÄÁË¡£µ«ÊÇÖ»ÊǶÔÓ¢ÎÄÖ§³ÖÈ«ÎļìË÷¡£
ÓÉÓÚÓ¢ÎÄÔÚÊéдÉϵÄÌØÊâÐÔ£¬Ê¹µÃ·Ö´ÊËã·¨Ïà¶ÔÖÐÎÄÀ´Ëµ£¬¼òµ¥µÃ¶à¡£Ò»°ãÀ´Ëµ£¬ÎÒÃÇ ......

ÊÕ¼¯Ò»Ð©mysqlʹÓ÷½·¨

1.linuxÏÂÆô¶¯mysqlµÄÃüÁ
  mysqladmin start
/ect/init.d/mysql start (Ç°ÃæΪmysqlµÄ°²×°Â·¾¶)
2.linuxÏÂÖØÆômysqlµÄÃüÁ
  mysqladmin restart
/ect/init.d/mysql restart (Ç°ÃæΪmysqlµÄ°²×°Â·¾¶)
3.linuxϹرÕmysqlµÄÃüÁ
  mysqladmin shutdown
  /ect/init.d/mysql&nbs ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ