部署 Rails 远程访问 MySQL,引起的 Mysql2::Error: Lost connection...

joseen · October 17, 2013 · Last by allenwei replied at October 18, 2013 · 5164 hits

Rails 程序和 Mysql 数据库分别部署在两台服务器上。 Rails 的 database.yml 将 reconnect 配置为 true Mysql 是默认配置 问题现象: 不定时的出现:

ActiveModel::MissingAttributeError (missing attribute:  _____ ):
ActiveRecord::StatementInvalid (Mysql2::Error: Lost connection to MySQL server during query:

检查一下 mysql 的 max_connections 也可能是内网连接超时,我们就在 rackspace 上遇到过,共享主机容易出这样的问题

@allenwei 顺便请教,在生产环境下。 Rails 和 Mysql 应该怎么配置,及哪些注意事项?

max_connections > Number of Rails Process * Size of Connection Pool

You need to Sign in before reply, if you don't have an account, please Sign up first.