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

MySQL¼Ü¹¹·½°¸(ת)

Scale Out£ººáÏòÀ©Õ¹£¬Ôö¼Ó´¦Àí½ÚµãÌá¸ßÕûÌå´¦ÀíÄÜÁ¦
Scale Up£º×ÝÏòÀ©Õ¹£¬Í¨¹ýÌáÉýµ¥¸ö½ÚµãµÄ´¦ÀíÄÜÁ¦´ïµ½ÌáÉýÕûÌå´¦ÀíÄÜÁ¦µÄÄ¿µÄ
Replication
MySQLµÄreplicationÊÇÒì²½µÄ£¬ÊÊÓÃÓÚ¶ÔÊý¾ÝʵʱÐÔÒªÇó²»ÊÇÌرð¹Ø¼üµÄ³¡¾°¡£slave¶ËµÄIOÏ̸߳ºÔð´Ómaster¶ÁÈ¡ÈÕÖ¾£¬SQLÏß ³ÌרߺÔðÔÚslave¶ËÓ¦ÓôÓmaster¶Á¹ýÀ´µÄÈÕÖ¾£¨ÔçÆÚMySQLÓÃÒ»¸öÏß³ÌʵÏÖ£¬ÐÔÄÜÎÊÌâ±È½ÏÃ÷ÏÔ£©¡£Ê¹ÓÃreplication±ØÐëÆôÓà binary log£¬MySQLÓÃbinary logÏòslave·Ö·¢¸üÐÂ
¸´ÖƼ¶±ð
1. Row Level£º5.1.5¿ªÊ¼Ö§³Ö¡£mater¼Ç¼ÿÐÐÊý¾ÝµÄ¸ü¸ÄÈÕÖ¾£¬slave¸ù¾ÝÈÕÖ¾ÖðÐÐÓ¦Óá£Óŵ㣺Êý¾ÝÒ»ÖÂÐÔ¸üÓб£ÕÏ¡£È±µã£º¿ÉÄÜÔì³ÉÈÕÖ¾Îļþ±È½Ï´ó
2. Statement Level£ºmaster¼Ç¼ÿ¸öÖ´ÐеÄqueryÓï¾äÒÔ¼°Ò»Ð©ÉÏÏÂÎÄÐÅÏ¢£¬slave½Úµã¸ù¾ÝÕâЩÐÅÏ¢ÖØÐÂÔÚslaveÉÏÖ´ÐС£Óŵ㣺binary log±È½ÏС¡£È±µã£ºÄ³Ð©Çé¿öÏÂÊý¾ÝÒ»ÖÂÐÔÄÑÒÔ±£ÕÏ
3. Mixed Level£ºMySQL¸ù¾ÝÇé¿öÑ¡ÔñÄÄÖÖ¸´ÖÆ·½Ê½¡£5.1.8¿ªÊ¼Ö§³Ö
³£Óüܹ¹
1. Master-Slaves£ºÍ¨³£¶¼²ÉÓÃÕâÖÖ·½Ê½
2. Dual Master(Master-Master)£º2¸ömaster½Úµã»¥Ïàͬ²½¸üС£ÒòΪMySQLµÄÒì²½¸´ÖÆ·½Ê½£¬ÎªÁË·ÀÖ¹Êý¾Ý³åÍ»Ôì³ÉµÄ²»Ò»ÖÂÐÔ£¬Ò»°ã ½ö½«ÆäÖÐһ̨ÓÃÓÚд²Ù×÷£¬Áíһ̨²»Óûò½öÓÃÓÚ¶Á²Ù×÷¡£Ä¿µÄÊÇÆäÖÐһ̨masterÍ£»úά»¤»òÕß¹ÊÕÏÖжÏʱ¿ÉÒÔʹÓÃÁíһ̨master
3. ¼¶Áª¸´ÖÆ(Master-Slaves-Slaves)£ºÔÚMaster SlavesÖУ¬Èç¹ûslaves¹ý¶àreplication½«Ôö¼ÓmasterµÄ¸ºÔØ£¬Õâʱ¿ÉÒÔÈÃmasterÖ»ÏòÆäÖм¸Ì¨slave·Ö·¢¸üÐÂÈÕÖ¾£¬Õâ ¼¸Ì¨slave×÷Ϊһ¼¶½ÚµãÔÙÏòϼ¶½Úµã·Ö·¢¸üÐÂÈÕÖ¾
Cluster
Ö÷Ҫͨ¹ýNDB Cluster´æ´¢ÒýÇæʵÏÖ£¬ÊÇÒ»¸öShare NothingµÄ¼Ü¹¹£¬¸÷¸öMySQL ServerÖ®¼ä²¢²»ÐèÒª¹²ÏíÈκÎÊý¾Ý¡£¿ÉÒÔʵÏÖÈßÓࣨ¿É¿¿ÐÔ£©ÒÔ¼°¸ºÔؾùºâ¡£¸Õ¿ªÊ¼MySQLÐèÒªËùÓÐÊý¾ÝºÍË÷Òý¶¼Äܹ»¼ÓÔص½ÄÚ´æÖвÅÄÜʹÓà Cluster£¬¶ÔÄÚ´æÒªÇó¸ß£¬Ä¿Ç°Í¨¹ý¸Ä½øÖ»ÒªÇóË÷ÒýÄÜÈ«²¿¼ÓÔص½ÄÚ´æ
   
                  MySQL Clusrer¼Ü¹¹Ê¾Òâͼ£¬Í¼Æ¬À´×ÔMySQL¹Ù·½Îĵµ
1. SQL Nodes£º¸ºÔð´æ´¢²ãÖ®ÍâµÄÊÂÇ飬ÀýÈçÁ¬½Ó¹ÜÀí¡¢query´¦ÀíºÍÓÅ»¯¡¢cache¹ÜÀíµÈ£¬¼´°þÀëÁË´æ´¢²ãµÄMySQL·þÎñÆ÷
2. Data Nodes£º´æ´¢²ãµÄNDB½Úµã£¬¼´Cluster»·¾³ÏµĴ洢ÒýÇ档ÿ¸öcluster½Úµã±£´æÍêÕûÊý¾ÝµÄÒ»¸ö·ÖƬ£¬ÊÓ½ÚµãÊýÄ¿ºÍÅäÖöø¶¨£¬Ò»°ã data nodes±»×éÖ¯³ÉΪһ¸ö¸ögroup£¬Ã¿¸ögroup´æÓÐÒ»·ÝÍêÈ«ÏàͬµÄÎ


Ïà¹ØÎĵµ£º

mysql²é¿´Êý¾Ý¿â´óС£¬Ë÷Òý´óС

mysql> use information_schema
Database changed
mysql> select concat(round(sum(index_LENGTH)/(1024*1024),2),'MB') as 'Data Size' from tables where table_schema='bbs';
+-----------+
| Data Size |
+-----------+
| 0.00MB    |
+-----------+
1 row in set (0.01 sec)
½âÊÍ£º
......

MySQL ÆÕͨË÷Òý¡¢Î¨Ò»Ë÷ÒýºÍÖ÷Ë÷Òý

1¡¢ÆÕͨË÷Òý
¡¡¡¡ÆÕͨË÷Òý£¨Óɹؼü×ÖKEY»òINDEX¶¨ÒåµÄË÷Òý£©µÄΨһÈÎÎñÊǼӿì¶ÔÊý¾ÝµÄ·ÃÎÊËٶȡ£Òò´Ë£¬Ó¦¸ÃֻΪÄÇЩ×î¾­³£³öÏÖÔÚ²éѯÌõ¼þ£¨WHEREcolumn=£©»òÅÅÐòÌõ¼þ£¨ORDERBYcolumn£©ÖеÄÊý¾ÝÁд´½¨Ë÷Òý¡£Ö»ÒªÓпÉÄÜ£¬¾ÍÓ¦¸ÃÑ¡ÔñÒ»¸öÊý¾Ý×îÕûÆë¡¢×î½ô´ÕµÄÊý¾ÝÁУ¨ÈçÒ»¸öÕûÊýÀàÐ͵ÄÊý¾ÝÁУ©À´´´½¨Ë÷Òý¡£
¡¡¡¡2¡¢Î¨Ò»Ë÷Òý ......

MYSQL ×Ö·û¼¯¼°±àÂëÎÊÌâ

MySQLµÄ×Ö·û¼¯Ö§³Ö(Character Set Support)ÓÐÁ½¸ö·½Ã棺
     ×Ö·û¼¯(Character set)ºÍÁ¬½ÓУ¶Ô(Collation)¡£
¶ÔÓÚ×Ö·û¼¯µÄÖ§³Öϸ»¯µ½Ëĸö²ã´Î:
     ·þÎñÆ÷(server)£¬Êý¾Ý¿â(database)£¬Êý¾Ý±í(table)ºÍÁ¬½Ó(connection)¡£
1.MySQLĬÈÏ×Ö·û¼¯
  MySQL¶ÔÓÚ×Ö·û¼¯µÄ ......

MySQLÊý¾Ý¿âµÄdb.optÎļþ


MySQLµÄÿ¸öÊý¾Ý¿âĿ¼ÖÐÓÐÒ»¸öÎļþdb.opt,¸ÃÎļþÖ÷Òª ÓÃÀ´´æ´¢µ±Ç°Êý¾Ý¿âµÄĬÈÏ×Ö·û¼¯ºÍ×Ö·ûУÑé¹æÔò¡£
eg.default-character-set=latin1
default-collation=latin1_swedish_ci
¸ÃÎļþÖд洢µÄÊÇ´´½¨Êý¾Ý¿âʱĬÈϵÄ×Ö·û¼¯ºÍ×Ö·û¼¯Ð£Ñé¹æÔò£¬Ôò¸ÃÊý¾Ý¿âÔÚÒÔºó´´½¨±íʱÈç¹ûûÓÐÖ¸¶¨×Ö·û¼¯ºÍУÑé¹æÔò£¬Ôò¸Ã±íµÄÕâÁ½¸ö ......

MySQL COUNT SUM

 select
count(*) as mcount ,
left(create_time,10) as ptime ,
count(if(receive_msg is null,id,null)) as nullcount ,
count(if(receive_msg = '1',receive_msg,null)) as apfcount ,
count(if(receive_msg = '2',receive_msg,null)) as dttcount ,
count(if(receive_msg = '3',receive_ms ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ