数据主从分离

一. 配置模板

1. 配置模板

  1. schemaName: master_slave_db
  2. dataSources:
  3. ds_master:
  4. url: jdbc:mysql://localhost:3306/ds_master
  5. username: root
  6. password:
  7. autoCommit: true
  8. connectionTimeout: 30000
  9. idleTimeout: 60000
  10. maxLifetime: 1800000
  11. maximumPoolSize: 65
  12. ds_slave0:
  13. url: jdbc:mysql://localhost:3306/ds_slave0
  14. username: root
  15. password:
  16. autoCommit: true
  17. connectionTimeout: 30000
  18. idleTimeout: 60000
  19. maxLifetime: 1800000
  20. maximumPoolSize: 65
  21. ds_slave1:
  22. url: jdbc:mysql://localhost:3306/ds_slave1
  23. username: root
  24. password:
  25. autoCommit: true
  26. connectionTimeout: 30000
  27. idleTimeout: 60000
  28. maxLifetime: 1800000
  29. maximumPoolSize: 65
  30. masterSlaveRule:
  31. name: ds_ms
  32. masterDataSourceName: ds_master
  33. slaveDataSourceNames:
  34. - ds_slave0
  35. - ds_slave1

2. 配套 SQL