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

ÅäÖÃMySQLÖ÷´Ó¸´ÖÆ(Replication)


ÅäÖÃMySQLÖ÷´Ó¸´ÖÆ(Replication)
±êÇ©£ºÖªÊ¶/̽Ë÷ mysql¸´ÖÆ replication mysql±¸·Ý 
·ÖÀࣺÊý¾Ý¿â
MySQLÖ§³Öµ¥Ïò¡¢Òì²½¸´ÖÆ£¬¸´Öƹý³ÌÖÐÒ»¸ö·þÎñÆ÷³äµ±Ö÷·þÎñÆ÷£¬¶øÒ»¸ö»ò¶à¸öÆäËü·þÎñÆ÷³äµ±´Ó·þÎñÆ÷¡£Ö÷·þÎñÆ÷½«¸üÐÂдÈë¶þ½øÖÆÈÕÖ¾Îļþ£¬²¢Î¬»¤ÈÕÖ¾ÎļþµÄÒ»¸öË÷ÒýÒÔ¸ú×ÙÈÕ־ѭ»·¡£µ±Ò»¸ö´Ó·þÎñÆ÷Á¬½Óµ½Ö÷·þÎñÆ÷ʱ£¬Ëü֪ͨÖ÷·þÎñÆ÷´Ó·þÎñÆ÷ÔÚÈÕÖ¾ÖжÁÈ¡µÄ×îºóÒ»´Î³É¹¦¸üеÄλÖᣴӷþÎñÆ÷½ÓÊÕ´ÓÄÇʱÆð·¢ÉúµÄÈκθüУ¬È»ºó·âËø²¢µÈ´ýÖ÷·þÎñÆ÷֪ͨÏÂÒ»´Î¸üС£
 
ΪʲôʹÓÃÖ÷´Ó¸´ÖÆ£¿
1¡¢Ö÷·þÎñÆ÷/´Ó·þÎñÆ÷ÉèÖÃÔö¼ÓÁ˽¡×³ÐÔ¡£Ö÷·þÎñÆ÷³öÏÖÎÊÌâʱ£¬Äã¿ÉÒÔÇл»µ½´Ó·þÎñÆ÷×÷Ϊ±¸·Ý¡£
2¡¢Í¨¹ýÔÚÖ÷·þÎñÆ÷ºÍ´Ó·þÎñÆ÷Ö®¼äÇзִ¦Àí¿Í»§²éѯµÄ¸ººÉ£¬¿ÉÒԵõ½¸üºÃµÄ¿Í»§ÏìӦʱ¼ä¡£µ«ÊDz»ÒªÍ¬Ê±ÔÚÖ÷´Ó·þÎñÆ÷ÉϽøÐиüУ¬ÕâÑù¿ÉÄÜÒýÆð³åÍ»¡£
3¡¢Ê¹Óø´ÖƵÄÁíÒ»¸öºÃ´¦ÊÇ¿ÉÒÔʹÓÃÒ»¸ö´Ó·þÎñÆ÷Ö´Ðб¸·Ý£¬¶ø²»»á¸ÉÈÅÖ÷·þÎñÆ÷¡£ÔÚ±¸·Ý¹ý³ÌÖÐÖ÷·þÎñÆ÷¿ÉÒÔ¼ÌÐø´¦Àí¸üС£
 
MySQLʹÓÃ3¸öÏß³ÌÀ´Ö´Ðи´Öƹ¦ÄÜ(ÆäÖÐ1¸öÔÚÖ÷·þÎñÆ÷ÉÏ£¬ÁíÁ½¸öÔÚ´Ó·þÎñÆ÷ÉÏ¡£µ±·¢³öSTART SLAVEʱ£¬´Ó·þÎñÆ÷´´½¨Ò»¸öI/OỊ̈߳¬ÒÔÁ¬½ÓÖ÷·þÎñÆ÷²¢ÈÃÖ÷·þÎñÆ÷·¢ËͶþ½øÖÆÈÕÖ¾¡£Ö÷·þÎñÆ÷´´½¨Ò»¸öÏ߳̽«¶þ½øÖÆÈÕÖ¾ÖеÄÄÚÈÝ·¢Ë͵½´Ó·þÎñÆ÷¡£´Ó·þÎñÆ÷I/OÏ̶߳ÁÈ¡Ö÷·þÎñÆ÷Binlog DumpÏ̷߳¢Ë͵ÄÄÚÈݲ¢½«¸ÃÊý¾Ý¿½±´µ½´Ó·þÎñÆ÷Êý¾ÝĿ¼Öеı¾µØÎļþÖУ¬¼´ÖмÌÈÕÖ¾¡£µÚ3¸öÏß³ÌÊÇSQLỊ̈߳¬´Ó·þÎñÆ÷ʹÓôËÏ̶߳ÁÈ¡ÖмÌÈÕÖ¾²¢Ö´ÐÐÈÕÖ¾Öаüº¬µÄ¸üС£SHOW PROCESSLISTÓï¾ä¿ÉÒÔ²éѯÔÚÖ÷·þÎñÆ÷ÉϺʹӷþÎñÆ÷ÉÏ·¢ÉúµÄ¹ØÓÚ¸´ÖƵÄÐÅÏ¢¡£
 
ĬÈÏÖмÌÈÕ־ʹÓÃhost_name-relay-bin.nnnnnnÐÎʽµÄÎļþÃû£¬ÆäÖÐhost_nameÊÇ´Ó·þÎñÆ÷Ö÷»úÃû£¬nnnnnnÊÇÐòÁкš£ÓÃÁ¬ÐøÐòÁкÅÀ´´´½¨Á¬ÐøÖмÌÈÕÖ¾Îļþ£¬´Ó000001¿ªÊ¼¡£´Ó·þÎñÆ÷¸ú×ÙÖмÌÈÕÖ¾Ë÷ÒýÎļþÀ´Ê¶±ðÄ¿Ç°ÕýʹÓõÄÖмÌÈÕÖ¾¡£Ä¬ÈÏÖмÌÈÕÖ¾Ë÷ÒýÎļþÃûΪhost_name-relay-bin.index¡£ÔÚĬÈÏÇé¿ö£¬ÕâЩÎļþÔÚ´Ó·þÎñÆ÷µÄÊý¾ÝĿ¼Öб»´´½¨¡£ÖмÌÈÕÖ¾Óë¶þ½øÖÆÈÕÖ¾µÄ¸ñʽÏàͬ£¬²¢ÇÒ¿ÉÒÔÓÃmysqlbinlog¶ÁÈ¡¡£µ±SQLÏß³ÌÖ´ÐÐÍêÖмÌÈÕÖ¾ÖеÄËùÓÐʼþºó£¬ÖмÌÈÕÖ¾½«»á±»×Ô¶¯É¾³ý¡£
 
´Ó·þÎñÆ÷ÔÚÊý¾ÝĿ¼ÖÐÁíÍâ´´½¨Á½¸ö״̬Îļþ--master.infoºÍrelay-log.info¡£×´Ì¬Îļþ±£´æÔÚÓ²ÅÌÉÏ£¬´Ó·þÎñÆ÷¹Ø±Õʱ²»»á¶ªÊ§¡£Ï´δӷþÎñÆ÷Æô¶¯Ê±£¬¶ÁÈ¡ÕâЩÎļþÒÔÈ·¶¨ËüÒѾ­´ÓÖ÷·þÎñÆ÷¶ÁÈ¡Á˶àÉÙ¶þ½øÖÆÈÕÖ¾£¬ÒÔ¼°´¦Àí×Ô¼ºµÄÖмÌÈÕÖ¾µÄ³Ì¶È¡£
 
É


Ïà¹ØÎĵµ£º

MYSQLѧϰ

MYSQLÓжàÖÖ´æ´¢ÒýÇæºÍ±íÀàÐÍ£¬InnoDBºÍBDBÖ§³ÖÊÂÎñ£¬Èç¹ûҪʹÓÃÊÂÎñ£¬±íµÄÀàÐ;ÍÓ¦¸ÃÊÇInnoDB.
Ìá¸ß±íµÄÐÔÄÜ£º
1¡¢ÓÃ×îСµÄÊý¾ÝÀàÐÍ¡£Õ¼ÓÿռäС£¬½ÚÊ¡´ÅÅÌ¿Õ¼äºÍÄÚ´æ¡£
2¡¢±í¸ñµÄÖ÷Ë÷ÒýÒª¾¡¿ÉÄܵĶ̣¬ÒÔÃ÷ÏÔÌá¸ßЧÂÊ¡£
3¡¢Ë÷Òý×îºÃ½¨ÔÚΨһµÄÁÐÉÏ£¬Ë÷ÒýÔ½¶Ì£¬ËÙ¶ÈÔ½¿ì¡£
4¡¢¶àÁÐË÷Òý±ØÐë°üº¬×î×ó±ßµÄǰ׺²ÅÓÐЧ¡£ ......

php+mysql±àÂëÎÊÌâ×ܽá

Òª²»³öÏÖÂÒÂ룬¾ÍÒª±£³ÖÊý¾Ý¿âºÍÒ³ÃæµÄ±àÂë¸ñʽһÖÂ.ÎÒÈ«²¿Ê¹ÓÃutf-8µÄ±àÂë.
Ê×ÏÈÒ³Ãæ:
 1. ½«ÎļþÓÃUE´ò¿ª,½«ÎļþÁí´æΪUTF-8ÎÞBOM¸ñʽ.ºÜ¶à±à¼­Æ÷¶¼¿ÉÓÃ.
 2.ʹÓà header("content-type:text/html;¡¡charset=utf-8"); Ç¿ÖÆת»»³Éutf-8µÄ±àÂë.
   Ò²¿ÉÒÔн¨Ò»¸öhead.php,ÈçÏÂ,ÔÚÒ³ÃæÖÐÓÃinclude( ......

mySql Îı¾×ֶ㤶È

BLOB
TEXT
Ò»¸öBLOB»òTEXTÁУ¬×î´ó³¤¶ÈΪ65535(2^16-1)¸ö×Ö·û¡£
MEDIUMBLOB
MEDIUMTEXT
Ò»¸öBLOB»òTEXTÁУ¬×î´ó³¤¶ÈΪ16777215(2^24-1)¸ö×Ö·û¡£
LONGBLOB
LONGTEXT
Ò»¸öBLOB»òTEXTÁУ¬×î´ó³¤¶ÈΪ4294967295(2^32-1)¸ö×Ö·û¡£
¿Éͨ¹ýÐÞ¸Äphp.iniÎļþ£¬¸Ä±ä×î´ó³¤¶ÈÉèÖá£
; Valid range 0 - 2147483647.  ......

[ÔÓ¼Ç] ÐÂÄêÎïÓï&¹ØÓÚMysqlÒýÇæÐÔÄܲâÊÔ

æµµÄ2009ÖÕÓÚ¹ýÈ¥£¬Ò²ÖÕÓÚ°ÑÈËÉú´óÊÂæÍêÁË£¬»Øµ½Õý³£µÄ¹¤×÷Éú»îÖÐÀ´¡£2010¶ÔÎÒÀ´ËµÓ¦¸ÃÊdzäÂúÐÂÆÚÍûµÄÒ»Ä꣬еÄÆõ»ú¾ÍÔÚÑÛÇ°£¬¼ÓÓÍŬÁ¦°É~
ÁíÍâ×¼±¸12¸öÔÂÖ®ºóÔÙÀ´×ܽáһϽñÄêµÄÖØ´óʼǣ¬ºÇºÇ~
˳±ã¿´µ½Ò»¸öMysqlµÄ²âÊÔÎÄÕ£¬¸Ð¾õ»¹ÂúÓвο¼¼ÛÖµµÄ£¬ÓÚÊǼǼÏÂÀ´ÒÔ±ã²Î¿¼¡£
ÒÔÏÂÊÇÒ»¸öMySQLÖÐMyISAMÒýÇæÓëInnoDBÒ ......

¼òµ¥µÄPHP²Ù×÷MysqlÀà

<?php
/*
 * Ãû³Æ : MySQLÊý¾Ý¿â»ù±¾²Ù×÷
 * ×÷Õß : pjx
 * °æ±¾ : v 2010/02/25 v 1.0
 * ˵Ã÷ : ¸ÃÀàÓÃÓÚ¶ÔMySQL×öһЩ¼òµ¥µÄ²Ù×÷
 * ʾÀý £º
 * ʵÀý => $db = new DB_MYSQL($database),´ò¸ö$databaseÊý¾Ý¿â
 * ²éѯÊý¾Ý¿â => $db->query($sql_str),²éѯ$sql_st ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ