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

joseen · 2013年10月17日 · 最后由 allenwei 回复于 2013年10月18日 · 5163 次阅读

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

需要 登录 后方可回复, 如果你还没有账号请 注册新账号