HA

    Namespace: http://shardingsphere.apache.org/schema/shardingsphere/database-discovery/database-discovery-5.1.1.xsd

    <database-discovery:data-source-rule />

    <database-discovery:discovery-type />

    1. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    2. xmlns:cluster="http://shardingsphere.apache.org/schema/shardingsphere/mode-repository/cluster"
    3. xmlns:shardingsphere="http://shardingsphere.apache.org/schema/shardingsphere/datasource"
    4. xmlns:database-discovery="http://shardingsphere.apache.org/schema/shardingsphere/database-discovery"
    5. xmlns:readwrite-splitting="http://shardingsphere.apache.org/schema/shardingsphere/readwrite-splitting"
    6. xsi:schemaLocation="http://www.springframework.org/schema/beans
    7. http://www.springframework.org/schema/beans/spring-beans.xsd
    8. http://shardingsphere.apache.org/schema/shardingsphere/database-discovery
    9. http://shardingsphere.apache.org/schema/shardingsphere/database-discovery/database-discovery.xsd
    10. http://shardingsphere.apache.org/schema/shardingsphere/readwrite-splitting
    11. http://shardingsphere.apache.org/schema/shardingsphere/readwrite-splitting/readwrite-splitting.xsd
    12. http://shardingsphere.apache.org/schema/shardingsphere/mode-repository/cluster
    13. http://shardingsphere.apache.org/schema/shardingsphere/mode-repository/cluster/repository.xsd
    14. http://shardingsphere.apache.org/schema/shardingsphere/datasource
    15. http://shardingsphere.apache.org/schema/shardingsphere/datasource/datasource.xsd
    16. ">
    17. <property name="driverClassName" value="com.mysql.jdbc.Driver" />
    18. <property name="jdbcUrl" value="jdbc:mysql://127.0.0.1:33306/primary_demo_ds?serverTimezone=UTC&amp;useSSL=false&amp;useUnicode=true&amp;characterEncoding=UTF-8" />
    19. <property name="username" value="root" />
    20. </bean>
    21. <bean id="ds_1" class="com.zaxxer.hikari.HikariDataSource" destroy-method="close">
    22. <property name="driverClassName" value="com.mysql.jdbc.Driver"/>
    23. <property name="jdbcUrl" value="jdbc:mysql://127.0.0.1:33307/primary_demo_ds?serverTimezone=UTC&amp;useSSL=false&amp;useUnicode=true&amp;characterEncoding=UTF-8" />
    24. <property name="username" value="root" />
    25. <property name="password" value="" />
    26. </bean>
    27. <bean id="ds_2" class="com.zaxxer.hikari.HikariDataSource" destroy-method="close">
    28. <property name="driverClassName" value="com.mysql.jdbc.Driver"/>
    29. <property name="jdbcUrl" value="jdbc:mysql://127.0.0.1:33308/primary_demo_ds?useSSL=false"/>
    30. <property name="username" value="root"/>
    31. <property name="password" value=""/>
    32. </bean>
    33. <cluster:repository id="clusterRepository" type="ZooKeeper" namespace="governance" server-lists="localhost:2181">
    34. <props>
    35. <prop key="max-retries">3</prop>
    36. <prop key="operation-timeout-milliseconds">3000</prop>
    37. </props>
    38. </cluster:repository>
    39. <readwrite-splitting:dynamic-strategy id="dynamicStrategy" auto-aware-data-source-name="readwrite_ds" />
    40. </readwrite-splitting:data-source-rule>
    41. </readwrite-splitting:rule>
    42. <database-discovery:rule id="mgrDatabaseDiscoveryRule">
    43. <database-discovery:data-source-rule id="readwrite_ds" data-source-names="ds_0,ds_1,ds_2" discovery-heartbeat-name="mgr-heartbeat" discovery-type-name="mgr" />
    44. <database-discovery:discovery-heartbeat id="mgr-heartbeat">
    45. <props>
    46. <prop key="keep-alive-cron" >0/5 * * * * ?</prop>
    47. </props>
    48. </database-discovery:discovery-heartbeat>
    49. </database-discovery:rule>
    50. <database-discovery:discovery-type id="mgr" type="MySQL.MGR">
    51. <props>
    52. <prop key="group-name">558edd3c-02ec-11ea-9bb3-080027e39bd2</prop>
    53. </props>
    54. </database-discovery:discovery-type>
    55. <shardingsphere:data-source id="databaseDiscoveryDataSource" schema-name="database-discovery-db" data-source-names="ds_0, ds_1, ds_2" rule-refs="readWriteSplittingRule, mgrDatabaseDiscoveryRule">
    56. <shardingsphere:mode repository-ref="clusterRepository" type="Cluster" />
    57. </shardingsphere:data-source>
    58. </beans>