Linode Forum
Linode Community Forums
 FAQFAQ    SearchSearch    MembersMembers      Register Register 
 LoginLogin [ Anonymous ] 
Post new topic  Reply to topic
Author Message
 Post subject: Daily my DB is crashing
PostPosted: Fri Jul 31, 2015 1:51 am 
Offline
Senior Newbie

Joined: Fri Jul 31, 2015 1:50 am
Posts: 8
Hi

Am using Mariadb in ISConfig. Daily my DB is crashing. I have to restart it to continue. Please suggest me the solution.

Thanks


Top
   
PostPosted: Fri Jul 31, 2015 6:31 am 
Offline
Senior Member

Joined: Fri May 02, 2008 8:44 pm
Posts: 1121
Running out of memory?

It's a pretty common situation when you're running Apache and MySQL/MariaDB with default settings on a smallish Linode.


Top
   
PostPosted: Mon Aug 03, 2015 3:36 am 
Offline
Senior Newbie

Joined: Fri Jul 31, 2015 1:50 am
Posts: 8
What is the solution for this ?


Top
   
PostPosted: Mon Aug 03, 2015 6:36 am 
Offline
Senior Member
User avatar

Joined: Sat Aug 30, 2008 1:55 pm
Posts: 1739
Location: Rochester, New York
Why is it crashing?

_________________
Code:
/* TODO: need to add signature to posts */


Top
   
PostPosted: Sat Aug 08, 2015 12:54 pm 
Offline
Senior Newbie

Joined: Fri Jul 31, 2015 1:50 am
Posts: 8
Ok, If I increase it to 2GB plan, will this crash solve ?


Top
   
PostPosted: Sat Aug 08, 2015 1:42 pm 
Offline
Senior Member

Joined: Fri Feb 17, 2012 8:20 pm
Posts: 365
You need to figure out -why- it is crashing. Simply increasing your node is not a solution. If it is crashing because it goes out of memory that means you configured it to use more memory than that you have available. Either change the config to use less memory or increase the node if you need stuff stored in memory. Though even then, if your settings are to let mysql consume 20GB memory (as an example) upgrading to 2GB obviously isn't a solution. So first fix the config file so you know how much memory MySQL can use.

mysqltuner is a nice utility that helps you figure this out. It'll tell you the maximum possible memory that MySQL can consume (http://mysqltuner.pl)


Top
   
PostPosted: Sat Aug 08, 2015 1:55 pm 
Offline
Senior Newbie

Joined: Fri Jul 31, 2015 1:50 am
Posts: 8
Hi,

Actually this is the log am getting from mysqltuner. Can you please suggest me the solution, Am using 1GB RAM Linode

http://www.codesend.com/view/a3c59e7c97 ... fe840b564/


Top
   
PostPosted: Sat Aug 08, 2015 2:52 pm 
Offline
Senior Member

Joined: Fri Feb 17, 2012 8:20 pm
Posts: 365
You have query/thread caching disabled. I'd enable them and lower the max connections from 151 to 50 or something. However as you can see here:
[OK] Maximum reached memory usage: 321.4M (32.41% of installed RAM)
[OK] Maximum possible memory usage: 708.0M (71.39% of installed RAM)

It seems that at the moment the memory usage is fine, unless your other applications are taking up all the RAM. You should check the logfiles to figure out why it is crashing,


Top
   
PostPosted: Sun Aug 09, 2015 7:48 am 
Offline
Senior Member

Joined: Fri May 02, 2008 8:44 pm
Posts: 1121
Often, what happens is that Apache uses up all the RAM and triggers the kernel's OOM (out-of-memory) killer. But Apache can usually survive one of its children being killed, so it just respawns the killed child and keeps on using a ton of RAM. Sooner or later, the kernel realizes that it's futile to try to kill Apache, so it kills MySQL/MariaDB instead. The poor database did nothing wrong, it just got sacrificed to make room for greedy Apache.

If that's what's happening, tweaking the database isn't going to help. You have to tweak all the other major programs that are running on the same server. Apache is the most common culprit. If you installed it with an off-the-shelf control panel, it's unlikely to have been optimized for your 1GB instance.


Top
   
PostPosted: Sun Aug 09, 2015 1:01 pm 
Offline
Senior Member

Joined: Fri Feb 13, 2015 8:12 pm
Posts: 101
Stop using Apache and switch to Nginx + PHP-FPM.


Top
   
PostPosted: Sun Aug 09, 2015 11:27 pm 
Offline
Senior Member
User avatar

Joined: Sun Jan 18, 2009 2:41 pm
Posts: 830
There's nothing wrong with using Apache if it's configured correctly.


Top
   
PostPosted: Mon Aug 10, 2015 12:46 pm 
Offline
Senior Member

Joined: Fri Feb 13, 2015 8:12 pm
Posts: 101
Well, the problem with Apache is that there are a lot of different ways to configure it and not all of them are suitable for a Linode 1024.

The OOM killer will probably go away just by using Apache + PHP-FPM, so that would be a good start.


Top
   
PostPosted: Tue Aug 11, 2015 2:11 am 
Offline
Senior Newbie

Joined: Fri Jul 31, 2015 1:50 am
Posts: 8
When I run # free -lm

Code:
# free -lm
              total        used        free      shared  buff/cache   available
Mem:            991         787          11           3         193         161
Low:            991         980          11
High:             0           0           0
Swap:           255         193          62


Its really frustrating for me. Daily my site will be offline for one hour. I need to keep tracking for all the time. Please suggest me any solutions for this.


Top
   
PostPosted: Tue Aug 11, 2015 3:31 am 
Offline
Senior Newbie

Joined: Fri Jul 31, 2015 1:50 am
Posts: 8
Will this help, If I add this in my.cnf

Code:
<IfModule mpm_worker_module>
    ServerLimit          40
    StartServers          2
    MaxClients          1000
    MinSpareThreads      25
    MaxSpareThreads      75
    ThreadsPerChild      25
    MaxRequestsPerChild   0
</IfModule>


Top
   
PostPosted: Tue Aug 11, 2015 6:42 am 
Offline
Senior Member

Joined: Fri May 02, 2008 8:44 pm
Posts: 1121
my.cnf is the configuration file for MySQL/MariaDB.
For Apache, it has to go somewhere in /etc/httpd or /etc/apache2, depending on which Linux distribution you're using.

You probably aren't using mpm_worker, either. Most Apache setups that cause memory issues use mpm_prefork.
Go to the directory I mentioned above and look in all the files to find the mpm_prefork section.
Set MaxClients (or MaxRequestWorkers, if it's there) to 10. Not 1000, not 100, just 10. Then restart Apache.


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic


Who is online

Users browsing this forum: No registered users and 4 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
RSS

Powered by phpBB® Forum Software © phpBB Group