一种查看oracle汉化sql的方法 [英] A way to check Oracle finished sql

查看:41
本文介绍了一种查看oracle汉化sql的方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有 Docker Compose 集群,其中一个容器是 Oracle 12c.有 schema.sql 文件来初始化数据库.我希望我的应用程序等到数据库执行所有 sql.如何使用 bash 以自动方式执行此操作?

I've got Docker Compose cluster and one of the containers is Oracle 12c. There is schema.sql file to initialize the db. I would like my application to wait until the db executes all the sql. How can I do it in an automatic fashion with bash?

非常感谢您的任何建议!

Thank you very much for any suggestions!

推荐答案

这里有很多要解释的,但我会链接我之前针对类似问题的答案之一 - 步骤实际上是相同的,因为只有数据库服务和背景不同.

There's a lot to explain here, but I'll link one of my previous answers for a similar problem - steps are actually the same because only the database service and background differs.

1)首先,您必须提供一个 bash 脚本,该脚本将等待服务通过 http 响应.在数据库中,这通常发生在 DB 准备就绪并且所有初始化都完成时.

1) First thing is, you have to provide a bash script that will wait until a service will respond via http. In databases it usually happens when DB is ready to go and all initializations are done.

等待.sh 脚本由 vishnubob 在他的 wait-for-it repo @ github 中编写.

the wait-for-it.sh script written by vishnubob in his wait-for-it repo @ github.

2)第二件事,您必须在需要您的数据库的每个容器中获取该脚本.

2) Second thing, you have to get that script inside each container that requires your DB.

3)第三,您在撰写文件中指定一个 entrypoint,它将在运行服务的实际 command 触发之前执行等待脚本.

3) Third, you specify a entrypoint in your compose file, that will execute the waiting script before the actual command running your service will trigger.

入口点示例(作为我链接到的答案的参考)

example of a entrypoint (as reference to the answer I link to)

docker-entrypoint.sh:

docker-entrypoint.sh:

#!/bin/bash
set -e
sh -c './wait-for-it.sh oracle:3306 -t 30'
exec "$@"

详细解释了所有这些步骤在场景 2 中,请注意我在此处指向的答案中对我的另一个答案的引用.这个问题对于初学者来说是一个很常见的问题,需要解释很多,所以我不能在这里全部贴出来.

All these steps are explained in detail here in scenario 2, be aware of a reference to my another answer inside the answer I'm pointing at here. This issue is a very common problem for beginners and takes quite a lot of explanation, so I cannot post it all here.

注意 这里关于 depends_on 您可能认为这是 docker 解决此问题的本机解决方案 - 正如 docs 所述,它只等到容器运行,而不是实际完成它的内部工作 - docker 不知道还有多少工作要做.

note here concerning depends_on which you might think is a native solution for this problem from docker - as docs state, it only waits until the container is running, not actually finished it's internal jobs - docker is not aware of how much there is to be done.

这篇关于一种查看oracle汉化sql的方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆