Apache or MySQL crash
my Linode has: 1gb ram, ubuntu 14.04 with 256mb swap size. My apache/php/mysql configuration is according the Linode tutorials for 1gb ram.
This is the syslog of when it occured. It seems like it tries to kill processes in order to free up memory and because (after some research) it has 0 swap file size.
Syslog
Jun 23 04:09:02 www CRON[26655]: (root) CMD ( [ -x /usr/lib/php5/maxlifetime ] && [ -x /usr/lib/php5/sessionclean ] && [ -d /var/lib/php5 ] && /usr/lib/php5/sessionclean /var/lib/php5 $(/usr/lib/php5/maxlifetime))
Jun 23 04:09:18 www kernel: apache2 invoked oom-killer: gfp_mask=0x200da, order=0, oom_score_adj=0
Jun 23 04:09:18 www kernel: apache2 cpuset=/ mems_allowed=0
Jun 23 04:09:18 www kernel: CPU: 0 PID: 26613 Comm: apache2 Not tainted 4.0.5-x86_64-linode58 #1
Jun 23 04:09:18 www kernel: 0000000000000000 ffff8800029d67c0 ffffffff8193b626 ffff8800029d6180
Jun 23 04:09:18 www kernel: ffffffff819360a4 0000000000000400 ffff88003fe16000 0000000000000020
Jun 23 04:09:18 www kernel: ffff88003fe16000 0000000000000000 0000000000000000 0000000000000000
Jun 23 04:09:18 www kernel: Call Trace:
Jun 23 04:09:18 www kernel: [<ffffffff8193b626>] ? dump_stack+0x40/0x50
Jun 23 04:09:18 www kernel: [<ffffffff819360a4>] ? dump_header.isra.10+0x78/0x1e3
Jun 23 04:09:18 www kernel: [<ffffffff81941bb6>] ? _raw_spin_unlock_irqrestore+0x2e/0x3f
Jun 23 04:09:18 www kernel: [<ffffffff81172f4a>] ? oom_kill_process+0xbe/0x380
Jun 23 04:09:18 www kernel: [<ffffffff8117369a>] ? __out_of_memory+0x43d/0x47d
Jun 23 04:09:18 www kernel: [<ffffffff8117381b>] ? out_of_memory+0x52/0x67
Jun 23 04:09:18 www kernel: [<ffffffff811777e5>] ? __alloc_pages_nodemask+0x708/0x846
Jun 23 04:09:18 www kernel: [<ffffffff81004a2d>] ? __raw_callee_save_xen_pte_val+0x11/0x1e
Jun 23 04:09:18 www kernel: [<ffffffff811a57d6>] ? alloc_pages_vma+0x111/0x15a
Jun 23 04:09:18 www kernel: [<ffffffff8119fc14>] ? read_swap_cache_async+0x76/0x121
Jun 23 04:09:18 www kernel: [<ffffffff8119fe04>] ? swapin_readahead+0x145/0x155
Jun 23 04:09:18 www kernel: [<ffffffff811700bb>] ? find_get_entry+0x1a/0x68
Jun 23 04:09:18 www kernel: [<ffffffff81170b9f>] ? pagecache_get_page+0x26/0x160
Jun 23 04:09:18 www kernel: [<ffffffff8119365a>] ? handle_mm_fault+0x9c1/0xd80
Jun 23 04:09:18 www kernel: [<ffffffff8104219d>] ? __do_page_fault+0x321/0x37b
Jun 23 04:09:18 www kernel: [<ffffffff8193ec28>] ? __schedule+0x5de/0x7cd
Jun 23 04:09:18 www kernel: [<ffffffff81943f08>] ? page_fault+0x28/0x30
Jun 23 04:09:18 www kernel: Mem-Info:
Jun 23 04:09:18 www kernel: Node 0 DMA per-cpu:
Jun 23 04:09:18 www kernel: CPU 0: hi: 0, btch: 1 usd: 0
Jun 23 04:09:18 www kernel: Node 0 DMA32 per-cpu:
Jun 23 04:09:18 www kernel: CPU 0: hi: 186, btch: 31 usd: 5
Jun 23 04:09:18 www kernel: active_anon:104835 inactive_anon:104945 isolated_anon:0
Jun 23 04:09:18 www kernel: active_file:38 inactive_file:348 isolated_file:0
Jun 23 04:09:18 www kernel: unevictable:0 dirty:0 writeback:0 unstable:0
Jun 23 04:09:18 www kernel: free:2444 slab_reclaimable:17327 slab_unreclaimable:5466
Jun 23 04:09:18 www kernel: mapped:4636 shmem:5034 pagetables:2252 bounce:0
Jun 23 04:09:18 www kernel: free_cma:0
Jun 23 04:09:18 www kernel: Node 0 DMA free:3948kB min:60kB low:72kB high:88kB active_anon:4084kB inactive_anon:4224kB active_file:16kB inactive_file:24kB unevictable:0kB isolated(anon):0kB isolated(file):0kB present:15996kB managed:15912kB mlocked:0kB dirty:0kB writeback:0kB mapped:836kB shmem:1152kB slab_reclaimable:864kB slab_unreclaimable:200kB kernel_stack:96kB pagetables:60kB unstable:0kB bounce:0kB free_cma:0kB writeback_tmp:0kB pages_scanned:252 all_unreclaimable? yes
Jun 23 04:09:18 www kernel: lowmem_reserve[]: 0 968 968 968
Jun 23 04:09:18 www kernel: Node 0 DMA32 free:5828kB min:3948kB low:4932kB high:5920kB active_anon:415256kB inactive_anon:415556kB active_file:136kB inactive_file:1368kB unevictable:0kB isolated(anon):0kB isolated(file):0kB present:1032192kB managed:995724kB mlocked:0kB dirty:0kB writeback:0kB mapped:17708kB shmem:18984kB slab_reclaimable:68444kB slab_unreclaimable:21664kB kernel_stack:2848kB pagetables:8948kB unstable:0kB bounce:0kB free_cma:0kB writeback_tmp:0kB pages_scanned:9264 all_unreclaimable? yes
Jun 23 04:09:18 www kernel: lowmem_reserve[]: 0 0 0 0
Jun 23 04:09:18 www kernel: Node 0 DMA: 13*4kB (UM) 10*8kB (UR) 11*16kB (R) 8*32kB (R) 5*64kB (R) 4*128kB (R) 2*256kB (R) 0*512kB 0*1024kB 1*2048kB (R) 0*4096kB = 3956kB
Jun 23 04:09:18 www kernel: Node 0 DMA32: 461*4kB (UEM) 122*8kB (UEMR) 30*16kB (MR) 17*32kB (R) 7*64kB (R) 2*128kB (R) 1*256kB (R) 0*512kB 1*1024kB (R) 0*2048kB 0*4096kB = 5828kB
Jun 23 04:09:18 www kernel: 7000 total pagecache pages
Jun 23 04:09:18 www kernel: 1563 pages in swap cache
Jun 23 04:09:18 www kernel: Swap cache stats: add 164053, delete 162490, find 242212/264237
[b]Jun 23 04:09:18 www kernel: Free swap = 0kB[/b]
Jun 23 04:09:18 www kernel: Total swap = 262140kB
Jun 23 04:09:18 www kernel: 262047 pages RAM
Jun 23 04:09:18 www kernel: 0 pages HighMem/MovableOnly
Jun 23 04:09:18 www kernel: 9138 pages reserved
Jun 23 04:09:18 www kernel: [ pid ] uid tgid total_vm rss nr_ptes nr_pmds swapents oom_score_adj name
Jun 23 04:09:18 www kernel: [ 1554] 0 1554 919 0 4 1 230 0 upstart-udev-br
Jun 23 04:09:18 www kernel: [ 1561] 0 1561 2505 1 7 2 124 -1000 systemd-udevd
Jun 23 04:09:18 www kernel: [ 2477] 0 2477 1379 42 5 1 395 0 dhclient
Jun 23 04:09:18 www kernel: [ 2696] 105 2696 1060 0 6 2 77 0 dbus-daemon
Jun 23 04:09:18 www kernel: [ 2736] 101 2736 7752 72 9 2 213 0 rsyslogd
Jun 23 04:09:18 www kernel: [ 2745] 0 2745 1055 2 6 2 74 0 systemd-logind
Jun 23 04:09:18 www kernel: [ 2774] 0 2774 765 15 5 2 34 0 cron
Jun 23 04:09:18 www kernel: [ 2776] 0 2776 1951 1 7 1 121 -1000 sshd
Jun 23 04:09:18 www kernel: [ 2814] 0 2814 789 0 4 1 126 0 upstart-file-br
Jun 23 04:09:18 www kernel: [ 2815] 0 2815 851 0 5 1 199 0 upstart-socket-
Jun 23 04:09:18 www kernel: [ 2831] 104 2831 85771 6457 72 1 11904 0 mysqld
Jun 23 04:09:18 www kernel: [ 2853] 0 2853 8720 1524 17 2 2162 0 linode-longview
Jun 23 04:09:18 www kernel: [ 2914] 0 2914 31136 841 34 1 961 0 apache2
Jun 23 04:09:18 www kernel: [ 2986] 0 2986 9731 576 14 2 566 0 fail2ban-server
Jun 23 04:09:18 www kernel: [ 3026] 0 3026 606 1 5 2 27 0 getty
Jun 23 04:09:18 www kernel: [ 4462] 0 4462 1077 4 5 1 63 0 ntpd
Jun 23 04:09:18 www kernel: [ 4463] 103 4463 1046 21 5 1 43 0 ntpd
Jun 23 04:09:18 www kernel: [ 4802] 0 4802 3321 1 10 1 242 0 sshd
Jun 23 04:09:18 www kernel: [ 4840] 1001 4840 3321 0 9 1 242 0 sshd
Jun 23 04:09:18 www kernel: [ 4841] 1001 4841 1414 2 6 2 84 0 bash
Jun 23 04:09:18 www kernel: [ 4850] 0 4850 3294 0 9 1 218 0 sshd
Jun 23 04:09:18 www kernel: [ 4887] 0 4887 3294 1 8 1 226 0 sshd
Jun 23 04:09:18 www kernel: [ 4907] 0 4907 3335 1 9 1 247 0 sshd
Jun 23 04:09:18 www kernel: [ 4908] 0 4908 3424 1 9 1 294 0 sshd
Jun 23 04:09:18 www kernel: [ 4910] 0 4910 3423 1 10 1 291 0 sshd
Jun 23 04:09:18 www kernel: [ 4912] 0 4912 3336 1 9 1 248 0 sshd
Jun 23 04:09:18 www kernel: [ 4916] 0 4916 3335 1 9 1 277 0 sshd
Jun 23 04:09:18 www kernel: [ 4917] 0 4917 3424 1 10 1 297 0 sshd
Jun 23 04:09:18 www kernel: [ 4918] 0 4918 3336 1 9 1 248 0 sshd
Jun 23 04:09:18 www kernel: [ 4920] 0 4920 3336 1 10 1 270 0 sshd
Jun 23 04:09:18 www kernel: [ 5242] 0 5242 3294 1 9 1 232 0 sshd
Jun 23 04:09:18 www kernel: [ 5243] 0 5243 3294 1 8 1 233 0 sshd
Jun 23 04:09:18 www kernel: [ 5244] 0 5244 3294 1 9 1 233 0 sshd
Jun 23 04:09:18 www kernel: [ 5245] 0 5245 3293 1 9 1 232 0 sshd
Jun 23 04:09:18 www kernel: [ 5247] 0 5247 3293 0 9 1 230 0 sshd
Jun 23 04:09:18 www kernel: [ 5248] 0 5248 3294 1 8 1 233 0 sshd
Jun 23 04:09:18 www kernel: [ 5249] 0 5249 3294 1 8 1 233 0 sshd
Jun 23 04:09:18 www kernel: [ 5250] 0 5250 3293 1 8 1 232 0 sshd
Jun 23 04:09:18 www kernel: [ 6504] 0 6504 3319 1 9 1 239 0 sshd
Jun 23 04:09:18 www kernel: [ 6564] 1001 6564 3319 0 8 1 239 0 sshd
Jun 23 04:09:18 www kernel: [ 6565] 1001 6565 1411 1 7 2 82 0 bash
Jun 23 04:09:18 www kernel: [25014] 33 25014 41642 12866 82 1 3171 0 apache2
Jun 23 04:09:18 www kernel: [25659] 33 25659 39383 13394 78 1 632 0 apache2
Jun 23 04:09:18 www kernel: [25957] 33 25957 39999 13490 79 1 1002 0 apache2
Jun 23 04:09:18 www kernel: [26400] 33 26400 39188 9968 77 1 3742 0 apache2
Jun 23 04:09:18 www kernel: [26458] 33 26458 39328 9139 77 1 4478 0 apache2
Jun 23 04:09:18 www kernel: [26471] 33 26471 39158 9203 67 1 3690 0 apache2
Jun 23 04:09:18 www kernel: [26477] 33 26477 39237 8606 58 1 4674 0 apache2
Jun 23 04:09:18 www kernel: [26487] 33 26487 38906 9313 66 1 3349 0 apache2
Jun 23 04:09:18 www kernel: [26548] 33 26548 38992 8646 58 1 3761 0 apache2
Jun 23 04:09:18 www kernel: [26556] 33 26556 39402 7976 59 1 5365 0 apache2
Jun 23 04:09:18 www kernel: [26603] 33 26603 38660 6534 46 1 2150 0 apache2
Jun 23 04:09:18 www kernel: [26606] 33 26606 38546 7032 46 1 1567 0 apache2
Jun 23 04:09:18 www kernel: [26607] 33 26607 38542 7204 46 1 1470 0 apache2
Jun 23 04:09:18 www kernel: [26610] 33 26610 38332 7546 45 1 902 0 apache2
Jun 23 04:09:18 www kernel: [26611] 33 26611 38330 7587 45 1 925 0 apache2
Jun 23 04:09:18 www kernel: [26612] 33 26612 38402 7610 45 1 844 0 apache2
Jun 23 04:09:18 www kernel: [26613] 33 26613 38272 7648 45 1 776 0 apache2
Jun 23 04:09:18 www kernel: [26618] 33 26618 38394 7857 45 1 589 0 apache2
Jun 23 04:09:18 www kernel: [26619] 33 26619 38460 7895 46 1 601 0 apache2
Jun 23 04:09:18 www kernel: [26620] 33 26620 38265 7766 45 1 609 0 apache2
Jun 23 04:09:18 www kernel: [26621] 33 26621 38336 7803 46 1 611 0 apache2
Jun 23 04:09:18 www kernel: [26622] 33 26622 38208 7745 45 1 602 0 apache2
Jun 23 04:09:18 www kernel: [26623] 33 26623 38272 7762 45 1 593 0 apache2
Jun 23 04:09:18 www kernel: [26624] 33 26624 38079 7614 45 1 586 0 apache2
Jun 23 04:09:18 www kernel: [26625] 33 26625 38009 7585 45 1 586 0 apache2
Jun 23 04:09:18 www kernel: [26631] 33 26631 37494 7152 44 1 598 0 apache2
Jun 23 04:09:18 www kernel: [26632] 33 26632 37815 7340 45 1 594 0 apache2
Jun 23 04:09:18 www kernel: [26633] 33 26633 37753 7305 44 1 594 0 apache2
Jun 23 04:09:18 www kernel: [26635] 33 26635 37433 6984 44 1 594 0 apache2
Jun 23 04:09:18 www kernel: [26640] 33 26640 31154 419 29 1 942 0 apache2
Jun 23 04:09:18 www kernel: [26641] 33 26641 31144 399 27 1 951 0 apache2
Jun 23 04:09:18 www kernel: [26642] 33 26642 31144 399 27 1 951 0 apache2
Jun 23 04:09:18 www kernel: [26643] 33 26643 31144 399 27 1 951 0 apache2
Jun 23 04:09:18 www kernel: [26644] 33 26644 31144 399 27 1 951 0 apache2
Jun 23 04:09:18 www kernel: [26645] 33 26645 31144 399 27 1 951 0 apache2
Jun 23 04:09:18 www kernel: [26646] 33 26646 31144 399 27 1 951 0 apache2
Jun 23 04:09:18 www kernel: [26647] 33 26647 31144 399 27 1 951 0 apache2
Jun 23 04:09:18 www kernel: [26648] 33 26648 31144 399 27 1 951 0 apache2
Jun 23 04:09:18 www kernel: [26650] 33 26650 31144 399 27 1 951 0 apache2
[b]Jun 23 04:09:18 www kernel: Out of memory: Kill process 2831 (mysqld) score 57 or sacrifice child[/b]
Jun 23 04:09:18 www kernel: Killed process 2831 (mysqld) total-vm:343084kB, anon-rss:25828kB, file-rss:0kB
Jun 23 04:09:18 www kernel: init: mysql main process (2831) killed by KILL signal
Jun 23 04:09:18 www kernel: init: mysql main process ended, respawning
Jun 23 04:09:19 www kernel: init: mysql main process (26693) terminated with status 1
Jun 23 04:09:19 www kernel: init: mysql main process ended, respawning
Jun 23 04:09:19 www kernel: init: mysql post-start process (26694) terminated with status 1
Jun 23 04:09:20 www kernel: init: mysql main process (26728) terminated with status 1
Jun 23 04:09:20 www kernel: init: mysql respawning too fast, stopped</ffffffff81943f08></ffffffff8193ec28></ffffffff8104219d></ffffffff8119365a></ffffffff81170b9f></ffffffff811700bb></ffffffff8119fe04></ffffffff8119fc14></ffffffff811a57d6></ffffffff81004a2d></ffffffff811777e5></ffffffff8117381b></ffffffff8117369a></ffffffff81172f4a></ffffffff81941bb6></ffffffff819360a4></ffffffff8193b626>
the error log from /var/log/mysql shows:
150623 4:09:18 [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.
150623 4:09:18 [Note] Plugin 'FEDERATED' is disabled.
150623 4:09:18 InnoDB: The InnoDB memory heap is disabled
150623 4:09:18 InnoDB: Mutexes and rw_locks use GCC atomic builtins
150623 4:09:18 InnoDB: Compressed tables use zlib 1.2.8
150623 4:09:18 InnoDB: Using Linux native AIO
150623 4:09:18 InnoDB: Initializing buffer pool, size = 128.0M
InnoDB: mmap(135987200 bytes) failed; errno 12
150623 4:09:18 InnoDB: Completed initialization of buffer pool
150623 4:09:18 InnoDB: Fatal error: cannot allocate memory for the buffer pool
150623 4:09:18 [ERROR] Plugin 'InnoDB' init function returned error.
150623 4:09:18 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
150623 4:09:18 [ERROR] Unknown/unsupported storage engine: InnoDB
150623 4:09:18 [ERROR] Aborting
150623 4:09:18 [Note] /usr/sbin/mysqld: Shutdown complete
150623 4:09:19 [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.
150623 4:09:19 [Note] Plugin 'FEDERATED' is disabled.
150623 4:09:19 InnoDB: The InnoDB memory heap is disabled
150623 4:09:19 InnoDB: Mutexes and rw_locks use GCC atomic builtins
150623 4:09:19 InnoDB: Compressed tables use zlib 1.2.8
150623 4:09:19 InnoDB: Using Linux native AIO
150623 4:09:20 InnoDB: Initializing buffer pool, size = 128.0M
InnoDB: mmap(135987200 bytes) failed; errno 12
150623 4:09:20 InnoDB: Completed initialization of buffer pool
150623 4:09:20 InnoDB: Fatal error: cannot allocate memory for the buffer pool
150623 4:09:20 [ERROR] Plugin 'InnoDB' init function returned error.
150623 4:09:20 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
150623 4:09:20 [ERROR] Unknown/unsupported storage engine: InnoDB
150623 4:09:20 [ERROR] Aborting
150623 4:09:20 [Note] /usr/sbin/mysqld: Shutdown complete
$ free -m
total used free shared buffers cached
Mem: 987 969 18 64 29 388
-/+ buffers/cache: 551 436
Swap: 255 21 234
How can I prevent (I think) MySQL from crashing?
Many thanks
18 Replies
Longview/munin/htop all have varying degrees of usefulness there.
- Les
![](
Jun 23 04:09:18 www kernel: Out of memory: Kill process 2831 (mysqld) score 57 or sacrifice child
MySQL got killed because there is no enough spam, either upgrade ram or optimize these service
which is very similar to my setup. I have set:
## Edit /etc/my.cnf, and add the following line under the [mysqld] heading.
[mysqld]
innodb_buffer_pool_size=64M
Think that will help in my situation?
> there is no enough spam
No, he does not need more spam, he just needs more swap.
@sanvila:
No, he does not need more spam, he just needs more swap.
More swap is never the best answer. It's far slower to access than physical memory. Issues with running out of memory should be addressed, as many folks have said here, by increasing the memory allocated to the system to provide more headroom, or by optimizing the processes on the system consuming unnecessary resources.
Instead, the Out Of Memory killer (OOM killer) decided somehow that some process had to die.
Let me quote Andries Brouwer:
> An aircraft company discovered that it was cheaper to fly its planes with less fuel on board. The planes would be lighter and use less fuel and money was saved. On rare occasions however the amount of fuel was insufficient, and the plane would crash. This problem was solved by the engineers of the company by the development of a special OOF (out-of-fuel) mechanism. In emergency cases a passenger was selected and thrown out of the plane. (When necessary, the procedure was repeated.) A large body of theory was developed and many publications were devoted to the problem of properly selecting the victim to be ejected. Should the victim be chosen at random? Or should one choose the heaviest person? Or the oldest? Should passengers pay in order not to be ejected, so that the victim would be the poorest on board? And if for example the heaviest person was chosen, should there be a special exception in case that was the pilot? Should first class passengers be exempted? Now that the OOF mechanism existed, it would be activated every now and then, and eject passengers even when there was no fuel shortage. The engineers are still studying precisely how this malfunction is caused.
Source:
My suggestion to have more swap is not for it to be actually used (which we all know it's a lot slower than real RAM),
it's just something that may help to keep the OOM killer away.
Try building a kernel without swap on a Linode 1024 and see what happens. With enough swap, it works.
Does somebody know how to "optimize" gcc? I for sure would not even know where to start.
Do I need a Linode 2048 to build the kernel? Surely not if I can use a Linode 1024 with 2G of swap.
You can reduce overcommiting in MySQL or Apache by "optimizing" them, but there is not a general recipe for optimizing everything.
BTW: What I do to avoid OOM killer myself (in addition to have plenty of swap, 1G or 2G), is to have a file called /etc/sysctl.d/10-no-overcommit.conf containing this:
vm.overcommit_ratio = 100
vm.overcommit_memory = 2
(enable with "sysctl –system").
Then I will worry whenever I see that the system runs slow, not whenever OOM killer randomly decides to kill a random process following some strange algorithm, as if they were passengers in a plane in the story by Brouwer.
> My suggestion to have more swap is not for it to be actually used (which we all know it's a lot slower than real RAM),
it's just something that may help to keep the OOM killer away.
> No, he does not need more spam, he just needs more swap.
Linode's documentation on swap:
In this post they say 256swap for 1gb ram is good. More will slow down the server.
So setting vm.overcommitratio = 100 and vm.overcommitmemory = 2 can stop the OOM and doesn't slow down my server?
Thanks
@robertstam:
So setting vm.overcommitratio = 100 and vm.overcommitmemory = 2 can stop the OOM and doesn't slow down my server?
Not exactly. Do not ever think of settting vm.overcommit_memory = 2 (which is what really disables OOM killer) without understanding the consequences. In particular, do not ever think of disabling OOM killer without increasing swap first.
Moreover, don't do this or that because you read it in a forum like this one, and don't do something just because I tell you that it works for me. Investigate for yourself and draw your own conclusions.
The problem of overcommiting is complex and it should be understood without over-simplifications.
Recommended readings:
BTW: More available swap by itself will not make your system to go slower.
In either case, it's actual usage of it what could make your system to go slower, but not its mere availability.
@robertstam:
my Linode has: 1gb ram, ubuntu 14.04 with 256mb swap size. My apache/php/mysql configuration is according the Linode tutorials for 1gb ram.
Hmm. If you refer to this page:
where it's suggested to install libapache2-mod-php5, you should really consider php5-fpm instead. Memory usage with php5-fpm is predictable and almost flat.
Ubuntu 14.04 LAMP guide
<ifmodule mpm_prefork_module="">StartServers 2
MinSpareServers 6
MaxSpareServers 12
MaxClients 30
MaxRequestsPerChild 3000</ifmodule>
The posted syslog shows 36 Apache processes running - reduce MaxClients and tune your MySQL settings and your memory problems will lessen.
@Vance:
Well, the OP clearly did not follow the instructions in Linode's
, since it suggests a MaxClients of 30. Ubuntu 14.04 LAMP guide
I count 39. Although my settings already were:
<ifmodule mpm_prefork_module="">StartServers 2
MinSpareServers 6
MaxSpareServers 12
MaxClients 30
MaxRequestsPerChild 3000</ifmodule>
apache2ctl -M
@Vance:
That is really odd. For mpm_prefork, the maximum number of Apache processes should be the MaxClients value plus one
Perhaps OP has some scripts that use the pcntl_fork() function in PHP.
I have only made 1 change since the mysql crashes occured
which is:
## Edit /etc/my.cnf, and add the following line under the [mysqld] heading.
[mysqld]
innodb_buffer_pool_size=64M
~~![](<URL url=)
Mysql error log:
[size]150711 18:16:41 [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.
150711 18:16:41 [Note] Plugin 'FEDERATED' is disabled.
150711 18:16:41 InnoDB: The InnoDB memory heap is disabled
150711 18:16:41 InnoDB: Mutexes and rw_locks use GCC atomic builtins
150711 18:16:41 InnoDB: Compressed tables use zlib 1.2.8
150711 18:16:41 InnoDB: Using Linux native AIO
150711 18:16:42 InnoDB: Initializing buffer pool, size = 64.0M
InnoDB: mmap(67993600 bytes) failed; errno 12
150711 18:16:42 InnoDB: Completed initialization of buffer pool
150711 18:16:42 InnoDB: Fatal error: cannot allocate memory for the buffer pool
150711 18:16:42 [ERROR] Plugin 'InnoDB' init function returned error.
150711 18:16:42 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
150711 18:16:42 [ERROR] Unknown/unsupported storage engine: InnoDB
150711 18:16:42 [ERROR] Aborting
150711 18:16:42 [Note] /usr/sbin/mysqld: Shutdown complete
150711 18:16:43 [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.
150711 18:16:43 [Note] Plugin 'FEDERATED' is disabled.
150711 18:16:43 InnoDB: The InnoDB memory heap is disabled
150711 18:16:43 InnoDB: Mutexes and rw_locks use GCC atomic builtins
150711 18:16:43 InnoDB: Compressed tables use zlib 1.2.8
150711 18:16:43 InnoDB: Using Linux native AIO
150711 18:16:43 InnoDB: Initializing buffer pool, size = 64.0M
InnoDB: mmap(67993600 bytes) failed; errno 12
150711 18:16:43 InnoDB: Completed initialization of buffer pool
150711 18:16:43 InnoDB: Fatal error: cannot allocate memory for the buffer pool
150711 18:16:43 [ERROR] Plugin 'InnoDB' init function returned error.
150711 18:16:43 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
150711 18:16:43 [ERROR] Unknown/unsupported storage engine: InnoDB
150711 18:16:43 [ERROR] Aborting
150711 18:16:43 [Note] /usr/sbin/mysqld: Shutdown complete[/size]
Syslog:
[size]Jul 11 18:16:34 www kernel: apache2 invoked oom-killer: gfp_mask=0x200da, order=0, oom_score_adj=0
Jul 11 18:16:34 www kernel: apache2 cpuset=/ mems_allowed=0
Jul 11 18:16:34 www kernel: CPU: 0 PID: 11467 Comm: apache2 Not tainted 4.1.0-x86_64-linode59 #1
Jul 11 18:16:34 www kernel: 0000000000000000 0000000000000000 ffffffff8195b396 ffff88003cc0b180
Jul 11 18:16:34 www kernel: ffffffff81955e58 ffffffff811396e5 ffff88003e033400 ffff88003e033400
Jul 11 18:16:34 www kernel: ffffffff811b549f ffff88000257b9e8 01ff88000257b9e8 ffffea0000659e80
Jul 11 18:16:34 www kernel: Call Trace:
Jul 11 18:16:34 www kernel: [<ffffffff8195b396>] ? dump_stack+0x40/0x50
Jul 11 18:16:34 www kernel: [<ffffffff81955e58>] ? dump_header+0x7b/0x1fe
Jul 11 18:16:34 www kernel: [<ffffffff811396e5>] ? css_next_descendant_pre+0x1c/0x34
Jul 11 18:16:34 www kernel: [<ffffffff811b549f>] ? mem_cgroup_iter+0x117/0x319
Jul 11 18:16:34 www kernel: [<ffffffff811b8922>] ? vmpressure+0x1e/0x78
Jul 11 18:16:34 www kernel: [<ffffffff81961c55>] ? _raw_spin_unlock_irqrestore+0x2d/0x3e
Jul 11 18:16:34 www kernel: [<ffffffff81178dee>] ? oom_kill_process+0xc5/0x387
Jul 11 18:16:34 www kernel: [<ffffffff811789d6>] ? find_lock_task_mm+0x2c/0x7b
Jul 11 18:16:34 www kernel: [<ffffffff81179535>] ? __out_of_memory+0x433/0x473
Jul 11 18:16:34 www kernel: [<ffffffff811796b6>] ? out_of_memory+0x52/0x67
Jul 11 18:16:34 www kernel: [<ffffffff8117d811>] ? __alloc_pages_nodemask+0x724/0x862
Jul 11 18:16:34 www kernel: [<ffffffff8195f1d9>] ? yield+0x37/0x37
Jul 11 18:16:34 www kernel: [<ffffffff811ac7f6>] ? alloc_pages_vma+0x111/0x15a
Jul 11 18:16:34 www kernel: [<ffffffff811a6bf4>] ? read_swap_cache_async+0x76/0x121
Jul 11 18:16:34 www kernel: [<ffffffff811a6de4>] ? swapin_readahead+0x145/0x155
Jul 11 18:16:34 www kernel: [<ffffffff81175f91>] ? find_get_entry+0x1a/0x68
Jul 11 18:16:34 www kernel: [<ffffffff81176aa3>] ? pagecache_get_page+0x27/0x161
Jul 11 18:16:34 www kernel: [<ffffffff8119a6de>] ? handle_mm_fault+0xa88/0xf00
Jul 11 18:16:34 www kernel: [<ffffffff81003415>] ? xen_load_sp0+0xe0/0x12c
Jul 11 18:16:34 www kernel: [<ffffffff810450e4>] ? __do_page_fault+0x320/0x37b
Jul 11 18:16:34 www kernel: [<ffffffff81963e58>] ? page_fault+0x28/0x30
Jul 11 18:16:34 www kernel: Mem-Info:
Jul 11 18:16:34 www kernel: active_anon:110494 inactive_anon:110526 isolated_anon:0
Jul 11 18:16:34 www kernel: active_file:604 inactive_file:653 isolated_file:0
Jul 11 18:16:34 www kernel: unevictable:0 dirty:0 writeback:0 unstable:0
Jul 11 18:16:34 www kernel: slab_reclaimable:6340 slab_unreclaimable:4953
Jul 11 18:16:34 www kernel: mapped:3819 shmem:3968 pagetables:2184 bounce:0
Jul 11 18:16:34 www kernel: free:2024 free_pcp:37 free_cma:0
Jul 11 18:16:34 www kernel: Node 0 DMA free:3948kB min:60kB low:72kB high:88kB active_anon:4472kB inactive_anon:4524kB active_file:32kB inactive_file:72kB unevictable:0kB isolated(anon):0kB isolated(file):0kB present:15996kB managed:15912kB mlocked:0kB dirty:0kB writeback:0kB mapped:32kB shmem:464kB slab_reclaimable:212kB slab_unreclaimable:284kB kernel_stack:64kB pagetables:80kB unstable:0kB bounce:0kB free_pcp:0kB local_pcp:0kB free_cma:0kB writeback_tmp:0kB pages_scanned:720 all_unreclaimable? yes
Jul 11 18:16:34 www kernel: lowmem_reserve[]: 0 970 970 970
Jul 11 18:16:34 www kernel: Node 0 DMA32 free:4148kB min:3952kB low:4940kB high:5928kB active_anon:437504kB inactive_anon:437580kB active_file:2384kB inactive_file:2540kB unevictable:0kB isolated(anon):0kB isolated(file):0kB present:1032192kB managed:995552kB mlocked:0kB dirty:0kB writeback:0kB mapped:15244kB shmem:15408kB slab_reclaimable:25148kB slab_unreclaimable:19528kB kernel_stack:2560kB pagetables:8656kB unstable:0kB bounce:0kB free_pcp:148kB local_pcp:148kB free_cma:0kB writeback_tmp:0kB pages_scanned:68800 all_unreclaimable? yes
Jul 11 18:16:34 www kernel: lowmem_reserve[]: 0 0 0 0
Jul 11 18:16:34 www kernel: Node 0 DMA: 5*4kB (UR) 1*8kB (R) 1*16kB (R) 2*32kB (R) 0*64kB 0*128kB 1*256kB (R) 1*512kB (R) 1*1024kB (R) 1*2048kB (R) 0*4096kB = 3948kB
Jul 11 18:16:34 www kernel: Node 0 DMA32: 215*4kB (UE) 31*8kB (UER) 18*16kB (R) 10*32kB (R) 8*64kB (R) 5*128kB (R) 1*256kB (R) 0*512kB 1*1024kB (R) 0*2048kB 0*4096kB = 4148kB
Jul 11 18:16:34 www kernel: 6057 total pagecache pages
Jul 11 18:16:34 www kernel: 831 pages in swap cache
Jul 11 18:16:34 www kernel: Swap cache stats: add 79452, delete 78621, find 71219/75780
Jul 11 18:16:34 www kernel: Free swap = 0kB
Jul 11 18:16:34 www kernel: Total swap = 262140kB
Jul 11 18:16:34 www kernel: 262047 pages RAM
Jul 11 18:16:34 www kernel: 0 pages HighMem/MovableOnly
Jul 11 18:16:34 www kernel: 9181 pages reserved
Jul 11 18:16:34 www kernel: [ pid ] uid tgid total_vm rss nr_ptes nr_pmds swapents oom_score_adj name
Jul 11 18:16:34 www kernel: [ 1561] 0 1561 919 3 5 2 207 0 upstart-udev-br
Jul 11 18:16:34 www kernel: [ 1567] 0 1567 2505 1 6 2 119 -1000 systemd-udevd
Jul 11 18:16:34 www kernel: [ 2523] 0 2523 1379 39 7 2 396 0 dhclient
Jul 11 18:16:34 www kernel: [ 2705] 105 2705 1060 1 6 2 79 0 dbus-daemon
Jul 11 18:16:34 www kernel: [ 2754] 0 2754 1055 1 5 2 71 0 systemd-logind
Jul 11 18:16:34 www kernel: [ 2756] 101 2756 7686 57 9 2 106 0 rsyslogd
Jul 11 18:16:34 www kernel: [ 2784] 0 2784 1951 12 8 2 111 -1000 sshd
Jul 11 18:16:34 www kernel: [ 2791] 0 2791 765 10 5 2 41 0 cron
Jul 11 18:16:34 www kernel: [ 2798] 0 2798 851 3 5 2 190 0 upstart-socket-
Jul 11 18:16:34 www kernel: [ 2802] 0 2802 756 17 5 2 78 0 upstart-file-br
Jul 11 18:16:34 www kernel: [ 2842] 104 2842 66538 5804 62 2 8543 0 mysqld
Jul 11 18:16:34 www kernel: [ 2869] 0 2869 8717 2055 17 2 1632 0 linode-longview
Jul 11 18:16:34 www kernel: [ 2991] 0 2991 9667 613 14 2 521 0 fail2ban-server
Jul 11 18:16:34 www kernel: [ 3035] 0 3035 606 1 5 2 28 0 getty
Jul 11 18:16:34 www kernel: [ 4034] 0 4034 1077 20 7 2 48 0 ntpd
Jul 11 18:16:34 www kernel: [ 4035] 103 4035 1046 14 7 2 42 0 ntpd
Jul 11 18:16:34 www kernel: [ 5878] 0 5878 31138 390 33 2 856 0 apache2
Jul 11 18:16:34 www kernel: [ 9188] 33 9188 43337 12691 85 2 3853 0 apache2
Jul 11 18:16:34 www kernel: [ 9214] 33 9214 41373 11431 82 2 3127 0 apache2
Jul 11 18:16:34 www kernel: [ 9241] 33 9241 39876 8462 79 2 4436 0 apache2
Jul 11 18:16:34 www kernel: [10485] 33 10485 39922 12156 78 2 733 0 apache2
Jul 11 18:16:34 www kernel: [10486] 33 10486 39721 12341 77 2 602 0 apache2
Jul 11 18:16:34 www kernel: [10657] 33 10657 39698 9866 77 2 2706 0 apache2
Jul 11 18:16:34 www kernel: [10914] 33 10914 39717 8909 77 2 3870 0 apache2
Jul 11 18:16:34 www kernel: [11181] 33 11181 39746 8494 78 2 3959 0 apache2
Jul 11 18:16:34 www kernel: [11192] 33 11192 39328 7451 77 2 4376 0 apache2
Jul 11 18:16:34 www kernel: [11249] 33 11249 39631 9259 77 2 3295 0 apache2
Jul 11 18:16:34 www kernel: [11462] 33 11462 38973 5740 46 2 3184 0 apache2
Jul 11 18:16:34 www kernel: [11466] 33 11466 38962 7115 46 2 2149 0 apache2
Jul 11 18:16:34 www kernel: [11467] 33 11467 38971 6980 46 2 2051 0 apache2
Jul 11 18:16:34 www kernel: [11470] 33 11470 38318 6764 45 2 1657 0 apache2
Jul 11 18:16:34 www kernel: [11471] 33 11471 38715 7221 46 2 1651 0 apache2
Jul 11 18:16:34 www kernel: [11472] 33 11472 38717 7173 46 2 1630 0 apache2
Jul 11 18:16:34 www kernel: [11473] 33 11473 38777 7250 46 2 1595 0 apache2
Jul 11 18:16:34 www kernel: [11478] 33 11478 38035 7179 45 2 1006 0 apache2
Jul 11 18:16:34 www kernel: [11479] 33 11479 38311 7930 45 2 993 0 apache2
Jul 11 18:16:34 www kernel: [11480] 33 11480 38311 7349 45 2 1025 0 apache2
Jul 11 18:16:34 www kernel: [11481] 33 11481 38311 7400 45 2 993 0 apache2
Jul 11 18:16:34 www kernel: [11482] 33 11482 38247 7619 45 2 1000 0 apache2
Jul 11 18:16:34 www kernel: [11483] 33 11483 38246 7436 45 2 964 0 apache2
Jul 11 18:16:34 www kernel: [11484] 33 11484 38247 7374 45 2 973 0 apache2
Jul 11 18:16:34 www kernel: [11485] 33 11485 38321 7478 45 2 917 0 apache2
Jul 11 18:16:34 www kernel: [11491] 33 11491 38247 7704 45 2 626 0 apache2
Jul 11 18:16:34 www kernel: [11492] 33 11492 38182 7678 45 2 659 0 apache2
Jul 11 18:16:34 www kernel: [11494] 33 11494 38247 7661 45 2 677 0 apache2
Jul 11 18:16:34 www kernel: [11496] 33 11496 38313 7714 45 2 642 0 apache2
Jul 11 18:16:34 www kernel: [11497] 33 11497 37860 7263 44 2 662 0 apache2
Jul 11 18:16:34 www kernel: [11499] 33 11499 31146 370 28 2 878 0 apache2
Jul 11 18:16:34 www kernel: [11501] 33 11501 31146 365 28 2 883 0 apache2
Jul 11 18:16:34 www kernel: [11502] 33 11502 31146 370 28 2 878 0 apache2
Jul 11 18:16:34 www kernel: [11503] 33 11503 31146 398 28 2 850 0 apache2
Jul 11 18:16:34 www kernel: [11504] 33 11504 31146 393 28 2 855 0 apache2
Jul 11 18:16:34 www kernel: [11505] 33 11505 31146 398 28 2 850 0 apache2
Jul 11 18:16:34 www kernel: [11506] 33 11506 31146 398 28 2 850 0 apache2
Jul 11 18:16:34 www kernel: [11507] 33 11507 31146 398 28 2 850 0 apache2
Jul 11 18:16:34 www kernel: [11508] 33 11508 31146 398 28 2 850 0 apache2
Jul 11 18:16:34 www kernel: [11509] 33 11509 31146 389 28 2 859 0 apache2
Jul 11 18:16:34 www kernel: Out of memory: Kill process 9188 (apache2) score 52 or sacrifice child
Jul 11 18:16:34 www kernel: Killed process 9188 (apache2) total-vm:173348kB, anon-rss:38844kB, file-rss:11920kB
Jul 11 18:16:40 www kernel: apache2 invoked oom-killer: gfp_mask=0x201da, order=0, oom_score_adj=0
Jul 11 18:16:40 www kernel: apache2 cpuset=/ mems_allowed=0
Jul 11 18:16:40 www kernel: CPU: 0 PID: 11473 Comm: apache2 Not tainted 4.1.0-x86_64-linode59 #1
Jul 11 18:16:40 www kernel: 0000000000000000 0000000000000000 ffffffff8195b396 ffff88003d7339c0
Jul 11 18:16:40 www kernel: ffffffff81955e58 ffffffff811396e5 ffff88003e033400 ffff88003e033400
Jul 11 18:16:40 www kernel: ffffffff811b549f ffff88000268ba78 01ff88000268ba78 ffffffff81004627
Jul 11 18:16:40 www kernel: Call Trace:
Jul 11 18:16:40 www kernel: [<ffffffff8195b396>] ? dump_stack+0x40/0x50
Jul 11 18:16:40 www kernel: [<ffffffff81955e58>] ? dump_header+0x7b/0x1fe
Jul 11 18:16:40 www kernel: [<ffffffff811396e5>] ? css_next_descendant_pre+0x1c/0x34
Jul 11 18:16:40 www kernel: [<ffffffff811b549f>] ? mem_cgroup_iter+0x117/0x319
Jul 11 18:16:40 www kernel: [<ffffffff81004627>] ? xen_mc_flush+0x11f/0x162
Jul 11 18:16:40 www kernel: [<ffffffff811b8922>] ? vmpressure+0x1e/0x78
Jul 11 18:16:40 www kernel: [<ffffffff81961c55>] ? _raw_spin_unlock_irqrestore+0x2d/0x3e
Jul 11 18:16:40 www kernel: [<ffffffff81178dee>] ? oom_kill_process+0xc5/0x387
Jul 11 18:16:40 www kernel: [<ffffffff811789d6>] ? find_lock_task_mm+0x2c/0x7b
Jul 11 18:16:40 www kernel: [<ffffffff81179535>] ? __out_of_memory+0x433/0x473
Jul 11 18:16:40 www kernel: [<ffffffff811796b6>] ? out_of_memory+0x52/0x67
Jul 11 18:16:40 www kernel: [<ffffffff8117d811>] ? __alloc_pages_nodemask+0x724/0x862
Jul 11 18:16:40 www kernel: [<ffffffff811aba9d>] ? alloc_pages_current+0xb2/0xcf
Jul 11 18:16:40 www kernel: [<ffffffff81177a30>] ? generic_file_read_iter+0x3ec/0x504
Jul 11 18:16:40 www kernel: [<ffffffff8119a9da>] ? handle_mm_fault+0xd84/0xf00
Jul 11 18:16:40 www kernel: [<ffffffff811c8886>] ? do_filp_open+0x30/0x74
Jul 11 18:16:40 www kernel: [<ffffffff811bae9e>] ? __vfs_read+0x93/0xb6
Jul 11 18:16:40 www kernel: [<ffffffff811bbd50>] ? vfs_read+0x85/0x11c
Jul 11 18:16:40 www kernel: [<ffffffff811bbe2d>] ? SyS_read+0x46/0x89
Jul 11 18:16:40 www kernel: [<ffffffff81964595>] ? sysenter_dispatch+0x7/0x21
Jul 11 18:16:40 www kernel: [<ffffffff8100122a>] ? xen_hypercall_xen_version+0xa/0x20
Jul 11 18:16:40 www kernel: [<ffffffff81008d25>] ? xen_force_evtchn_callback+0x9/0xa
Jul 11 18:16:40 www kernel: [<ffffffff81009312>] ? check_events+0x12/0x20
Jul 11 18:16:40 www kernel: Mem-Info:
Jul 11 18:16:40 www kernel: active_anon:110403 inactive_anon:110420 isolated_anon:32
Jul 11 18:16:40 www kernel: active_file:844 inactive_file:635 isolated_file:32
Jul 11 18:16:40 www kernel: unevictable:0 dirty:0 writeback:4 unstable:0
Jul 11 18:16:40 www kernel: slab_reclaimable:6328 slab_unreclaimable:4922
Jul 11 18:16:40 www kernel: mapped:842 shmem:3884 pagetables:2121 bounce:0
Jul 11 18:16:40 www kernel: free:1999 free_pcp:73 free_cma:0
Jul 11 18:16:40 www kernel: Node 0 DMA free:3952kB min:60kB low:72kB high:88kB active_anon:4372kB inactive_anon:4412kB active_file:128kB inactive_file:164kB unevictable:0kB isolated(anon):0kB isolated(file):0kB present:15996kB managed:15912kB mlocked:0kB dirty:0kB writeback:0kB mapped:24kB shmem:464kB slab_reclaimable:212kB slab_unreclaimable:284kB kernel_stack:64kB pagetables:80kB unstable:0kB bounce:0kB free_pcp:0kB local_pcp:0kB free_cma:0kB writeback_tmp:0kB pages_scanned:1780 all_unreclaimable? yes
Jul 11 18:16:40 www kernel: lowmem_reserve[]: 0 970 970 970
Jul 11 18:16:40 www kernel: Node 0 DMA32 free:4044kB min:3952kB low:4940kB high:5928kB active_anon:437240kB inactive_anon:437268kB active_file:3248kB inactive_file:2376kB unevictable:0kB isolated(anon):128kB isolated(file):128kB present:1032192kB managed:995552kB mlocked:0kB dirty:0kB writeback:16kB mapped:3344kB shmem:15072kB slab_reclaimable:25100kB slab_unreclaimable:19404kB kernel_stack:2544kB pagetables:8404kB unstable:0kB bounce:0kB free_pcp:292kB local_pcp:292kB free_cma:0kB writeback_tmp:0kB pages_scanned:41164 all_unreclaimable? yes
Jul 11 18:16:40 www kernel: lowmem_reserve[]: 0 0 0 0
Jul 11 18:16:40 www kernel: Node 0 DMA: 6*4kB (UR) 1*8kB (R) 1*16kB (R) 2*32kB (R) 0*64kB 0*128kB 1*256kB (R) 1*512kB (R) 1*1024kB (R) 1*2048kB (R) 0*4096kB = 3952kB
Jul 11 18:16:40 www kernel: Node 0 DMA32: 183*4kB (UEM) 34*8kB (MR) 18*16kB (R) 10*32kB (R) 8*64kB (R) 5*128kB (R) 1*256kB (R) 0*512kB 1*1024kB (R) 0*2048kB 0*4096kB = 4044kB
Jul 11 18:16:40 www kernel: 6164 total pagecache pages
Jul 11 18:16:40 www kernel: 786 pages in swap cache
Jul 11 18:16:40 www kernel: Swap cache stats: add 91607, delete 90821, find 75334/83696
Jul 11 18:16:40 www kernel: Free swap = 0kB
Jul 11 18:16:40 www kernel: Total swap = 262140kB
Jul 11 18:16:40 www kernel: 262047 pages RAM
Jul 11 18:16:40 www kernel: 0 pages HighMem/MovableOnly
Jul 11 18:16:40 www kernel: 9181 pages reserved
Jul 11 18:16:40 www kernel: [ pid ] uid tgid total_vm rss nr_ptes nr_pmds swapents oom_score_adj name
Jul 11 18:16:40 www kernel: [ 1561] 0 1561 919 3 5 2 207 0 upstart-udev-br
Jul 11 18:16:40 www kernel: [ 1567] 0 1567 2505 1 6 2 119 -1000 systemd-udevd
Jul 11 18:16:40 www kernel: [ 2523] 0 2523 1379 34 7 2 401 0 dhclient
Jul 11 18:16:40 www kernel: [ 2705] 105 2705 1060 1 6 2 79 0 dbus-daemon
Jul 11 18:16:40 www kernel: [ 2754] 0 2754 1055 1 5 2 71 0 systemd-logind
Jul 11 18:16:40 www kernel: [ 2756] 101 2756 7686 95 9 2 109 0 rsyslogd
Jul 11 18:16:40 www kernel: [ 2784] 0 2784 1951 12 8 2 111 -1000 sshd
Jul 11 18:16:40 www kernel: [ 2791] 0 2791 765 10 5 2 41 0 cron
Jul 11 18:16:40 www kernel: [ 2798] 0 2798 851 3 5 2 190 0 upstart-socket-
Jul 11 18:16:40 www kernel: [ 2802] 0 2802 756 17 5 2 78 0 upstart-file-br
Jul 11 18:16:40 www kernel: [ 2842] 104 2842 66538 5343 62 2 9024 0 mysqld
Jul 11 18:16:40 www kernel: [ 2869] 0 2869 8717 1723 17 2 1964 0 linode-longview
Jul 11 18:16:40 www kernel: [ 2991] 0 2991 9667 558 14 2 576 0 fail2ban-server
Jul 11 18:16:40 www kernel: [ 3035] 0 3035 606 1 5 2 28 0 getty
Jul 11 18:16:40 www kernel: [ 4034] 0 4034 1077 19 7 2 49 0 ntpd
Jul 11 18:16:40 www kernel: [ 4035] 103 4035 1046 13 7 2 43 0 ntpd
Jul 11 18:16:40 www kernel: [ 5878] 0 5878 31138 341 33 2 905 0 apache2
Jul 11 18:16:40 www kernel: [ 9214] 33 9214 41373 5153 82 2 6443 0 apache2
Jul 11 18:16:40 www kernel: [ 9241] 33 9241 40004 6056 79 2 4225 0 apache2
Jul 11 18:16:40 www kernel: [10485] 33 10485 39986 9280 78 2 855 0 apache2
Jul 11 18:16:40 www kernel: [10486] 33 10486 39945 9139 78 2 846 0 apache2
Jul 11 18:16:40 www kernel: [10657] 33 10657 39922 7515 78 2 2495 0 apache2
Jul 11 18:16:40 www kernel: [10914] 33 10914 39941 6502 78 2 3660 0 apache2
Jul 11 18:16:40 www kernel: [11181] 33 11181 39938 6295 79 2 3728 0 apache2
Jul 11 18:16:40 www kernel: [11192] 33 11192 39440 5665 78 2 4154 0 apache2
Jul 11 18:16:40 www kernel: [11249] 33 11249 39855 6949 77 2 3174 0 apache2
Jul 11 18:16:40 www kernel: [11462] 33 11462 38973 5826 46 2 3213 0 apache2
Jul 11 18:16:40 www kernel: [11466] 33 11466 39158 7350 47 2 2051 0 apache2
Jul 11 18:16:40 www kernel: [11467] 33 11467 39163 7233 47 2 2136 0 apache2
Jul 11 18:16:40 www kernel: [11470] 33 11470 38318 6587 45 2 1833 0 apache2
Jul 11 18:16:40 www kernel: [11471] 33 11471 39042 7675 46 2 1548 0 apache2
Jul 11 18:16:40 www kernel: [11472] 33 11472 39106 7727 46 2 1555 0 apache2
Jul 11 18:16:40 www kernel: [11473] 33 11473 39099 7636 46 2 1566 0 apache2
Jul 11 18:16:40 www kernel: [11478] 33 11478 38971 7946 46 2 1069 0 apache2
Jul 11 18:16:40 www kernel: [11479] 33 11479 39101 8272 46 2 999 0 apache2
Jul 11 18:16:40 www kernel: [11480] 33 11480 39038 8082 46 2 1072 0 apache2
Jul 11 18:16:40 www kernel: [11481] 33 11481 39034 8113 46 2 962 0 apache2
Jul 11 18:16:40 www kernel: [11482] 33 11482 39042 8098 46 2 1059 0 apache2
Jul 11 18:16:40 www kernel: [11483] 33 11483 38972 8167 46 2 1019 0 apache2
Jul 11 18:16:40 www kernel: [11484] 33 11484 38907 8017 46 2 1081 0 apache2
Jul 11 18:16:40 www kernel: [11485] 33 11485 39035 8330 46 2 926 0 apache2
Jul 11 18:16:40 www kernel: [11491] 33 11491 39034 8404 46 2 832 0 apache2
Jul 11 18:16:40 www kernel: [11492] 33 11492 38958 8291 46 2 775 0 apache2
Jul 11 18:16:40 www kernel: [11494] 33 11494 38976 8434 46 2 836 0 apache2
Jul 11 18:16:40 www kernel: [11496] 33 11496 39110 8993 46 2 878 0 apache2
Jul 11 18:16:40 www kernel: [11497] 33 11497 38912 8377 46 2 874 0 apache2
Jul 11 18:16:40 www kernel: [11499] 33 11499 31162 370 29 2 891 0 apache2
Jul 11 18:16:40 www kernel: [11501] 33 11501 31146 323 28 2 925 0 apache2
Jul 11 18:16:40 www kernel: [11502] 33 11502 31146 328 28 2 920 0 apache2
Jul 11 18:16:40 www kernel: [11503] 33 11503 31146 356 28 2 892 0 apache2
Jul 11 18:16:40 www kernel: [11504] 33 11504 31146 351 28 2 897 0 apache2
Jul 11 18:16:40 www kernel: [11505] 33 11505 31146 356 28 2 892 0 apache2
Jul 11 18:16:40 www kernel: [11506] 33 11506 31146 356 28 2 892 0 apache2
Jul 11 18:16:40 www kernel: [11507] 33 11507 31146 356 28 2 892 0 apache2
Jul 11 18:16:40 www kernel: [11508] 33 11508 31146 356 28 2 892 0 apache2
Jul 11 18:16:40 www kernel: [11509] 33 11509 31146 347 28 2 901 0 apache2
Jul 11 18:16:40 www kernel: Out of memory: Kill process 2842 (mysqld) score 45 or sacrifice child
Jul 11 18:16:40 www kernel: Killed process 2842 (mysqld) total-vm:266152kB, anon-rss:21372kB, file-rss:0kB
Jul 11 18:16:40 www kernel: init: mysql main process (2842) killed by KILL signal
Jul 11 18:16:40 www kernel: init: mysql main process ended, respawning
Jul 11 18:16:42 www kernel: init: mysql main process (11535) terminated with status 1
Jul 11 18:16:42 www kernel: init: mysql main process ended, respawning
Jul 11 18:16:43 www kernel: init: mysql post-start process (11536) terminated with status 1
Jul 11 18:16:43 www kernel: init: mysql main process (11570) terminated with status 1
Jul 11 18:16:43 www kernel: init: mysql respawning too fast, stopped[/size]</ffffffff81009312></ffffffff81008d25></ffffffff8100122a></ffffffff81964595></ffffffff811bbe2d></ffffffff811bbd50></ffffffff811bae9e></ffffffff811c8886></ffffffff8119a9da></ffffffff81177a30></ffffffff811aba9d></ffffffff8117d811></ffffffff811796b6></ffffffff81179535></ffffffff811789d6></ffffffff81178dee></ffffffff81961c55></ffffffff811b8922></ffffffff81004627></ffffffff811b549f></ffffffff811396e5></ffffffff81955e58></ffffffff8195b396></ffffffff81963e58></ffffffff810450e4></ffffffff81003415></ffffffff8119a6de></ffffffff81176aa3></ffffffff81175f91></ffffffff811a6de4></ffffffff811a6bf4></ffffffff811ac7f6></ffffffff8195f1d9></ffffffff8117d811></ffffffff811796b6></ffffffff81179535></ffffffff811789d6></ffffffff81178dee></ffffffff81961c55></ffffffff811b8922></ffffffff811b549f></ffffffff811396e5></ffffffff81955e58></ffffffff8195b396>
~~
Don't trust the memory graphs in Longview too much. Those graphs only update once every few minutes, so a very short spike in memory usage (e.g. caused by somebody opening your website in several browser windows at the same time) might not show up at all. Trust the kernel instead. If the kernel says you're running out of memory, you're running out of memory.
My suspicion is on Apache. You have over 30 apache2 processes, each consuming a copious amount of memory. You've tweaked MySQL since the last time, but you don't seem to have tweaked Apache at all. It's time to take a long hard look at what Apache is doing.
I know that the documentation recommends 30 processes for a 1GB linode. But the documentation might not be appropriate for your usage pattern, because every website is different. 30 processes are okay if you're only serving static files or running simple PHP scripts. If you're using anything serious, such as WordPress, Drupal, or any custom website based on a modern framework or CMS, it's only a matter of time before you run out of memory. You need to cut that MaxClients in half, if not more, in order to keep your server stable.
@hybinet:
You need to cut that MaxClients in half, if not more, in order to keep your server stable.
Good idea. I have about 5 wordpress websites on there with lots of PHP and Ajax.
I've just set maxclients to 15 - let's see if it will still run out of memory this way.
Thanks!