
1 jixiangqd Feb 29, 2016 mycat 、 oneproxy 可以试试这种对应用层透明的中间件。。。 |
2 MasterYoda Feb 29, 2016 http://stackoverflow.com/questions/8947918/read-slave-read-write-master-setup 作者自己的答案。 他博客里还写过别的方法,判断 is_flush 的,在底层做读写分离。 |
3 wdg8106 OP @MasterYoda 太感谢了,困扰了好长时间,终于有解决思路了 |
5 SlipStupig Mar 2, 2016 @wdg8106 mysql-proxy 是神坑,可以用一下 360 的 atlas |
6 siteshen Mar 7, 2016 继承实现 Session.get_bind 方法就行: def get_bind(self, mapper=None, clause=None): # 增强版,支持 User.use_master().get(1024) # 当然还需要实现 Query._execute_and_instances ,增加 Query.use_master 方法 # if use_master: # return bind['master'] if not self._flushing and bind['slaves']: return random.choice(bind['slaves']) else: return bind['master'] |