galaxylqx opened a new issue #15881:
URL: https://github.com/apache/shardingsphere/issues/15881


   Problem description: Multiple data sources use the same database instance. 
For example, if the host is 127.0.0.1 and the port is 3306, multiple data 
sources need to be created. If the same database instance has 100 databases, 
100 data sources need to be created.
   ```
   schemaName: sharding_db
     dataSources:
       ds_1:
         url: jdbc:mysql://127.0.0.1:3306/db_1?serverTimezone=UTC&useSSL=false
         username: root
         password:
         connectionTimeoutMilliseconds: 30000
         idleTimeoutMilliseconds: 60000
         maxLifetimeMilliseconds: 1800000
         maxPoolSize: 50
         minPoolSize: 1
       ds_2:
         url: jdbc:mysql://127.0.0.1:3306/db_2?serverTimezone=UTC&useSSL=false
         username: root
         password:
         connectionTimeoutMilliseconds: 30000
         idleTimeoutMilliseconds: 60000
         maxLifetimeMilliseconds: 1800000
         maxPoolSize: 50
         minPoolSize: 1
   ```
   Solution: The data source connection does not specify a specific database, 
the data source is only a database connection, and the real database 
corresponding to the data source can be periodically updated from the target 
database through the background thread and maintained in memory.
   ```
   schemaName: sharding_db
   dataSources:
     ds:
       url: jdbc:mysql://127.0.0.1:3306/?serverTimezone=UTC&useSSL=false
       username: root
       password:
       connectionTimeoutMilliseconds: 30000
       idleTimeoutMilliseconds: 60000
       maxLifetimeMilliseconds: 1800000
       maxPoolSize: 50
       minPoolSize: 1
    rules:
   - !SHARDING
     tables:
       t_order:
         actualDataNodes: ds.order_db_${0..1}.t_order_${0..1}
         tableStrategy:
           standard:
             shardingColumn: order_id
             shardingAlgorithmName: t_order_inline
   ```
   Add parameters to regularly update metadata.
   server.yaml
   ```
   props:
      flush-metadata-interval-seconds: 0 # The default value is 0.
   ```
   


-- 
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]


Reply via email to