mysql Chef数据库配方在大文件上失败 [英] mysql chef database recipe fails on large file

查看:66
本文介绍了mysql Chef数据库配方在大文件上失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

"MySQL服务器已消失".嗯.

"MySQL server has gone away". Hmm.

我正在使用流浪汉和厨师来设置我的虚拟开发环境.我快到了,但是在最后一步,厨师在尝试执行我的外部db_setup.sql文件时失败.我可以通过SSH'进入虚拟服务器来执行相同的脚本,并且可以轻松安装.

I am using vagrant and chef to setup my virtual development environment. I'm almost there, but on the last step chef fails when attempting to execute my external db_setup.sql file. I can execute this same script by SSH'ing into the virtual server and it installs without difficulty.

这是我的问题代码(在cookbooks/database/recipies/mysql.rb文件中):

This is my problem code (in cookbooks/database/recipies/mysql.rb file):

# Query a database from a sql script on disk
mysql_database 'run script' do
  database_name 'my_db'
  connection mysql_connection_info
  retries 3
  sql { ::File.open('/vagrant/db_setup.sql').read }
  action :query
end

文件为6.9mb,运行vagrant provision时收到的错误是:

The file is 6.9mb and the error I receive when I run vagrant provision is:

==> default: [2014-08-24T16:04:53-07:00] ERROR: mysql_database[run script] 
(database::mysql line 50) had an error: Mysql::Error: MySQL server has gone away

对于它的价值,当我将db_setup.sql文件替换为更小的,更简单的文件(仅创建几个空表)时,它执行起来很容易.

For what it's worth, when I replace the db_setup.sql file with a smaller, simpler file that just creates a few empty tables, it executes without difficulty.

有什么建议吗?预先谢谢你!

Any suggestions? Thank you in advance!

推荐答案

很多东西可以导致此错误.以我的经验,它通常是一个超过1MB的SQL文件,或者您的服务器my.cnf中的wait_timeout设置得很低(六十秒),需要适当调整.部署my.cnf时,请尝试使用wait_timeout 86400和足够"的max_allowed_pa​​cket导入该文件.

Many, many things can cause this error. In my experience it's usually an SQL file of over 1MB, or, the wait_timeout in your servers my.cnf is set very low (sixty seconds) needs properly tuned. When deploying my.cnf try a wait_timeout 86400 and a max_allowed_packet of "enough" to import that file.

例如:

 [mysqld]
 wait_timeout = 86400
 max_allowed_packet = 1GB

PS.我不建议在实际生产中使用如此高的参数.

PS. I would not recommend this high of parameters in actual production.

这篇关于mysql Chef数据库配方在大文件上失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆