mysql server shuts down on its own every 5 minutes - mysql

I'm running a Wordpress Blog in a 512mb RAM Ubuntu 12.04 Server. The blog i'm working with has a considerable amount of traffic.
At first, the mysql server shuts down every time I enter the dashboard (sometimes I don't even reach wp-login.php). I thought that by disabling the wp plugins directory temporarily should do the trick, thinking that a plugin may be causing it. When I did just that, mysql doesn't shutdown anymore...for just a while. After 5 to 10 minutes, the problem occurs again and mysql shutdowns by itself. The only good thing that action did was to prolong the life of the mysql server before it shuts down by itself.
This is my error log from /var/log/mysql/error.log . It consists of several blocks of these:
131218 12:39:34 [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.
131218 12:39:34 [Note] Plugin 'FEDERATED' is disabled.
131218 12:39:34 InnoDB: The InnoDB memory heap is disabled
131218 12:39:34 InnoDB: Mutexes and rw_locks use GCC atomic builtins
131218 12:39:34 InnoDB: Compressed tables use zlib 1.2.3.4
131218 12:39:34 InnoDB: Initializing buffer pool, size = 128.0M
InnoDB: mmap(137363456 bytes) failed; errno 12
131218 12:39:34 InnoDB: Completed initialization of buffer pool
131218 12:39:34 InnoDB: Fatal error: cannot allocate memory for the buffer pool
131218 12:39:34 [ERROR] Plugin 'InnoDB' init function returned error.
131218 12:39:34 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
131218 12:39:34 [ERROR] Unknown/unsupported storage engine: InnoDB
131218 12:39:34 [ERROR] Aborting
131218 12:39:34 [Note] /usr/sbin/mysqld: Shutdown complete
Research points that I may indeed be lacking in memory but i'm trying to avoid upgrading not until I confirmed that that is the only solution.
Any ideas? TIA

Related

XAMPP: MySQL not starting

I was in the middle of developing my site and both apache and mysql were running normally until suddenly, the database failed to connect. I checked my XAMPP control panel and MySQL had stopped running. I searched for a solution here and some other similar questions on SO but i haven't been able to find a solution that works for me. Here is the contents of mysql_error.log file:
2016-04-15 20:30:18 150c InnoDB: Warning: Using innodb_additional_mem_pool_size is DEPRECATED. This option may be removed in future releases, together with the option innodb_use_sys_malloc and with the InnoDB's internal memory allocator.
160415 20:30:18 [Note] InnoDB: Using mutexes to ref count buffer pool pages
160415 20:30:18 [Note] InnoDB: The InnoDB memory heap is disabled
160415 20:30:18 [Note] InnoDB: Mutexes and rw_locks use Windows interlocked functions
160415 20:30:18 [Note] InnoDB: Memory barrier is not used
160415 20:30:18 [Note] InnoDB: Compressed tables use zlib 1.2.3
160415 20:30:18 [Note] InnoDB: Not using CPU crc32 instructions
160415 20:30:18 [Note] InnoDB: Initializing buffer pool, size = 16.0M
160415 20:30:18 [Note] InnoDB: Completed initialization of buffer pool
160415 20:30:18 [Note] InnoDB: Restoring page 0 of tablespace 0
160415 20:30:18 [Warning] InnoDB: Doublewrite does not have page_no=0 of space: 0
160415 20:30:18 [ERROR] InnoDB: space header page consists of zero bytes in data file D:\xampp\mysql\data\ibdata1
160415 20:30:18 [ERROR] InnoDB: Could not open or create the system tablespace. If you tried to add new data files to the system tablespace, and it failed here, you should now edit innodb_data_file_path in my.cnf back to what it was, and remove the new ibdata files InnoDB created in this failed attempt. InnoDB only wrote those files full of zeros, but did not yet use them in any way. But be careful: do not remove old data files which contain your precious data!
160415 20:30:18 [ERROR] Plugin 'InnoDB' init function returned error.
160415 20:30:18 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
160415 20:30:18 [Note] Plugin 'FEEDBACK' is disabled.
160415 20:30:18 [ERROR] Unknown/unsupported storage engine: InnoDB
160415 20:30:18 [ERROR] Aborting
160415 20:30:18 [Note] D:\xampp\mysql\bin\mysqld.exe: Shutdown complete
What i have tried until now:
i have changed to port address for from 3306 to 3307, 3310. Didn't work.
i deleted ibdata1 file. Although the file reappeared back in its place after i attempted to restart MySQL. (I learnt later that i would lose my tables if ibdata1 is missing. i don't want that.)
Why did MySQL suddenly run into problems and and how to start MySQL without losing my tables?
There are several reason MySql keeps shutting down unexpectedly.
I am assuming that you have not installed multiple mysql server versions in the same machine.
Stop Mysql service from xampp control panel or stop it manually from services.msc and quit the xampp control panel.
Delete these two log files (ib_logfile0 and ib_logfile1) from xampp/mysql/ directory. (Note: I am not sure about the exact path of log files, check in all the folders of xampp/mysql/ directory)
Restart Mysql service manually from services.msc
open xampp control panel, you should see mysql is running.
I also see your innodb_buffer_pool_size is very low.
Increase the buffer_pool_size to about 50-60% of your RAM. For example, If you have 2GB ram, then set buffer_pool_size= 1GB
run this query in mysql.
set innodb_buffer_pool_size=1073741824;
or
set global innodb_buffer_pool_size=1073741824;
restart mysql server.

AWS Micro Instance - MySQL keeps failing in Wordpress installation

I have a Ubuntu micro instance with default settings. As a matter of fact, this instance is the same as 8 others I have created prior and since to host Wordpress websites.
This one belongs to a Church, and unfortunately, it keeps having its MySql server going to heaven! I am not sure how to sort this, as the mysql.err log shows:
160301 5:03:40 [Warning] Using unique option prefix myisam-recover instead of myisam-recover-options is deprecated and will be removed in$
160301 5:03:40 [Note] Plugin 'FEDERATED' is disabled.
160301 5:03:40 InnoDB: The InnoDB memory heap is disabled
160301 5:03:40 InnoDB: Mutexes and rw_locks use GCC atomic builtins
160301 5:03:40 InnoDB: Compressed tables use zlib 1.2.8
160301 5:03:40 InnoDB: Using Linux native AIO
160301 5:03:40 InnoDB: Initializing buffer pool, size = 128.0M
InnoDB: mmap(137363456 bytes) failed; errno 12
160301 5:03:40 InnoDB: Completed initialization of buffer pool
160301 5:03:40 InnoDB: Fatal error: cannot allocate memory for the buffer pool
160301 5:03:40 [ERROR] Plugin 'InnoDB' init function returned error.
160301 5:03:40 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
160301 5:03:40 [ERROR] Unknown/unsupported storage engine: InnoDB
160301 5:03:40 [ERROR] Aborting
160301 5:03:40 [Note] /usr/sbin/mysqld: Shutdown complete
This is telling me it could not allocate the 128MB required for the buffer pool.
But, my free -m shows there is plenty of memory for this (I also set up a 2GB swap).
ubuntu#ip-xxx-xxx-xxx-xxx:/var/log/mysql$ free -m
total used free shared buffers cached
Mem: 992 634 358 54 76 308
-/+ buffers/cache: 249 742
Swap: 2047 0 2047
Any suggestions are appreciated!
Looks like there is not enough memory left for allocation during the start process.
add this to your /etc/mysql/my.cnf
innodb_buffer_pool_size = 20M

mysql Fatal error: cannot allocate memory for the buffer pool

I have this error log from MySQL, any idea?
Website works for some time and then I get MySQL shutdown completely after a couple of hours.
140919 10:48:27 [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.
140919 10:48:27 [Note] Plugin 'FEDERATED' is disabled.
140919 10:48:27 InnoDB: The InnoDB memory heap is disabled
140919 10:48:27 InnoDB: Mutexes and rw_locks use GCC atomic builtins
140919 10:48:27 InnoDB: Compressed tables use zlib 1.2.3.4
140919 10:48:28 InnoDB: Initializing buffer pool, size = 128.0M
InnoDB: mmap(137363456 bytes) failed; errno 12
140919 10:48:28 InnoDB: Completed initialization of buffer pool
140919 10:48:28 InnoDB: Fatal error: cannot allocate memory for the buffer pool
140919 10:48:28 [ERROR] Plugin 'InnoDB' init function returned error.
140919 10:48:28 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
140919 10:48:28 [ERROR] Unknown/unsupported storage engine: InnoDB
140919 10:48:28 [ERROR] Aborting
140919 10:48:28 [Note] /usr/sbin/mysqld: Shutdown complete
140919 10:48:28 [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.
140919 10:48:28 [Note] Plugin 'FEDERATED' is disabled.
140919 10:48:28 InnoDB: The InnoDB memory heap is disabled
140919 10:48:28 InnoDB: Mutexes and rw_locks use GCC atomic builtins
140919 10:48:28 InnoDB: Compressed tables use zlib 1.2.3.4
140919 10:48:28 InnoDB: Initializing buffer pool, size = 128.0M
InnoDB: mmap(137363456 bytes) failed; errno 12
140919 10:48:28 InnoDB: Completed initialization of buffer pool
140919 10:48:28 InnoDB: Fatal error: cannot allocate memory for the buffer pool
140919 10:48:28 [ERROR] Plugin 'InnoDB' init function returned error.
140919 10:48:28 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
140919 10:48:28 [ERROR] Unknown/unsupported storage engine: InnoDB
140919 10:48:28 [ERROR] Aborting
140919 10:48:28 [Note] /usr/sbin/mysqld: Shutdown complete
TLDR;
Mysql can't restart because it's out of memory, check that you have an appropriate swapfile configured.
Didn't help? If that's not your issue, more qualified questions to continue research are:
mysqld service stops once a day on ec2 server
https://askubuntu.com/questions/422037/optimising-mysql-settings-mysqld-running-out-of-memory
Background
I had exactly this problem on the very first system I set up on EC2, characterised by the wordpress site hosted there going down on occasion with "Error establishing database connection".
The logs showed the same error that the OP posted. My reading of the error (timestamps removed) is:
Out of memory error:
InnoDB: Fatal error: cannot allocate memory for the buffer pool
InnoDB can't start without enough memory
[ERROR] Plugin 'InnoDB' init function returned error.
[ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
[ERROR] Unknown/unsupported storage engine: InnoDB
[ERROR] Aborting
mysqld is shutting down, which in this context, really means failing to restart!
[Note] /usr/sbin/mysqld: Shutdown complete
Checking /var/log/syslog and searching for mysql yields:
Out of memory: Kill process 15452 (mysqld) score 93 or sacrifice child
Killed process 15452 (mysqld) total-vm:888672kB, anon-rss:56252kB, file-rss:0kB
init: mysql main process (15452) killed by KILL signal
init: mysql main process ended, respawning
type=1400 audit(1443812767.391:30): apparmor="STATUS" operation="profile_replace" name="/usr/sbin/mysqld" pid=21984 comm="apparmor_parser"
init: mysql main process (21996) terminated with status 1
init: mysql main process ended, respawning
init: mysql post-start process (21997) terminated with status 1
<repeated>
Note: you may have to gunzip and search through archived logs if the error occurred before the logs were rotated by cron.
Solution
In my case the underlying issue was that I'd neglected to configure a swapfile.
You can check to see if you have one configured by running free -m.
total used free shared buffers cached
Mem: 604340 587364 16976 0 29260 72280
-/+ buffers/cache: 485824 118516
Swap: 0 0 0
In the example above, Swap: 0 indicates no swapfile.
Tutorials on setting one up:
https://www.digitalocean.com/community/tutorials/how-to-add-swap-on-ubuntu-14-04
https://help.ubuntu.com/community/SwapFaq
Note that bigger is not necessarily better! From the Ubuntu guide:
The "diminishing returns" means that if you need more swap space than twice your RAM size, you'd better add more RAM as Hard Disk Drive (HDD) access is about 10³ slower then RAM access, so something that would take 1 second, suddenly takes more then 15 minutes! And still more then a minute on a fast Solid State Drive (SSD)...
Regarding the other answers here...
The InnoDB memory heap is disabled
This isn’t really an error, just an indication that InnoDB is using the system’s internal memory allocator instead of its own. The default is yes/1, and is acceptable for production.
According to the docs, this command is deprecated, and will be removed in MySQL versions above 5.6 (and I assume MariaDB):
http://dev.mysql.com/doc/refman/5.6/en/innodb-performance-use_sys_malloc.html
Thanks to: Ruben Schade comment
[Note] Plugin 'FEDERATED' is disabled.
The message about FEDERATED disabled is not an error. It just meant that the FEDERATED engine its not ON for your mysql server. It's not used by default. If you don't need it, don't care about this message.
See: https://stackoverflow.com/a/16470822/2586761
I found this answer adds to the discussion: https://www.digitalocean.com/community/questions/mysql-server-keeps-stopping-unexpectedly?answer=26021
In short, on top of setting innodb_buffer_pool_size to something reasonable like 64M, you also may need to modify /etc/apache2/mods-enabled/mpm_prefork.conf to reduce the number of connections started by apache;
<IfModule mpm_prefork_module>
StartServers 3
MinSpareServers 3
MaxSpareServers 5
MaxRequestWorkers 25
MaxConnectionsPerChild 1024
</IfModule>
The solution is NOT more space, Problem is Apache web server not mysql, actually you need to decrease innodb-buffer-pool-size
This buffer is used by the mysql process right off the start, so when Apache needs more resources the kernel will clear RAM from services this means stopping mysql instead of crashing the server.
Would also add a CRON to check the db status and restart it if you dont want to change to ngnx or httplight.

Mysql stops working in my ubuntu machine 13.04

I am facing this weird issue. Suddenly mysql stops working and i am getting error log in /var/log/mysql/error.log
**
140501 17:21:09 [Note] Plugin 'FEDERATED' is disabled.
140501 17:21:09 InnoDB: The InnoDB memory heap is disabled
140501 17:21:09 InnoDB: Mutexes and rw_locks use GCC atomic builtins
140501 17:21:09 InnoDB: Compressed tables use zlib 1.2.3.4
140501 17:21:10 InnoDB: Initializing buffer pool, size = 128.0M
140501 17:21:10 InnoDB: Completed initialization of buffer pool
140501 17:21:10 InnoDB: highest supported file format is Barracuda.
InnoDB: No valid checkpoint found.
InnoDB: If this error appears when you are creating an InnoDB database,
InnoDB: the problem may be that during an earlier attempt you managed
InnoDB: to create the InnoDB data files, but log file creation failed.
InnoDB: If that is the case, please refer to
InnoDB: http://dev.mysql.com/doc/refman/5.5/en/error-creating-innodb.html
140501 17:21:10 [ERROR] Plugin 'InnoDB' init function returned error.
140501 17:21:10 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
140501 17:21:10 [ERROR] Unknown/unsupported storage engine: InnoDB
140501 17:21:10 [ERROR] Aborting
140501 17:21:10 [Note] /usr/sbin/mysqld: Shutdown complete
**
Its very itching problem as I can write a single code without myqsl connection. How to solve this issue.
PS: Sorry Ubuntu fellas as I am using 13.04 unsupported version, I have already installed 14.04 and will move to it in a couple of days.
After going through lots of suggestions I found in stackoverflow and other mysql related websites, I did not success to fix this issue. then I reconfigure my mysql installations and voila its working now.
Command I used is
sudo dpkg-reconfigure mysql-server-5.5

Mysql / InnoDB stops working?

I've been running a new server instance fine for the past two weeks. Starting today, mysql stoped working by itself, and here is the logs I'm getting.
130922 13:32:39 [Note] Plugin 'FEDERATED' is disabled.
130922 13:32:39 InnoDB: The InnoDB memory heap is disabled
130922 13:32:39 InnoDB: Mutexes and rw_locks use GCC atomic builtins
130922 13:32:39 InnoDB: Compressed tables use zlib 1.2.3.4
130922 13:32:39 InnoDB: Initializing buffer pool, size = 128.0M
InnoDB: mmap(135987200 bytes) failed; errno 12
130922 13:32:39 InnoDB: Completed initialization of buffer pool
130922 13:32:39 InnoDB: Fatal error: cannot allocate memory for the buffer pool
130922 13:32:39 [ERROR] Plugin 'InnoDB' init function returned error.
130922 13:32:39 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
130922 13:32:39 [ERROR] Unknown/unsupported storage engine: InnoDB
130922 13:32:39 [ERROR] Aborting
130922 13:32:39 [Note] /usr/sbin/mysqld: Shutdown complete
From what I'm looking at, it seems that there is a problem allocating memory to the databases (there are only a wordpress installed on this machine)... Although, Googling around gives me multiple answers to multiple problem, and I'm not quite sure what do do now.
Right now, the only way to solve the problem is to reboot the machine, then mysql will work again until the next time I see that kind of messages in the log.
Should I try to find a way to change anything in my.cnf for memory? Or is there any other avenue that you could suggest?
In the end, I moved the server over new specs with higher memory and it seems it did the trick, as #Bill-Karwin suggested.