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

MYSQLÖ÷´Ó·þÎñÆ÷µÄÅäÖÃ

·¢²¼Ê±¼ä:2008-10-11 00:09:10À´Ô´:ºìÁª×÷Õß:juanbic
mysql·þÎñÆ÷µÄÖ÷´ÓÅäÖ㬱¾À´ÊÇÒ»¼þºÜ¼òµ¥µÄÊÂÇ飬ÎÞÄβ»ÊÇ´ÓÁ㿪ʼ£¬×ÜÊÇÔÚ±ðÈËÒѾ­°²×°ºÃµÄmysql·þÎñÆ÷Ö®ÉÏ £¬Õâ¾Í»áÇ£³¶µ½£¬mysqlµÄ°æ±¾£¬Æô¶¯Îļþ£¬µÈһЩÎÊÌâ¡£

²»¹ýû¹Øϵ£¬ÏÈÎÊÇå³þÁ½µã

1¡¢mysqlÅäÖÃÎļþmy.cnfµÄλÖÃ

2¡¢ÈçºÎÆô¶¯¡¢Í£Ö¹mysql£¬ÕÒºÃÆô¶¯Îļþ

¼ÙÉèÓÐÁ½Ì¨»úÆ÷£¬ÒѾ­°²×°ºÃÁËmysql£¨¾¡Á¿Í¬°æ±¾£¬ÇÒÁ½Ì¨»úÆ÷ͬһÍøÂ磬¿ÉÒÔpingͨ£©

ÓÐÅóÓÑ˵£º¡°´Ó·þÎñÆ÷£¬²»ÄܵÍÓÚÖ÷·þÎñÆ÷µÄ°æ±¾¡±£¬²»¹ýÎÒÊǵÍÓڵģ¬Ã»ÓгöÏÖÎÊÌâ¡£

Ö÷»úA: 192.168.1.100

´Ó»úB:192.168.1.101

¿ÉÒÔÓжą̀´Ó»ú

1¡¢ÏȵǼÖ÷»ú A

mysql>GRANT REPLICATION SLAVE ON *.* TO ¡®backup¡¯@¡¯192.168.1.101¡® IDENTIFIED BY ¡®123456¡¯;

¸³Óè´Ó»úȨÏÞ£¬Óжą̀´Ô»ú£¬¾ÍÖ´Ðжà´Î

2¡¢ ´ò¿ªÖ÷»úAµÄmy.cnf£¬ÊäÈë

server-id = 1 #Ö÷»ú±êʾ£¬ÕûÊý
log_bin = /var/log/mysql/mysql-bin.log #È·±£´ËÎļþ¿Éд
read-only =0 #Ö÷»ú£¬¶Áд¶¼¿ÉÒÔ
binlog-do-db =test #ÐèÒª±¸·ÝÊý¾Ý£¬¶à¸öд¶àÐÐ
binlog-ignore-db=mysql #²»ÐèÒª±¸·ÝµÄÊý¾Ý¿â£¬¶à¸öд¶àÐÐ

3¡¢´ò¿ª´Ó»úBµÄmy.cnf£¬ÊäÈë

server-id = 2
log_bin = /var/log/mysql/mysql-bin.log
master-host =192.168.1.100
master-user =backup
master-pass =123456
master-port =3306
master-connect-retry=60 #Èç¹û´Ó·þÎñÆ÷·¢ÏÖÖ÷·þÎñÆ÷¶Ïµô£¬ÖØÐÂÁ¬½ÓµÄʱ¼ä²î(Ãë)
replicate-do-db =test #Ö»¸´ÖÆij¸ö¿â
replicate-ignore-db=mysql #²»¸´ÖÆij¸ö¿â

4¡¢Í¬²½Êý¾Ý¿â

ÓжàÖÖ·½·¨£¬ÎÒ˵×µÄÒ»ÖÖ£¬ÏÈmysqldumpµ¼³öÖ÷»úAµÄÊý¾ÝtestΪ test.sql

È»ºóÔÚ£¬´Ó»úBÉϽ¨Á¢Êý¾Ý¿âtest£¬mysqlµ¼Èë test.sqlµ½test¿âÖÐ

5¡¢ÏÈÖØÆôÖ÷»úAµÄmysql£¬ÔÙÖØÆô´Ó»úBµÄmysql

6¡¢ÑéÖ¤

ÔÚÖ÷»úAÖУ¬mysql>show master status\G;

ÔÚ´Ó»úBÖУ¬mysql>show slave status\G;

ÄÜ¿´µ½´óÖÂÕâЩÄÚÈÝ

File: mysql-bin.000001
Position: 1374
Binlog_Do_DB: test
Binlog_Ignore_DB: mysql

¿ÉÒÔÔÚÖ÷»úAÖУ¬×öһЩINSERT, UPDATE, DELETE ²Ù×÷£¬¿´¿´Ö÷»úBÖУ¬ÊÇ·ñÒѾ­±»Ð޸ġ£
ÎÄÕÂÆÀÂÛ

¹²ÓÐ 10 ÌõÆÀÂÛ

  1. zhimamaigua ÓÚ 2013-11-04 17:14:49·¢±í:

    Ö§³Ö£¬Ö§³Ö

  2. 214679 ÓÚ 2013-10-20 21:59:15·¢±í:

    Ö§³Ö,Ö§³Ö!!

  3. brightlee ÓÚ 2013-10-18 14:47:53·¢±í:

    лл£¬¸Ð¾õºÜ²»´í£¬ÕýºÃÐèÒª

  4. daen ÓÚ 2011-06-28 14:32:29·¢±í:

    ºÃ°¡ ¡£

  5. ftd505 ÓÚ 2011-04-18 15:43:04·¢±í:

    {:2_99:}

  6. bob.wu ÓÚ 2010-04-27 17:59:30·¢±í:

    ºÇºÇ£¬»¹Õæû¸ã¹ý£¬¶¼ÊÇÈ˼ÒÅäÖÃÎÒ¿´....

  7. xczwhx ÓÚ 2009-11-01 19:59:19·¢±í:

    ûÉæ¼°¹ý£¬µ«»¹ÊÇÇ¿ÁÒµÄÖ§³ÖÏ£¬Ñ§Ï°Ï£¡£¡£¡

  8. baizx ÓÚ 2009-08-14 16:16:52·¢±í:

    5:ty(

  9. wangyoubang ÓÚ 2009-07-14 22:28:20·¢±í:

    ¶à·¢Ò»Ð©ÕâÑùµÄºÃÌû

  10. wangyoubang ÓÚ 2009-07-14 22:27:48·¢±í:

    Ö§³Ö Ö§³Ö