You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by "java-meow (via GitHub)" <gi...@apache.org> on 2025/04/13 16:28:32 UTC

[I] How can shardingsphere proxy be configured datasources with environment variables? [shardingsphere]

java-meow opened a new issue, #35192:
URL: https://github.com/apache/shardingsphere/issues/35192

   ```java
   Exception in thread "main" java.lang.NumberFormatException: For input string: ""
   	at java.base/java.lang.NumberFormatException.forInputString(NumberFormatException.java:67)
   	at java.base/java.lang.Integer.parseInt(Integer.java:672)
   	at java.base/java.lang.Integer.parseInt(Integer.java:778)
   	at org.apache.shardingsphere.infra.database.core.connector.url.StandardJdbcUrlParser.parsePort(StandardJdbcUrlParser.java:76)
   	at org.apache.shardingsphere.infra.database.core.connector.url.StandardJdbcUrlParser.parse(StandardJdbcUrlParser.java:61)
   	at org.apache.shardingsphere.infra.database.mysql.connector.MySQLConnectionPropertiesParser.parse(MySQLConnectionPropertiesParser.java:37)
   	at org.apache.shardingsphere.infra.metadata.database.resource.unit.StorageUnitNodeMapCreator.create(StorageUnitNodeMapCreator.java:60)
   	at org.apache.shardingsphere.infra.metadata.database.resource.unit.StorageUnitNodeMapCreator.create(StorageUnitNodeMapCreator.java:54)
   	at org.apache.shardingsphere.infra.metadata.database.resource.unit.StorageUnitNodeMapCreator.lambda$create$0(StorageUnitNodeMapCreator.java:49)
   	at java.base/java.util.stream.Collectors.lambda$toMap$68(Collectors.java:1637)
   	at java.base/java.util.stream.ReduceOps$3ReducingSink.accept(ReduceOps.java:169)
   	at java.base/java.util.Iterator.forEachRemaining(Iterator.java:133)
   	at java.base/java.util.Spliterators$IteratorSpliterator.forEachRemaining(Spliterators.java:1939)
   	at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509)
   	at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499)
   	at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:921)
   	at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
   	at java.base/java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:682)
   	at org.apache.shardingsphere.infra.metadata.database.resource.unit.StorageUnitNodeMapCreator.create(StorageUnitNodeMapCreator.java:49)
   	at org.apache.shardingsphere.infra.config.database.impl.DataSourceGeneratedDatabaseConfiguration.<init>(DataSourceGeneratedDatabaseConfiguration.java:55)
   	at org.apache.shardingsphere.proxy.backend.config.yaml.swapper.YamlProxyConfigurationSwapper.swapDatabaseConfigurations(YamlProxyConfigurationSwapper.java:84)
   	at org.apache.shardingsphere.proxy.backend.config.yaml.swapper.YamlProxyConfigurationSwapper.swap(YamlProxyConfigurationSwapper.java:60)
   	at org.apache.shardingsphere.proxy.initializer.BootstrapInitializer.init(BootstrapInitializer.java:51)
   	at org.apache.shardingsphere.proxy.Bootstrap.main(Bootstrap.java:64)
   ```
   
   I met such a problem when I tried to replace the specific datasource url by environment variables. I checked there is a sample configuration guideline in Shardingsphere JDBC [documentation](https://shardingsphere.apache.org/document/current/en/user-manual/shardingsphere-jdbc/yaml-config/jdbc-driver/known-implementation/), but no similar content is mentioned in the Proxy part.
   
   Within the proxy Yaml configuration file, I tried what is described in the JDBC part documentation but obviously it doesn't work. 
   
   As my understanding, the log is saying it cannot parse datasource URLs properly.
   My Shardingsphere Proxy configuration file looks like below:
   
   ```yml
   # global.yaml
   
   authority:
     users:
       - user: root@%
         password: dbproxy
         admin: true
       - user: dbproxy
         password: dbproxy
     privilege:
       type: ALL_PERMITTED
   
   sqlFederation:
     sqlFederationEnabled: true
     executionPlanCache:
       initialCapacity: 2000
       maximumSize: 65535
   
   props:
     sql-show: false
   ```
   
   ```yml
   # datasource.yaml
   
   databaseName: db_proxy
   
   dataSources:
     db_core:
       url: jdbc:mysql://$${DB_CORE::mysql_core:3306}/ttsa_server?useSSL=true&placeholder-type=environment
       username: myusername
       password: mypassword
       connectionTimeoutMilliseconds: 30000
       idleTimeoutMilliseconds: 60000
       maxLifetimeMilliseconds: 1800000
       maxPoolSize: 50
       minPoolSize: 1
   ```
   Where `DB_CORE` is an environment variable with a preset value by executing commands like `export DB_CORE=ip_address:port_no`.
   
   Before I changed the datasource configuration file like this, I have tried to put the exact IP address and port number the database is located, and it works.
   
   Does the proxy project support putting placeholders in Yaml configuration files? If yes, how I can approach it?


-- 
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: notifications-unsubscribe@shardingsphere.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] How can shardingsphere proxy be configured datasources with environment variables? [shardingsphere]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on issue #35192:
URL: https://github.com/apache/shardingsphere/issues/35192#issuecomment-2819671415

   There hasn't been any activity on this issue recently, and in order to prioritize active issues, it will be marked as stale.


-- 
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: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] How can shardingsphere proxy be configured datasources with environment variables? [shardingsphere]

Posted by "linghengqian (via GitHub)" <gi...@apache.org>.
linghengqian commented on issue #35192:
URL: https://github.com/apache/shardingsphere/issues/35192#issuecomment-2800448540

   > Does the proxy project support putting placeholders in Yaml configuration files? If yes, how I can approach it?
   
   - Currently this is not possible, the content of https://shardingsphere.apache.org/document/current/en/user-manual/shardingsphere-jdbc/yaml-config/jdbc-driver/known-implementation/ is only available on ShardingSphere JDBC Driver. This design was originally to circumvent the problem that ShardingSphere JDBC Driver cannot use DistSQL in unit testing.
   - You can certainly consider submitting a PR to expand support to the configuration file of the logical database of ShardingSphere Proxy. But I would say that it sounds a bit overlapping with the positioning of DistSQL.
   - The fact that `global.yaml` cannot be configured via DistSQL is indeed another issue.


-- 
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: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] How can shardingsphere proxy be configured datasources with environment variables? [shardingsphere]

Posted by "terrymanu (via GitHub)" <gi...@apache.org>.
terrymanu closed issue #35192: How can shardingsphere proxy be configured datasources with environment variables?
URL: https://github.com/apache/shardingsphere/issues/35192


-- 
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: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org