taetaetae commented on issue #24292: URL: https://github.com/apache/shardingsphere/issues/24292#issuecomment-1441079785
@totalo Thank you very much for your advice. It's a big help! As you said, after cloning and building the entire shardingsphere project, In the https://github.com/apache/shardingsphere/blob/master/examples/shardingsphere-example-generator/src/main/resources/config.yaml settings, you created an example source after setting it as follows: ``` output: - ./examples/shardingsphere-example-generator/target/generated-sources/ products: - jdbc modes: - standalone transactions: - local features: - sharding frameworks: - spring-boot-starter-mybatis props: host: localhost port: 3306 username: root password: 1234 ``` When I run the ExampleMain.main() method of the 'sharding--spring-boot-starter-mybatis--standalone--local' project resulting in this, I get a message that there is no db. So, after generating the db as below, it was executed normally. Do you think this is a good example? ``` create database `demo_ds_0` create database `demo_ds_1` create database `demo_ds_2` // This db is not actually used ``` This is the example config.yaml. ``` mode: type: Standalone repository: type: JDBC props: path: demo dataSources: ds_0: dataSourceClassName: com.zaxxer.hikari.HikariDataSource driverClassName: com.mysql.jdbc.Driver jdbcUrl: jdbc:mysql://localhost:3306/demo_ds_0?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8&allowPublicKeyRetrieval=true username: root password: 1234 maxPoolSize: 10 ds_1: dataSourceClassName: com.zaxxer.hikari.HikariDataSource driverClassName: com.mysql.jdbc.Driver jdbcUrl: jdbc:mysql://localhost:3306/demo_ds_1?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8&allowPublicKeyRetrieval=true username: root password: 1234 maxPoolSize: 10 ds_2: dataSourceClassName: com.zaxxer.hikari.HikariDataSource driverClassName: com.mysql.jdbc.Driver jdbcUrl: jdbc:mysql://localhost:3306/demo_ds_2?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8&allowPublicKeyRetrieval=true username: root password: 1234 maxPoolSize: 10 rules: - !SHARDING tables: t_order: actualDataNodes: ds_$->{0..1}.t_order_$->{0..1} tableStrategy: standard: shardingColumn: order_id shardingAlgorithmName: t_order_inline keyGenerateStrategy: column: order_id keyGeneratorName: snowflake_generator t_order_item: actualDataNodes: ds_$->{0..1}.t_order_item_$->{0..1} tableStrategy: standard: shardingColumn: order_id shardingAlgorithmName: t_order_item_inline keyGenerateStrategy: column: order_item_id keyGeneratorName: snowflake_generator bindingTables: - t_order,t_order_item broadcastTables: - t_address defaultDatabaseStrategy: standard: shardingColumn: user_id shardingAlgorithmName: database_inline shardingAlgorithms: database_inline: type: INLINE props: algorithm-expression: ds_${user_id % 2} t_order_inline: type: INLINE props: algorithm-expression: t_order_$->{order_id % 2} t_order_item_inline: type: INLINE props: algorithm-expression: t_order_item_$->{order_id % 2} keyGenerators: snowflake_generator: type: SNOWFLAKE props: sql-show: true ``` If so, I think it would be good to add a code to make a db or specify in the guide that there should be a db in advance. Also, https://github.com/apache/shardingsphere/blob/master/examples/shardingsphere-example-generator/src/main/resources/config.yaml Is there a guide to setting up this file? I want to know what each means. Thank you for your kind explanation! -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
