【发布时间】:2018-06-26 08:35:14
【问题描述】:
关注official guide 编写堆栈部署文件:
stack.yml
version: "3"
services:
kong-database:
image: cassandra:3
ports:
- "9042:9042"
networks:
- kong-net
kong-migration:
image: kong:latest
depends_on:
- kong-database
environment:
- KONG_DATABASE=cassandra
- KONG_CASSANDRA_CONTACT_POINTS=kong-database
command: kong migrations up
networks:
- kong-net
kong:
image: kong:latest
depends_on:
- kong-database
- kong-migration
deploy:
replicas: 3
environment:
- KONG_DATABASE=cassandra
- KONG_CASSANDRA_CONTACT_POINTS=kong-database
- KONG_PROXY_ACCESS_LOG=/dev/stdout
- KONG_ADMIN_ACCESS_LOG=/dev/stdout
- KONG_PROXY_ERROR_LOG=/dev/stderr
- KONG_ADMIN_ERROR_LOG=/dev/stderr
- KONG_ADMIN_LISTEN=0.0.0.0:8001, 0.0.0.0:8444 ssl
ports:
- "8000:8000"
- "8443:8443"
- "8001:8001"
- "8444:8444"
networks:
- kong-net
networks:
kong-net:
部署:
$ docker stack deploy -c stack.yml gateway
检查服务:
$ docker service ls
ID NAME MODE REPLICAS IMAGE PORTS
xg3qld08ziio gateway_kong replicated 1/3 kong:latest *:8000-8001->8000-8001/tcp, *:8443-8444->8443-8444/tcp
kam7fw265ons gateway_kong-database replicated 1/1 cassandra:3 *:9042->9042/tcp
kr0vqoc66izn gateway_kong-migration replicated 0/1 kong:latest
查看gateway_kong日志:
gateway_kong.2.zn0tfalwxylx@ip-1-2-3-4 | [C]: in function 'error'
gateway_kong.2.zxuwxm5xbroe@ip-1-2-3-4 | init_by_lua:3: in main chunk
gateway_kong.2.zxuwxm5xbroe@ip-1-2-3-4 | nginx: [error] init_by_lua error: /usr/local/share/lua/5.1/kong/init.lua:172: [cassandra error] the current database schema does not match this version of Kong. Please run `kong migrations up` to update/initialize the database schema. Be aware that Kong migrations should only run from a single node, and that nodes running migrations concurrently will conflict with each other and might corrupt your database schema!
gateway_kong.1.zr8biqoaccfz@ip-1-2-3-4 | init_by_lua:3: in main chunk
gateway_kong.1.zy0u3ul9gp0l@ip-1-2-3-4 | init_by_lua:3: in main chunk
gateway_kong.2.zn0tfalwxylx@ip-1-2-3-4 | /usr/local/share/lua/5.1/kong/init.lua:169: in function 'init'
gateway_kong.1.zy0u3ul9gp0l@ip-1-2-3-4 | nginx: [error] init_by_lua error: /usr/local/share/lua/5.1/kong/init.lua:172: [cassandra error] the current database schema does not match this version of Kong. Please run `kong migrations up` to update/initialize the database schema. Be aware that Kong migrations should only run from a single node, and that nodes running migrations concurrently will conflict with each other and might corrupt your database schema!
gateway_kong.2.zxuwxm5xbroe@ip-1-2-3-4 | stack traceback:
gateway_kong.2.zxuwxm5xbroe@ip-1-2-3-4 | [C]: in function 'assert'
gateway_kong.2.zn0tfalwxylx@ip-1-2-3-4 | init_by_lua:3: in main chunk
gateway_kong.1.zy0u3ul9gp0l@ip-1-2-3-4 | stack traceback:
gateway_kong.1.zy0u3ul9gp0l@ip-1-2-3-4 | [C]: in function 'assert'
gateway_kong.2.zxuwxm5xbroe@ip-1-2-3-4 | /usr/local/share/lua/5.1/kong/init.lua:172: in function 'init'
gateway_kong.2.zxuwxm5xbroe@ip-1-2-3-4 | init_by_lua:3: in main chunk
gateway_kong.1.zy0u3ul9gp0l@ip-1-2-3-4 | /usr/local/share/lua/5.1/kong/init.lua:172: in function 'init'
gateway_kong.1.zy0u3ul9gp0l@ip-1-2-3-4 | init_by_lua:3: in main chunk
gateway_kong.3.zq9rrsn2pd2r@ip-1-2-3-5 | /usr/local/share/lua/5.1/kong/init.lua:172: in function 'init'
gateway_kong.3.zq9rrsn2pd2r@ip-1-2-3-5 | init_by_lua:3: in main chunk
已定义kong-migration 并设置命令kong migrations up。偶set依赖depends_on,为什么不能迁移?
【问题讨论】:
-
你从教程中改变了什么?
-
@ShiheZhang 添加了
depends_on。我想就是这样。 -
@vv 我知道我迟到了,但是在 YAML 的第 3 版中,取决于已弃用,并且根据 docker 文档它不向后兼容。取决于功能可以使用 docker 文档中提到的 shell 脚本来实现。你能解决问题吗?
标签: docker docker-compose database-migration docker-swarm kong