Tuesday, 25 November 2014

InnoDB: Unable to lock ./ibdata1, error: 11

 While trying to start MySQL server  (using /etc/init.d/mysql start), I got the following error,

141024 14:43:40 mysqld_safe Starting mysqld.bin daemon with databases from /opt/bitnami/mysql/data
141024 14:43:40 [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.
141024 14:43:40 [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.
141024 14:43:40 [Note] Plugin 'FEDERATED' is disabled.
141024 14:43:40 InnoDB: The InnoDB memory heap is disabled
141024 14:43:40 InnoDB: Mutexes and rw_locks use GCC atomic builtins
141024 14:43:40 InnoDB: Compressed tables use zlib 1.2.3
141024 14:43:40 InnoDB: Using Linux native AIO
141024 14:43:40 InnoDB: Initializing buffer pool, size = 8.0G
141024 14:43:41 InnoDB: Completed initialization of buffer pool
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.
141024 14:43:41  InnoDB: Retrying to lock the first data file
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.
141024 14:45:21  InnoDB: Unable to open the first data file
InnoDB: Error in opening ./ibdata1
141024 14:45:21  InnoDB: Operating system error number 11 in a file operation.
InnoDB: Error number 11 means 'Resource temporarily unavailable'.
InnoDB: Some operating system error numbers are described at
InnoDB: http://dev.mysql.com/doc/refman/5.5/en/operating-system-error-codes.html
141024 14:45:21 InnoDB: Could not open or create data files.
141024 14:45:21 InnoDB: If you tried to add new data files, and it failed here,
141024 14:45:21 InnoDB: you should now edit innodb_data_file_path in my.cnf back
141024 14:45:21 InnoDB: to what it was, and remove the new ibdata files InnoDB created
141024 14:45:21 InnoDB: in this failed attempt. InnoDB only wrote those files full of
141024 14:45:21 InnoDB: zeros, but did not yet use them in any way. But be careful: do not
141024 14:45:21 InnoDB: remove old data files which contain your precious data!
141024 14:45:21 [ERROR] Plugin 'InnoDB' init function returned error.
141024 14:45:21 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
141024 14:45:21 [ERROR] Unknown/unsupported storage engine: InnoDB
141024 14:45:21 [ERROR] Aborting

141024 14:45:21 [Note] /opt/bitnami/mysql/bin/mysqld.bin: Shutdown complete

From the error log it is found that already there is an MySQL running in the same server with same port.

You can check the current running MySQL by,

ps –ef | grep mysql

root@localhost:/opt/bitnami/mysql/data# ps -ef | grep mysql
root     25478 20976  0 14:25 pts/2    00:00:00 /opt/bitnami/mysql/bin/mysql.bin --defaults-file=/opt/bitnami/mysql/my.cnf -u dba –p
root     25555     1  0 14:26 ?        00:00:00 /bin/sh /opt/bitnami/mysql/scripts/ctl.sh start
root     25557 25555  0 14:26 ?        00:00:00 /bin/sh /opt/bitnami/mysql/bin/mysqld_safe --defaults-file=/opt/bitnami/mysql/my.cnf --port=3306 --socket=/opt/bitnami/mysql/tmp/mysql.sock --datadir=/opt/bitnami/mysql/data --log-error=/opt/bitnami/mysql/data/mysqld.log --pid-file=/opt/bitnami/mysql/data/mysqld.pid --lower-case-table-names=1
mysql    25929 25557  1 14:26 ?        00:00:00 /opt/bitnami/mysql/bin/mysqld.bin --defaults-file=/opt/bitnami/mysql/my.cnf --basedir=/opt/bitnami/mysql --datadir=/opt/bitnami/mysql/data --plugin-dir=/opt/bitnami/mysql/lib/plugin --user=mysql --lower-case-table-names=1 --log-error=/opt/bitnami/mysql/data/mysqld.log --pid-file=/opt/bitnami/mysql/data/mysqld.pid --socket=/opt/bitnami/mysql/tmp/mysql.sock --port=3306
root     25979 20976  0 14:27 pts/2    00:00:00 /bin/sh /etc/init.d/mysql restart
root     26025 25979  0 14:27 pts/2    00:00:00 /bin/sh /etc/init.d/mysql start
root     26038 26025  1 14:27 pts/2    00:00:00 /bin/sh /opt/bitnami/mysql/bin/mysqld_safe --datadir=/opt/bitnami/mysql/data --pid-file=/opt/bitnami/mysql/data/ip-172-31-59-38.pid
mysql    26345 26038 38 14:27 pts/2    00:00:00 /opt/bitnami/mysql/bin/mysqld.bin --basedir=/opt/bitnami/mysql --datadir=/opt/bitnami/mysql/data --plugin-dir=/opt/bitnami/mysql/lib/plugin --user=mysql --log-error=/opt/bitnami/mysql/data/ip-172-31-59-38.err --pid-file=/opt/bitnami/mysql/data/ip-172-31-59-38.pid --socket=/opt/bitnami/mysql/tmp/mysql.sock --port=3306
root     26349 22899  0 14:27 pts/0    00:00:00 grep --color=auto mysql


Here you could see there are two MySQL running’s with same base and data directories. But the error log path is mentioned different for both.

It was due to a script which made mysql to start automatically if MySQL is not running.

Solved by  killing all the running MySQL process and removed the script .Then made MySQL to start it started without error