You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by zh...@apache.org on 2021/09/17 04:24:09 UTC
[shardingsphere] branch master updated: Add sharding and
readwrite-splitting example conf for proxy. (#12508)
This is an automated email from the ASF dual-hosted git repository.
zhangliang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git
The following commit(s) were added to refs/heads/master by this push:
new e6dad7a Add sharding and readwrite-splitting example conf for proxy. (#12508)
e6dad7a is described below
commit e6dad7a5e1cc431167679bcd9fc3645fa9111e3d
Author: Guocheng Tang <to...@qq.com>
AuthorDate: Fri Sep 17 12:23:35 2021 +0800
Add sharding and readwrite-splitting example conf for proxy. (#12508)
* Add sharding and readwrite-splitting example conf for proxy.
* Remove useless blank line and fix ci error.
* Remove useless blank line and fix ci error.
* Remove useless blank line and fix ci error.
* Add new line.
---
examples/shardingsphere-proxy-example/pom.xml | 2 +
.../pom.xml | 9 +-
.../pom.xml | 11 +--
.../resources/conf/config-readwrite-splitting.yaml | 62 ++++++++++++
.../src/main/resources/conf/server.yaml | 39 ++++++++
.../pom.xml | 10 +-
.../src/main/resources/conf/config-sharding.yaml | 106 +++++++++++++++++++++
.../src/main/resources/conf/server.yaml | 39 ++++++++
8 files changed, 257 insertions(+), 21 deletions(-)
diff --git a/examples/shardingsphere-proxy-example/pom.xml b/examples/shardingsphere-proxy-example/pom.xml
index 32824eb..30c022b 100644
--- a/examples/shardingsphere-proxy-example/pom.xml
+++ b/examples/shardingsphere-proxy-example/pom.xml
@@ -32,5 +32,7 @@
<modules>
<module>shardingsphere-proxy-boot-mybatis-example</module>
<module>shardingsphere-proxy-hint-example</module>
+ <module>shardingsphere-proxy-memory-example</module>
</modules>
</project>
+
diff --git a/examples/shardingsphere-proxy-example/pom.xml b/examples/shardingsphere-proxy-example/shardingsphere-proxy-memory-example/pom.xml
similarity index 82%
copy from examples/shardingsphere-proxy-example/pom.xml
copy to examples/shardingsphere-proxy-example/shardingsphere-proxy-memory-example/pom.xml
index 32824eb..e5088cb 100644
--- a/examples/shardingsphere-proxy-example/pom.xml
+++ b/examples/shardingsphere-proxy-example/shardingsphere-proxy-memory-example/pom.xml
@@ -22,15 +22,16 @@
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.apache.shardingsphere.example</groupId>
- <artifactId>shardingsphere-example</artifactId>
+ <artifactId>shardingsphere-proxy-example</artifactId>
<version>5.0.0-RC1-SNAPSHOT</version>
</parent>
- <artifactId>shardingsphere-proxy-example</artifactId>
+ <artifactId>shardingsphere-proxy-memory-example</artifactId>
<packaging>pom</packaging>
<name>${project.artifactId}</name>
<modules>
- <module>shardingsphere-proxy-boot-mybatis-example</module>
- <module>shardingsphere-proxy-hint-example</module>
+ <module>shardingsphere-proxy-memory-local-sharding-example</module>
+ <module>shardingsphere-proxy-memory-local-readwrite-splitting-example</module>
</modules>
+
</project>
diff --git a/examples/shardingsphere-proxy-example/pom.xml b/examples/shardingsphere-proxy-example/shardingsphere-proxy-memory-example/shardingsphere-proxy-memory-local-readwrite-splitting-example/pom.xml
similarity index 78%
copy from examples/shardingsphere-proxy-example/pom.xml
copy to examples/shardingsphere-proxy-example/shardingsphere-proxy-memory-example/shardingsphere-proxy-memory-local-readwrite-splitting-example/pom.xml
index 32824eb..759b281 100644
--- a/examples/shardingsphere-proxy-example/pom.xml
+++ b/examples/shardingsphere-proxy-example/shardingsphere-proxy-memory-example/shardingsphere-proxy-memory-local-readwrite-splitting-example/pom.xml
@@ -22,15 +22,8 @@
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.apache.shardingsphere.example</groupId>
- <artifactId>shardingsphere-example</artifactId>
+ <artifactId>shardingsphere-proxy-memory-example</artifactId>
<version>5.0.0-RC1-SNAPSHOT</version>
</parent>
- <artifactId>shardingsphere-proxy-example</artifactId>
- <packaging>pom</packaging>
- <name>${project.artifactId}</name>
-
- <modules>
- <module>shardingsphere-proxy-boot-mybatis-example</module>
- <module>shardingsphere-proxy-hint-example</module>
- </modules>
+ <artifactId>shardingsphere-proxy-memory-local-readwrite-splitting-example</artifactId>
</project>
diff --git a/examples/shardingsphere-proxy-example/shardingsphere-proxy-memory-example/shardingsphere-proxy-memory-local-readwrite-splitting-example/src/main/resources/conf/config-readwrite-splitting.yaml b/examples/shardingsphere-proxy-example/shardingsphere-proxy-memory-example/shardingsphere-proxy-memory-local-readwrite-splitting-example/src/main/resources/conf/config-readwrite-splitting.yaml
new file mode 100644
index 0000000..1261433
--- /dev/null
+++ b/examples/shardingsphere-proxy-example/shardingsphere-proxy-memory-example/shardingsphere-proxy-memory-local-readwrite-splitting-example/src/main/resources/conf/config-readwrite-splitting.yaml
@@ -0,0 +1,62 @@
+#
+# 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.
+#
+
+schemaName: readwrite-splitting_db
+
+dataSources:
+ write_ds:
+ url: jdbc:mysql://127.0.0.1:3306/demo_write_ds?serverTimezone=UTC&useSSL=false
+ username: root
+ password:
+ connectionTimeoutMilliseconds: 30000
+ idleTimeoutMilliseconds: 60000
+ maxLifetimeMilliseconds: 1800000
+ maxPoolSize: 50
+ minPoolSize: 1
+ read_ds_0:
+ url: jdbc:mysql://127.0.0.1:3306/demo_read_ds_0?serverTimezone=UTC&useSSL=false
+ username: root
+ password:
+ connectionTimeoutMilliseconds: 30000
+ idleTimeoutMilliseconds: 60000
+ maxLifetimeMilliseconds: 1800000
+ maxPoolSize: 50
+ minPoolSize: 1
+ read_ds_1:
+ url: jdbc:mysql://127.0.0.1:3306/demo_read_ds_1?serverTimezone=UTC&useSSL=false
+ username: root
+ password:
+ connectionTimeoutMilliseconds: 30000
+ idleTimeoutMilliseconds: 60000
+ maxLifetimeMilliseconds: 1800000
+ maxPoolSize: 50
+ minPoolSize: 1
+
+rules:
+- !READWRITE_SPLITTING
+ dataSources:
+ pr_ds:
+ writeDataSourceName: write_ds
+ readDataSourceNames:
+ - read_ds_0
+ - read_ds_1
+ loadBalancerName: read_balance
+ queryConsistent: false
+
+ loadBalancers:
+ read_balance:
+ type: ROUND_ROBIN
diff --git a/examples/shardingsphere-proxy-example/shardingsphere-proxy-memory-example/shardingsphere-proxy-memory-local-readwrite-splitting-example/src/main/resources/conf/server.yaml b/examples/shardingsphere-proxy-example/shardingsphere-proxy-memory-example/shardingsphere-proxy-memory-local-readwrite-splitting-example/src/main/resources/conf/server.yaml
new file mode 100644
index 0000000..ed3c912
--- /dev/null
+++ b/examples/shardingsphere-proxy-example/shardingsphere-proxy-memory-example/shardingsphere-proxy-memory-local-readwrite-splitting-example/src/main/resources/conf/server.yaml
@@ -0,0 +1,39 @@
+#
+# 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.
+#
+
+# Memory mode is the default mode, you can ignore this configuration.
+mode:
+ type: Memory
+
+rules:
+ - !AUTHORITY
+ users:
+ - root@:root
+ - sharding@:sharding
+ provider:
+ type: NATIVE
+
+props:
+ max-connections-size-per-query: 1
+ executor-size: 16 # Infinite by default.
+ proxy-frontend-flush-threshold: 128 # The default value is 128.
+ proxy-opentracing-enabled: false
+ proxy-hint-enabled: false
+ sql-show: false
+ check-table-metadata-enabled: false
+ sql-simple: false
+ check-duplicate-table-enabled: false
diff --git a/examples/shardingsphere-proxy-example/pom.xml b/examples/shardingsphere-proxy-example/shardingsphere-proxy-memory-example/shardingsphere-proxy-memory-local-sharding-example/pom.xml
similarity index 81%
copy from examples/shardingsphere-proxy-example/pom.xml
copy to examples/shardingsphere-proxy-example/shardingsphere-proxy-memory-example/shardingsphere-proxy-memory-local-sharding-example/pom.xml
index 32824eb..948de1d 100644
--- a/examples/shardingsphere-proxy-example/pom.xml
+++ b/examples/shardingsphere-proxy-example/shardingsphere-proxy-memory-example/shardingsphere-proxy-memory-local-sharding-example/pom.xml
@@ -22,15 +22,9 @@
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.apache.shardingsphere.example</groupId>
- <artifactId>shardingsphere-example</artifactId>
+ <artifactId>shardingsphere-proxy-memory-example</artifactId>
<version>5.0.0-RC1-SNAPSHOT</version>
</parent>
- <artifactId>shardingsphere-proxy-example</artifactId>
- <packaging>pom</packaging>
+ <artifactId>shardingsphere-proxy-memory-local-sharding-example</artifactId>
<name>${project.artifactId}</name>
-
- <modules>
- <module>shardingsphere-proxy-boot-mybatis-example</module>
- <module>shardingsphere-proxy-hint-example</module>
- </modules>
</project>
diff --git a/examples/shardingsphere-proxy-example/shardingsphere-proxy-memory-example/shardingsphere-proxy-memory-local-sharding-example/src/main/resources/conf/config-sharding.yaml b/examples/shardingsphere-proxy-example/shardingsphere-proxy-memory-example/shardingsphere-proxy-memory-local-sharding-example/src/main/resources/conf/config-sharding.yaml
new file mode 100644
index 0000000..45bddb6
--- /dev/null
+++ b/examples/shardingsphere-proxy-example/shardingsphere-proxy-memory-example/shardingsphere-proxy-memory-local-sharding-example/src/main/resources/conf/config-sharding.yaml
@@ -0,0 +1,106 @@
+#
+# 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.
+#
+
+######################################################################################################
+#
+# Here you can configure the rules for the proxy.
+# This example is configuration of sharding rule.
+#
+######################################################################################################
+
+schemaName: sharding_db
+
+dataSources:
+ ds_0:
+ url: jdbc:mysql://127.0.0.1:3306/demo_ds_0?serverTimezone=UTC&useSSL=false
+ username: root
+ password:
+ connectionTimeoutMilliseconds: 30000
+ idleTimeoutMilliseconds: 60000
+ maxLifetimeMilliseconds: 1800000
+ maxPoolSize: 50
+ minPoolSize: 1
+ ds_1:
+ url: jdbc:mysql://127.0.0.1:3306/demo_ds_1?serverTimezone=UTC&useSSL=false
+ username: root
+ password:
+ connectionTimeoutMilliseconds: 30000
+ idleTimeoutMilliseconds: 60000
+ maxLifetimeMilliseconds: 1800000
+ maxPoolSize: 50
+ minPoolSize: 1
+
+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
+ 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
+ autoTables:
+ t_order_auto:
+ actualDataSources: ds_0
+ shardingStrategy:
+ standard:
+ shardingColumn: user_id
+ shardingAlgorithmName: t_order_inline
+ bindingTables:
+ - t_order,t_order_item
+ broadcastTables:
+ - t_address
+ defaultDatabaseStrategy:
+ standard:
+ shardingColumn: user_id
+ shardingAlgorithmName: database_inline
+ defaultTableStrategy:
+ none:
+ defaultKeyGenerateStrategy:
+ none:
+
+ 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:
+ type: SNOWFLAKE
+ props:
+ worker-id: 123
diff --git a/examples/shardingsphere-proxy-example/shardingsphere-proxy-memory-example/shardingsphere-proxy-memory-local-sharding-example/src/main/resources/conf/server.yaml b/examples/shardingsphere-proxy-example/shardingsphere-proxy-memory-example/shardingsphere-proxy-memory-local-sharding-example/src/main/resources/conf/server.yaml
new file mode 100644
index 0000000..6fe73ea
--- /dev/null
+++ b/examples/shardingsphere-proxy-example/shardingsphere-proxy-memory-example/shardingsphere-proxy-memory-local-sharding-example/src/main/resources/conf/server.yaml
@@ -0,0 +1,39 @@
+#
+# 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.
+#
+
+# Memory mode is the default mode, you don’t need to configure it.
+mode:
+ type: Memory
+
+rules:
+ - !AUTHORITY
+ users:
+ - root@:root
+ - sharding@:sharding
+ provider:
+ type: NATIVE
+
+props:
+ max-connections-size-per-query: 1
+ executor-size: 16 # Infinite by default.
+ proxy-frontend-flush-threshold: 128 # The default value is 128.
+ proxy-opentracing-enabled: false
+ proxy-hint-enabled: false
+ sql-show: false
+ check-table-metadata-enabled: false
+ sql-simple: false
+ check-duplicate-table-enabled: false