Giter Site home page Giter Site logo

第四期 作业五:基于MySQL Replication Connection 实现通用同区域优先以及 Zone 多活架构 about java-training-camp HOT 2 OPEN

mercyblitz avatar mercyblitz commented on May 26, 2024
第四期 作业五:基于MySQL Replication Connection 实现通用同区域优先以及 Zone 多活架构

from java-training-camp.

Comments (2)

Kurok1 avatar Kurok1 commented on May 26, 2024

Kurok1/microsphere-multiactive@f9a716b

数据库定义(classpath:/META-INF/microsphere-database-zone.properties)

microsphere.multiple.jdbc.defaultZone=localhost:33306,localhost:13306
microsphere.multiple.jdbc.AZone=localhost:3306

jdbcUrl定义
jdbc:mysql:replication://localhost:33306,localhost:13306,localhost:3306/test?ha.loadBalanceStrategy=io.microsphere.multiple.active.zone.jdbc.mysql.ZonePreferenceBalanceStrategy

from java-training-camp.

walklown avatar walklown commented on May 26, 2024

可直接使用 ReplicationConnectionProxy 多主多从策略,将同区域MySQL实例配置为SOURCE,其他区域MySQL实例配置为REPLICA),配置方式如下:
jdbc:mysql:replication://root:root123456@(host=localhost,port=3309,type=SOURCE),root:root123456@(host=localhost,port=3310,type=SOURCE),root:root123456@(host=localhost,port=3311,type=REPLICA),root:root123456@(host=localhost,port=3312,type=REPLICA)/my_schema?ha.loadBalanceStrategy=random
参考代码:com.mysql.cj.conf.ConnectionUrlParser
配置效果:
image

优点:无入侵,完全使用MySQL驱动原生实现和配置;可在实现多区域多活、同区域优先的前提下,支持LoadBalance策略。
缺点:功能仅限于多区域多活、同区域优先,如果需要指定区域优先级等定制策略,还是需要自定义扩展。

from java-training-camp.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.