简体   繁体   English

使用Ansible在Ubuntu 14.04上自动安装MySQL

[英]Automate MySQL install on Ubuntu 14.04 using Ansible

I'm trying to setup a Vagrant environment involving a few Ubuntu machines with Ansible and am having trouble writing an Ansible Playbook to automate the process. 我正在尝试使用Ansible设置一个涉及少量Ubuntu机器的Vagrant环境,并且在编写Ansible Playbook以自动化该过程时遇到问题。 Primarily, I'm following the instructions from this answer - https://stackoverflow.com/a/26598887 首先,我按照这个答案的说明进行操作 - https://stackoverflow.com/a/26598887

Here is the snippet of the error I'm getting from running the playbook; 这是我从运行剧本中得到的错误片段;

PLAY [web] ******************************************************************** 

GATHERING FACTS *************************************************************** 
ok: [business-web1]

TASK: [Install MySQL] ********************************************************* 
failed: [business-web1] => (item=mysql-server) => {"failed": true, "item": "mysql-server"}
stderr: start: Job failed to start
invoke-rc.d: initscript mysql, action "start" failed.
dpkg: error processing package mysql-server-5.5 (--configure):
 subprocess installed post-installation script returned error exit status 1
dpkg: dependency problems prevent configuration of mysql-server:
 mysql-server depends on mysql-server-5.5; however:
  Package mysql-server-5.5 is not configured yet.

dpkg: error processing package mysql-server (--configure):
 dependency problems - leaving unconfigured
No apport report written because the error message indicates its a followup error from a previous failure.
Errors were encountered while processing:
 mysql-server-5.5
 mysql-server
E: Sub-process /usr/bin/dpkg returned an error code (1)

stdout: Reading package lists...
Building dependency tree...
Reading state information...
mysql-server is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 52 not upgraded.
2 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
Setting up mysql-server-5.5 (5.5.44-0ubuntu0.14.04.1) ...

msg: '/usr/bin/apt-get -y -o "Dpkg::Options::=--force-confdef" -o "Dpkg::Options::=--force-confold"   install 'mysql-server'' failed: start: Job failed to start
invoke-rc.d: initscript mysql, action "start" failed.
dpkg: error processing package mysql-server-5.5 (--configure):
 subprocess installed post-installation script returned error exit status 1
dpkg: dependency problems prevent configuration of mysql-server:
 mysql-server depends on mysql-server-5.5; however:
  Package mysql-server-5.5 is not configured yet.

dpkg: error processing package mysql-server (--configure):
 dependency problems - leaving unconfigured
No apport report written because the error message indicates its a followup error from a previous failure.
Errors were encountered while processing:
 mysql-server-5.5
 mysql-server
E: Sub-process /usr/bin/dpkg returned an error code (1)


FATAL: all hosts have already failed -- aborting

PLAY RECAP ******************************************************************** 
           to retry, use: --limit @/home/vagrant/provision-business-mysql.retry

business-web1              : ok=1    changed=0    unreachable=0    failed=1   

To the best of my understanding, it looks like the first 'install mysql' step isn't being run. 据我所知,看起来第一个“安装mysql”步骤没有运行。 To verify this, I managed to recreate the problem by running the ansible module directly from command line; 为了验证这一点,我设法通过直接从命令行运行ansible模块来重新创建问题;

vagrant@mgmt:~$ ansible web -m apt -a "name=mysql-server update_cache=yes cache_valid_time=3600 state=latest" --sudo
business-web1 | FAILED >> {
    "failed": true,
    "msg": "'/usr/bin/apt-get -y -o \"Dpkg::Options::=--force-confdef\" -o \"Dpkg::Options::=--force-confold\"   install 'mysql-server'' failed: start: Job failed to start\ninvoke-rc.d: initscript mysql, action \"start\" failed.\ndpkg: error processing package mysql-server-5.5 (--configure):\n subprocess installed post-installation script returned error exit status 1\ndpkg: dependency problems prevent configuration of mysql-server:\n mysql-server depends on mysql-server-5.5; however:\n  Package mysql-server-5.5 is not configured yet.\n\ndpkg: error processing package mysql-server (--configure):\n dependency problems - leaving unconfigured\nNo apport report written because the error message indicates its a followup error from a previous failure.\nErrors were encountered while processing:\n mysql-server-5.5\n mysql-server\nE: Sub-process /usr/bin/dpkg returned an error code (1)\n",
    "stderr": "start: Job failed to start\ninvoke-rc.d: initscript mysql, action \"start\" failed.\ndpkg: error processing package mysql-server-5.5 (--configure):\n subprocess installed post-installation script returned error exit status 1\ndpkg: dependency problems prevent configuration of mysql-server:\n mysql-server depends on mysql-server-5.5; however:\n  Package mysql-server-5.5 is not configured yet.\n\ndpkg: error processing package mysql-server (--configure):\n dependency problems - leaving unconfigured\nNo apport report written because the error message indicates its a followup error from a previous failure.\nErrors were encountered while processing:\n mysql-server-5.5\n mysql-server\nE: Sub-process /usr/bin/dpkg returned an error code (1)\n",
    "stdout": "Reading package lists...\nBuilding dependency tree...\nReading state information...\nmysql-server is already the newest version.\n0 upgraded, 0 newly installed, 0 to remove and 52 not upgraded.\n2 not fully installed or removed.\nAfter this operation, 0 B of additional disk space will be used.\nSetting up mysql-server-5.5 (5.5.44-0ubuntu0.14.04.1) ...\n"
}

vagrant@mgmt:~$ 

Any idea how I can get mysql installed and a DB setup using Ansible? 知道如何安装mysql和使用Ansible进行数据库设置吗?

I had this same error occurring trying to install mysql on a fresh ubuntu/trusty64 box. 尝试在新的ubuntu / trusty64框上安装mysql时发生同样的错误。 Crazily enough it turned out to be due to the VM instance having less than 512MB of memory. 疯狂的原因是由于VM实例的内存少于512MB。 Make sure your Vagrantfile allots your VM enough memory. 确保您的Vagrantfile为您的VM分配足够的内存。

config.vm.provider "virtualbox" do |vb|
  vb.memory = "512"
end

@MicahElliott points into the right direction. @MicahElliott指出了正确的方向。 The error is not related to ansible, but to apt. 该错误与ansible无关,但与apt无关。

E: Sub-process /usr/bin/dpkg returned an error code (1) E:子进程/ usr / bin / dpkg返回错误代码(1)

stdout: Reading package lists... Building dependency tree... Reading state information... mysql-server is already the newest version. stdout:读取包列表...构建依赖树...读取状态信息... mysql-server已经是最新版本了。 0 upgraded, 0 newly installed, 0 to remove and 52 not upgraded. 0升级,0新安装,0删除,52未升级。 2 not fully installed or removed. 2未完全安装或移除。

Look here for a solution: https://askubuntu.com/a/438843/231051 在这里寻找解决方案: https//askubuntu.com/a/438843/231051

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM