Database Error Connection & Timing Out Issues?

Questions regarding the Database Server
MySQL, PostgreSQL, MariaDB, Percona Server, phpMyAdmin, phpPgAdmin
JRobinsonOnline
Posts: 8
Joined: Sun Feb 14, 2016 11:56 pm

Database Error Connection & Timing Out Issues?

Postby JRobinsonOnline » Tue Oct 04, 2016 9:30 pm

Guys, I'm having an issue where one of my DB's are getting "connection error's" when trying to login to Wordpress as well as just going directly to the URL. I've repaired the database via WordPress config, no fix! When I go in via SSH using [sudo /etc/init.d/mysqld stop] and then [sudo mysqld_safe --skip-grant-tables &] once I restart out of safe mode everything works - but only for a day or so (maybe 24 hrs) Can someone help with this time out issue? I have other sites (2) on WordPress using DB's that work fine when the one in question is down.

mehargags
Moderators
Posts: 749
Joined: Sat Sep 06, 2014 9:58 pm

Re: Database Error Connection & Timing Out Issues?

Postby mehargags » Wed Oct 05, 2016 7:13 am

did you bother to atleast look at some forum thread ? It is the most common problem on low RAM servers. Even Google would give you links to useful threads. https://www.google.com/search?q=vestacp+mysql+crash
and
always give your server specs plus OS details when opening threads for help

JRobinsonOnline
Posts: 8
Joined: Sun Feb 14, 2016 11:56 pm

Re: Database Error Connection & Timing Out Issues?

Postby JRobinsonOnline » Wed Oct 05, 2016 12:10 pm

I never post without looking for a fix first. Hence my post history. Albeit a newbie I can pretty much get things done by searching on google and the forums.

Here's my server specs:

CentOS 6
Disk Space 115 GB
Bandwidth 4.39 TB
Memory 3 GB
VSwap 512 MB
----
Bandwidth Usage
3.03 GB of 4.39 TB Used / 4.39 TB Free
Memory Usage
1.17 GB of 3 GB Used / 1.83 GB Free
VSwap Usage
89.57 MB of 512 MB Used / 422.43 MB Free
Disk Usage
62.85 GB of 115 GB Used / 52.15 GB Free

Thanks. appreciate more help if its out there! I'll check the link and report back on my fix.

mehargags
Moderators
Posts: 749
Joined: Sat Sep 06, 2014 9:58 pm

Re: Database Error Connection & Timing Out Issues?

Postby mehargags » Wed Oct 05, 2016 4:21 pm

post your htop results when the mysql goes down

JRobinsonOnline
Posts: 8
Joined: Sun Feb 14, 2016 11:56 pm

Re: Database Error Connection & Timing Out Issues?

Postby JRobinsonOnline » Wed Oct 05, 2016 7:58 pm

Thanks for the reply, my mysql DB is down but only for one site on my server the others are still up! Hope this info below helps solve my problem...

total used free shared buffers cached
Mem: 3072 1343 1728 34 0 146
-/+ buffers/cache: 1197 1874
Swap: 512 88 423


3145728 total memory
1375556 used memory
252440 active memory
1071396 inactive memory
1770172 free memory
0 buffer memory
149172 swap cache
524288 total swap
90180 used swap
434108 free swap
410979 non-nice user cpu ticks
1951 nice user cpu ticks
57392 system cpu ticks
141009385 idle cpu ticks
719 IO-wait cpu ticks
0 IRQ cpu ticks
0 softirq cpu ticks
0 stolen cpu ticks
17460096 pages paged in
12471912 pages paged out
93571 pages swapped in
134705 pages swapped out
0 interrupts
28583824 CPU context switches
1475341261 boot time
270906 forks

mehargags
Moderators
Posts: 749
Joined: Sat Sep 06, 2014 9:58 pm

Re: Database Error Connection & Timing Out Issues?

Postby mehargags » Fri Oct 07, 2016 11:39 am

the mysql cannot be down for just one site, either it stops for all or else I would check some problem with your app.

Are you using cloudflare by any chance ?

JRobinsonOnline
Posts: 8
Joined: Sun Feb 14, 2016 11:56 pm

Re: Database Error Connection & Timing Out Issues?

Postby JRobinsonOnline » Fri Oct 07, 2016 1:37 pm

mehargags wrote:the mysql cannot be down for just one site, either it stops for all or else I would check some problem with your app.

Are you using cloudflare by any chance ?


Yes, I'm using CloudFlare....Why do you ask?
Tell me that's my fix...

mehargags
Moderators
Posts: 749
Joined: Sat Sep 06, 2014 9:58 pm

Re: Database Error Connection & Timing Out Issues?

Postby mehargags » Sun Oct 09, 2016 5:38 am

it is most likely Cloudflare caching problem in this case...!

What part of the world are you ? CF particularly has (caching) problems to Asian routes. Try to Disable CloudFlare Protection and caching by clicking on the CLOUD icon.

you can continue to use CF for DNS resolution... it works well.
Last edited by mehargags on Thu Oct 13, 2016 7:28 pm, edited 1 time in total.

JRobinsonOnline
Posts: 8
Joined: Sun Feb 14, 2016 11:56 pm

Re: Database Error Connection & Timing Out Issues?

Postby JRobinsonOnline » Wed Oct 12, 2016 12:47 pm

XoXiLhJ0mn wrote:Hi JRobinsonOnline,

If you show htop values, when were they captured, during some other time or at the time of crash? At some other time, it is possible that the values were not severely bad for a crash. Check in the mysql log files and see what errors are given at the time of crash or hanging out.

It appears that you have sufficient RAM 3GB. Why do you have swap of 0,5GB? Make it to half of the total physical RAM to 1,5GB. How about tweaking the my.conf. For this Skurudo has given solution in many threads. Have a look. Did you try that?

Regardless of your problem, there may be a different problem on the domain related to crawlers and bots, which may be - in addition to description of your problem above - causing timeouts on that domain.

Did you check from the Vesta log menu for that domain, if bots are attacking your server causing mysql crash? If you do not know how to, let me know. I think the first thing you need to do is check this problem area...

If the bots and crawlers are activating 500 processes, like Majectic crawler regularly does, then it is VERY CLEAR FROM THE SWAP SIZE OF 0,5GB that the mysql server will crash, while nginx remains loaded!

Give in Google "Majestic" and "bad bots crawlers" and help yourself for many strategies to block them.

While using Cloudflare, you could use IP Blocking of bots and crawlers. Mind you, use 1.1.1.0/24, especially use at the end 0/24 to block the entire Octet of 256 IPs, in the Firewall menu of Cloudflare account.
There are sites, which will give you IP lists to block Octets of such bad crawlers and bots. They are OK but the crawlers and bots often change their IPs as they know this method of blocking strategy.
The best is to see in Vesta logs about them and simply add in Firewall of Cloudflare account an entire Octet of their IP.
After doing this, you will see under Traffic menu that there are many hundred blocking of their IPs.
Once you do this exercise for about two to four weeks, then your MySQL Server will cool down and not remain vulnerable to such bad bots and crawlers.

Once you began to apply IP Blocking, do come here and tell everyone here how my solution has finally helped you out.


Here's the log for that domain via Vesta: http://sightandsoundproductions.net/empme.org.access-log.txt any further help would be great. I do need help with the commands for some of the solutions you mentioned. Thanks!!!

mehargags
Moderators
Posts: 749
Joined: Sat Sep 06, 2014 9:58 pm

Re: Database Error Connection & Timing Out Issues?

Postby mehargags » Wed Oct 12, 2016 4:58 pm

OP... You said it only happens with one particular domain while the others keep working on the same server... is that correct ?

if that is the case, you are hunting in the dark with the logs and other things. Your services will either run or crash for all, not just one single site on the server.

Did you put off cloud DDos protection and caching for your domain in CloudFlare?


Return to “Database Server”



Who is online

Users browsing this forum: No registered users and 3 guests

cron