Home  >  Q&A  >  body text

mysql的主从复制、读写分离,关于从的问题

a=主库,快速插入数据
b=从库,复制主库数据

疑问:主库只有主键索引,复制过来后,我能不能给从库建立其他字段的索引?还是两个库的结构必须一模一样?

大家讲道理大家讲道理2742 days ago633

reply all(1)I'll reply

  • 天蓬老师

    天蓬老师2017-04-17 14:57:01

    Theoretically, the data from the slave database is not synchronized to the main database, and changes to the data structure of the slave database do not affect the data in the main database. This can be done.

    But there are potential problems:

    • The slave database has a unique index on a certain field, but the master database does not have such a setting. Synchronization data may fail to be inserted, causing synchronization interruption

    • The slave library directly modified the structure, and the data of the main library could not be stored in the database at all, and the synchronization failed

    • When the primary machine fails, the data structure of the backup machine is inconsistent, which affects recovery and business replacement

    SO, it’s up to you

    reply
    0
  • Cancelreply