Shadow DB

    For details, see list of built-in shadow algorithms

    1. Configure the shadow library rules in the SpringBoot file, including configuration items such as data sources, shadow rules, and global properties.
    2. Start the SpringBoot program, the configuration will be loaded automatically, and the ShardingSphereDataSource will be initialized.
    1. spring.shardingsphere.datasource.ds.jdbc-url=jdbc:mysql://localhost:3306/ds?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8
    2. spring.shardingsphere.datasource.ds.type=com.zaxxer.hikari.HikariDataSource
    3. spring.shardingsphere.datasource.ds.driver-class-name=com.mysql.jdbc.Driver
    4. spring.shardingsphere.datasource.ds.password=
    5. spring.shardingsphere.datasource.shadow-ds.jdbc-url=jdbc:mysql://localhost:3306/shadow_ds?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8
    6. spring.shardingsphere.datasource.shadow-ds.driver-class-name=com.mysql.jdbc.Driver
    7. spring.shardingsphere.datasource.shadow-ds.username=root
    8. spring.shardingsphere.datasource.shadow-ds.password=
    9. spring.shardingsphere.rules.shadow.data-sources.shadow-data-source.production-data-source-name=ds
    10. spring.shardingsphere.rules.shadow.data-sources.shadow-data-source.shadow-data-source-name=shadow-ds
    11. spring.shardingsphere.rules.shadow.tables.t_user.data-source-names=shadow-data-source
    12. spring.shardingsphere.rules.shadow.shadow-algorithms.user-id-insert-match-algorithm.type=VALUE_MATCH
    13. spring.shardingsphere.rules.shadow.shadow-algorithms.user-id-insert-match-algorithm.props.operation=insert
    14. spring.shardingsphere.rules.shadow.shadow-algorithms.user-id-insert-match-algorithm.props.column=user_id
    15. spring.shardingsphere.rules.shadow.shadow-algorithms.user-id-insert-match-algorithm.props.value=1
    16. spring.shardingsphere.rules.shadow.shadow-algorithms.simple-hint-algorithm.type=SIMPLE_HINT
    17. spring.shardingsphere.rules.shadow.shadow-algorithms.simple-hint-algorithm.props.shadow=true