From a94d3ebae31793e1f55be7e51e4c43c33a5a2e64 Mon Sep 17 00:00:00 2001 From: totalo Date: Mon, 25 Sep 2023 10:43:35 -0500 Subject: [PATCH] Remove outdated docker examples (#28581) --- examples/docker/docker-compose-zh.md | 21 -- examples/docker/docker-compose.md | 21 -- .../governance/docker-compose.yml | 42 ---- .../shardingsphere-proxy/governance/run.sh | 19 -- .../shardingsphere-proxy/governance/stop.sh | 19 -- .../sharding/conf/config-sharding.yaml | 94 --------- .../sharding/conf/server.yaml | 43 ---- .../sharding/docker-compose.yml | 57 ----- examples/docker/tools/wait-for-it.sh | 195 ------------------ 9 files changed, 511 deletions(-) delete mode 100644 examples/docker/docker-compose-zh.md delete mode 100644 examples/docker/docker-compose.md delete mode 100644 examples/docker/shardingsphere-proxy/governance/docker-compose.yml delete mode 100644 examples/docker/shardingsphere-proxy/governance/run.sh delete mode 100644 examples/docker/shardingsphere-proxy/governance/stop.sh delete mode 100644 examples/docker/shardingsphere-proxy/sharding/conf/config-sharding.yaml delete mode 100644 examples/docker/shardingsphere-proxy/sharding/conf/server.yaml delete mode 100644 examples/docker/shardingsphere-proxy/sharding/docker-compose.yml delete mode 100755 examples/docker/tools/wait-for-it.sh diff --git a/examples/docker/docker-compose-zh.md b/examples/docker/docker-compose-zh.md deleted file mode 100644 index 3ed0ae6d39d90..0000000000000 --- a/examples/docker/docker-compose-zh.md +++ /dev/null @@ -1,21 +0,0 @@ -## 使用docker-compose初始化开始环境 - -在开始使用docker compose之前,根据下述参考网址安装docker和docker-compose:https://docs.docker.com/compose/install/ - -#### ShardingSphere-JDBC - -1. 运行 'cd docker/shardingsphere-jdbc/sharding',进入 docker 文件夹 -2. 运行 'docker-compose up -d',启动 docker compose 环境 -3. 根据需要,开启 mysql/etcd/zookeeper -4. 如果有端口冲突,在 docker-compose.yml 中修改相应的端口,然后再次使用 'docker-compose up -d' 启动 docker compose -5. 如果需要关闭程序,请使用命令 'docker-compose down' - -#### ShardingSphere-Proxy - -1. 运行 'cd docker/shardingsphere-proxy/sharding',进入 docker 文件夹 -2. 运行 'docker-compose up -d',启动 docker compose 环境 -3. 运行 `psql -d sharding_db -h 127.0.0.1 -U root -p 3308 -W` 登录代理, 示例的默认密码:root -4. 如果有端口冲突,在docker-compose.yml中修改相应的端口,然后再次使用 'docker-compose up -d'启动docker compose -5. 如果需要关闭程序,请使用命令 'docker-compose down' - -需要注意,请谨慎使用 docker 删除指令`docker ps -a -q`去删除docker容器。 diff --git a/examples/docker/docker-compose.md b/examples/docker/docker-compose.md deleted file mode 100644 index ceda43fabffbe..0000000000000 --- a/examples/docker/docker-compose.md +++ /dev/null @@ -1,21 +0,0 @@ -## Using docker-compose to config startup environment - -before we use docker compose, please install docker and docker-compose first : https://docs.docker.com/compose/install/ - -#### ShardingSphere-JDBC - -1. access the docker folder (cd docker/shardingsphere-jdbc/sharding) -2. launch the environment by docker compose (docker-compose up -d) -3. access mysql / etcd / zookeeper as you want -4. if there is conflict on port, just modify the corresponding port defined in docker-compose.yml and then launch docker compose again(docker-compose up -d) -5. if you want to stop the environment, use command docker-compose down - -#### ShardingSphere-Proxy - -1. access the docker folder (cd docker/shardingsphere-proxy/sharding) -2. launch the environment by docker compose (docker-compose up -d) -3. access proxy by `psql -d sharding_db -h 127.0.0.1 -U root -p 3308 -W`, default password for example: root -4. if there is conflict on port, just modify the corresponding port defined in docker-compose.yml and then launch docker compose again(docker-compose up -d) -5. if you want to stop the environment, use command docker-compose down - -to clean the docker container , you could use docker rm `docker ps -a -q` (be careful) diff --git a/examples/docker/shardingsphere-proxy/governance/docker-compose.yml b/examples/docker/shardingsphere-proxy/governance/docker-compose.yml deleted file mode 100644 index 7acfd46ad1bb6..0000000000000 --- a/examples/docker/shardingsphere-proxy/governance/docker-compose.yml +++ /dev/null @@ -1,42 +0,0 @@ -# -# 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. -# - -version: '3' -services: - zookeeper: - ## get more versions of zookeeper here : https://hub.docker.com/_/zookeeper?tab=tags - image: "zookeeper:3.4" - ports: - - "2181:2181" - container_name: shardingsphere-example-zookeeper - - etcd: - ## get more versions of etcd here : https://quay.io/repository/coreos/etcd?tag=latest&tab=tags - image: "quay.io/coreos/etcd:v3.3.12" - ports: - - "2379:2379" - - "2380:2380" - - "4001:4001" - container_name: shardingsphere-example-etcd - entrypoint: /usr/local/bin/etcd - command: - - '--advertise-client-urls=http://0.0.0.0:2379' - - '--listen-client-urls=http://0.0.0.0:2379' - - '--initial-advertise-peer-urls=http://0.0.0.0:2380' - - '--listen-peer-urls=http://0.0.0.0:2380' - - '--initial-cluster' - - 'default=http://0.0.0.0:2380' diff --git a/examples/docker/shardingsphere-proxy/governance/run.sh b/examples/docker/shardingsphere-proxy/governance/run.sh deleted file mode 100644 index 235d08e27b914..0000000000000 --- a/examples/docker/shardingsphere-proxy/governance/run.sh +++ /dev/null @@ -1,19 +0,0 @@ -#!/usr/bin/env bash -# -# 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. -# - -docker-compose up -d diff --git a/examples/docker/shardingsphere-proxy/governance/stop.sh b/examples/docker/shardingsphere-proxy/governance/stop.sh deleted file mode 100644 index fcf30fdd28f4e..0000000000000 --- a/examples/docker/shardingsphere-proxy/governance/stop.sh +++ /dev/null @@ -1,19 +0,0 @@ -#!/usr/bin/env bash -# -# 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. -# - -docker-compose down diff --git a/examples/docker/shardingsphere-proxy/sharding/conf/config-sharding.yaml b/examples/docker/shardingsphere-proxy/sharding/conf/config-sharding.yaml deleted file mode 100644 index 4a9a1b5531c10..0000000000000 --- a/examples/docker/shardingsphere-proxy/sharding/conf/config-sharding.yaml +++ /dev/null @@ -1,94 +0,0 @@ -# -# 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. -# -###################################################################################################### - -databaseName: sharding_db - -dataSources: - ds_0: - url: jdbc:postgresql://shardingsphere-example-postgres:5432/demo_ds_0?useUnicode=true&characterEncoding=utf-8&allowEncodingChanges=true - username: postgres - password: postgres - connectionTimeoutMilliseconds: 30000 - idleTimeoutMilliseconds: 60000 - maxLifetimeMilliseconds: 1800000 - maxPoolSize: 50 - ds_1: - url: jdbc:postgresql://shardingsphere-example-postgres:5432/demo_ds_1?useUnicode=true&characterEncoding=utf-8&allowEncodingChanges=true - username: postgres - password: postgres - connectionTimeoutMilliseconds: 30000 - idleTimeoutMilliseconds: 60000 - maxLifetimeMilliseconds: 1800000 - maxPoolSize: 50 - -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_id - keyGeneratorName: snowflake - - bindingTables: - - t_order,t_order_item - - defaultDatabaseStrategy: - standard: - shardingColumn: user_id - shardingAlgorithmName: database_inline - - defaultTableStrategy: - 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 \ No newline at end of file diff --git a/examples/docker/shardingsphere-proxy/sharding/conf/server.yaml b/examples/docker/shardingsphere-proxy/sharding/conf/server.yaml deleted file mode 100644 index ffd2f1e2c785a..0000000000000 --- a/examples/docker/shardingsphere-proxy/sharding/conf/server.yaml +++ /dev/null @@ -1,43 +0,0 @@ -# -# 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. -# - -###################################################################################################### -# -# If you want to configure governance, authorization and proxy properties, please refer to this file. -# -###################################################################################################### - -#mode: -# type: Cluster -# repository: -# type: ZooKeeper -# props: -# namespace: governance_ds -# server-lists: localhost:2181 - -authority: - users: - - user: root - password: root - privilege: - type: ALL_PERMITTED - -props: - max-connections-size-per-query: 1 - kernel-executor-size: 16 # Infinite by default. - proxy-frontend-flush-threshold: 128 # The default value is 128. - sql-show: true diff --git a/examples/docker/shardingsphere-proxy/sharding/docker-compose.yml b/examples/docker/shardingsphere-proxy/sharding/docker-compose.yml deleted file mode 100644 index bb0153ac4e1cd..0000000000000 --- a/examples/docker/shardingsphere-proxy/sharding/docker-compose.yml +++ /dev/null @@ -1,57 +0,0 @@ -# -# 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. -# - -version: '3' -services: - postgres: - ## for different postgres version, you could get more at here : https://hub.docker.com/_/postgres?tab=tags - image: "postgres:latest" - ## port binding to 5432, you could change to 15432:5432 or any other available port you want - ports: - - "5432:5432" - container_name: shardingsphere-example-postgres - ## you could access Postgres like `psql -d your_database_name -h 127.0.0.1 -U root -p 5432 -W` - environment: - - TZ=Asia/Shanghai - - POSTGRES_USER=postgres - - POSTGRES_PASSWORD=postgres - ## copy the manual_schema.sql to /docker-entrypoint-initdb.d/ . this will init the sql file when the Postgres in container start up - volumes: - - ../../../src/resources/manual_schema.sql:/docker-entrypoint-initdb.d/manual_schema.sql - - proxy: - ## get more versions of proxy here : https://hub.docker.com/r/apache/shardingsphere-proxy/tags - image: "apache/shardingsphere-proxy:latest" - container_name: shardingsphere-example-proxy - depends_on: - - postgres - ## wait-for-it.sh will make proxy entry point wait until Postgres container 5432 port open - entrypoint: > - /bin/sh -c "/opt/wait-for-it.sh shardingsphere-example-postgres:5432 --timeout=20 --strict -- - && /opt/shardingsphere-proxy/bin/start.sh 3308 - && tail -f /opt/shardingsphere-proxy/logs/stdout.log" - ports: - - "3308:3308" - links: - - "postgres:postgres" - volumes: - - ./conf/:/opt/shardingsphere-proxy/conf - - ../../tools/wait-for-it.sh:/opt/wait-for-it.sh - environment: - - JVM_OPTS="-Djava.awt.headless=true" - - diff --git a/examples/docker/tools/wait-for-it.sh b/examples/docker/tools/wait-for-it.sh deleted file mode 100755 index b4bf36b306f2b..0000000000000 --- a/examples/docker/tools/wait-for-it.sh +++ /dev/null @@ -1,195 +0,0 @@ -#!/usr/bin/env bash -# -# 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. -# - -# Use this script to test if a given TCP host/port are available - -WAITFORIT_cmdname=${0##*/} - -echoerr() { if [[ $WAITFORIT_QUIET -ne 1 ]]; then echo "$@" 1>&2; fi } - -usage() -{ - cat << USAGE >&2 -Usage: - $WAITFORIT_cmdname host:port [-s] [-t timeout] [-- command args] - -h HOST | --host=HOST Host or IP under test - -p PORT | --port=PORT TCP port under test - Alternatively, you specify the host and port as host:port - -s | --strict Only execute subcommand if the test succeeds - -q | --quiet Don't output any status messages - -t TIMEOUT | --timeout=TIMEOUT - Timeout in seconds, zero for no timeout - -- COMMAND ARGS Execute command with args after the test finishes -USAGE - exit 1 -} - -wait_for() -{ - if [[ $WAITFORIT_TIMEOUT -gt 0 ]]; then - echoerr "$WAITFORIT_cmdname: waiting $WAITFORIT_TIMEOUT seconds for $WAITFORIT_HOST:$WAITFORIT_PORT" - else - echoerr "$WAITFORIT_cmdname: waiting for $WAITFORIT_HOST:$WAITFORIT_PORT without a timeout" - fi - WAITFORIT_start_ts=$(date +%s) - while : - do - if [[ $WAITFORIT_ISBUSY -eq 1 ]]; then - nc -z $WAITFORIT_HOST $WAITFORIT_PORT - WAITFORIT_result=$? - else - (echo > /dev/tcp/$WAITFORIT_HOST/$WAITFORIT_PORT) >/dev/null 2>&1 - WAITFORIT_result=$? - fi - if [[ $WAITFORIT_result -eq 0 ]]; then - WAITFORIT_end_ts=$(date +%s) - echoerr "$WAITFORIT_cmdname: $WAITFORIT_HOST:$WAITFORIT_PORT is available after $((WAITFORIT_end_ts - WAITFORIT_start_ts)) seconds" - break - fi - sleep 1 - done - return $WAITFORIT_result -} - -wait_for_wrapper() -{ - # In order to support SIGINT during timeout: http://unix.stackexchange.com/a/57692 - if [[ $WAITFORIT_QUIET -eq 1 ]]; then - timeout $WAITFORIT_BUSYTIMEFLAG $WAITFORIT_TIMEOUT $0 --quiet --child --host=$WAITFORIT_HOST --port=$WAITFORIT_PORT --timeout=$WAITFORIT_TIMEOUT & - else - timeout $WAITFORIT_BUSYTIMEFLAG $WAITFORIT_TIMEOUT $0 --child --host=$WAITFORIT_HOST --port=$WAITFORIT_PORT --timeout=$WAITFORIT_TIMEOUT & - fi - WAITFORIT_PID=$! - trap "kill -INT -$WAITFORIT_PID" INT - wait $WAITFORIT_PID - WAITFORIT_RESULT=$? - if [[ $WAITFORIT_RESULT -ne 0 ]]; then - echoerr "$WAITFORIT_cmdname: timeout occurred after waiting $WAITFORIT_TIMEOUT seconds for $WAITFORIT_HOST:$WAITFORIT_PORT" - fi - return $WAITFORIT_RESULT -} - -# process arguments -while [[ $# -gt 0 ]] -do - case "$1" in - *:* ) - WAITFORIT_hostport=(${1//:/ }) - WAITFORIT_HOST=${WAITFORIT_hostport[0]} - WAITFORIT_PORT=${WAITFORIT_hostport[1]} - shift 1 - ;; - --child) - WAITFORIT_CHILD=1 - shift 1 - ;; - -q | --quiet) - WAITFORIT_QUIET=1 - shift 1 - ;; - -s | --strict) - WAITFORIT_STRICT=1 - shift 1 - ;; - -h) - WAITFORIT_HOST="$2" - if [[ $WAITFORIT_HOST == "" ]]; then break; fi - shift 2 - ;; - --host=*) - WAITFORIT_HOST="${1#*=}" - shift 1 - ;; - -p) - WAITFORIT_PORT="$2" - if [[ $WAITFORIT_PORT == "" ]]; then break; fi - shift 2 - ;; - --port=*) - WAITFORIT_PORT="${1#*=}" - shift 1 - ;; - -t) - WAITFORIT_TIMEOUT="$2" - if [[ $WAITFORIT_TIMEOUT == "" ]]; then break; fi - shift 2 - ;; - --timeout=*) - WAITFORIT_TIMEOUT="${1#*=}" - shift 1 - ;; - --) - shift - WAITFORIT_CLI=("$@") - break - ;; - --help) - usage - ;; - *) - echoerr "Unknown argument: $1" - usage - ;; - esac -done - -if [[ "$WAITFORIT_HOST" == "" || "$WAITFORIT_PORT" == "" ]]; then - echoerr "Error: you need to provide a host and port to test." - usage -fi - -WAITFORIT_TIMEOUT=${WAITFORIT_TIMEOUT:-15} -WAITFORIT_STRICT=${WAITFORIT_STRICT:-0} -WAITFORIT_CHILD=${WAITFORIT_CHILD:-0} -WAITFORIT_QUIET=${WAITFORIT_QUIET:-0} - -# check to see if timeout is from busybox? -WAITFORIT_TIMEOUT_PATH=$(type -p timeout) -WAITFORIT_TIMEOUT_PATH=$(realpath $WAITFORIT_TIMEOUT_PATH 2>/dev/null || readlink -f $WAITFORIT_TIMEOUT_PATH) -if [[ $WAITFORIT_TIMEOUT_PATH =~ "busybox" ]]; then - WAITFORIT_ISBUSY=1 - WAITFORIT_BUSYTIMEFLAG="-t" - -else - WAITFORIT_ISBUSY=0 - WAITFORIT_BUSYTIMEFLAG="" -fi - -if [[ $WAITFORIT_CHILD -gt 0 ]]; then - wait_for - WAITFORIT_RESULT=$? - exit $WAITFORIT_RESULT -else - if [[ $WAITFORIT_TIMEOUT -gt 0 ]]; then - wait_for_wrapper - WAITFORIT_RESULT=$? - else - wait_for - WAITFORIT_RESULT=$? - fi -fi - -if [[ $WAITFORIT_CLI != "" ]]; then - if [[ $WAITFORIT_RESULT -ne 0 && $WAITFORIT_STRICT -eq 1 ]]; then - echoerr "$WAITFORIT_cmdname: strict mode, refusing to execute subprocess" - exit $WAITFORIT_RESULT - fi - exec "${WAITFORIT_CLI[@]}" -else - exit $WAITFORIT_RESULT -fi