MySQL Replication可行性分析
AUTO_INCREMENT
Version<5.5.30,AUTO_INCREMENT column->AUTO_INCREMENT column
ALL
Yes www.2cto.com
Update AUTO_INCREMENT column by invoking a trigger or function
!InnoDB
No
复合主键中AUTO_INCREMENT列不是首列,此时的INSERT不安全
ALL
No
Character Set
Use UTF8 in master and slave
InnoDB
Yes
Temporary table
混合模式,更新和插入操作正常,但临时表打开计数按官方指导无法消除,只能通过stop slave;flush slave消除
InnoDB
Yes
Create if ..exists
Mixed Mode 正常
InnoDB
Yes
Create table ..select
Mixed Mode 正常
InnoDB
Yes
Create/Alter/Drop server
需要从库单独维护
InnoDB
No
Current_user()
可以同步,通常不会用到
InnoDB
Yes
Drop .. If exists
Mixed Mode 正常
InnoDB
Yes
Memory table
Mixed Mode,插入、读取、联合更新;主从的内存表大小限制须一致
InnoDB
Yes www.2cto.com
Rand(),UUID(),Last_insert_id()
Only Mixed Mode
InnoDB
Yes
Limit
Mixed Mode
InnoDB
Yes
Different table definition
表定义和引擎可以不同,但列的顺序需要相同
InnoDB
Yes
Directory permission
必须在从库上为路径赋权
InnoDB
Yes
Invorked Features
5.5之前会有跨DB更新的问题,目前版本可以正常同步
InnoDB
Yes
Floating Point Value
使用Decimal可以解决
ALL
No
Flush
测试范围:Flush Hosts\Slave\Logs;此类维护从库需要单独进行
InnoDB
No www.2cto.com
System Function
Mixed Mode-Row Base正常
ALL
Yes
Load Data infile
5.5.0后可以正常复制,5.5.6后使用Mixed-Row Base
ALL
Yes
Slow query log
不复制
ALL
No
Repair table
此类维护前停止复制,维护完成手动保障主从结构一致,再恢复复制
ALL
No
Master and slave shutdown
安全操作,但master异常停止时,会有数据丢失。可以设置syn_binlog=1减少损失。
ALL
No
Max_allowed_packet
当最大列(TEXT)过大导致master失败时,复制会终止。
ALL
Yes
System database
MySQL DB正常同步,Mixed模式使用RowBase方式,反之,使用直接Update的方式
ALL
Yes
Query optimizer
根据语法而定,可能出现不一致的情况
ALL
Yes
Reserved word
主要发生在新版本增加保留字的情况,出现后需要修改字段名
ALL
Yes
Set password and row-base rep
已知Bug,不复制。主(5.1)->从(5.5);
ALL
No
Slave errors
根据情况选择是否跳过错误。处理方式参考复制故障处理。
Null
Null
Sql mode
主从统一SQL MODE可以规避
ALL
No
Retried and timeouts
事务锁定或超时时,重试次数。文档描述默认值是10,实际默认值是0;
ALL
Yes
Timestamp
版本问题,5.5没有此问题
ALL
Yes
Time zones
系统级别需要保持时间同步
ALL
Yes
Transactions
Mixed模式下可以正常复制
InnoDB
Yes
Triggers
不使用该特性。
ALL
Yes/No
Views
会复制,防止包含指定忽略复制的表。
ALL
Yes
Truncate table
Mixed模式下可以正常复制
InnoDB
Yes
Variables
单独维护。通过my.cnf统一管理相关参数。
ALL
No
结论
根据我们
数据库开发以及后续维护所需要的特性,目前的复制是可以正常使用的。