Service mysql stopped is not working

57 views
Skip to first unread message

marc cyprien

unread,
Jun 8, 2015, 10:20:23 AM6/8/15
to ansible...@googlegroups.com
**context**
I am trying to install mysql for openstack but I got a problem with mysql. Here are my tasks:
<pre>
---
# Tasks for the base controller node

#- name: Edit /etc/hosts
#  template: src=hosts.j2 dest=/etc/hosts  owner=root group=root mode=0644

- name: configure /etc/hosts
  lineinfile: dest=/etc/hosts regexp={{ item.regexp }} line={{ item.line }}
  with_items:
    - { regexp: "{{ controller_ip }}", line: '"{{ controller_ip }} controller"' }
    - { regexp: "{{ network_ip }}", line: '"{{ network_ip }} network"' }
    - { regexp: "{{ compute_ip }}", line: '"{{ compute_ip }} compute"' }

- name: Install the base packages
  apt: pkg={{ item }} state=present
  with_items:
   - ntp
   - mysql-server
   - python-mysqldb
   - rabbitmq-server
 
- name: install mysql config file that binds to management network interface
  template:
    src: my.cnf.j2
    dest: /etc/mysql/my.cnf
    owner: root
    group: root
    mode: 0644

- name: restart mysql
  service: name=mysql state=restarted

- name: update mysql root password for all root accounts
  mysql_user:
    name: root
    host: localhost
    password: "{{ mysql_root_password }}"

- name: copy user my.cnf file with root passwd credentials
  template: src=.my.cnf.j2 dest=/root/.my.cnf owner=root group=root mode=0600

- name: delete anonymous mysql user
  mysql_user: name="" state=absent
 
- name: remove mysql test database
  mysql_db: name=test state=absent
</pre>

**Expected**
When mysql is restarted, I just expect it to shutdown and start smoothly. Like that, openstack modules can connect to their database and work.

**What I get**
Mysql is not restarted correctly and I can't connect to it.
<pre>
mysql -u root -p
Enter password:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
</pre>

In fact the mysql stopped state doesn't work, reslting in this error:

 <pre>
InnoDB: Unable to lock ./ibdata1, error: 11
InnoDB: Check that you do not already have another mysqld process
InnoDB: using the same InnoDB data or log files.
InnoDB: Unable to lock ./ibdata1, error: 11
InnoDB: Check that you do not already have another mysqld process
InnoDB: using the same InnoDB data or log files.
InnoDB: Unable to lock ./ibdata1, error: 11
InnoDB: Check that you do not already have another mysqld process
InnoDB: using the same InnoDB data or log files.
130210 21:17:53  InnoDB: Unable to open the first data file
InnoDB: Error in opening ./ibdata1
130210 21:17:53  InnoDB: Operating system error number 11 in a file operation.
</pre>

It only do it when I use ansible. If I do :
<pre>
sudo service mysql restart
</pre>
there is no problem. If I don't restart mysql I don't get any problem in logs.


Brian Coca

unread,
Jun 8, 2015, 11:16:58 AM6/8/15
to ansible...@googlegroups.com
check your mysql data directory in the config, it is either pointing
at an invalid directory or the directory it is pointing at does not
have appropriate permissions for the user that runs mysql.
> --
> You received this message because you are subscribed to the Google Groups
> "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to ansible-proje...@googlegroups.com.
> To post to this group, send email to ansible...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/f7391d1f-25ef-4f12-bbd1-e6e4cdac07c9%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.



--
Brian Coca
Reply all
Reply to author
Forward
0 new messages