【问题标题】:Puppet won't start MySQLPuppet 不会启动 MySQL
【发布时间】:2014-09-19 14:43:16
【问题描述】:

通过学习使用 puppet 和 vagrant,我的生活变得更轻松(我希望如此)。 我已经知道如何使用 Vagrant,但我想进行一个开箱即用的配置,以启动所有设置。所以我想用Puppet。 我使用了http://jamesmcfadden.co.uk/using-vagrant-and-puppet-to-build-a-php-nginx-and-mysql-environment/ 的教程,但似乎无法弄清楚如何启动 MySQL。

运行 Ubuntu 14.04LTS 我的 init.pp for MySQL 是

    class mysql {

  # Install mysql
  package { ['mysql-server']:
    ensure => present,
    require => Exec['apt-get update'],
  }

  # Run mysql
  service { 'mysql':
    ensure  => running,
    require => Package['mysql-server'],
  }

  # Use a custom mysql configuration file
  file { '/etc/mysql/my.cnf':
    source  => 'puppet:///modules/mysql/my.cnf',
    require => Package['mysql-server'],
    notify  => Service['mysql'],
  }

  # We set the root password here
  exec { 'set-mysql-password':
    unless  => 'mysqladmin -uroot -proot status',
    command => "mysqladmin -uroot password a9120ed2b58af37862a83f5b9f850819ed08b2a9",
    path    => ['/bin', '/usr/bin'],
    require => Service['mysql'];
  }
}

但这给了我一个找不到mysql的错误。

err: /Stage[main]/Mysql/Service[mysql]/ensure: change from stopped to running fa
iled: Could not start Service[mysql]: Execution of '/sbin/start mysql' returned
1:  at /tmp/vagrant-puppet-2/modules-0/mysql/manifests/init.pp:13

并将其更改为 mysqld(注意 'd')此消息消失了,但存在无法找到检查 mysql 是否正在运行的依赖项的问题(将它们更改为 'Service['mysqld ']':

err: /Stage[main]/Mysql/Service[mysqld]: Could not evaluate: Could not find init
 script or upstart conf file for 'mysqld'

我做错了吗?

【问题讨论】:

  • 显然mysql 没有尾随 d 是正确的,但您需要调查启动脚本失败的原因。尝试 syslog 或您可能让服务写入的任何专用 mysql 日志。

标签: mysql vagrant puppet ubuntu-14.04


【解决方案1】:

您的脚本有以下几行:

require => Exec['apt-get update'],

但不要定义'Exec'。添加以下行:

exec { 'apt-get update':

command => 'sudo apt-get update',

path    => ['/bin', '/usr/bin'],

}

之后应该可以正常工作。

【讨论】:

    【解决方案2】:

    不要尝试编写自己的 MySQL 模块。请使用官方支持的puppet MySQL 模块。要安装它,请调用:

    puppet module install puppetlabs-mysql
    

    一般来说,如果你想通过puppet安装/管理一些应用程序,首先检查puppet forge上是否存在专用模块。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-05-21
      • 2018-05-08
      • 2015-03-30
      • 2020-06-17
      • 2014-06-20
      • 2017-09-11
      • 2013-06-30
      相关资源
      最近更新 更多