You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by "taetaetae (via GitHub)" <gi...@apache.org> on 2023/02/22 05:19:05 UTC
[GitHub] [shardingsphere] taetaetae opened a new issue, #24292: I want to know more about how to run the example.
taetaetae opened a new issue, #24292:
URL: https://github.com/apache/shardingsphere/issues/24292
Hello.
I found out about shardingsphere by looking for shaded tables to call queries as a single query.
The concept of shadingsphere is understood by reference to official documents. I'd like to run an example to help you understand more.
https://github.com/apache/shardingsphere/tree/master/examples/shardingsphere-example-generator
When I ran 'ExampleGeneratorMain' above, a considerable amount of example code was generated under `./examples/shardingsphere-example-generator/target/generated-sources/`
Do you have a guide on what to do after this? Also, I wonder how the database should be configured in advance for normal example execution.
It's hard to understand what needs to be done and what needs to be configured before it can be done by looking at README alone.
--
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
[GitHub] [shardingsphere] taetaetae commented on issue #24292: I want to know more about how to run the example.
Posted by "taetaetae (via GitHub)" <gi...@apache.org>.
taetaetae commented on issue #24292:
URL: https://github.com/apache/shardingsphere/issues/24292#issuecomment-1451488965
You have successfully run the example! Thank you for your help!
--
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
[GitHub] [shardingsphere] taetaetae closed issue #24292: I want to know more about how to run the example.
Posted by "taetaetae (via GitHub)" <gi...@apache.org>.
taetaetae closed issue #24292: I want to know more about how to run the example.
URL: https://github.com/apache/shardingsphere/issues/24292
--
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
[GitHub] [shardingsphere] taetaetae commented on issue #24292: I want to know more about how to run the example.
Posted by "taetaetae (via GitHub)" <gi...@apache.org>.
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: notifications-unsubscribe@shardingsphere.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [shardingsphere] totalo commented on issue #24292: I want to know more about how to run the example.
Posted by "totalo (via GitHub)" <gi...@apache.org>.
totalo commented on issue #24292:
URL: https://github.com/apache/shardingsphere/issues/24292#issuecomment-1440066977
hi @taetaetae.
> Hello.
>
> I found out about shardingsphere by looking for shaded tables to call queries as a single query.
>
> The concept of shadingsphere is understood by reference to official documents. I'd like to run an example to help you understand more.
>
> https://github.com/apache/shardingsphere/tree/master/examples/shardingsphere-example-generator
>
> When I ran 'ExampleGeneratorMain' above, a considerable amount of example code was generated under `./examples/shardingsphere-example-generator/target/generated-sources/`
>
> Do you have a guide on what to do after this? Also, I wonder how the database should be configured in advance for normal example execution.
As you can see,`. / examples/shardingsphere-example-the generator/target/generated sources/` generated a lot of sample code, each folders under this directory is a complete project, You can choose an example of the appropriate feature module.
It's even better to combine the example module with the documentation on the official website. https://shardingsphere.apache.org/document/current/en/overview/
One more thing, you can decide the module and type of the generated sample code by configuring the following fileļ¼
https://github.com/apache/shardingsphere/blob/master/examples/shardingsphere-example-generator/src/main/resources/config.yaml
>
> It's hard to understand what needs to be done and what needs to be configured before it can be done by looking at README alone.
>
> In addition, I am not sure how to initialize the database table. Is the script below the latest version?
>
> https://github.com/apache/shardingsphere/blob/master/examples/src/resources/manual_schema.sql
You can ignore this initialized sql.
>
> If there is a link with related articles or example documents, please share it.
>
> Please give me some advice.
If you have any further questions, Please let me know.
--
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
[GitHub] [shardingsphere] totalo commented on issue #24292: I want to know more about how to run the example.
Posted by "totalo (via GitHub)" <gi...@apache.org>.
totalo commented on issue #24292:
URL: https://github.com/apache/shardingsphere/issues/24292#issuecomment-1441222332
> @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
> ```
Yes, it should. The default is three libraries, because some of the example code will use three libraries.
You can configure them with the feature module documentation. The main responsibility of the example module is to help users quickly verify some configurations. By generating general and normal running projects, we can let users personalize the corresponding configuration combined with the document, so that users can quickly verify whether the function meets the requirements and the correctness of the configuration.
>
> 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.
Yes, we are negligent. I will improve the document later.
> 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!
hi @taetaetae,
Glad to help, this example generation module is a brand new pattern that was recently completed. There's still a lot to be desired. We'll cover this in detail in a future article. Currently you can view the configuration of The Times[1]. Looking forward to your suggestions, let us make the example module better.
[1] https://github.com/apache/shardingsphere/blob/master/examples/shardingsphere-example-generator/README.md
--
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