首页 文章

Chef MySql Cookbook:重启后MySql无法启动

提问于
浏览
0

我正在尝试在vagrant中安装mysql配方 . 我使用this食谱 .

MySql服务在 vagrant up 之后启动,但在重启后我无法执行 vagrant provisionvagrant up ,因为服务器无法启动 .

我已经意识到,那个Vagrant擦拭 /var/run 目录;它创建mysqld目录(用于套接字),但不创建mysql(用于pid文件) . MySql可以't find the directory and can' t创建pid文件 .

我怎样才能使它工作?为什么Vagrant创建mysqld,而不是mysql?

我也尝试了不同的盒子(精确32, Cloud 每日精确64) .

框:http://files.vagrantup.com/precise32.box Vagrantfile:

Vagrant.configure("2") do |config|
  config.vm.box = "precise32"
  config.omnibus.chef_version = :latest

  config.vm.box_url = "http://files.vagrantup.com/precise32.box"

  config.vm.network :forwarded_port, guest: 8000, host: 8080

  config.vm.provider :virtualbox do |vb|
    vb.gui = true
  end
  config.vm.provision :chef_solo do |chef|
    chef.cookbooks_path = "./chef-repo/cookbooks"
    chef.add_recipe "apt"
    chef.add_recipe "mysql::server"
    chef.json = {
      "mysql" => {
                  "server_root_password" => "password",
                  "server_repl_password" => "password",
                  "server_debian_password" => "password"
                 }
    }
  end
end

2 回答

  • 0

    问题出在MySql cookbook中:某种方式/ var / run / mysqld没有被擦除,因此解决方法是:更改 <mysql_cookbook>/libraries/provider_mysql_service_ubuntu.rb

    pid_file = '/var/run/mysql/mysql.pid'
    

    pid_file = '/var/run/mysqld/mysqld.pid'
    

    我在github上也提出了一个问题,因此将来可以在master中修复bug

  • 1

    eviltnan是对的 . 这是第一次运行ubuntu 12.04的脚本化解决方法 .

    ruby_block "ensure mysql server starts on reboot" do
      block do
        fe = Chef::Util::FileEdit.new("/etc/mysql/my.cnf")
        fe.search_file_replace_line(/pid-file/, 'pid-file                       = /var/run/mysqld/mysql.pid')
        Chef::Log.warn("Edited /etc/mysql/my.cnf to re-enable start on reboot.") if fe.write_file
      end
    end
    

相关问题