一种检查Oracle完成的sql的方法 [英] A way to check Oracle finished sql

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

问题描述

我有Docker Compose集群,其中一个容器是Oracle 12c.有schema.sql文件可以初始化db.我希望我的应用程序等到数据库执行所有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.

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

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.

注释,您可能认为这是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天全站免登陆