首页 > 解决方案 > MySQL 从 5.6 升级到 5.7 的 Grails 更改

问题描述

我们是 grails 2.3.11 并且一直在使用 MySQL 5.6 (AWS RDS) 和 Hibernate

MySQL 和 hibernate 的现有运行时依赖项如下

dependencies {
        runtime 'mysql:mysql-connector-java:5.1.27'
...
...
...
plugins {
       runtime ":hibernate:3.6.10.19"

数据源配置如下。(注意我们从来没有在这里设置方言)

dataSource {
    pooled = true
    jmxExport = true
    url = myjdbcURL
    driverClassName = "com.mysql.jdbc.Driver"
    username = myjdbcUserName
    password = myJdbcPassword
    properties {
        jmxEnabled = true
        initialSize = System.getenv("DB_INITIAL_SIZE")
        maxActive = System.getenv("DB_MAX_ACTIVE")
        minIdle = 5
        maxIdle = 25
        maxWait = 10000
        maxAge = 10 * 60000
        timeBetweenEvictionRunsMillis = 5000
        minEvictableIdleTimeMillis = 60000
        validationQuery = "SELECT 1"
        validationQueryTimeout = 3
        validationInterval = 15000
        testOnBorrow = true
        testWhileIdle = true
        testOnReturn = false
        ignoreExceptionOnPreLoad = true
        // http://tomcat.apache.org/tomcat-7.0-doc/jdbc-pool.html#JDBC_interceptors
        jdbcInterceptors = "ConnectionState;StatementCache(max=200)"
        defaultTransactionIsolation = java.sql.Connection.TRANSACTION_READ_COMMITTED // safe default
        // controls for leaked connections
        abandonWhenPercentageFull = 100 // settings are active only when pool is full
        removeAbandonedTimeout = 120
        removeAbandoned = true
        // use JMX console to change this setting at runtime
        logAbandoned = false // causes stacktrace recording overhead, use only for debugging
    }
}
hibernate {
    cache.use_second_level_cache = true
    cache.use_query_cache = false
    cache.region.factory_class = 'net.sf.ehcache.hibernate.EhCacheRegionFactory' // Hibernate 3
    show_sql = false
    format_sql = false
    use_sql_comments = false
}

现在我们正在寻找将 MySQL 升级到 5.7 并试图找到 grails 的任何文档,但找不到它。

我可以看到的一件事是我们一直使用的 MySQL 连接器仅支持 5.6,因此第一步是将其更新为 mysql-connector-java:5.1.49,因为我看到这是最新版本,而 grails 是运行 jdk 7,我无法切换到连接器 8。

我找不到任何与休眠相关的东西,因为我们一直在使用 grails 的休眠 gorm 插件是我能找到的唯一一个 https://mvnrepository.com/artifact/org.grails.plugins/hibernate/3.6.10.19

最后,直到现在我们还没有为 MySQL 设置方言,所以不确定我们是否应该明确设置方言。

我们正在寻找最少的停机时间,因此我们的计划是让 Grails 应用程序首先支持 MySQL 5.7 并保持与 MySQL 5.6 的向后兼容性,然后将 MySQL 升级到 5.7 并且应该仍然可以工作。

有人做过这样的升级吗?您的意见对我来说非常有价值。

标签: hibernategrailsgrails-ormmysql-connectormysqlupgrade

解决方案


很长一段时间以来,我一直通过 MySQL 连接器版本 5.1.45 使用带有 MySQL 5.7 的 Grails 2.3.11 实例。所以我想说你的一般方法应该很好,它是一个有效且有效的组合。


推荐阅读