mysql not starting in LXC container

tgoetten

New Member
Feb 19, 2014
11
0
1
Hi,

i've set up a LXC container running Debian 8 along with MySQL. Everything was fine until i did a restart. Now mysql is not started automatically during boot.

A manual try "service mysql start" has the following result:
Code:
Job for mysql.service failed. See 'systemctl status mysql.service' and 'journalctl -xn' for details.

Here is the output for both commands

"systemctl status mysql.service":
Code:
● mysql.service - LSB: Start and stop the mysql database server daemon
   Loaded: loaded (/etc/init.d/mysql)
   Active: failed (Result: exit-code) since Tue 2016-05-17 09:36:45 CEST; 20s ago
  Process: 5100 ExecStart=/etc/init.d/mysql start (code=exited, status=1/FAILURE)

May 17 09:36:45 icePIM systemd[1]: mysql.service: control process exited, code=exited status=1
May 17 09:36:45 icePIM systemd[1]: Failed to start LSB: Start and stop the mysql database server daemon.
May 17 09:36:45 icePIM systemd[1]: Unit mysql.service entered failed state.
May 17 09:36:45 icePIM mysql[5100]: Starting MySQL database server: mysqld . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . failed!

"journalctl -xn":
Code:
-- Logs begin at Mon 2016-05-16 09:30:15 CEST, end at Tue 2016-05-17 09:36:45 CEST. --
May 17 09:36:14 icePIM systemd[1]: Failed to reset devices.list on /lxc/103/system.slice/mysql.service: Permission denied
May 17 09:36:45 icePIM /etc/init.d/mysql[5829]: 0 processes alive and '/usr/bin/mysqladmin --defaults-file=/etc/mysql/debian.cnf ping' resulted in
May 17 09:36:45 icePIM /etc/init.d/mysql[5829]: [61B blob data]
May 17 09:36:45 icePIM /etc/init.d/mysql[5829]: error: 'Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)'
May 17 09:36:45 icePIM /etc/init.d/mysql[5829]: Check that mysqld is running and that the socket: '/var/run/mysqld/mysqld.sock' exists!
May 17 09:36:45 icePIM /etc/init.d/mysql[5829]:
May 17 09:36:45 icePIM systemd[1]: mysql.service: control process exited, code=exited status=1
May 17 09:36:45 icePIM systemd[1]: Failed to start LSB: Start and stop the mysql database server daemon.
-- Subject: Unit mysql.service has failed
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit mysql.service has failed.
--
-- The result is failed.
May 17 09:36:45 icePIM systemd[1]: Unit mysql.service entered failed state.
May 17 09:36:45 icePIM mysql[5100]: Starting MySQL database server: mysqld . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . failed!

But, if i start mysql not through the service, it works - no error messages.

"/usr/sbin/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib/mysql/plugin --user=mysql --log-error=/var/log/mysql/error.log --pid-file=/var/run/mysqld/mysqld.pid --socket=/var/run/mysqld/mysqld.sock --port=3306"

Code:
160517  9:37:59 [Warning] Using unique option prefix key_buffer instead of key_buffer_size is deprecated and will be removed in a future release. Please use the full name instead.
160517  9:37:59 [Note] /usr/sbin/mysqld (mysqld 5.5.47-0+deb8u1) starting as process 5835 ...
160517  9:37:59 [Warning] Using unique option prefix myisam-recover instead of myisam-recover-options is deprecated and will be removed in a future release. Please use the full name instead.
160517  9:37:59 [Note] Plugin 'FEDERATED' is disabled.
160517  9:37:59 InnoDB: The InnoDB memory heap is disabled
160517  9:37:59 InnoDB: Mutexes and rw_locks use GCC atomic builtins
160517  9:37:59 InnoDB: Compressed tables use zlib 1.2.8
160517  9:37:59 InnoDB: Using Linux native AIO
160517  9:37:59 InnoDB: Initializing buffer pool, size = 128.0M
160517  9:37:59 InnoDB: Completed initialization of buffer pool
160517  9:37:59 InnoDB: highest supported file format is Barracuda.
InnoDB: The log sequence number in ibdata files does not match
InnoDB: the log sequence number in the ib_logfiles!
160517  9:37:59  InnoDB: Database was not shut down normally!
InnoDB: Starting crash recovery.
InnoDB: Reading tablespace information from the .ibd files...
InnoDB: Restoring possible half-written data pages from the doublewrite
InnoDB: buffer...
160517  9:37:59  InnoDB: Waiting for the background threads to start
160517  9:38:00 InnoDB: 5.5.47 started; log sequence number 38106972740
160517  9:38:00 [Note] Server hostname (bind-address): '0.0.0.0'; port: 3306
160517  9:38:00 [Note]   - '0.0.0.0' resolves to '0.0.0.0';
160517  9:38:00 [Note] Server socket created on IP: '0.0.0.0'.
160517  9:38:00 [Note] Event Scheduler: Loaded 0 events
160517  9:38:00 [Note] /usr/sbin/mysqld: ready for connections.
Version: '5.5.47-0+deb8u1'  socket: '/var/run/mysqld/mysqld.sock'  port: 3306  (Debian)

Any Idea on this?

Thanks
Thomas
 
Last edited:
Hi,
I have faced similar issues, but after a backup and restore of LXC.

It had to do with the "/var/run", etc. directory missing or having the wrong ownership.

HTH,
Shantanu