Mysql master/slave replication

  • First, DBCP is creating a single JDBC connection through the MySQL driver. This connection will point to the master until set to read-only at which point it will switch over to the slave.
  • Second, Spring is getting a connection from the pool and writing to the debug log that it has acquired a connection. Because the connection has not yet been set to read-only mode, it will route queries to the master.
  • Third, Spring is changing the connection over to read-only mode at which point queries will be routed to the slave.
  • Next, your application (or iBatis or w/e) is given the connection to perform some work with the database.
  • After you return control to Spring, the transaction on the connection will be committed. Because the connection is in read-only mode, you can see the transaction debug message showing that queries will be routed to the slave server.
  • Finally, the connection is reset before being returned to the pool. The read-only mode is cleared and the last log message once again reflects that the connection will route queries to the master server.

 

 

 

The issue with that is that the MySQL replication driver will attempt to reconnect to the master each time the connection is returned to the pool. This happens when read-only mode is cleared. The simplest workaround I can see for this situation is to use a separate data source (and transaction manager) for the master and the slaves. You can them specify (along with read-only if you desire) the name of the datasource/transactionmanager in the annotation,

转载于:https://my.oschina.net/wanghhao/blog/504468

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
《10天掌握MongoDB》2012翻新完整版,大小 4.6 MB,NewSQL 中文社区系列课程。本版本带有 PDF 书签,方便读者朋友阅览。 目录: 第一天:认识MONGODB 从NOSQL说起 NOSQL数据库特点 NOSQL数据库类型 MONGODB简介 数据库、集合、文档命名规范 MONGODB的下载与安装 MONGODB SHELL MONGODB的数据类型 MONGODB的基本数据类型 MONGODB的数组 MONGODB的文档嵌套 MONGODB的OBJECTID 结束语 第二天:初识增删改 添加文档 删除文档 更新文档-文档更换1 更新文档-文档替换2 更新文档-UPSERT模式 更新文档-MULTI模式 更新文档-修改器 定位操作符("$")-神马是定位 定位操作符("$")-未知 FINDANDMODIFY-有神马不同 FINDANDMODIFY-返回已更新的文档 FINDANDMODIFY-实现自增标识 其他 第三天:学会FIND 认识FIND 子键筛选 复杂查询 查询条件操作符 正则表达式 数组查询 数组查询-$SIZE 数组查询-$SLICE 数组查询-子项定位 数组查询-$ELEMMATCH 游标 $WHERE 排序分页 排序分页-排序比较的顺序 排序分页-分页示例 排序分页-不使用SKIP分页 结束语 第四天:使用索引 创建索引 修改索引 删除索引 唯一索引 地理空间索引-创建1 地理空间索引-创建2 地理空间索引-$NEAR 地理空间索引-$WITHIN(BOX) 地理空间索引-$WITHIN(CENTER) 地理空间索引-$WITHIN(POLYGON) 地理空间索引-球形查找 查询计划 强制使用索引 实战技巧 第五天:聚合操作 聚合操作-COUNT 聚合操作-DISTINCT 聚合操作-GROUP 聚合操作-GROUP完成器 聚合操作-GROUP键函数 聚合操作-MAPREDUCE(简介) 聚合操作-MAPREDUCE(OUTPUT) 第六天:进阶指南 数据库命令-概览 数据库命令-BUILDINFO 数据库命令-COLLSTATS 数据库命令-DROP 数据库命令-DROPINDEXES 数据库命令-GETLASTERROR 数据库命令-ISMASTER 数据库命令-LISTCOMMANDS 数据库命令-LISTDATABASES 数据库命令-PING 数据库命令-RENAMECOLLECTION 数据库命令-REPAREDATABASE 数据库命令-SERVERSTATUS 定容集合 定容集合-自然排序 定容集合-尾部游标 GRIDFS GRDFS-原理 服务器端脚本 服务器端脚本-存储JAVASCRIPT 数据库引用-DBREF 第七天:服务器管理 启动和停止 配置文件 管理界面 安全与认证 备份与恢复 备份与恢复-冷备份 备份与恢复-热备份 备份与恢复-主从复制备份 备份与恢复-修复 第八天:MONGODB复制 主从复制 主从复制-选项 副本集 副本集-特点 副本集-活跃节点选举 读写分离 工作原理-OPLOG 工作原理-同步 复制管理-诊断 复制管理-变更OPLOG容量 复制管理-复制认证 第九天:MONGODB分片 分片与自动分片 片键与片键选择 分片集群的组成部分 创建分片 管理分片 结语 第十天:分享实战经验 对NOSQL的理解 为什么是MONGODB 文档结构设计 索引及查询优化 复制分片及副本集 其他
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值