现在有一个网站,想在另外一台服务器上做一个这个网站的镜像。 
在主网站上的数据更新要同步到镜像服务器上 
同时用户访问镜像服务器时的数据更新也要同步到主网站上 其中数据更新 主要包括 Mysql数据库的更新  和 用户上传的文件更新 我现在在看mysql数据库的同步。 在两台服务器上的mysql数据库之间的同步 
网上查了下mysql热备份,大多讲的是数据从 主服务器 到 从服务器上。讲双向热备的比较少。由于mysql热备份是异步处理的,对于auto_increment字段的值,双向热备的时候不知道会不会出问题? 
希望大家可以给小弟提供一些建议和方案,谢谢。 

解决方案 »

  1.   

    http://dev.mysql.com/doc/refman/5.1/zh/ndbcluster.html17. MySQL簇
    17.1. MySQL簇概述
    17.2. MySQL簇的基本概念
      

  2.   

    MySQL簇 要求服务器是在一个局域网之内才可以。广域网上很难成功啊。
      

  3.   

    Mysql Replication 功能可以做双向的吗  我的需求是两台服务器上的数据库数据可以互相同步,可以实现吗? 我看到Mysql手册里:The target uses for replication in MySQL include: Scale-out solutions - spreading the load among multiple slaves to improve performance. In this environment, all writes and updates must take place on the master server. Reads, however, may take place on one or more slaves. This model can improve the performance of writes (since the master is dedicated to updates), while dramatically increasing read speed across an increasing number of slaves. 而我的要求是两台服务器都可以随时更新数据,然后互相同步。
      

  4.   

    可以考虑用replication的master-master方式,至于自增列上的选择,可以通过下面2个参数 auto_increment_increment
     auto_increment_offset
    来设置,从而达到2机器上不会出现重复的自增列值
      

  5.   

    vinsonshen  能具体点吗  关于replication的master-master方式 你说的是MMM( MySQL Master-Master Replication Manager )吗
      

  6.   

    在主网站上的数据更新要同步到镜像服务器上 
    同时用户访问镜像服务器时的数据更新也要同步到主网站上 ------------
    这个不用MMM了,MMM只是实现了写服务器的自动故障切换来实现高可用如果像你上面说的主、镜像服务器都要写的话,且只有2台机器的话,则只要单纯master-master方式就行了。
      

  7.   

    即模式A <--> B 即分别在A、B的两端像平时正常设置master的配置信息,但要注意忽略--logs-slave-updates参数,否则引起循环。
      

  8.   

    至于自增列上的选择,可以通过下面2个参数 auto_increment_increment, auto_increment_offset 
    来设置,从而达到2机器上不会出现重复的自增列值有没有这样配置的文章或资料啊  我找了很多 都是A -> B的模式 ,说A <--> B模式 把A -> B反过来再做一遍就可以了,没有说可能出现的问题。
      

  9.   


    你在配置文件里面配置就可以了(windows下my.ini;linux下my.cnf),例如,将A设置:
    auto_increment_increment=5
    auto_increment_offset=1将A设置:
    auto_increment_increment=5
    auto_increment_offset=2
      

  10.   

    手快有误:你在配置文件里面配置就可以了(windows下my.ini;linux下my.cnf),例如,将A设置: 
    auto_increment_increment=5 
    auto_increment_offset=1 将B设置: 
    auto_increment_increment=5 
    auto_increment_offset=2