ÅäÖÃ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¡£×´Ì¬Îļþ±£´æÔÚÓ²ÅÌÉÏ£¬´Ó·þÎñÆ÷¹Ø±Õʱ²»»á¶ªÊ§¡£Ï´δӷþÎñÆ÷Æô¶¯Ê±£¬¶ÁÈ¡ÕâЩÎļþÒÔÈ·¶¨ËüÒѾ´ÓÖ÷·þÎñÆ÷¶ÁÈ¡Á˶àÉÙ¶þ½øÖÆÈÕÖ¾£¬ÒÔ¼°´¦Àí×Ô¼ºµÄÖмÌÈÕÖ¾µÄ³Ì¶È¡£
É
Ïà¹ØÎĵµ£º
ÄÚ´æ±íʹÓùþϣɢÁÐË÷Òý°ÑÊý¾Ý±£´æÔÚÄÚ´æÖУ¬Òò´Ë¾ßÓм«¿ìµÄËٶȣ¬Êʺϻº´æÖÐСÐÍÊý¾Ý¿â£¬µ«ÊÇʹÓÃÉÏÊܵ½Ò»Ð©ÏÞÖÆ£¬ÒÔÏÂÊÇÀ¶²ÝʹÓõÄһЩ¸ÐÊÜ¡£
1¡¢heap¶ÔËùÓÐÓû§µÄÁ¬½ÓÊǿɼûµÄ£¬ÕâʹµÃËü·Ç³£ÊʺÏ×ö»º´æ¡£
2¡¢½öÊʺÏʹÓõij¡ºÏ¡£heap²»ÔÊÐíʹÓÃxxxTEXTºÍxxxBLOBÊý¾ÝÀàÐÍ£»Ö»ÔÊÐíʹÓÃ=ºÍ<=>²Ù×÷·ûÀ´ËÑË÷¼Ç¼£¨²» ......
Tomcat ÏÂ×îÈÝÒ×µ½µÄÎÊÌâ¾ÍÊÇÖÐÎÄÂÒÂëÎÊÌâÁË , ÏÂÃæ¾ÍÀ´Ì¸Ì¸ÎÒÔÚ Windows +Tomcat5 ϵ÷ÊÔ JSP ³ÌÐòʱ , ËùÅöµ½µÄÎÊÌâÒÔ¼°½â¾ö°ì·¨¡£
Õâ´Îµ÷ÊÔËùÓöµ½µÄÂÒÂëÎÊÌâÖ÷ÒªÓÐÈýÀࣺ
Ò»¡¢ Ò³Ãæ×Ö·ûÂÒÂë¡£
¼´Õû¸öÒ³Ãæ³öÏÖºº×ÖÂÒ ......
×öÏîĿʱÓÉÓÚÒµÎñÂß¼µÄÐèÒª£¬±ØÐë¶ÔÊý¾Ý±íµÄÒ»Ðлò¶àÐмÓÈëÐÐËø£¬¾Ù¸ö×î¼òµ¥µÄÀý×Ó£¬Í¼Êé½èÔÄϵͳ¡£¼ÙÉè
id=1
µÄÕâ±¾Êé¿â´æΪ
1
£¬µ«ÊÇÓÐ
2
¸öÈËͬʱÀ´½èÕâ±¾Ê飬´Ë´¦µÄÂ߼Ϊ
Select restnum from book where id =1 ;
-- Èç¹û restnum ´óÓÚ 0 £¬Ö´ÐÐ update
Update boo ......
µ¼ÈëÊý¾ÝÖ¸¶¨ÁÐ
load data local infile 'D:\\service_func_utf8.txt' into table service_func fields terminated by '\t' (service_id, func_id1, func_id2, func_id3, func_id4, func_id5, func_id6);
MYSQL½«²éѯ½á¹ûµ¼³öµ½Îļþ
select * from tablename into outfile '/tmp/test.txt';
MYSQLÁªºÏÖ÷¼ü
create  ......
#ÐÂÔöÒ»¸ö×ֶΣ¬Ä¬ÈÏֵΪ0£¬·Ç¿Õ£¬×Ô¶¯Ôö³¤£¬Ö÷¼ü
alter table tabelname add new_field_name field_type default 0 not null auto_increment ,add primary key (new_field_name);
#Ôö¼ÓÒ»¸öÐÂ×Ö¶Î
alter table tableName ......