xforty / vagrant-drupal

Template repo for a new drupal project built on top of a vagrant vm.
Other
46 stars 11 forks source link

MySQL doesn't seem to be loaded in time for a provision #11

Open pearcec opened 12 years ago

pearcec commented 12 years ago

When I vagrant halt, then run vagrant up after initial deployment, I get this. The work around is to run vagrant provision. Seems MySQL isn't running quite yet.

[Wed, 15 Feb 2012 14:45:19 +0100] INFO: execute[mysql-install-privileges] sh(/usr/bin/mysql -u root -p"root" < /etc/mysql/mysql_grants.sql)
[Wed, 15 Feb 2012 14:45:19 +0100] ERROR: execute[mysql-install-privileges] (mysql::server line 129) has had an error
[Wed, 15 Feb 2012 14:45:19 +0100] ERROR: template[/etc/mysql/mysql_grants.sql] (/tmp/vagrant-chef-1/chef-solo-1/cookbooks/mysql/recipes/server.rb:120:in `from_file') had an error:
execute[mysql-install-privileges] (mysql::server line 129) had an error: Chef::Exceptions::ShellCommandFailed: Expected process to exit with [0], but received '1'
---- Begin output of /usr/bin/mysql -u root -p"root" < /etc/mysql/mysql_grants.sql ----
STDOUT: 
STDERR: ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
---- End output of /usr/bin/mysql -u root -p"root" < /etc/mysql/mysql_grants.sql ----
Ran /usr/bin/mysql -u root -p"root" < /etc/mysql/mysql_grants.sql returned 1
/opt/ruby/lib/ruby/gems/1.8/gems/chef-0.10.8/bin/../lib/chef/shell_out.rb:206:in `invalid!'
/opt/ruby/lib/ruby/gems/1.8/gems/chef-0.10.8/bin/../lib/chef/shell_out.rb:192:in `error!'
/opt/ruby/lib/ruby/gems/1.8/gems/chef-0.10.8/bin/../lib/chef/mixin/shell_out.rb:36:in `shell_out!'
/opt/ruby/lib/ruby/gems/1.8/gems/chef-0.10.8/bin/../lib/chef/provider/execute.rb:58:in `action_run'
/opt/ruby/lib/ruby/gems/1.8/gems/chef-0.10.8/bin/../lib/chef/resource.rb:440:in `send'
/opt/ruby/lib/ruby/gems/1.8/gems/chef-0.10.8/bin/../lib/chef/resource.rb:440:in `run_action'
/opt/ruby/lib/ruby/gems/1.8/gems/chef-0.10.8/bin/../lib/chef/runner.rb:45:in `run_action'
/opt/ruby/lib/ruby/gems/1.8/gems/chef-0.10.8/bin/../lib/chef/runner.rb:53:in `run_action'
/opt/ruby/lib/ruby/gems/1.8/gems/chef-0.10.8/bin/../lib/chef/runner.rb:51:in `each'
/opt/ruby/lib/ruby/gems/1.8/gems/chef-0.10.8/bin/../lib/chef/runner.rb:51:in `run_action'
/opt/ruby/lib/ruby/gems/1.8/gems/chef-0.10.8/bin/../lib/chef/runner.rb:81:in `converge'
/opt/ruby/lib/ruby/gems/1.8/gems/chef-0.10.8/bin/../lib/chef/runner.rb:81:in `each'
/opt/ruby/lib/ruby/gems/1.8/gems/chef-0.10.8/bin/../lib/chef/runner.rb:81:in `converge'
/opt/ruby/lib/ruby/gems/1.8/gems/chef-0.10.8/bin/../lib/chef/resource_collection.rb:94:in `execute_each_resource'
/opt/ruby/lib/ruby/gems/1.8/gems/chef-0.10.8/bin/../lib/chef/resource_collection/stepable_iterator.rb:116:in `call'
/opt/ruby/lib/ruby/gems/1.8/gems/chef-0.10.8/bin/../lib/chef/resource_collection/stepable_iterator.rb:116:in `call_iterator_block'
/opt/ruby/lib/ruby/gems/1.8/gems/chef-0.10.8/bin/../lib/chef/resource_collection/stepable_iterator.rb:85:in `step'
/opt/ruby/lib/ruby/gems/1.8/gems/chef-0.10.8/bin/../lib/chef/resource_collection/stepable_iterator.rb:104:in `iterate'
/opt/ruby/lib/ruby/gems/1.8/gems/chef-0.10.8/bin/../lib/chef/resource_collection/stepable_iterator.rb:55:in `each_with_index'
/opt/ruby/lib/ruby/gems/1.8/gems/chef-0.10.8/bin/../lib/chef/resource_collection.rb:92:in `execute_each_resource'
/opt/ruby/lib/ruby/gems/1.8/gems/chef-0.10.8/bin/../lib/chef/runner.rb:76:in `converge'
/opt/ruby/lib/ruby/gems/1.8/gems/chef-0.10.8/bin/../lib/chef/client.rb:312:in `converge'
/opt/ruby/lib/ruby/gems/1.8/gems/chef-0.10.8/bin/../lib/chef/client.rb:160:in `run'
/opt/ruby/lib/ruby/gems/1.8/gems/chef-0.10.8/bin/../lib/chef/application/solo.rb:192:in `run_application'
/opt/ruby/lib/ruby/gems/1.8/gems/chef-0.10.8/bin/../lib/chef/application/solo.rb:183:in `loop'
/opt/ruby/lib/ruby/gems/1.8/gems/chef-0.10.8/bin/../lib/chef/application/solo.rb:183:in `run_application'
/opt/ruby/lib/ruby/gems/1.8/gems/chef-0.10.8/bin/../lib/chef/application.rb:67:in `run'
/opt/ruby/lib/ruby/gems/1.8/gems/chef-0.10.8/bin/chef-solo:25
/opt/ruby/bin/chef-solo:19:in `load'
/opt/ruby/bin/chef-solo:19
[Wed, 15 Feb 2012 14:45:19 +0100] ERROR: Running exception handlers
[Wed, 15 Feb 2012 14:45:19 +0100] ERROR: Exception handlers complete
[Wed, 15 Feb 2012 14:45:19 +0100] FATAL: Stacktrace dumped to /tmp/vagrant-chef-1/chef-stacktrace.out
[Wed, 15 Feb 2012 14:45:19 +0100] FATAL: Chef::Exceptions::ShellCommandFailed: execute[mysql-install-privileges] (mysql::server line 129) had an error: Chef::Exceptions::ShellCommandFailed: Expected process to exit with [0], but received '1'
---- Begin output of /usr/bin/mysql -u root -p"root" < /etc/mysql/mysql_grants.sql ----
STDOUT: 
STDERR: ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
---- End output of /usr/bin/mysql -u root -p"root" < /etc/mysql/mysql_grants.sql ----
Ran /usr/bin/mysql -u root -p"root" < /etc/mysql/mysql_grants.sql returned 1
Chef never successfully completed! Any errors should be visible in the
output above. Please fix your recipes so that they properly complete.
everm1nd commented 12 years ago

It's opscode mysql cookbook problem. I have the same crap in my own recipe

pearcec commented 12 years ago

Is it possible to fix? What is the issue do you know? Can we patch it and send out a pull request?

everm1nd commented 12 years ago

seems I fixed it here https://github.com/everm1nd/mysql

Sgoettschkes commented 12 years ago

I can confirm this. Ubuntu 10.04, trying to get lamp up and running. Indeed a vagrant provision does work. After a vagrant up, even if it fails, mysql is up and running (confirmed by logging in with ssh and doing mysql -u root -p "somepass").

From what I understand, it would be necessary to wait for mysql to be "really" started, like checking service mysql status till it reports mysql start/running!

everm1nd commented 12 years ago

I think so, but still don't find any way how to do it

Sgoettschkes commented 12 years ago

I just recognized another behaviour: If I kill the virtualbox process (Called VBoxHeadless.exe on my Windows 7 64 bit) and then do vagrant up, it works as expected without the need to run vagrant provision! I don't know if this helps though.

pearcec commented 12 years ago

I am closing this. We updated to 10.04.4 and some newer version of cookbooks. Not sure which version might of resolved it but it isn't happening for me.

pearcec commented 12 years ago

This appears to happen after a reload.

jdx commented 12 years ago

+1

rjmunro commented 12 years ago

This happens to me, but not every time. It's not waiting for the mysql process to be running before trying to run the grant command. Sometimes it is running, sometimes it isn't, I guess depending on the load of other parts of the system etc.

patcon commented 12 years ago

Hm. Weird. Have never hit this myself... running 10.04 LTS VM on macbook dual core (latest vbox 4.1.x)

danylevskyi commented 11 years ago

I have the same issue on Ubuntu 12.04 64bit. Strange, but i386 works great... Here some ugly, but working solution.

service "mysql" do
  action :start
  only_if "test -f /etc/init.d/mysql"
end

include_recipe "mysql::server"
jeremyquinton commented 11 years ago

I get this isssue on cent os 6.3. The comment above fixes it. Something odd with certain versions of linux

binlialfie commented 11 years ago

the above fixes does not work on ubuntu 12.04, do i just replace the sever recipe with the fixes in the right section?