Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
apache
Shardingsphere
提交
ba7baf5a
Shardingsphere
项目概览
apache
/
Shardingsphere
通知
56
Star
3
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
Shardingsphere
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
ba7baf5a
编写于
3月 14, 2019
作者:
C
cherrylzhao
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'taojintianxia-docker-enhancement-proxy-environment' into dev
上级
20a83936
2a1e0b61
变更
5
显示空白变更内容
内联
并排
Showing
5 changed file
with
306 addition
and
4 deletion
+306
-4
docker/sharding-jdbc/sharding/docker-compose.yml
docker/sharding-jdbc/sharding/docker-compose.yml
+4
-4
docker/sharding-proxy/sharding/conf/config-sharding.yaml
docker/sharding-proxy/sharding/conf/config-sharding.yaml
+55
-0
docker/sharding-proxy/sharding/conf/server.yaml
docker/sharding-proxy/sharding/conf/server.yaml
+28
-0
docker/sharding-proxy/sharding/docker-compose.yml
docker/sharding-proxy/sharding/docker-compose.yml
+41
-0
docker/tools/wait-for-it.sh
docker/tools/wait-for-it.sh
+178
-0
未找到文件。
docker/docker-compose.yml
→
docker/
sharding-jdbc/sharding/
docker-compose.yml
浏览文件 @
ba7baf5a
...
...
@@ -3,7 +3,7 @@ services:
mysql
:
## mysql version, you could get more tags at here : https://hub.docker.com/_/mysql?tab=tags
image
:
"
mysql:5.7"
##
hos
t port is 3306, you could change to 33060 or any other port doesn't conflict MySQL on your OS
##
defaul
t port is 3306, you could change to 33060 or any other port doesn't conflict MySQL on your OS
ports
:
-
"
3306:3306"
container_name
:
sharding-sphere-mysql
...
...
@@ -15,7 +15,7 @@ services:
## if you insist to use password in mysql, remove MYSQL_ALLOW_EMPTY_PASSWORD=yes and uncomment following args
# - MYSQL_ROOT_PASSWORD=root
volumes
:
-
../src/resources/manual_schema.sql:/docker-entrypoint-initdb.d/manual_schema.sql
-
../
../../
src/resources/manual_schema.sql:/docker-entrypoint-initdb.d/manual_schema.sql
zookeeper
:
## get more versions of zookeeper here : https://hub.docker.com/_/zookeeper?tab=tags
...
...
docker/sharding-proxy/sharding/conf/config-sharding.yaml
0 → 100644
浏览文件 @
ba7baf5a
######################################################################################################
#
# Here you can configure the rules for the proxy.
# This example is configuration of sharding rule.
#
# If you want to use sharding, please refer to this file;
# if you want to use master-slave, please refer to the config-master_slave.yaml.
#
######################################################################################################
schemaName
:
sharding_db
dataSources
:
ds_0
:
url
:
jdbc:mysql://sharding-sphere-mysql:3306/demo_ds_0?serverTimezone=UTC&useSSL=false
username
:
root
password
:
connectionTimeoutMilliseconds
:
30000
idleTimeoutMilliseconds
:
60000
maxLifetimeMilliseconds
:
1800000
maxPoolSize
:
50
ds_1
:
url
:
jdbc:mysql://sharding-sphere-mysql:3306/demo_ds_1?serverTimezone=UTC&useSSL=false
username
:
root
password
:
connectionTimeoutMilliseconds
:
30000
idleTimeoutMilliseconds
:
60000
maxLifetimeMilliseconds
:
1800000
maxPoolSize
:
50
shardingRule
:
tables
:
t_order
:
actualDataNodes
:
ds_${0..1}.t_order_${0..1}
tableStrategy
:
inline
:
shardingColumn
:
order_id
algorithmExpression
:
t_order_${order_id % 2}
keyGeneratorColumnName
:
order_id
t_order_item
:
actualDataNodes
:
ds_${0..1}.t_order_item_${0..1}
tableStrategy
:
inline
:
shardingColumn
:
order_id
algorithmExpression
:
t_order_item_${order_id % 2}
keyGeneratorColumnName
:
order_item_id
bindingTables
:
-
t_order,t_order_item
defaultDatabaseStrategy
:
inline
:
shardingColumn
:
user_id
algorithmExpression
:
ds_${user_id % 2}
defaultTableStrategy
:
none
:
defaultKeyGeneratorClassName
:
io.shardingsphere.core.keygen.DefaultKeyGenerator
docker/sharding-proxy/sharding/conf/server.yaml
0 → 100644
浏览文件 @
ba7baf5a
######################################################################################################
#
# If you want to configure orchestration, authorization and proxy properties, please refer to this file.
#
######################################################################################################
#orchestration:
# name: orchestration_ds
# overwrite: true
# registry:
# serverLists: localhost:2181
# namespace: orchestration
#
authentication
:
username
:
root
password
:
root
props
:
max.connections.size.per.query
:
1
acceptor.size
:
16
# The default value is available processors count * 2.
executor.size
:
16
# Infinite by default.
proxy.frontend.flush.threshold
:
128
# The default value is 128.
# LOCAL: Proxy will run with LOCAL transaction.
# XA: Proxy will run with XA transaction.
# BASE: Proxy will run with B.A.S.E transaction.
proxy.transaction.type
:
LOCAL
proxy.opentracing.enabled
:
false
sql.show
:
false
docker/sharding-proxy/sharding/docker-compose.yml
0 → 100644
浏览文件 @
ba7baf5a
version
:
'
3'
services
:
mysql
:
## mysql version, you could get more tags at here : https://hub.docker.com/_/mysql?tab=tags
image
:
"
mysql:5.7"
## default port is 3306, you could change to 33060 or any other port doesn't conflict MySQL on your OS
ports
:
-
"
33060:3306"
container_name
:
sharding-sphere-mysql
## launch mysql without password
## you could access the mysql in container by following command :
## docker exec -it sharding-sphere-mysql mysql -uroot
environment
:
-
MYSQL_ALLOW_EMPTY_PASSWORD=yes
## if you insist to use password in mysql, remove MYSQL_ALLOW_EMPTY_PASSWORD=yes and uncomment following args
# - MYSQL_ROOT_PASSWORD=root
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/shardingsphere/sharding-proxy/tags
image
:
"
shardingsphere/sharding-proxy:3.1.0"
container_name
:
sharding-sphere-proxy
depends_on
:
-
mysql
## wait-for-it.sh will make proxy entrypoint wait until mysql container 3306 port open
entrypoint
:
>
/bin/sh -c "/opt/wait-for-it.sh sharding-sphere-mysql:3306 --timeout=20 --strict --
&& /opt/sharding-proxy/bin/start.sh 3308
&& tail -f /opt/sharding-proxy/logs/stdout.log"
ports
:
-
"
13308:3308"
links
:
-
"
mysql:mysql"
volumes
:
-
./conf/:/opt/sharding-proxy/conf
-
../../tools/wait-for-it.sh:/opt/wait-for-it.sh
environment
:
-
JVM_OPTS="-Djava.awt.headless=true"
docker/tools/wait-for-it.sh
0 → 100755
浏览文件 @
ba7baf5a
#!/usr/bin/env bash
# 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
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录