Ê×ÏÈ£¬°²×°mysql£¬¾ßÌå²½Öè¾Í²»ËµÁË¡£
¼ÙÉèA·þÎñÆ÷Ϊ£¨192.168.10.101£©B·þÎñÆ÷Ϊ£¨192.168.10.102£©
ÔÚA·þÎñÆ÷ÉÏÐÞ¸Ä/etc/my.cnfÎļþ ÔÚmysqldÏÂÐÞ¸Ä
server-id = 1 ####ÕâÀïÊDZíʾΪÖ÷·þÎñÆ÷¼´master
ʵÏÖË«»ú±¸·Ý¶Î£¬¸øMASTERͬʱ¼ÓÉÏSLAVE¶Î,¿ÉÑ¡£¬Èç¹û²»Ñ¡£¬ÄǾÍÊǵ¥ÏîµÄÖ÷´Ó±¸·Ý¡£
master-host=192.168.10.102
master-user=backup #############̞
master-password=backup #############ÃÜÂë
master-port=3327
master-connect-retry=60
Ö®ºóµÇ½mysql
ʹÓÃÈçÏÂÃüÁîÀ´¿ªÆôMASTER£¨A£©-¡·slave£¨B£©Ö÷»úµÄÕʺÅ
Êý¾Ý¿âÖмÓÒ»¸öÕ˺Å:
GRANT FILE,REPLICATION SLAVE,REPLICATION CLIENT,SUPER ON *.*
TO backup@'192.168.10.102' IDENTIFIED by 'backup';
Õâ¸öȨÏÞ±íʾ£¬Õâ¸öbackupÕ˺ÅÖ»ÄÜÓÉ´Ó±¸·Ý»ú192.168.10.102·ÃÎÊÖ»ÄÜÓÃÀ´½øÐб¸·Ý²Ù×÷¡£
ÕâÑùAÉϵÄmysql¾ÍÅäÖúÃÁË¡£
B·þÎñÆ÷ÉϵÄÅäÖÃ
1.ÐÞ¸Ämy.cnf Îļþ
Ìí¼ÓÈçÏÂ×Ö¶Î
master-host=192.168.10.101
master-user=backup
master-password=backup
master-port=3327
master-connect-retry=60
¾Ý¿âÖмÓÒ»¸öÕ˺Å:
GRANT FILE,REPLICATION SLAVE,REPLICATION CLIENT,SUPER ON *.*
TO backup@'192.168.10.101' IDENTIFIED by 'backup';
ÕâÑùÎÒÃǵÄB·þÎñÆ÷¾ÍÅäÖúÃÁË£¡Ö®ºó´ÓÆômysql¡£
´ÓÆôºó²é¿´Êý¾Ý¿âÊÇ·ñͬ²½³É¹¦£»Ê¹ÓÃÈçÏÂÃüÁî¡£
ÓÃshow slave status\G;¿´Ò»Ï´ӷþÎñÆ÷µÄͬ²½Çé¿ö
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
Èç¹û¶¼ÊÇyes£¬ÄÇ´ú±íÒѾÔÚͬ²½
Èç¹û³öÏÖNOÕâÑùÎÒÃÇÐèҪʹÓÃÏÂÃæµÄ·½·¨È¥½â¾öÎÊÌâ¡£
ÔÚ´Ó·þÎñÆ÷ÉÏʹÓà MySQLÃüÁî·ûÏ£º
slave stop£»
CHANGE MASTER TO MASTER_LOG_FILE='ÄãµÄÖ÷·þÎñÆ÷µÄbin',MASTER_LOG_POS=ÄãµÄÖ÷·þÎñÆ÷µÄÈÕÖ¾;
slave start;
Ôõô²é¿´Ö÷·þÎñÆ÷µÄbin £»ºÍÈÕÖ¾ÄØ¡£Ê¹ÓÃÈçÏÂÃüÁî¡£
show master status;
ÏÔʾ£¨µ±È»Õâ¸öÊÇÎÒ»úÆ÷µÄÇé¿ö£¬ÄãµÄ²»¿ÉÄܸúÎÒÒ»Ñù¹þ£¬Ö»ÊǸöÀý×Ó£©£º
+------------------+----------+-------------------+------------------+
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB |
+------------------+----------+-------------------+------------------+
| mysql-bin.000025 | 313361 | test | mysql |
+------------------+----------+-------------------+------------------+