xml - 对 Oracle 数据库运行 Liquibase GenerateChangeLog 命令导致空闲,在特定点之后日志文件/控制台中没有输出
问题描述
我正在尝试DatabaseChangeLog.xml
针对具有特定模式的现有 Oracle 数据库创建新的 Liqubase 文件,以从中获取数据库结构。目标是用 changeSet 格式替换现有的 sql 脚本,并使 Liquibase 迁移同时适用于 PostgreSQL 和 Oracle 数据库。
我已将我的liquibase.properties
文件指定为:
changeLogFile: DatabaseChangelog.xml
schemas: schema1,schema2,schema3
driver: oracle.jdbc.OracleDriver
classpath: ojdbc8.jar
url: jdbc:oracle:thin:@host:port:SID
username: User
password: PASSWORD
logLevel: debug
logFile: log.txt
当我liquibase generateChangeLog
在 cli 中执行时,我得到以下输出:
Liquibase Community 4.0.0 by Datical
Starting Liquibase at 12:44:52 (version 4.0.0 #19 built at 2020-07-13 19:45+0000)
一段时间后它会输出错误:
Unexpected error running Liquibase: liquibase.exception.DatabaseException: liquibase.exception.DatabaseException: Connection could not be created to jdbc:oracle:thin:@host:port:SID with driver oracle.jdbc.OracleDriver. Possibly the wrong driver for the given database URL
For more information, please use the --logLevel flag
log.txt 的输出不包含错误消息,并且似乎 liquibase 与数据库连接良好,但日志意外结束。这是一段日志:
[2020-09-14 12:44:52] FINE [liquibase.database] Properties:
[2020-09-14 12:44:52] FINE [liquibase.database] Key:'password' Value:'**********'
[2020-09-14 12:44:52] FINE [liquibase.database] Key:'user' Value:'USER'
[2020-09-14 12:44:52] FINE [liquibase.database] Connecting to the URL:'jdbc:oracle:thin:@host:port:SID' using driver:'oracle.jdbc.OracleDriver'
[2020-09-14 12:44:52] FINE [liquibase.servicelocator] Loaded liquibase.database.DatabaseConnection instance liquibase.database.jvm.JdbcConnection
[2020-09-14 12:44:52] FINE [liquibase.servicelocator] Loaded liquibase.database.DatabaseConnection instance com.datical.liquibase.ext.database.jvm.ProJdbcConnection
[2020-09-14 12:44:59] FINE [liquibase.database] Connection has been created
[2020-09-14 12:45:00] FINE [liquibase.database] Connected to USER@jdbc:oracle:thin:@host:port:SID
[2020-09-14 12:45:00] FINE [liquibase.database] Setting auto commit to false from true
...
[2020-09-14 12:45:40] FINE [liquibase.executor] Executing with the 'jdbc' executor
最后一行是日志文件中的最后一行。
Liquibase版本是Community 4.0.0
,oracle驱动是ojdbc8.jar
。
我ojdbc8.jar
在同一个目录中liquibase.properties
。
数据库和用户凭据是正确的,我可以使用 DBForge 连接到数据库(tnsnames.ora
格式与地址和用户凭据相同)。
有没有人在尝试DatabaseChangeLog.xml
从现有的 oracle 数据库创建新数据库时遇到同样的问题?我很高兴看到任何建议。
提前致谢。
编辑:实际上它在工作 1 小时后给了我一个输出:
Unexpected error running Liquibase: liquibase.exception.DatabaseException: java.sql.SQLRecoverableException: No data to read from socket
For more information, please use the --logLevel flag
但是模式中有数据/表。
解决方案
您可以使用命令行工具从现有架构生成更改日志。使用以下命令并注意多余的空格,因为 liquibase 会抱怨这一点。
确保复制从下面提到的位置下载的 liquibase-zipojdbc8-19.3.0.0.jar
的lib文件夹中。我已经从这里下载了 liquibase.zip 并使用了以下命令
liquibase_zip
liquibase.bat --driver=oracle.jdbc.driver.OracleDriver --url="jdbc:oracle:thin:@localhost:1521/orcl" --username=TEST_A --password=test --changeLogFile=db.test.xml generateChangeLog
或者 你可以使用相同的方法。我已经在 liquibase.properties 文件中替换了这样的属性,它工作正常。注意之间没有空格
键=值
changeLogFile=DatabaseChangelog.xml
schemas=TEST
driver=oracle.jdbc.OracleDriver
url=jdbc:oracle:thin:@localhost:1521/service_name
username=TEST_A
password=password
logLevel=debug
logFile=log.txt
对于 SID,请像这样替换 URL
url=jdbc:oracle:thin:@localhost:1521:sid
推荐阅读
- ruby-on-rails - 在更改我的开发数据库之前我应该知道什么?
- angular - “如果没有描述,'@param' 在 TypeScript 代码中是多余的。” TSLint 错误?
- elasticsearch - Elasticsearch 字段数据与字段映射
- php - 通过 Laravel/Lumen 中的 Config::set 动态更改数据库名称后 DB::Connection 未更新?
- batch-file - 你能只比较文件名,不比较扩展名吗?
- r - 错误:不知道如何将 ggplot 添加到绘图中
- c++ - CMake:包括外部库头文件
- javascript - Internet Explorer 11 中的段落溢出。Chrome 和 Firefox 都很好
- regex - 正则表达式匹配 0\n 但不匹配 0\.+
- javascript - 为什么 http 请求需要更长的时间从 angularjs 响应,而从 ajax 请求中响应的时间更短?