简体   繁体   English

用主从设置执行mysql事务?

[英]performing mysql transactions with master and slave setup?

how do you deal with transactions when you have master and slave db setup? 在设置主数据库和从数据库时,如何处理事务? typically i do all the reads from slaves and writes from master but when performing transactions, it seems i need to do reads from master (the one which is performing the transactions) and so i can't have all my transactions all in one place ... 通常情况下,我会执行所有从属设备的读取操作,并会从主设备执行写入操作,但是在执行事务时,似乎需要从主设备(正在执行事务的操作)进行读取操作,因此我无法将所有事务都放在一个地方。 ..

im also using zend db multidb so i got a separate db instance for master and slave. 我还使用了zend db multidb,所以我为主服务器和从服务器分别设置了一个数据库实例。 whats the best way of approaching this? 解决这个问题的最佳方法是什么?

There's nothing in MySQL that would prevent you from using the Master db instance for reads as well as writes. MySQL中没有什么可以阻止您将Master数据库实例用于读取和写入的。 It won't hurt anything. 它不会伤害任何东西。 For your transaction-based queries, I think you'll have to do so. 对于基于事务的查询,我认为您必须这样做。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM