Shadow DB

    1. Configure shadow DB rules in the YAML file, including data sources, shadow library rules, global properties and other configuration items;
    2. Call the method of the YamlShardingSphereDataSourceFactory object to create a ShardingSphereDataSource based on the configuration information in the YAML file.
    1. dataSources:
    2. ds:
    3. url: jdbc:mysql://127.0.0.1:3306/ds?serverTimezone=UTC&useSSL=false
    4. username: root
    5. password:
    6. connectionTimeoutMilliseconds: 30000
    7. idleTimeoutMilliseconds: 60000
    8. maxLifetimeMilliseconds: 1800000
    9. maxPoolSize: 50
    10. minPoolSize: 1
    11. url: jdbc:mysql://127.0.0.1:3306/shadow_ds?serverTimezone=UTC&useSSL=false
    12. username: root
    13. connectionTimeoutMilliseconds: 30000
    14. idleTimeoutMilliseconds: 60000
    15. maxLifetimeMilliseconds: 1800000
    16. maxPoolSize: 50
    17. minPoolSize: 1
    18. rules:
    19. - !SHADOW
    20. dataSources:
    21. shadowDataSource:
    22. productionDataSourceName: ds
    23. shadowDataSourceName: shadow_ds
    24. tables:
    25. t_order:
    26. - shadowDataSource
    27. shadowAlgorithmNames:
    28. - user_id_insert_match_algorithm
    29. - simple_hint_algorithm
    30. shadowAlgorithms:
    31. user_id_insert_match_algorithm:
    32. type: REGEX_MATCH
    33. props:
    34. operation: insert
    35. column: user_id
    36. regex: "[1]"
    37. simple_hint_algorithm:
    38. type: SIMPLE_HINT
    39. props: