ºìÁªLinuxÃÅ»§
Linux°ïÖú

MySQLÊÖ²á°æ±¾ 5.0.20-MySQLͬ²½(ËÄ)

·¢²¼Ê±¼ä:2006-08-22 00:01:32À´Ô´:ºìÁª×÷Õß:ͯѫ
6.8 ͬ²½Æô¶¯Ñ¡Ïî


²»¹ÜÊÇmaster»¹ÊÇslave£¬¶¼ÒªÉ趨 server-id Ñ¡ÏîÀ´È·¶¨Ê¹ËüÃǶ¼Óи÷×ÔΨһµÄͬ²½ID¡£±ØÐëÑ¡Ôñ 1 µ½ 2^32-1 Ö®¼äµÄÕýÕûÊý¡£ÀýÈ磺 server-id=3¡£


¹ØÓÚmaster·þÎñÆ÷ÉÏ¿ÉÓÃÓÚ¿ØÖƶþ½øÖÆÈÕÖ¾¼Ç¼µÄÑ¡ÏîÏêϸÃèÊöÇë¿´"5.9.4 The Binary Log"¡£


ϱíÃèÊöÁËslaveͬ²½¿ÉÓõÄÑ¡Ï¿ÉÒÔÔÚÃüÁîÐлòÕßÅäÖÃÎļþÖÐÉ趨ËüÃÇ¡£


һЩslaveͬ²½Ñ¡ÏîÒÔÌض¨µÄ·½Ê½À´´¦Àí£¬ÔÚslaveÆô¶¯Ê±£¬Èç¹û´æÔÚ `master.info` Îļþ²¢ÇÒ°üº¬ÕâЩѡÏÄÇôslave½«ÂÔ¹ýËüÃÇ¡£ÕâЩѡÏîÈçÏ£º


--master-host


--master-user


--master-password


--master-port


--master-connect-retry


´ÓMySQL 4.1.1¿ªÊ¼£¬Ò»ÏÂÑ¡ÏîÒ²°´ÕÕÉÏÊö·½Ê½ÌØÊâ´¦Àí£º


--master-ssl


--master-ssl-ca


--master-ssl-capath


--master-ssl-cert


--master-ssl-cipher


--master-ssl-key


ÔÚMySQL 4.1.1ÖУ¬ `master.info` ÎļþµÄ¸ñʽ¸Ä±äÁËÒÔ°üº¬ÏàÓ¦µÄSSLÑ¡Ïî¡£ÁíÍ⣬MySQL 4.1.1Îļþ¸ñʽ»¹°üÀ¨ÁËÔÚµÚÒ»ÐÐÖеÄÎļþ×ÜÐÐÊý¡£Èç¹û´Ó¾É°æ±¾Éý¼¶µ½4.1.1£¬ÄÇô·þÎñÆ÷Æô¶¯Ê±»á×Ô¶¯Éý¼¶ `master.info` Ϊеĸñʽ¡£²»¹ý£¬Èç¹ûÊÇ´Ó4.1.1½µ¼¶µ½¾É°æ±¾£¬¾ÍÐèÒªÔÚϵͳµÚÒ»´ÎÆô¶¯Ê±ÊÖ¹¤É¾³ýÎļþµÄµÚÒ»ÐС£×¢Ò⣬ÕâÖÖÇé¿öÏ£¬±»½µ¼¶µÄ·þÎñÆ÷¾Í²»ÄÜÔÙʹÓÃSSLÑ¡ÏîÁ¬½Óµ½masterÁË¡£


slaveÆô¶¯Ê±Èç¹û²»´æÔÚ `master.info` Îļþ£¬Ëü¾ÍʹÓÃÔÚÃüÁîÐлòÕßÅäÖÃÎļþÖÐÖ¸¶¨µÄ²ÎÊýÖµÀ´Æô¶¯¡£ÕâÔÚÿ´ÎµÚÒ»´ÎÆô¶¯slave·þÎñÆ÷ʱ¶¼ÊÇÕâÑù£¬»òÕßÖ´ÐÐ RESET SLAVE Óï¾ä¹Ø±ÕÇÒÖØÆôslaveÖ®ºó¡£


slaveÆô¶¯Ê±Èç¹û´æÔÚ `master.info` Îļþ£¬ÄÇôËü¾ÍÂÔ¹ýÕâЩѡÏ¶øÊÇÖ±½Ó¶ÁÈ¡ `master.info` ÎļþÖеÄÖµ¡£


Èç¹ûÖØÆôsalveʱʹÓõÄÑ¡ÏîÖµºÍ `master.info` ÖеIJ»Ò»Ñù£¬ÄÇôÕâ¸öеÄÖµ²»»áÉúЧ£¬ÒòΪslave·þÎñÆ÷»¹ÊÇÕÕÑùÖ»¶ÁÈ¡ `master.info` Îļþ¡£ÏëҪʹÓò»Í¬µÄÑ¡ÏîÖµ£¬¿ÉÒÔÔÚɾ³ý `master.info` ºóÖØÆôslave»òÕßʹÓà CHANGE MASTER TO Óï¾ä(ÍƼö)ÖØÖÃÑ¡ÏîÖµ¡£


¼Ù¶¨ÔÚ `my.cnf` É趨ÁËÒÔÏÂÑ¡ÏîÖµ£º


[mysqld]

master-host=some_host


µÚÒ»´ÎÆô¶¯slaveµÄʱºò£¬Ëü´Ó `my.cnf` ÖжÁÈ¡Ñ¡ÏîÖµ£¬È»ºóÔÙ°ÑËüÃDZ£´æÔÚ `master.info` ÖС£Ï´ÎÖØÆôslaveʱ£¬Ëü¾ÍÖ»¶ÁÈ¡ `master.info` µÄÄÚÈݶøÂÔ¹ý `my.cnf` ÖеÄÑ¡ÏîÖµÁË¡£ÆóͼÐÞ¸Ä `my.cnf` À´¸Ä±äͬ²½Ñ¡ÏîÊDz»¿ÉÐеģ¬²»¹ý¿ÉÒÔͨ¹ýÖ´ÐÐ CHANGE MASTER TO Óï¾äÀ´ÊµÏÖ£º


ÓÉÓÚ·þÎñÆ÷ÈÏΪ `master.info` µÄÓÅÏȼ¶±ÈÅäÖÃÎļþ¸ß£¬Òò´Ë½¨Òé¸ù±¾²»ÒªÔÚÆô¶¯Ê±¸½¼Óͬ²½Ñ¡Ï¶øÖ»Óà CHANGE MASTER TO Óï¾ä¡£ÏêÇéÇë¿´"14.6.2.1 CHANGE MASTER TO Syntax"¡£


ÏÂÀýÏÔʾÁËһЩÅäÖÃslaveµÄÀ©Õ¹Ñ¡Ï


[mysqld]

server-id=2

master-host=db-master.mycompany.com

master-port=3306

master-user=pertinax

master-password=freitag

master-connect-retry=60

report-host=db-slave.mycompany.com

ÏÂÁÐËùÊöÆô¶¯Ñ¡ÏÊÇÓÃÀ´¿ØÖÆͬ²½µÄ£ºËüÃÇÖеĴ󲿷ֶ¼¿ÉÒÔÔÚÔËÐÐʱÓà CHANGE MASTER TO Óï¾äÀ´¸Ä±ä¡£ÆäËûµÄ£¬ÀýÈç --replicate-*£¬Ö»ÄÜÔÚsalveÆô¶¯Ê±Ö¸¶¨¡£ÎÒÃÇ´òËãÔÚ½«À´½â¾öÕâ¸öÎÊÌâ¡£


--log-slave-updates


ͨ³££¬slave´Ómaster½ÓÊÕ¸üвÙ×÷ºó²¢Ã»ÓÐÔÙ°ÑËüÃǼǼÔÚ¶þ½øÖÆÈÕÖ¾ÖС£Õâ¸öÑ¡Ïî¸æËßslaveµÄSQLÏß³ÌÒª°ÑÕâЩ¸üвÙ×÷¼Ç¼ÔÚ¶þ½øÖÆÈÕÖ¾ÖС£ÏëÒªÕâ¸öÑ¡ÏîÆð×÷Óã¬ÐèҪͬʱÆôÓà --log-bin Ñ¡Ïî²ÅÄÜÆôÓöþ½øÖÆÈÕÖ¾¡£ÔÚʹÓÃͬ²½Á´»úÖÆʱ£¬¾ÍÐèҪʹÓà --log-slave-updates Ñ¡Ïî¡£ÀýÈ磬¿ÉÄÜÐèÒªÉèÖÃÈçÏÂͬ²½¹Øϵ£º


A -> B -> C

ÔÚÕâÀAµ±×÷BµÄmaster£¬Bµ±×÷CµÄmaster¡£BͬʱÊÇslaveÓÖÊÇmaster£¬ÔÚAºÍBÉ϶¼ÐèÒªÆôÓà --log-bin Ñ¡Ï²¢ÇÒÔÚBÉÏ»¹ÐèÒªÆôÓà --log-slave-updates Ñ¡Ïî¡£


--log-warnings


ÈÃslaveÔÚÖ´ÐÐͬ²½Ê±¼Ç¼¸ü¶àµÄ´íÎóÈÕÖ¾¡£ÀýÈ磬Ëü»á֪ͨÄãÔÚÍøÂç/Á¬½Óʧ°ÜºóÖØÁ¬³É¹¦£¬²¢ÇÒ֪ͨÁËÿ¸öslaveÏß³ÌÈçºÎÆô¶¯µÄ¡£Õâ¸öÑ¡ÏîÔÚMySQL 4.0.19ºÍ4.1.12Ö®ºóĬÈÏÆôÓÃÁË£»Óà --skip-log-warnings ¾Í¿ÉÒÔ½ûÓÃËü¡£´ÓMySQL 4.0.21ºÍMySQL 4.1.3¿ªÊ¼£¬³ý·ÇÕâ¸öÑ¡ÏîµÄÖµ´óÓÚ1£¬·ñÔò·ÅÆúµÄÁ¬½Ó²»ÔټǼÔÚ´íÎóÈÕÖ¾ÖС£Õâ¸öÑ¡Ïî²»Ö»ÊÇÓÃÓÚÏÞÖÆͬ²½£¬Ëü²úÉúµÄ¾¯¸æ¿çÔ½Á˴󲿷ֲÙ×÷¡£


--master-connect-retry=seconds


ÔÚmasterµ±»ú»òÕßÍøÂçÁ¬½ÓÖжϺó£¬slaveÔÚÖØÐÂÁ¬½Óµ½master֮ǰÐÝÃßµÄÃëÊý¡£Èç¹ûÔÚ `master.info` ÎļþÖдæÔÚ£¬¾ÍÓÅÏÈʹÓÃËü¡£Èç¹ûûÓÐÉèÖã¬Ä¬ÈÏÊÇ60¡£


--master-host=host


master·þÎñÆ÷µÄÖ÷»úÃû»òÕßipµØÖ·¡£Èç¹ûûÓÐÉèÖÃËü£¬slaveÏß³ÌÎÞ·¨Æô¶¯¡£Èç¹û´æÔڵĻ°£¬`master.info` ÎļþÖÐÑ¡ÏîÖµÓÅÏȱ»¶ÁÈ¡¡£


--master-info-file=file_name


slave¼Ç¼masterÐÅÏ¢µÄÎļþÃû¡£Ä¬ÈÏÃû×ÖÊÇ `master.info`£¬·ÅÔÚÊý¾ÝÎļþĿ¼Ï¡£


--master-password=password


ÓÃÓÚ±»ÊÚȨÁ¬½Óµ½masterÉÏÔËÐÐͬ²½µÄÕÊ»§ÃÜÂë¡£Èç¹û´æÔڵĻ°£¬`master.info` ÎļþÖÐÑ¡ÏîÖµÓÅÏȱ»¶ÁÈ¡¡£Èç¹ûûÓÐÉèÖ㬾͵±×÷ÊÇ¿ÕÃÜÂë¡£


--master-port=port_number


masterÉϼàÌýµÄTCP/IP¶Ë¿ÚºÅ¡£Èç¹û´æÔڵĻ°£¬`master.info` ÎļþÖÐÑ¡ÏîÖµÓÅÏȱ»¶ÁÈ¡¡£Èç¹ûûÓÐÉèÖ㬾͵±×÷Ô¤±àÒëµÄÉèÖá£Èç¹ûûÓÐÐÞ¸Ä configure Ñ¡Ïî²ÎÊý£¬ÄÇô¾ÍÊÇ3306¡£


--master-ssl,--master-ssl-ca=file_name,--master-ssl-capath=directory_name,

--master-ssl-cert=file_name,--master-ssl-cipher=cipher_list,--master-ssl-key=file_name


ÓÃÓÚÉ趨ÓÃSSL°²È«Á¬½Óµ½masterµÄÑ¡Ïî¡£ËüÃǵÄÒâÒå¶ÔÓ¦ÓÚ"5.6.7.5 SSL Command-Line Options"ÖÐÌáµ½µÄ --ssl, --ssl-ca, --ssl-capath, --ssl-cert, --ssl-cipher, --ssl-key Ñ¡Ïî¡£Èç¹û´æÔڵĻ°£¬`master.info` ÎļþÖÐÑ¡ÏîÖµÓÅÏȱ»¶ÁÈ¡¡£ÕâЩѡÏîÊÇ´ÓMySQL 4.1.1Ö®ºó¿ªÊ¼¿ÉÒÔÓõġ£


--master-user=username


ÓÃÓÚ±»ÊÚȨÁ¬½Óµ½masterÉÏÔËÐÐͬ²½µÄÕÊ»§¡£Õâ¸öÕÊ»§±ØÐëÓÐ REPLICATION SLAVE ȨÏÞ(ÔÚMySQL 4.0.2ÒÔÇ°£¬ÔòÊÇ FILE ȨÏÞ)¡£Èç¹û´æÔڵĻ°£¬`master.info` ÎļþÖÐÑ¡ÏîÖµÓÅÏȱ»¶ÁÈ¡¡£Èç¹ûûÓÐÉèÖ㬾͵±×÷ÊÇ test¡£


--max-relay-log-size=#


ÖмÌÈÕÖ¾×Ô¶¯ÂÖת(rotate)µÄ´óС¡£ÏêÇéÇë¿´"5.2.3 Server System Variables"¡£Õâ¸öÑ¡ÏîÊÇ´ÓMySQL 4.0.14Ö®ºó²Å¿ÉÒÔÓõġ£


--read-only


Õâ¸öÑ¡ÏîÁîslave³ýÁËslaveÏ̻߳òÕßÓµÓÐ SUPER ȨÏÞÓû§Ö®ÍâµÄ¶¼²»ÄܸüÐÂÊý¾Ý¡£ÕâÄÜÈ·±£slave²»»á½ÓÊÜÀ´×ÔÆäËû¿Í»§¶ËµÄ¸üС£Õâ¸öÑ¡ÏîÊÇ´ÓMySQL 4.0.14¿ªÊ¼Óеġ£


--relay-log=file_name


ÖмÌÈÕÖ¾µÄÃû×Ö¡£Ä¬ÈÏÃû×ÖÊÇ host_name-relay-bin.nnn£¬host_name ÊÇslave·þÎñÆ÷µÄÖ÷»úÃû£¬nnn ÊÇÖ¸ÖмÌÈÕÖ¾µÄ˳ÐòºÅ¡£¿ÉÒÔÓÃÕâ¸öÑ¡Ïî´´½¨²»ÒÀÀµÖ÷»úÃûµÄÖмÌÈÕÖ¾£¬»òÕßÔÚÖмÌÈÕÖ¾Ô½À´Ô½´ó(²»Ïë½µµÍ max_relay_log_size µÄÖµ)ÇÒÐèÒª½«ËüÃÇ·ÅÔÚ·ÇÊý¾ÝÎļþĿ¼Ï£¬»òÕßÏëʹÓôÅÅ̼äµÄ¸ºÔؾùºâÀ´Ìá¸ßËٶȵÈÇé¿ö¡£


--relay-log-index=file_name


ÖмÌÈÕÖ¾Ë÷ÒýÎļþµÄλÖü°ÎļþÃû¡£ËüµÄĬÈÏÖµÊÇ host_name-relay-bin.index£¬host_name ÊÇslave·þÎñÆ÷Ö÷»úÃû¡£


--relay-log-info-file=file_name


slaveÉϼǼÖмÌÈÕÖ¾ÐÅÏ¢µÄÎļþÃû¡£Ä¬ÈÏÊÇÊý¾ÝÎļþĿ¼ÏµÄ`relay-log.info`¡£


--relay-log-purge={0|1}


ÔÚ²»ÐèÒªÖмÌÈÕ־ʱ½ûÓûòÆôÓÃ×Ô¶¯Çå³ý¡£Ä¬ÈÏÖµÊÇ1(ÆôÓÃ)¡£ÕâÊÇÒ»¸öÈ«¾Ö±äÁ¿£¬¿ÉÒÔÓà SET GLOBAL relay_log_purge À´¶¯Ì¬¸ü¸Ä¡£Õâ¸öÑ¡Ïî´ÓMySQL 4.1.1¿ªÊ¼¿ÉÒÔÓá£


--relay-log-space-limit=#


ÓÃÓÚ¼Ó´óslaveÉÏÖмÌÈÕÖ¾µÄ×Ü´óС(Èç¹ûֵΪ0±íʾ"ÎÞÏÞ")¡£ÕâÔÚslaveÖ÷»úÖ»ÓÐÓÐÏ޵ĿռäʱºÜÓÐÓᣵ±´ïµ½Õâ¸öÏÞÖƺó£¬I/OÏß³ÌÖ±µ½SQLÏß³Ìɾ³ýһЩÎÞÓõÄÖмÌÈÕÖ¾ºó²Å»á¼ÌÐø´Ómaster¶ÁÈ¡¶þ½øÖÆÈÕ־ʼþ¡£×¢Ò⣬Õâ¸öÏÞÖƲ»ÊǾø¶ÔµÄ£ºÔÚɾ³ýÖмÌÈÕ־֮ǰ£¬SQLÏ߳̿ÉÄÜ»¹ÐèÒª¸ü¶àµÄ¶þ½øÖÆÈÕ־ʼþ¡£ÕâÖÖÇé¿öÏ£¬I/OÏ̻߳ᳬԽÕâ¸öÏÞÖÆ£¬Ö±µ½SQLÏß³Ìɾ³ýһЩÖмÌÈÕÖ¾£¬ÒòΪÈç¹û²»Õâô×öµÄ»°¾Í»áµ¼ÖÂËÀËø(ÔÚMySQL 4.0.13֮ǰ¾ÍÊÇÕâÑù)¡£²»ÒªÉèÖà --relay-log-space-limit µÄֵСÓÚ2±¶ --max-relay-log-size (Èç¹û --max-relay-log-size µÄֵΪ0£¬ÔòÊÇ --max-binlog-size ) µÄÖµ¡£ÔÚÕâÖÖÇé¿öÏ£¬ÓÉÓÚÒѾ­³¬¹ý --relay-log-space-limit ÁË£¬I/OÏß³ÌÐèÒªµÈ´ý¸ü¶àµÄÊ£Óà¿Õ¼ä£¬µ«ÊÇSQLÏß³ÌûÓпÉÒÔɾ³ýµÄÖмÌÈÕÖ¾À´Âú×ãI/OÏ̵߳ÄÐèÇó¡£Õâ¾Í»áÇ¿ÖÆI/OÏß³ÌÔÝʱºöÂÔ --relay-log-space-limit ÏÞÖÆ¡£


--replicate-do-db=db_name


¸æËßslaveֻͬ²½ÄÇЩȱʡÊý¾Ý¿âÊÇ db_name (Ò²¾ÍÊÇÓà USE Ñ¡ÖеÄ)µÄÓï¾ä¡£ÏëÒªÖ¸¶¨¸ü¶àµÄÊý¾Ý¿â£¬Ö»Ðè¶à´ÎʹÓøÃÑ¡Ïÿ´ÎÖ¸¶¨Ò»¸öÊý¾Ý¿â¡£×¢Ò⣬ÀàËÆ UPDATE some_db.some_table SET foo='bar' ÕâÑùµÄ¿ç¿â²Ù×÷Óï¾äÒÔ¼°Ã»ÓÐÑ¡ÖÐÊý¾Ý¿âµÄ²Ù×÷¶¼²»»á±»Í¬²½¡£Èç¹û±ØÐëʹÓÿç¿â²Ù×÷£¬ÒªÈ·±£Ê¹ÓÃMySQL 3.23.28»ò¸ü¸ß£¬²¢ÇÒʹÓà --replicate-wild-do-table=db_name.% Ñ¡Ïî¡£Çë×ÐϸÔĶÁ×îºóÃæµÄ×¢ÒâÊÂÏî¡£


ÏÂÃæÊÇÒ»¸ö²»ÄÜ°´ÕÕÔ¤ÆÚ¹¤×÷µÄÀý×Ó£ºÈç¹ûÆô¶¯slaveʱʹÓà --replicate-do-db=sales Ñ¡Ï²¢ÇÒÔÚmasterÉÏÖ´ÐÐÏÂÁÐÓï¾ä£¬ÄÇôÕâ¸ö UPDATE Óï¾ä²»»á±»Í¬²½£º


USE prices;

UPDATE sales.january SET amount=amount+1000;

Èç¹ûÐèҪͬ²½¿ç¿â²Ù×÷£¬Ö»ÐèʹÓà --replicate-wild-do-table=db_name.% Ñ¡Ïî¡£Õâ¸ö"Ö»¼ì²éȱʡÊý¾Ý¿â"ÌØÐÔµÄÖ÷ÒªÔ­ÒòÊÇÒòΪÏëÒªµ¥´ÓÒ»¸öÓï¾äÖÐÅжÏÊÇ·ñÒª±»Í¬²½±È½ÏÀ§ÄÑ(ÀýÈ磬ʹÓöà±í DELETE »òÕß UPDATE£¬Õâ¾Í¿ç¿âÁË)¡£²»¹ýÏëÒª¼ì²éÊÇ·ñÊÇȱʡÊý¾Ý¿âÈ´ºÜ¿ì¡£


--replicate-do-table=db_name.tbl_name


¸æËßslaveֻͬ²½ÄÇЩָ¶¨µÄÊý¾Ý±í¡£ÏëÒªÖ¸¶¨¸ü¶àµÄÊý¾Ý±í£¬Ö»Ðè¶à´ÎʹÓøÃÑ¡Ïÿ´ÎÖ¸¶¨Ò»¸öÊý¾Ý±í¡£Õâ¸öÑ¡ÏîÖ§³Ö¿ç¿â¸üУ¬ºÍ --replicate-do-db Ñ¡ÏîÏà·´¡£Çë×ÐϸÔĶÁ×îºóÃæµÄ×¢ÒâÊÂÏî¡£


--replicate-ignore-db=db_name


¸æËßslave²»ÒªÍ¬²½ÄÇЩȱʡÊý¾Ý¿âÊÇ db_name (Ò²¾ÍÊÇÓà USE Ñ¡ÖеÄ)µÄÓï¾ä¡£ÏëÒªÖ¸¶¨¸ü¶àµÄÊý¾Ý¿â£¬Ö»Ðè¶à´ÎʹÓøÃÑ¡Ïÿ´ÎÖ¸¶¨Ò»¸öÊý¾Ý¿â¡£Èç¹ûÓпç¿â²Ù×÷ÇÒÏ£ÍûÕâЩ²Ù×÷Òª±»Í¬²½¾Í²»ÒªÊ¹ÓøÃÑ¡Ïî¡£Çë×ÐϸÔĶÁ×îºóÃæµÄ×¢ÒâÊÂÏî¡£


ÏÂÃæÊÇÒ»¸ö²»ÄÜ°´ÕÕÔ¤ÆÚ¹¤×÷µÄÀý×Ó£ºÈç¹ûÆô¶¯slaveʱʹÓà --replicate-ignore-db=sales Ñ¡Ï²¢ÇÒÔÚmasterÉÏÖ´ÐÐÏÂÁÐÓï¾ä£¬ÄÇôÕâ¸ö UPDATE Óï¾ä²»»á±»Í¬²½£º


USE prices;

UPDATE sales.january SET amount=amount+1000;

ÏëÒªÈÿç¿â²Ù×÷ÄÜÕý³£Í¬²½£¬Ö»ÐèʹÓà --replicate-wild-ignore-table=db_name.% Ñ¡Ïî¡£


--replicate-ignore-table=db_name.tbl_name


¸æËßslave²»ÒªÍ¬²½Ö¸¶¨Êý¾Ý±íµÄÈκθüÐÂÓï¾ä(ÉõÖÁÓÃͬһ¸öÓï¾ä¸üеÄÆäËû±í)¡£ÏëÒªÖ¸¶¨¸ü¶àµÄÊý¾Ý±í£¬Ö»Ðè¶à´ÎʹÓøÃÑ¡Ïÿ´ÎÖ¸¶¨Ò»¸öÊý¾Ý±í¡£Õâ¸öÑ¡ÏîÖ§³Ö¿ç¿â¸üУ¬ºÍ --replicate-ignore-db Ñ¡ÏîÏà·´¡£Çë×ÐϸÔĶÁ×îºóÃæµÄ×¢ÒâÊÂÏî¡£


--replicate-wild-do-table=db_name.tbl_name


ÏÞÖÆslaveֻͬ²½ÄÇЩƥÅäÖ¸¶¨Ä£Ê½µÄÊý¾Ý±í¡£Ä£Ê½ÖпÉÒÔ°üº¬Í¨Åä·û `%` ºÍ `_`£¬ËüÃǵĺ¬ÒåºÍ LIKE ģʽһÑù¡£ÏëÒªÖ¸¶¨¸ü¶àµÄÊý¾Ý±í£¬Ö»Ðè¶à´ÎʹÓøÃÑ¡Ïÿ´ÎÖ¸¶¨Ò»¸öÊý¾Ý±í¡£Çë×ÐϸÔĶÁ×îºóÃæµÄ×¢ÒâÊÂÏî¡£


ÀýÈ磺 --replicate-wild-do-table=foo%.bar% »áͬ²½ËùÓÐÒÔ foo ¿ªÍ·µÄÊý¾Ý¿âϵÄÒÔ bar ¿ªÍ·µÄÊý¾Ý±íÉϵĸüвÙ×÷¡£


Èç¹ûÆ¥ÅäģʽÊÇ %£¬ÔòÆ¥ÅäËùÓеıíÃû£¬ÇÒÓ¦Óõ½Êý¾Ý¿â¼¶Óï¾ä(CREATE DATABASE, DROP DATABASE,ºÍ ALTER DATABASE)¡£ÀýÈ磬ʹÓà --replicate-wild-do-table=foo%.% Ñ¡ÏîµÄ»°£¬ËùÓÐÆ¥Åä foo% ģʽµÄÊý¾Ý¿â¼¶²Ù×÷¶¼»á±»Í¬²½¡£


Èç¹ûÏëÒªÔÚÊý¾Ý¿â/±íģʽÖаüº¬Ô­ÒåͨÅä·û£¬ÐèÒªÓ÷´Ð±¸ÜÀ´×ªÒåËüÃÇ¡£ÀýÈ磬ÏëҪͬ²½ my_own%db Êý¾Ý¿âϵÄËùÓÐ±í£¬µ«ÊDz»Ïëͬ²½ my1ownAABCdb Êý¾Ý¿âÏÂµÄ±í£¬¾ÍÐèҪתÒå×Ö·û `_`£º --replicate-wild-do-table=my\_own\%db¡£Èç¹ûÊÇÔÚÃüÁîÐÐÖÐʹÓÃÕâ¸öÑ¡Ï¾Í¿ÉÄÜÐèÒªÁ½¸ö·´Ð±¸ÜÀ´×ªÒ壬ÕâÒÀÀµÓÚÃüÁîÐнâÊÍÆ÷¡£ÀýÈ磬ÔÚ bash shellÏ£¬¾ÍÐèÒªÊäÈ룺 --replicate-wild-do-table=my\\_own\\%db¡£


--replicate-wild-ignore-table=db_name.tbl_name

ÏÞÖÆslave²»Í¬²½ÄÇЩƥÅäÖ¸¶¨Ä£Ê½µÄÊý¾Ý±í¡£ÏëÒªÖ¸¶¨¸ü¶àµÄÊý¾Ý±í£¬Ö»Ðè¶à´ÎʹÓøÃÑ¡Ïÿ´ÎÖ¸¶¨Ò»¸öÊý¾Ý±í¡£Çë×ÐϸÔĶÁ×îºóÃæµÄ×¢ÒâÊÂÏî¡£

ÀýÈ磬--replicate-wild-ignore-table=foo%.bar% ¾Í²»»áͬ²½ËùÓÐÒÔ foo ¿ªÍ·µÄÊý¾Ý¿âϵÄÒÔ bar ¿ªÍ·µÄÊý¾Ý±íÉϵĸüвÙ×÷¡£

ÏëÒªÁ˽âÆ¥ÅäģʽÈçºÎ¹¤×÷µÄ£¬Çë²é¿´ --replicate-wild-ignore-table Ñ¡ÏîµÄ¾ßÌåÃèÊö¡£Ä£Ê½Öаüº¬Ô­ÒåͨÅä·ûµÄ¹æÔòºÍ --replicate-wild-ignore-table Ñ¡ÏîÒ»Ñù¡£


--replicate-rewrite-db=from_name->to_name


¸æËßslave°ÑÔÚmasterÉϵÄȱʡÊý¾Ý¿â from_name (Ö»ÓÐÓà USE Ñ¡ÖеÄ)ת»»³É to_name ¡£Ö»ÓÐÉæ¼°µ½Êý¾Ý±íµÄÓï¾ä(²»°üÀ¨ÀàËÆ CREATE DATABASE, DROP DATABASE,ºÍ ALTER DATABASE)²Å»á±»Í¬²½£¬²¢ÇÒÖ»Õë¶ÔmasterÉÏȱʡÊý¾Ý¿âΪ from_name µÄÇé¿ö¡£Õâ¸öÑ¡Ïî²»Ö§³Ö¿ç¿â²Ù×÷¡£×¢Ò⣬Êý¾Ý¿âÃû×Öת»»ÏÈÓÚ --replicate-* ¹æÔò֮ǰ²âÊÔ¡£Èç¹ûÊÇÔÚÃüÁîÐÐÖÐʹÓÃÕâ¸öÑ¡ÏÐèÒª°Ñ `>' ×Ö·ûÓÃÒýºÅÒýÓÃÆðÀ´¡£ÀýÈ磺


shell> mysqld --replicate-rewrite-db="olddb->newdb"


--replicate-same-server-id


¸ÃÑ¡ÏîÓÃÓÚslaveÖ®ÉÏ¡£Í¨³£Ê¹ÓÃËüµÄĬÈÏÖµ0£¬ÓÃÓÚ±ÜÃâÎÞÏÞͬ²½Ñ­»·¡£Èç¹ûÉèÖÃΪ1£¬ÄÇôslave¾Í²»»áºöÂÔÄÇЩ¸úËüÓÐͬÑù·þÎñÆ÷±àºÅµÄ¸üÐÂÈÕÖ¾ÁË£»Í¨³£ËüÖ»ÓÃÓڱȽϺ±¼ûµÄÅäÖÃÖС£Èç¹ûÆôÓà --log-slave-updates Ñ¡ÏÔò²»ÄÜÉèÖÃΪ1¡£×¢Ò⣬´ÓMySQL 4.1¿ªÊ¼£¬slaveµÄI/OÏß³ÌĬÈϲ»°Ñ°üº¬slaveµÄ·þÎñÆ÷±àºÅµÄ¶þ½øÖÆÈÕ־дµ½ÖмÌÈÕÖ¾ÖÐ(Ïà¶Ô4.0ÕâÄܽÚÊ¡´ÅÅÌʹÓÃ)¡£Òò´ËÏëÒªÔÚ4.1ÖÐʹÓà --replicate-same-server-id Ñ¡ÏÔÚslave¶ÁÈ¡×Ô¼ºµÄ¸üÐÂʼþÈÃSQLÏß³ÌÀ´Ö´ÐÐ֮ǰҪȷ±£Æô¶¯slaveʱʹÓøÃÑ¡Ïî¡£


--report-host=host


ÔÚsalve×¢²áʱҪ±¨¸æµÄmasterÖ÷»úÃû»òIPµØÖ·¡£ÔÚmasterÉÏÖ´ÐÐ SHOW SLAVE HOSTS Óï¾äʱ¾Í»áÏÔʾ³öÀ´ÁË¡£Èç¹û²»Ïëslave×¢²áµ½master¾ÍÎÞÐèÉèÖÃÕâ¸öÑ¡Ïî¡£×¢Ò⣬ÕâÔÚslaveÁ¬½Óµ½masterÖ®ºó£¬Ö»¸ù¾ÝÕâ¸öÅäÖÃmaster»¹²»ÄÜÖ±½Ó´ÓTCP/IPÌ×½Ó×ÖÖжÁÈ¡slaveµÄIPµØÖ·¡£ÒòΪ´æÔÚ NAT »òÕßÆäËû·ÓÉ»úÖÆ£¬Õâ¸öIPÐÅÏ¢»¹²»×ãÒÔÔÚmaster»òÕßÆäËûÖ÷»úÉÏÁ¬½Óµ½slaveÉÏ¡£Õâ¸öÑ¡ÏîÊÇ´ÓMySQL 4.0.0¿ªÊ¼¿ÉÒÔÓõġ£


--report-port=port_number


Á¬½Óµ½slaveµÄTCP/IP¶Ë¿Ú£¬ÔÚslave×¢²áµ½masterʱÓõĵ½¡£³ý·ÇslaveÔÚ·ÇĬÈ϶˿ÚÉϼàÌý»òÕß´Ómaster»òÆäËû¿Í»§¶ËÉϵ½Á¬½Óµ½slaveʹÓõÄÊÇÌض¨µÄËíµÀ£¬·ñÔòÎÞÐèÉèÖÃÕâ¸öÖµ¡£Èç¹û²»È·¶¨£¬¾Í²»ÒªÉèÖÃËü¡£Õâ¸öÑ¡ÏîÊÇ´ÓMySQL 4.0.0¿ªÊ¼¿ÉÒÔÓõġ£


--skip-slave-start


¸æËßslave·þÎñÆ÷ÔÚÆô¶¯Ê±²»ÒªÔËÐÐslaveÏ̡߳£Ö»ÐèʹÓà START SLAVE Óï¾äÀ´Æô¶¯slaveÏ̡߳£


--slave_compressed_protocol={0|1}


Èç¹ûËüÉèÖÃΪ1£¬²¢ÇÒmaste/slave¶¼Ö§³ÖµÄ»°£¬¾Í²ÉÓÃѹËõЭÒé´«ÊäÊý¾Ý¡£


--slave-load-tmpdir=file_name


slave´´½¨ÁÙʱÎļþµÄĿ¼¡£Õâ¸öÑ¡ÏîֵĬÈϵغÍϵͳ±äÁ¿ tmpdir µÄÖµÒ»Ñù¡£slaveµÄSQLÏß³Ìͬ²½ LOAD DATA INFILE Óï¾äʱ£¬Ëü´ÓÖмÌÈÕÖ¾ÖÐÌáÈ¡³öÒª±»¼ÓÔصÄÎļþ·Åµ½ÁÙʱÎļþÖУ¬È»ºó°ÑËüÃǼÓÔص½slaveÖС£Èç¹ûÔÚmasterÉϼÓÔصÄÎļþºÜ´ó£¬ÄÇôslaveÉϵÄÁÙʱÎļþÒ²»áºÜ´ó¡£Òò´Ë½¨ÒéÔÚslaveÉÏÖ¸¶¨Õâ¸öÑ¡Ïîʱ°ÑËü·ÅÔÚÊ£Óà¿Õ¼ä±È½Ï¶àµÄÎļþϵͳÉÏ¡£ÕâÊÇ£¬×îºÃÒ²Ö¸¶¨ --relay-log µ½ÄǸöÎļþϵͳÖУ¬ÒòΪÖмÌÈÕÖ¾¿ÉÄÜÒ²»áºÜ´ó¡£--slave-load-tmpdir ±ØÐëÖ¸Ïò»ùÓÚ´ÅÅ̵ÄÎļþϵͳ£¬¶ø²»ÄÜÊÇ»ùÓÚÄÚ´æµÄÎļþϵͳ£ºslave¿ÉÄÜ»áÔÚ»úÆ÷ÖØÆôºóͬ²½ LOAD DATA INFILE Óï¾äʱÐèÒªÓõ½Õâ¸öÁÙʱÎļþ¡£Õâ¸öĿ¼ͬÑù²»ÄÜÔڻᱻ²Ù×÷ϵͳµÄÆô¶¯½ø³ÌÇå³ýµÄĿ¼Ï¡£


--slave-net-timeout=seconds


salve·ÅÆú¶ÁÖ®ºóµÈ´ý¶àÉÙÃëÔٴδÓmaster¶ÁÈ¡¸ü¶àµÄÊý¾Ý£¬¿¼Âǵ½ÁËÁ¬½Ó¶Ï¿ª£¬³¢ÊÔÖØÁ¬µÄÇé¿ö¡£µÚÒ»´ÎÖØÊÔ»áÔÚ³¬Ê±ºóÁ¢¿ÌÖ´ÐС£ÖØÊÔµÄʱ¼ä¼ä¸ôÓÉÑ¡Ïî --master-connect-retry ¿ØÖÆ¡£


--slave-skip-errors= [err_code1,err_code2,... | all]


ͨ³££¬·¢Éú´íÎóʱͬ²½¾Í»áÍ£Ö¹£¬ÒÔÌṩÊÖ¹¤½â¾öÊý¾Ý²»Ò»ÖµÄÇé¿ö¡£Õâ¸öÑ¡Ïî¸æËßslaveµÄSQLÏ̵߳±Ö´ÐÐÓï¾äʱ·µ»ØµÄ´íÎó´úÂëÔÚ¸ÃÁбíÖÐʱ¼ÌÐøÔËÐС£


³ý·ÇÕæÕýµÄÀí½âÁËΪʲô»á²úÉúÏàÓ¦µÄ´íÎóºó£¬·ñÔò²»ÒªÉèÖÃÕâ¸öÑ¡Ïî¡£Èç¹ûͬ²½ÉèÖÃÒÔ¼°¿Í»§¶Ë³ÌÐò¶¼Ã»ÓÐbug£¬²¢ÇÒÒ²²»ÊÇMySQL×ÔÉíµÄbugµÄ»°£¬ÄÇô¾Í²»»á³öÏÖÈÃͬ²½Í£Ö¹µÄ´íÎóÁË¡£²»¼ÓÇø·ÖµØʹÓÃÕâ¸öÑ¡Ï»áµ¼ÖÂslaveÎ޿ɾÈÒ©µØ±³ÀëmasterµÄͬ²½£¬²¢ÇÒÄãÒ²²»ÖªµÀÕâÊÇΪʲô¡£


¿ÉÒÔÔÚ´ÓslaveµÄ´íÎóÈÕÖ¾²¢ÇÒÔÚslaveÉÏÖ´ÐÐ SHOW SLAVE STATUS Óï¾äµÄ½á¹ûÖоÍÄÜ¿´µ½´íÎó´úÂëÁË¡£·þÎñÆ÷´íÎó´úÂëÏêÇéÇë¿´"22 Error Handling in MySQL"¡£


ÄãÒ²¿ÉÒÔ(×îºÃ²»Òª)ʹÓ÷dz£²»ÍƼöʹÓõÄÖµ all£¬ËüÄܺöÂÔËùÓеĴíÎóÐÅÏ¢£¬²»¹ÜʲôÇé¿ö¶¼¼ÌÐø±£³Öͬ²½¡£²»Ïû˵£¬Èç¹ûʹÓÃÕâ¸öÑ¡ÏîÖµ£¬¾Í²»¿ÉÄÜÆÚ´ýÓÐÊý¾ÝµÄÍêÕûÐÔÁË¡£ÕâÖÖÇé¿öÏ£¬¾Í²»Äܱ§Ô¹slaveµÄÊý¾ÝÎÞÂÛÔÚÄĸöµØ·½¶¼ºÍmaster²»½Ó½üÁË¡£ÒѾ­¾¯¸æ¹ýÄãÁË¡£ÀýÈ磺


--slave-skip-errors=1062,1053

--slave-skip-errors=all

--replicate-* ģʽ¸ù¾ÝÒÔϹæÔòÀ´¾ö¶¨Ò»¸öÓï¾äÊÇÒªÖ´Ðл¹ÊDZ»ºöÂÔ£º


ÊÇ·ñÓÐ --replicate-do-db »ò --replicate-ignore-db ¹æÔò?


ÊÇ£º²âÊÔ --binlog-do-db ºÍ --binlog-ignore-db Ñ¡Ïî(ÏêÇéÇë¿´"5.9.4 The Binary Log")¡£²âÊÔ½á¹û?


ºöÂÔ£ººöÂÔ²¢ÇÒÍ˳ö¡£


Ö´ÐУº²»Á¢¿ÌÖ´ÐУ¬ÍƳÙÅжϣ¬µ½ÏÂÒ»²½¡£


·ñ£ºµ½ÏÂÒ»²½¡£


ÊÇ·ñÓÐ --replicate-*-table ¹æÔò?


·ñ£ºÖ´Ðв¢ÇÒÍ˳ö¡£


ÊÇ£º×ßµ½ÏÂÒ»²½¡£Ö»ÓÐÒª±»¸üеıí²ÅºÍÕâ¸ö¹æÔò×÷±È½Ï(INSERT INTO sales SELECT * FROM prices:ÖÐÖ»ÓÐ sales ºÍ¹æÔò±È½Ï)¡£Èç¹ûÓкü¸¸ö±íÒ»Æ𱻸üÐÂ(¶à±íÓï¾ä)£¬µÚÒ»¸öÆ¥ÅäµÄ±í(Æ¥Åä `do` »ò `ignore`)ʤ³ö¡£Ò²¾ÍÊÇ˵£¬Ö»ÓеÚÒ»¸ö±íºÍ¹æÔò×÷±È½Ï¡£È»ºó£¬Èç¹û»¹Ã»ÓвúÉúÈκξö¶¨£¬¾Í±È½ÏµÚ¶þ¸ö±í£¬ÒÔ´ËÀàÍÆ¡£


ÊÇ·ñÓÐ --replicate-do-table ¹æÔò?


ÊÇ£ºÕâ¸ö±íÊÇ·ñÆ¥ÅäÕâЩ¹æÔò?


ÊÇ£ºÖ´Ðв¢ÇÒÍ˳ö¡£


·ñ£º×ßµ½ÏÂÒ»²½¡£


·ñ£º×ßµ½ÏÂÒ»²½¡£


ÊÇ·ñÓÐ --replicate-ignore-table ¹æÔò?


ÊÇ£ºÕâ¸ö±íÊÇ·ñÆ¥ÅäÕâЩ¹æÔò?


ÊÇ£ººöÂÔ²¢ÇÒÍ˳ö¡£


·ñ£º×ßµ½ÏÂÒ»²½¡£


·ñ£º×ßµ½ÏÂÒ»²½¡£


ÊÇ·ñÓÐ --replicate-wild-do-table ¹æÔò?


ÊÇ£ºÕâ¸ö±íÊÇ·ñÆ¥ÅäÕâЩ¹æÔò?


ÊÇ£ºÖ´Ðв¢ÇÒÍ˳ö¡£


·ñ£º×ßµ½ÏÂÒ»²½¡£


·ñ£º×ßµ½ÏÂÒ»²½¡£


ÊÇ·ñÓÐ --replicate-wild-ignore-table ¹æÔò?


ÊÇ£ºÕâ¸ö±íÊÇ·ñÆ¥ÅäÕâЩ¹æÔò?


ÊÇ£ººöÂÔ²¢ÇÒÍ˳ö¡£


·ñ£º×ßµ½ÏÂÒ»²½¡£


·ñ£º×ßµ½ÏÂÒ»²½¡£


ûÓÐÆ¥Åä --replicate-*-table ¹æÔò¡£ÊÇ·ñÓÐÆäËû±íÆ¥ÅäÕâЩ¹æÔò?


ÊÇ£ºÑ­»·²éÕÒÆ¥Åä¡£


·ñ£ºÒѾ­²âÊÔËùÓÐÒª±»¸üеıíÇÒÕÒ²»µ½ÈκÎÆ¥Åä¹æÔò¡£ÊÇ·ñÓÐ --replicate-do-table »ò --replicate-wild-do-table ¹æÔò?


ÊÇ£ººöÂÔ²¢ÇÒÍ˳ö¡£


·ñ£ºÖ´Ðв¢ÇÒÍ˳ö¡£
ÎÄÕÂÆÀÂÛ

¹²ÓÐ 0 ÌõÆÀÂÛ