简体   繁体   English

如何将 liquibase 连接到 AWS RDS Aurora MySQL 数据库

[英]How to connect liquibase to AWS RDS Aurora MySQL database

I am trying to set up liquibase for syncing my dev and prod databases based upon AWS RDS Aurora MySql for a project.我正在尝试设置 liquibase 以基于 AWS RDS Aurora MySql 为项目同步我的开发和生产数据库。 Unfortunately I can not get liquibase connected to my AWS Aurora MySQL database.不幸的是,我无法将 liquibase 连接到我的 AWS Aurora MySQL 数据库。

What did I do?我做了什么?

  1. Installed liquibase已安装的 liquibase
  2. Followed the article https://docs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide/Aurora.Connecting.html which explains how to connect to AWS RDS Aurora MySQL database cluster via JDBC. Followed the article https://docs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide/Aurora.Connecting.html which explains how to connect to AWS RDS Aurora MySQL database cluster via JDBC.
    • I downloaded the Maria DB JDBC Connector我下载了 Maria DB JDBC 连接器
    • I configured the liquibase.properties file with data as stated in Appendix 1我使用附录 1 中所述的数据配置了 liquibase.properties 文件
    • I ran the command `liquibase --driver=org.mariadb.jdbc.Driver --classpath=<PATH_TO_JAR>mariadb-java-client-2.7.1.jar generateChangeLog``我运行了命令`liquibase --driver=org.mariadb.jdbc.Driver --classpath=<PATH_TO_JAR>mariadb-java-client-2.7.1.Z68995FCBF432492D15484D04AZD生成
  3. liquibase starts as expected and tries to connect to the database prod cluster but then hangs for a while before it terminates with an exception "Communications link failure with primary. No active connection found for master." liquibase 按预期启动并尝试连接到数据库 prod 集群,但随后挂起一段时间,然后终止并出现异常“与主服务器的通信链接失败。没有找到主服务器的活动连接。” - see stacktrace in Appendix 2 - 参见附录 2 中的堆栈跟踪

My question:我的问题:

How do I have to configure liquibase in order to get it running with an AWS RDS Aurora MySQL database cluster?如何配置 liquibase 才能使其与 AWS RDS Aurora MySQL 数据库集群一起运行?

Thanks and best regards The Smart Home Maker感谢和最好的问候智能家居制造商

Appendix 1: liquibase.properties:附录一:liquibase.properties:

# Enter the path for your changelog file.
changeLogFile=<CHANGE_LOG_FILENAME>

#### Enter the Target database 'url' information  ####
url=jdbc:mariadb:aurora//<ENDPOINT_URL_FOR_AWS_AURORA_PROD_CLUSTER>:<PORT_FOR_AWS_AURORA_PROD_CLUSTER>/<PROD_DATABASE_NAME>

# Enter the username for your Target database.
username: <PROD_DATABASE_USER>

# Enter the password for your Target database.
password: <PROD_DATABASE_PASSWORD>

#### Enter the Source Database 'referenceUrl' information ####
## The source database is the baseline or reference against which your target database is compared for diff/diffchangelog commands.

# Enter URL for the source database
referenceUrl: jdbc:mariadb:aurora//<ENDPOINT_URL_FOR_AWS_AURORA_DEV_CLUSTER>:<PORT_FOR_AWS_AURORA_DEV_CLUSTER>/<DEV_DATABASE_NAME>

# Enter the username for your source database
referenceUsername: <DEV_DATABASE_USER>

# Enter the password for your source database
referencePassword: <DEV_DATABASE_PASSWORD>

logLevel: DEBUG

Appendix 2: Stacktrace:附录 2:堆栈跟踪:

[2020-12-29 14:43:05] FEIN [liquibase.servicelocator] Loaded liquibase.license.LicenseService instance liquibase.pro.license.keymgr.DaticalTrueLicenseService
[2020-12-29 14:43:05] INFORMATION [liquibase.integration] No Liquibase Pro license key supplied. Please set liquibaseProLicenseKey on command line or in liquibase.properties to use Liquibase Pro features.
Liquibase Community 4.2.2 by Datical
####################################################
##   _     _             _ _                      ##
##  | |   (_)           (_) |                     ##
##  | |    _  __ _ _   _ _| |__   __ _ ___  ___   ##
##  | |   | |/ _` | | | | | '_ \ / _` / __|/ _ \  ##
##  | |___| | (_| | |_| | | |_) | (_| \__ \  __/  ##
##  \_____/_|\__, |\__,_|_|_.__/ \__,_|___/\___|  ##
##              | |                               ##
##              |_|                               ##
##                                                ## 
##  Get documentation at docs.liquibase.com       ##
##  Get certified courses at learn.liquibase.com  ## 
##  Free schema change activity reports at        ##
##      https://hub.liquibase.com                 ##
##                                                ##
####################################################
Starte Liquibase am 14:43:05 (Version 4.2.2 #36, kompiliert am 2020-12-09 20:07+0000)
[2020-12-29 14:43:05] FEIN [liquibase.integration] 'file:<PATH_TO_JAR_FILE>mariadb-java-client-2.7.1.jar' will be added to Java Classpath.
[2020-12-29 14:43:05] FEIN [liquibase.integration] Liquibase Hub URL:      https://hub.liquibase.com
[2020-12-29 14:43:05] FEIN [liquibase.integration] Liquibase Hub Mode:     all
[2020-12-29 14:43:05] FEIN [liquibase.resource] Adding path <PATH_WHERE_LIQUIBASE_IS_RUNNING>. to resourceAccessor liquibase.resource.FileSystemResourceAccessor
[2020-12-29 14:43:05] FEIN [liquibase.servicelocator] Loaded liquibase.database.Database instance liquibase.database.core.CockroachDatabase
[2020-12-29 14:43:05] FEIN [liquibase.servicelocator] Loaded liquibase.database.Database instance liquibase.database.core.DB2Database
[2020-12-29 14:43:05] FEIN [liquibase.servicelocator] Loaded liquibase.database.Database instance liquibase.database.core.Db2zDatabase
[2020-12-29 14:43:08] FEIN [liquibase.servicelocator] Loaded liquibase.database.Database instance liquibase.database.core.DerbyDatabase
[2020-12-29 14:43:08] FEIN [liquibase.servicelocator] Loaded liquibase.database.Database instance liquibase.database.core.Firebird3Database
[2020-12-29 14:43:08] FEIN [liquibase.servicelocator] Loaded liquibase.database.Database instance liquibase.database.core.FirebirdDatabase
[2020-12-29 14:43:08] FEIN [liquibase.servicelocator] Loaded liquibase.database.Database instance liquibase.database.core.H2Database
[2020-12-29 14:43:08] FEIN [liquibase.servicelocator] Loaded liquibase.database.Database instance liquibase.database.core.HsqlDatabase
[2020-12-29 14:43:08] FEIN [liquibase.servicelocator] Loaded liquibase.database.Database instance liquibase.database.core.InformixDatabase
[2020-12-29 14:43:08] FEIN [liquibase.servicelocator] Loaded liquibase.database.Database instance liquibase.database.core.Ingres9Database
[2020-12-29 14:43:08] FEIN [liquibase.servicelocator] Loaded liquibase.database.Database instance liquibase.database.core.MSSQLDatabase
[2020-12-29 14:43:08] FEIN [liquibase.servicelocator] Loaded liquibase.database.Database instance liquibase.database.core.MariaDBDatabase
[2020-12-29 14:43:08] FEIN [liquibase.servicelocator] Loaded liquibase.database.Database instance liquibase.database.core.MockDatabase
[2020-12-29 14:43:08] FEIN [liquibase.servicelocator] Loaded liquibase.database.Database instance liquibase.database.core.MySQLDatabase
[2020-12-29 14:43:08] FEIN [liquibase.servicelocator] Loaded liquibase.database.Database instance liquibase.database.core.OracleDatabase
[2020-12-29 14:43:08] FEIN [liquibase.servicelocator] Loaded liquibase.database.Database instance liquibase.database.core.PostgresDatabase
[2020-12-29 14:43:08] FEIN [liquibase.servicelocator] Loaded liquibase.database.Database instance liquibase.database.core.SQLiteDatabase
[2020-12-29 14:43:08] FEIN [liquibase.servicelocator] Loaded liquibase.database.Database instance liquibase.database.core.SybaseASADatabase
[2020-12-29 14:43:08] FEIN [liquibase.servicelocator] Loaded liquibase.database.Database instance liquibase.database.core.SybaseDatabase
[2020-12-29 14:43:08] FEIN [liquibase.servicelocator] Loaded liquibase.database.Database instance liquibase.database.core.UnsupportedDatabase
[2020-12-29 14:43:08] FEIN [liquibase.database] Properties:
[2020-12-29 14:43:08] FEIN [liquibase.database] Key:'password' Value:'**********'
[2020-12-29 14:43:08] FEIN [liquibase.database] Key:'user' Value:'***********'
[2020-12-29 14:43:08] FEIN [liquibase.database] Connecting to the URL:'jdbc:mariadb:aurora//jdbc:mariadb:aurora//<ENDPOINT_URL_FOR_AWS_AURORA_PROD_CLUSTER>:<PORT_FOR_AWS_AURORA_PROD_CLUSTER>/<PROD_DATABASE_NAME>' using driver:'org.mariadb.jdbc.Driver'
[2020-12-29 14:43:08] FEIN [liquibase.servicelocator] Loaded liquibase.database.DatabaseConnection instance liquibase.database.jvm.JdbcConnection
[2020-12-29 14:43:08] FEIN [liquibase.servicelocator] Loaded liquibase.database.DatabaseConnection instance com.datical.liquibase.ext.database.jvm.ProJdbcConnection
Unexpected exception when executing liquibase: liquibase.exception.DatabaseException: liquibase.exception.DatabaseException: Connection could not be created to jdbc:mariadb:aurora//jdbc:mariadb:aurora//<ENDPOINT_URL_FOR_AWS_AURORA_PROD_CLUSTER>:<PORT_FOR_AWS_AURORA_PROD_CLUSTER>/<PROD_DATABASE_NAME> with driver org.mariadb.jdbc.Driver.  Communications link failure with primary. No active connection found for master. 
Bitte verwenden Sie die '--logLevel'-Option, um mehr Informationen zu erhalten.
[2020-12-29 15:02:59] FATAL [liquibase.integration] Unexpected Exception when running liquibase: liquibase.exception.DatabaseException: liquibase.exception.DatabaseException: Connection could not be created to jdbc:mariadb:aurora//jdbc:mariadb:aurora//<ENDPOINT_URL_FOR_AWS_AURORA_PROD_CLUSTER>:<PORT_FOR_AWS_AURORA_PROD_CLUSTER>/<PROD_DATABASE_NAME> with driver org.mariadb.jdbc.Driver.  Communications link failure with primary. No active connection found for master. 
liquibase.exception.DatabaseException: liquibase.exception.DatabaseException: liquibase.exception.DatabaseException: liquibase.exception.DatabaseException: Connection could not be created to jdbc:mariadb:aurora//jdbc:mariadb:aurora//<ENDPOINT_URL_FOR_AWS_AURORA_PROD_CLUSTER>:<PORT_FOR_AWS_AURORA_PROD_CLUSTER>/<PROD_DATABASE_NAME> with driver org.mariadb.jdbc.Driver.  Communications link failure with primary. No active connection found for master. 
    at liquibase.integration.commandline.CommandLineUtils.createDatabaseObject(CommandLineUtils.java:131)
    at liquibase.integration.commandline.Main.doMigration(Main.java:1409)
    at liquibase.integration.commandline.Main$1.lambda$run$0(Main.java:361)
    at liquibase.Scope.lambda$child$0(Scope.java:160)
    at liquibase.Scope.child(Scope.java:169)
    at liquibase.Scope.child(Scope.java:159)
    at liquibase.Scope.child(Scope.java:138)
    at liquibase.Scope.child(Scope.java:222)
    at liquibase.Scope.child(Scope.java:226)
    at liquibase.integration.commandline.Main$1.run(Main.java:360)
    at liquibase.integration.commandline.Main$1.run(Main.java:193)
    at liquibase.Scope.child(Scope.java:169)
    at liquibase.Scope.child(Scope.java:145)
    at liquibase.integration.commandline.Main.run(Main.java:193)
    at liquibase.integration.commandline.Main.main(Main.java:156)
Caused by: liquibase.exception.DatabaseException: liquibase.exception.DatabaseException: liquibase.exception.DatabaseException: Connection could not be created to jdbc:mariadb:aurora//jdbc:mariadb:aurora//<ENDPOINT_URL_FOR_AWS_AURORA_PROD_CLUSTER>:<PORT_FOR_AWS_AURORA_PROD_CLUSTER>/<PROD_DATABASE_NAME> with driver org.mariadb.jdbc.Driver.  Communications link failure with primary. No active connection found for master. 
    at liquibase.database.DatabaseFactory.openConnection(DatabaseFactory.java:216)
    at liquibase.database.DatabaseFactory.openConnection(DatabaseFactory.java:175)
    at liquibase.database.DatabaseFactory.openDatabase(DatabaseFactory.java:140)
    at liquibase.integration.commandline.CommandLineUtils.createDatabaseObject(CommandLineUtils.java:96)
    ... 14 more
Caused by: liquibase.exception.DatabaseException: liquibase.exception.DatabaseException: Connection could not be created to jdbc:mariadb:aurora//jdbc:mariadb:aurora//<ENDPOINT_URL_FOR_AWS_AURORA_PROD_CLUSTER>:<PORT_FOR_AWS_AURORA_PROD_CLUSTER>/<PROD_DATABASE_NAME> with driver org.mariadb.jdbc.Driver.  Communications link failure with primary. No active connection found for master. 
    at liquibase.database.ConnectionServiceFactory.create(ConnectionServiceFactory.java:36)
    at liquibase.database.DatabaseFactory.openConnection(DatabaseFactory.java:213)
    ... 17 more
Caused by: liquibase.exception.DatabaseException: Connection could not be created to jdbc:mariadb:aurora//jdbc:mariadb:aurora//<ENDPOINT_URL_FOR_AWS_AURORA_PROD_CLUSTER>:<PORT_FOR_AWS_AURORA_PROD_CLUSTER>/<PROD_DATABASE_NAME> with driver org.mariadb.jdbc.Driver.  Communications link failure with primary. No active connection found for master. 
    at liquibase.database.jvm.JdbcConnection.open(JdbcConnection.java:43)
    at com.datical.liquibase.ext.database.jvm.ProJdbcConnection.open(Unknown Source)
    at liquibase.database.ConnectionServiceFactory.create(ConnectionServiceFactory.java:33)
    ... 18 more

I'm still looking into that myself, this is a good article provided by a senior technical account manager in AWS to get familiar how things could be connected together.我自己还在研究,这是一篇很好的文章,由 AWS 的高级技术客户经理提供,以熟悉如何将事物连接在一起。

To sum things up you have to work on AWS ecosystem, deploying Liquibase and CI/CD software like Jenkins on EC2 and commit your SQL repo into AWS codecommit.总而言之,您必须在 AWS 生态系统上工作,在 EC2 上部署 Liquibase 和 CI/CD 软件(如 Jenkins)并将您的 SQL 存储库提交到 AWS 代码提交中。 Note that this generally will work with Aurora but in case of serverless you may encounter issues with connectivity so I suggest you connect it over HTTP through Data API but this is ongoing process I'm still investigating.请注意,这通常适用于 Aurora,但在无服务器的情况下,您可能会遇到连接问题,因此我建议您通过数据 API通过 HTTP 连接它,但这是我仍在调查的持续过程。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM