一般都是触发器+MYSQL6.0本身的同步?自己手写比对代码同步可行吗?差别在哪里

解决方案 »

  1.   

    本身同步比较省事。 本身同步的机制是,host会把所有的操作记录到logfile,然后slave从机,会定时读这个logfile中的update / insert / delete / create ... 等等到语句,然后执行。触发器,由于跨服务器,一般主从数据库都不会在同一台SERVER上。如果在同一数据库内的两张表倒是可以。自己手写比对代码同步可行,也有,通过对从机中的表A中的最后一条记录的时标tlastUpdate,然后再到主机表A中取tlastUpdate之后的记录。 如果表很小,则可以直接全表复制。
      

  2.   

    一天加3W记录的 用 MySQL本身同步 吧。
      

  3.   

    算法好,主要需要看你的数据变化程度是什么。如果你每天30,000 记录,都是新增 则你可以通过 select * from yourTable where date>curdate()或者通过ID之类的就可以了。 但如果你还有删除,更新,比如删除/更新 了一条 20天前的记录时,会比较麻烦。除非你的表中有删除标记,和更新时间。
      

  4.   

    中文的只有5.1 的,英文的有 6.0 的没试过 6.0 的,但想象中应该差不多啊。http://dev.mysql.com/doc/refman/5.1/zh/replication.html
    第6章:MySQL中的复制
    http://dev.mysql.com/doc/refman/6.0/en/index.html
    6.0 的手册。http://dev.mysql.com/doc/refman/6.0/en/replication.html
    Chapter 16. Replication
    Table of Contents     [+/-]16.1. Replication Configuration     [+/-]
    16.1.1. How to Set Up Replication 
    16.1.2. Replication Formats 
    16.1.3. Replication and Binary Logging Options and Variables 
    16.1.4. Common Replication Administration Tasks 
    16.2. Replication Solutions     [+/-]
    16.2.1. Using Replication for Backups 
    16.2.2. Using Replication with Different Master and Slave Storage Engines 
    16.2.3. Using Replication for Scale-Out 
    16.2.4. Replicating Different Databases to Different Slaves 
    16.2.5. Improving Replication Performance 
    16.2.6. Switching Masters During Failover 
    16.2.7. Upgrading Multi-Master Replication 
    16.2.8. Setting Up Replication Using SSL 
    16.2.9. Semisynchronous Replication 
    16.3. Replication Notes and Tips     [+/-]
    16.3.1. Replication Features and Issues 
    16.3.2. Replication Compatibility Between MySQL Versions 
    16.3.3. Upgrading a Replication Setup 
    16.3.4. Replication FAQ 
    16.3.5. Troubleshooting Replication 
    16.3.6. How to Report Replication Bugs or Problems 
    16.4. Replication Implementation     [+/-]
    16.4.1. Replication Implementation Details 
    16.4.2. Replication Relay and Status Files 
    16.4.3. How Servers Evaluate Replication Rules