You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by GitBox <gi...@apache.org> on 2022/01/18 02:27:45 UTC
[GitHub] [shardingsphere] wl4g opened a new issue #14845: In 5.1.0, how to exclude tables that do not require fragmentation and read-write separation? Are there any cases? Removed defaultDataSource property for 4.x?
wl4g opened a new issue #14845:
URL: https://github.com/apache/shardingsphere/issues/14845
In 5.1.0, how to exclude tables that do not require fragmentation and read-write separation? Are there any cases? Removed defaultDataSource property for 4.x?
--
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] RaigorJiang commented on issue #14845: In 5.1.0, how to exclude tables that do not require fragmentation and read-write separation? Are there any cases? Removed defaultDataSource property for 4.x?
Posted by GitBox <gi...@apache.org>.
RaigorJiang commented on issue #14845:
URL: https://github.com/apache/shardingsphere/issues/14845#issuecomment-1015089638
Hi @wl4g
If some tables do not need sharding, so they do not need to be configured and will be recognized as single table.
https://shardingsphere.apache.org/document/current/en/features/sharding/concept/table/#single-table
`defaultDataSource` is removed in 5.x
--
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] wl4g edited a comment on issue #14845: In 5.1.0, how to exclude tables that do not require fragmentation and read-write separation? Are there any cases? Removed defaultDataSource property for 4.x?
Posted by GitBox <gi...@apache.org>.
wl4g edited a comment on issue #14845:
URL: https://github.com/apache/shardingsphere/issues/14845#issuecomment-1015132790
Share with you my complete enterprise project configuration:
---------
```yaml
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
##################### Configuration of 'userdb' by group sharding v5.1.0 #######################
# External logical database schema.
schemaName: userdb
# Extension default datasource configuration.
# @see:com.wl4g.shardingproxy.config.ProxyConfigurationLoader2.loadRuleConfiguration
extensionDefaultDataSource:
username: root
password: 123456
connectionTimeoutMilliseconds: 30000
idleTimeoutMilliseconds: 60000
maxLifetimeMilliseconds: 1800000
maxPoolSize: 50
minPoolSize: 1
# Specification datasource configuration.
dataSources:
#################################### Sharding datasource group0 ####################################
ds_userdb_single:
url: 'jdbc:mysql://n0.rds.local:3306/userdb_single?serverTimezone=UTC&useSSL=false&allowMultiQueries=true&characterEncoding=utf-8'
ds_userdb_g0db0_0:
url: 'jdbc:mysql://n0.rds.local:3306/userdb_g0db0?serverTimezone=UTC&useSSL=false&allowMultiQueries=true&characterEncoding=utf-8'
ds_userdb_g0db0_1:
url: 'jdbc:mysql://n1.rds.local:3306/userdb_g0db0?serverTimezone=UTC&useSSL=false&allowMultiQueries=true&characterEncoding=utf-8'
ds_userdb_g0db0_2:
url: 'jdbc:mysql://n2.rds.local:3306/userdb_g0db0?serverTimezone=UTC&useSSL=false&allowMultiQueries=true&characterEncoding=utf-8'
ds_userdb_g0db1_0:
url: 'jdbc:mysql://n0.rds.local:3306/userdb_g0db1?serverTimezone=UTC&useSSL=false&allowMultiQueries=true&characterEncoding=utf-8'
ds_userdb_g0db1_1:
url: 'jdbc:mysql://n1.rds.local:3306/userdb_g0db1?serverTimezone=UTC&useSSL=false&allowMultiQueries=true&characterEncoding=utf-8'
ds_userdb_g0db1_2:
url: 'jdbc:mysql://n2.rds.local:3306/userdb_g0db1?serverTimezone=UTC&useSSL=false&allowMultiQueries=true&characterEncoding=utf-8'
ds_userdb_g0db2_0:
url: 'jdbc:mysql://n0.rds.local:3306/userdb_g0db2?serverTimezone=UTC&useSSL=false&allowMultiQueries=true&characterEncoding=utf-8'
ds_userdb_g0db2_1:
url: 'jdbc:mysql://n1.rds.local:3306/userdb_g0db2?serverTimezone=UTC&useSSL=false&allowMultiQueries=true&characterEncoding=utf-8'
ds_userdb_g0db2_2:
url: 'jdbc:mysql://n2.rds.local:3306/userdb_g0db2?serverTimezone=UTC&useSSL=false&allowMultiQueries=true&characterEncoding=utf-8'
# Schema rules configuration.
rules:
## @see:org.apache.shardingsphere.singletable.config.SingleTableRuleConfiguration
## @see:org.apache.shardingsphere.singletable.yaml.config.swapper.SingleTableRuleConfigurationYamlSwapper#getRuleTagName
- !SINGLE
defaultDataSource: ds_userdb_single
#################################### Sharding rules group0 ####################################
## @see:https://shardingsphere.apache.org/document/current/en/user-manual/shardingsphere-jdbc/builtin-algorithm/sharding/
## @see:org.apache.shardingsphere.sharding.api.config.ShardingRuleConfiguration
- !SHARDING
tables:
t_user:
actualDataNodes: rw_userdb_g0db${0..2}.t_user_${0..2}
#actualDataNodes: 'rw_userdb_g0db0.t_user_${0..3},rw_userdb_g0db1.t_user_${0..2},rw_userdb_g0db2.t_user_${0..2},rw_userdb_g0db${0..2}.t_user_${0..2}'
#databaseStrategy:
tableStrategy:
standard:
shardingColumn: id
shardingAlgorithmName: alg_table_volume_range_g0_0
keyGenerateStrategy:
column: id
keyGeneratorName: gen_snowflake0
bindingTables:
- t_user
defaultDatabaseStrategy:
standard:
shardingColumn: id
shardingAlgorithmName: alg_database_inline_g0_0
#shardingAlgorithmName: alg_complex_smart_mod_g0_0
defaultTableStrategy:
shardingAlgorithms:
#alg_complex_smart_mod_g0_0:
# type: SMART_MOD
# props:
# algorithm-expression: '_g0db0->0,1,2,3|_g0db1->4,5,6|_g0db2->7,8,9'
alg_database_inline_g0_0:
type: INLINE
props:
algorithm-expression: rw_userdb_g0db${(id % 9) as int}
alg_table_volume_range_g0_0: # see:org.apache.shardingsphere.sharding.algorithm.sharding.range.VolumeBasedRangeShardingAlgorithm
type: VOLUME_RANGE2
props: # Must use quotation marks(string) or you cannot get them.
range-lower: '0'
range-upper: '40000000'
sharding-volume: '10000000'
keyGenerators:
gen_snowflake0:
type: SNOWFLAKE
props:
worker-id: '1' # Range[0,1024),see:org.apache.shardingsphere.sharding.algorithm.keygen.SnowflakeKeyGenerateAlgorithm#getWorkerId()
## @see:org.apache.shardingsphere.readwritesplitting.api.ReadwriteSplittingRuleConfiguration
- !READWRITE_SPLITTING
dataSources:
rw_userdb_g0db0:
writeDataSourceName: ds_userdb_g0db0_1
readDataSourceNames:
- ds_userdb_g0db0_1
- ds_userdb_g0db0_2
loadBalancerName: r_lb_0
rw_userdb_g0db1:
writeDataSourceName: ds_userdb_g0db1_1
readDataSourceNames:
- ds_userdb_g0db1_1
- ds_userdb_g0db1_2
loadBalancerName: r_lb_0
rw_userdb_g0db2:
writeDataSourceName: ds_userdb_g0db2_1
readDataSourceNames:
- ds_userdb_g0db2_1
- ds_userdb_g0db2_2
loadBalancerName: r_lb_0
loadBalancers:
r_lb_0:
type: RANDOM
## @see:org.apache.shardingsphere.readwritesplitting.api.DatabaseDiscoveryRuleConfiguration
- !DB_DISCOVERY
dataSources:
ha_userdb_g0db0:
discoveryTypeName: cn_south1_a1_mgr_g0_0
discoveryHeartbeatName: mgr_heartbeat_0
dataSourceNames:
- ds_userdb_g0db0_0
- ds_userdb_g0db0_1
- ds_userdb_g0db0_2
ha_userdb_g0db1:
discoveryTypeName: cn_south1_a1_mgr_g0_0
discoveryHeartbeatName: mgr_heartbeat_0
dataSourceNames:
- ds_userdb_g0db1_0
- ds_userdb_g0db1_1
- ds_userdb_g0db1_2
ha_userdb_g0db2:
discoveryTypeName: cn_south1_a1_mgr_g0_0
discoveryHeartbeatName: mgr_heartbeat_0
dataSourceNames:
- ds_userdb_g0db2_0
- ds_userdb_g0db2_1
- ds_userdb_g0db2_2
discoveryHeartbeats:
mgr_heartbeat_0:
props:
keep-alive-cron: '0/5 * * * * ?'
discoveryTypes:
# HA MGR architecture see: https://blog.csdn.net/n88Lpo/article/details/118315051
cn_south1_a1_mgr_g0_0:
type: MGR
props:
# Must be consistent with the MGR configuration group name.
# see: https://github.com/apache/shardingsphere/blob/5.1.0/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-provider/shardingsphere-db-discovery-mgr/src/main/java/org/apache/shardingsphere/dbdiscovery/mgr/MGRDatabaseDiscoveryType.java#L104
# see: https://github.com/mysql/mysql-server/blob/mysql-5.7.30/rapid/plugin/group_replication/src/plugin.cc#L1726
# see: SELECT * FROM performance_schema.global_variables WHERE VARIABLE_NAME='group_replication_group_name'
group-name: 5db40c3c-180c-11e9-afbf-005056ac6820
## @see:org.apache.shardingsphere.dbdiscovery.mgr.MGRDatabaseDiscoveryType#extDiscoveryConfig
extensionDiscoveryConfigJson: |-
{
"memberHostMappings": [{
"rds-mgr-0:3306": [
"n0.rds.local:3306"
]
}, {
"rds-mgr-1:3306": [
"n1.rds.local:3306"
]
}, {
"rds-mgr-2:3306": [
"n2.rds.local:3306"
]
}]
}
```
--
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] wl4g edited a comment on issue #14845: In 5.1.0, how to exclude tables that do not require fragmentation and read-write separation? Are there any cases? Removed defaultDataSource property for 4.x?
Posted by GitBox <gi...@apache.org>.
wl4g edited a comment on issue #14845:
URL: https://github.com/apache/shardingsphere/issues/14845#issuecomment-1015132790
share with everyone:
---------
```yaml
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
##################### Configuration of 'userdb' by group sharding v5.1.0 #######################
# External logical database schema.
schemaName: userdb
# Extension default datasource configuration.
# @see:com.wl4g.shardingproxy.config.ProxyConfigurationLoader2.loadRuleConfiguration
extensionDefaultDataSource:
username: root
password: 123456
connectionTimeoutMilliseconds: 30000
idleTimeoutMilliseconds: 60000
maxLifetimeMilliseconds: 1800000
maxPoolSize: 50
minPoolSize: 1
# Specification datasource configuration.
dataSources:
#################################### Sharding datasource group0 ####################################
ds_userdb_single:
url: 'jdbc:mysql://n0.rds.local:3306/userdb_single?serverTimezone=UTC&useSSL=false&allowMultiQueries=true&characterEncoding=utf-8'
ds_userdb_g0db0_0:
url: 'jdbc:mysql://n0.rds.local:3306/userdb_g0db0?serverTimezone=UTC&useSSL=false&allowMultiQueries=true&characterEncoding=utf-8'
ds_userdb_g0db0_1:
url: 'jdbc:mysql://n1.rds.local:3306/userdb_g0db0?serverTimezone=UTC&useSSL=false&allowMultiQueries=true&characterEncoding=utf-8'
ds_userdb_g0db0_2:
url: 'jdbc:mysql://n2.rds.local:3306/userdb_g0db0?serverTimezone=UTC&useSSL=false&allowMultiQueries=true&characterEncoding=utf-8'
ds_userdb_g0db1_0:
url: 'jdbc:mysql://n0.rds.local:3306/userdb_g0db1?serverTimezone=UTC&useSSL=false&allowMultiQueries=true&characterEncoding=utf-8'
ds_userdb_g0db1_1:
url: 'jdbc:mysql://n1.rds.local:3306/userdb_g0db1?serverTimezone=UTC&useSSL=false&allowMultiQueries=true&characterEncoding=utf-8'
ds_userdb_g0db1_2:
url: 'jdbc:mysql://n2.rds.local:3306/userdb_g0db1?serverTimezone=UTC&useSSL=false&allowMultiQueries=true&characterEncoding=utf-8'
ds_userdb_g0db2_0:
url: 'jdbc:mysql://n0.rds.local:3306/userdb_g0db2?serverTimezone=UTC&useSSL=false&allowMultiQueries=true&characterEncoding=utf-8'
ds_userdb_g0db2_1:
url: 'jdbc:mysql://n1.rds.local:3306/userdb_g0db2?serverTimezone=UTC&useSSL=false&allowMultiQueries=true&characterEncoding=utf-8'
ds_userdb_g0db2_2:
url: 'jdbc:mysql://n2.rds.local:3306/userdb_g0db2?serverTimezone=UTC&useSSL=false&allowMultiQueries=true&characterEncoding=utf-8'
# Schema rules configuration.
rules:
## @see:org.apache.shardingsphere.singletable.config.SingleTableRuleConfiguration
## @see:org.apache.shardingsphere.singletable.yaml.config.swapper.SingleTableRuleConfigurationYamlSwapper#getRuleTagName
- !SINGLE
defaultDataSource: ds_userdb_single
#################################### Sharding rules group0 ####################################
## @see:https://shardingsphere.apache.org/document/current/en/user-manual/shardingsphere-jdbc/builtin-algorithm/sharding/
## @see:org.apache.shardingsphere.sharding.api.config.ShardingRuleConfiguration
- !SHARDING
tables:
t_user:
actualDataNodes: rw_userdb_g0db${0..2}.t_user_${0..2}
#actualDataNodes: 'rw_userdb_g0db0.t_user_${0..3},rw_userdb_g0db1.t_user_${0..2},rw_userdb_g0db2.t_user_${0..2},rw_userdb_g0db${0..2}.t_user_${0..2}'
#databaseStrategy:
tableStrategy:
standard:
shardingColumn: id
shardingAlgorithmName: alg_table_volume_range_g0_0
keyGenerateStrategy:
column: id
keyGeneratorName: gen_snowflake0
bindingTables:
- t_user
defaultDatabaseStrategy:
standard:
shardingColumn: id
shardingAlgorithmName: alg_database_inline_g0_0
#shardingAlgorithmName: alg_complex_smart_mod_g0_0
defaultTableStrategy:
shardingAlgorithms:
#alg_complex_smart_mod_g0_0:
# type: SMART_MOD
# props:
# algorithm-expression: '_g0db0->0,1,2,3|_g0db1->4,5,6|_g0db2->7,8,9'
alg_database_inline_g0_0:
type: INLINE
props:
algorithm-expression: rw_userdb_g0db${(id % 9) as int}
alg_table_volume_range_g0_0: # see:org.apache.shardingsphere.sharding.algorithm.sharding.range.VolumeBasedRangeShardingAlgorithm
type: VOLUME_RANGE2
props: # Must use quotation marks(string) or you cannot get them.
range-lower: '0'
range-upper: '40000000'
sharding-volume: '10000000'
keyGenerators:
gen_snowflake0:
type: SNOWFLAKE
props:
worker-id: '1' # Range[0,1024),see:org.apache.shardingsphere.sharding.algorithm.keygen.SnowflakeKeyGenerateAlgorithm#getWorkerId()
## @see:org.apache.shardingsphere.readwritesplitting.api.ReadwriteSplittingRuleConfiguration
- !READWRITE_SPLITTING
dataSources:
rw_userdb_g0db0:
writeDataSourceName: ds_userdb_g0db0_1
readDataSourceNames:
- ds_userdb_g0db0_1
- ds_userdb_g0db0_2
loadBalancerName: r_lb_0
rw_userdb_g0db1:
writeDataSourceName: ds_userdb_g0db1_1
readDataSourceNames:
- ds_userdb_g0db1_1
- ds_userdb_g0db1_2
loadBalancerName: r_lb_0
rw_userdb_g0db2:
writeDataSourceName: ds_userdb_g0db2_1
readDataSourceNames:
- ds_userdb_g0db2_1
- ds_userdb_g0db2_2
loadBalancerName: r_lb_0
loadBalancers:
r_lb_0:
type: RANDOM
## @see:org.apache.shardingsphere.readwritesplitting.api.DatabaseDiscoveryRuleConfiguration
- !DB_DISCOVERY
dataSources:
ha_userdb_g0db0:
discoveryTypeName: cn_south1_a1_mgr_g0_0
discoveryHeartbeatName: mgr_heartbeat_0
dataSourceNames:
- ds_userdb_g0db0_0
- ds_userdb_g0db0_1
- ds_userdb_g0db0_2
ha_userdb_g0db1:
discoveryTypeName: cn_south1_a1_mgr_g0_0
discoveryHeartbeatName: mgr_heartbeat_0
dataSourceNames:
- ds_userdb_g0db1_0
- ds_userdb_g0db1_1
- ds_userdb_g0db1_2
ha_userdb_g0db2:
discoveryTypeName: cn_south1_a1_mgr_g0_0
discoveryHeartbeatName: mgr_heartbeat_0
dataSourceNames:
- ds_userdb_g0db2_0
- ds_userdb_g0db2_1
- ds_userdb_g0db2_2
discoveryHeartbeats:
mgr_heartbeat_0:
props:
keep-alive-cron: '0/5 * * * * ?'
discoveryTypes:
# HA MGR architecture see: https://blog.csdn.net/n88Lpo/article/details/118315051
cn_south1_a1_mgr_g0_0:
type: MGR
props:
# Must be consistent with the MGR configuration group name.
# see: https://github.com/apache/shardingsphere/blob/5.1.0/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-provider/shardingsphere-db-discovery-mgr/src/main/java/org/apache/shardingsphere/dbdiscovery/mgr/MGRDatabaseDiscoveryType.java#L104
# see: https://github.com/mysql/mysql-server/blob/mysql-5.7.30/rapid/plugin/group_replication/src/plugin.cc#L1726
# see: SELECT * FROM performance_schema.global_variables WHERE VARIABLE_NAME='group_replication_group_name'
group-name: 5db40c3c-180c-11e9-afbf-005056ac6820
## @see:org.apache.shardingsphere.dbdiscovery.mgr.MGRDatabaseDiscoveryType#extDiscoveryConfig
extensionDiscoveryConfigJson: |-
{
"memberHostMappings": [{
"rds-mgr-0:3306": [
"n0.rds.local:3306"
]
}, {
"rds-mgr-1:3306": [
"n1.rds.local:3306"
]
}, {
"rds-mgr-2:3306": [
"n2.rds.local:3306"
]
}]
}
```
--
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] RaigorJiang closed issue #14845: In 5.1.0, how to exclude tables that do not require fragmentation and read-write separation? Are there any cases? Removed defaultDataSource property for 4.x?
Posted by GitBox <gi...@apache.org>.
RaigorJiang closed issue #14845:
URL: https://github.com/apache/shardingsphere/issues/14845
--
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] wl4g commented on issue #14845: In 5.1.0, how to exclude tables that do not require fragmentation and read-write separation? Are there any cases? Removed defaultDataSource property for 4.x?
Posted by GitBox <gi...@apache.org>.
wl4g commented on issue #14845:
URL: https://github.com/apache/shardingsphere/issues/14845#issuecomment-1015132790
```yaml
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
##################### Configuration of 'userdb' by group sharding v5.1.0 #######################
# External logical database schema.
schemaName: userdb
# Extension default datasource configuration.
# @see:com.wl4g.shardingproxy.config.ProxyConfigurationLoader2.loadRuleConfiguration
extensionDefaultDataSource:
username: root
password: 123456
connectionTimeoutMilliseconds: 30000
idleTimeoutMilliseconds: 60000
maxLifetimeMilliseconds: 1800000
maxPoolSize: 50
minPoolSize: 1
# Specification datasource configuration.
dataSources:
#################################### Sharding datasource group0 ####################################
ds_userdb_single:
url: 'jdbc:mysql://n0.rds.local:3306/userdb_single?serverTimezone=UTC&useSSL=false&allowMultiQueries=true&characterEncoding=utf-8'
ds_userdb_g0db0_0:
url: 'jdbc:mysql://n0.rds.local:3306/userdb_g0db0?serverTimezone=UTC&useSSL=false&allowMultiQueries=true&characterEncoding=utf-8'
ds_userdb_g0db0_1:
url: 'jdbc:mysql://n1.rds.local:3306/userdb_g0db0?serverTimezone=UTC&useSSL=false&allowMultiQueries=true&characterEncoding=utf-8'
ds_userdb_g0db0_2:
url: 'jdbc:mysql://n2.rds.local:3306/userdb_g0db0?serverTimezone=UTC&useSSL=false&allowMultiQueries=true&characterEncoding=utf-8'
ds_userdb_g0db1_0:
url: 'jdbc:mysql://n0.rds.local:3306/userdb_g0db1?serverTimezone=UTC&useSSL=false&allowMultiQueries=true&characterEncoding=utf-8'
ds_userdb_g0db1_1:
url: 'jdbc:mysql://n1.rds.local:3306/userdb_g0db1?serverTimezone=UTC&useSSL=false&allowMultiQueries=true&characterEncoding=utf-8'
ds_userdb_g0db1_2:
url: 'jdbc:mysql://n2.rds.local:3306/userdb_g0db1?serverTimezone=UTC&useSSL=false&allowMultiQueries=true&characterEncoding=utf-8'
ds_userdb_g0db2_0:
url: 'jdbc:mysql://n0.rds.local:3306/userdb_g0db2?serverTimezone=UTC&useSSL=false&allowMultiQueries=true&characterEncoding=utf-8'
ds_userdb_g0db2_1:
url: 'jdbc:mysql://n1.rds.local:3306/userdb_g0db2?serverTimezone=UTC&useSSL=false&allowMultiQueries=true&characterEncoding=utf-8'
ds_userdb_g0db2_2:
url: 'jdbc:mysql://n2.rds.local:3306/userdb_g0db2?serverTimezone=UTC&useSSL=false&allowMultiQueries=true&characterEncoding=utf-8'
# Schema rules configuration.
rules:
## @see:org.apache.shardingsphere.singletable.config.SingleTableRuleConfiguration
## @see:org.apache.shardingsphere.singletable.yaml.config.swapper.SingleTableRuleConfigurationYamlSwapper#getRuleTagName
- !SINGLE
defaultDataSource: ds_userdb_single
#################################### Sharding rules group0 ####################################
## @see:https://shardingsphere.apache.org/document/current/en/user-manual/shardingsphere-jdbc/builtin-algorithm/sharding/
## @see:org.apache.shardingsphere.sharding.api.config.ShardingRuleConfiguration
- !SHARDING
tables:
t_user:
actualDataNodes: rw_userdb_g0db${0..2}.t_user_${0..2}
#actualDataNodes: 'rw_userdb_g0db0.t_user_${0..3},rw_userdb_g0db1.t_user_${0..2},rw_userdb_g0db2.t_user_${0..2},rw_userdb_g0db${0..2}.t_user_${0..2}'
#databaseStrategy:
tableStrategy:
standard:
shardingColumn: id
shardingAlgorithmName: alg_table_volume_range_g0_0
keyGenerateStrategy:
column: id
keyGeneratorName: gen_snowflake0
bindingTables:
- t_user
defaultDatabaseStrategy:
standard:
shardingColumn: id
shardingAlgorithmName: alg_database_inline_g0_0
#shardingAlgorithmName: alg_complex_smart_mod_g0_0
defaultTableStrategy:
shardingAlgorithms:
#alg_complex_smart_mod_g0_0:
# type: SMART_MOD
# props:
# algorithm-expression: '_g0db0->0,1,2,3|_g0db1->4,5,6|_g0db2->7,8,9'
alg_database_inline_g0_0:
type: INLINE
props:
algorithm-expression: rw_userdb_g0db${(id % 9) as int}
alg_table_volume_range_g0_0: # see:org.apache.shardingsphere.sharding.algorithm.sharding.range.VolumeBasedRangeShardingAlgorithm
type: VOLUME_RANGE2
props: # Must use quotation marks(string) or you cannot get them.
range-lower: '0'
range-upper: '40000000'
sharding-volume: '10000000'
keyGenerators:
gen_snowflake0:
type: SNOWFLAKE
props:
worker-id: '1' # Range[0,1024),see:org.apache.shardingsphere.sharding.algorithm.keygen.SnowflakeKeyGenerateAlgorithm#getWorkerId()
## @see:org.apache.shardingsphere.readwritesplitting.api.ReadwriteSplittingRuleConfiguration
- !READWRITE_SPLITTING
dataSources:
rw_userdb_g0db0:
writeDataSourceName: ds_userdb_g0db0_1
readDataSourceNames:
- ds_userdb_g0db0_1
- ds_userdb_g0db0_2
loadBalancerName: r_lb_0
rw_userdb_g0db1:
writeDataSourceName: ds_userdb_g0db1_1
readDataSourceNames:
- ds_userdb_g0db1_1
- ds_userdb_g0db1_2
loadBalancerName: r_lb_0
rw_userdb_g0db2:
writeDataSourceName: ds_userdb_g0db2_1
readDataSourceNames:
- ds_userdb_g0db2_1
- ds_userdb_g0db2_2
loadBalancerName: r_lb_0
loadBalancers:
r_lb_0:
type: RANDOM
## @see:org.apache.shardingsphere.readwritesplitting.api.DatabaseDiscoveryRuleConfiguration
- !DB_DISCOVERY
dataSources:
ha_userdb_g0db0:
discoveryTypeName: cn_south1_a1_mgr_g0_0
discoveryHeartbeatName: mgr_heartbeat_0
dataSourceNames:
- ds_userdb_g0db0_0
- ds_userdb_g0db0_1
- ds_userdb_g0db0_2
ha_userdb_g0db1:
discoveryTypeName: cn_south1_a1_mgr_g0_0
discoveryHeartbeatName: mgr_heartbeat_0
dataSourceNames:
- ds_userdb_g0db1_0
- ds_userdb_g0db1_1
- ds_userdb_g0db1_2
ha_userdb_g0db2:
discoveryTypeName: cn_south1_a1_mgr_g0_0
discoveryHeartbeatName: mgr_heartbeat_0
dataSourceNames:
- ds_userdb_g0db2_0
- ds_userdb_g0db2_1
- ds_userdb_g0db2_2
discoveryHeartbeats:
mgr_heartbeat_0:
props:
keep-alive-cron: '0/5 * * * * ?'
discoveryTypes:
# HA MGR architecture see: https://blog.csdn.net/n88Lpo/article/details/118315051
cn_south1_a1_mgr_g0_0:
type: MGR
props:
# Must be consistent with the MGR configuration group name.
# see: https://github.com/apache/shardingsphere/blob/5.1.0/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-provider/shardingsphere-db-discovery-mgr/src/main/java/org/apache/shardingsphere/dbdiscovery/mgr/MGRDatabaseDiscoveryType.java#L104
# see: https://github.com/mysql/mysql-server/blob/mysql-5.7.30/rapid/plugin/group_replication/src/plugin.cc#L1726
# see: SELECT * FROM performance_schema.global_variables WHERE VARIABLE_NAME='group_replication_group_name'
group-name: 5db40c3c-180c-11e9-afbf-005056ac6820
## @see:org.apache.shardingsphere.dbdiscovery.mgr.MGRDatabaseDiscoveryType#extDiscoveryConfig
extensionDiscoveryConfigJson: |-
{
"memberHostMappings": [{
"rds-mgr-0:3306": [
"n0.rds.local:3306"
]
}, {
"rds-mgr-1:3306": [
"n1.rds.local:3306"
]
}, {
"rds-mgr-2:3306": [
"n2.rds.local:3306"
]
}]
}
```
--
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] wl4g edited a comment on issue #14845: In 5.1.0, how to exclude tables that do not require fragmentation and read-write separation? Are there any cases? Removed defaultDataSource property for 4.x?
Posted by GitBox <gi...@apache.org>.
wl4g edited a comment on issue #14845:
URL: https://github.com/apache/shardingsphere/issues/14845#issuecomment-1015132317
Ok, The experiment was successful, thank you very much! @RaigorJiang
--
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] wl4g commented on issue #14845: In 5.1.0, how to exclude tables that do not require fragmentation and read-write separation? Are there any cases? Removed defaultDataSource property for 4.x?
Posted by GitBox <gi...@apache.org>.
wl4g commented on issue #14845:
URL: https://github.com/apache/shardingsphere/issues/14845#issuecomment-1015132317
Ok, The experiment was successful, thank you very much!
--
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