error establishing database connection

Started by htsanders, October 04, 2018, 06:05:51 AM

Previous topic - Next topic

htsanders

Every day i have to restart mysql service because i get the message:
¨error establishing database connection¨

please advise
Herman

Jamshed Datori

Depends on number of factors. Can you paste here the mysql logs?

htsanders

thank you for the reply,
Which log files do you need?
Do you have filenames?

bullten

what is output of this command

systemctl status mariadb.service -l

htsanders

here you have it.

● mariadb.service - MariaDB 10.1.36 database server
   Loaded: loaded (/usr/lib/systemd/system/mariadb.service; enabled; vendor preset: disabled)
  Drop-In: /etc/systemd/system/mariadb.service.d
           └─migrated-from-my.cnf-settings.conf
   Active: active (running) since ma 2018-10-08 03:05:17 CEST; 9h ago
     Docs: man:mysqld(8)
           https://mariadb.com/kb/en/library/systemd/
  Process: 11940 ExecStartPost=/bin/sh -c systemctl unset-environment _WSREP_START_POSITION (code=exited, status=0/SUCCESS)
  Process: 11874 ExecStartPre=/bin/sh -c [ ! -e /usr/bin/galera_recovery ] && VAR= ||   VAR=`/usr/bin/galera_recovery`; [ $? -eq 0 ]   && systemctl set-environment _WSREP_START_POSITION=$VAR || exit 1 (code=exited, status=0/SUCCESS)
  Process: 11868 ExecStartPre=/bin/sh -c systemctl unset-environment _WSREP_START_POSITION (code=exited, status=0/SUCCESS)
Main PID: 11889 (mysqld)
   Status: "InnoDB: Error: Could not find a valid tablespace file for 'oudersb_blog/blogfak_wfVulnScanners'. See http://dev.mysql.com/doc/refman/5.6/en/innodb-troubleshooting-datadict.html for how to resolve the issue."
   CGroup: /system.slice/mariadb.service
           └─11889 /usr/sbin/mysqld

okt 08 04:08:11 srv1.bcoin.nl mysqld[11889]: 2018-10-08  4:08:11 139755295288064 [ERROR] Got error 180 when reading table './bcoin_wp/wp_posts'
okt 08 04:08:11 srv1.bcoin.nl mysqld[11889]: 2018-10-08  4:08:11 139755295288064 [ERROR] Got error 180 when reading table './bcoin_wp/wp_posts'
okt 08 04:08:11 srv1.bcoin.nl mysqld[11889]: 2018-10-08  4:08:11 139755295288064 [ERROR] Got error 180 when reading table './bcoin_wp/wp_posts'
okt 08 04:09:37 srv1.bcoin.nl mysqld[11889]: 2018-10-08  4:09:37 139755295288064 [ERROR] Got error 180 when reading table './bcoin_wp/wp_posts'
okt 08 04:09:37 srv1.bcoin.nl mysqld[11889]: 2018-10-08  4:09:37 139755295288064 [ERROR] Got error 180 when reading table './bcoin_wp/wp_posts'
okt 08 04:09:37 srv1.bcoin.nl mysqld[11889]: 2018-10-08  4:09:37 139755295288064 [ERROR] Got error 180 when reading table './bcoin_wp/wp_posts'
okt 08 04:09:37 srv1.bcoin.nl mysqld[11889]: 2018-10-08  4:09:37 139755295288064 [ERROR] Got error 180 when reading table './bcoin_wp/wp_posts'             
okt 08 04:10:59 srv1.bcoin.nl mysqld[11889]: 2018-10-08  4:10:59 139755397507840 [ERROR] Got error 180 when reading table './bcoin_wp/wp_posts'             
okt 08 04:10:59 srv1.bcoin.nl mysqld[11889]: 2018-10-08  4:10:59 139755397507840 [ERROR] Got error 180 when reading table './bcoin_wp/wp_posts'             
okt 08 04:10:59 srv1.bcoin.nl mysqld[11889]: 2018-10-08  4:10:59 139755397507840 [ERROR] Got error 180 when reading table './bcoin_wp/wp_posts'             
[root@srv1 ~]# Connection to 192.168.2.10 closed by remote host.                                                                                           
Connection to 192.168.2.10 closed.

htsanders

after reboot:

● mariadb.service - MariaDB 10.1.36 database server
   Loaded: loaded (/usr/lib/systemd/system/mariadb.service; enabled; vendor preset: disabled)
  Drop-In: /etc/systemd/system/mariadb.service.d
           └─migrated-from-my.cnf-settings.conf
   Active: active (running) since ma 2018-10-08 13:19:01 CEST; 1min 16s ago
     Docs: man:mysqld(8)
           https://mariadb.com/kb/en/library/systemd/
  Process: 1634 ExecStartPost=/bin/sh -c systemctl unset-environment _WSREP_START_POSITION (code=exited, status=0/SUCCESS)
  Process: 942 ExecStartPre=/bin/sh -c [ ! -e /usr/bin/galera_recovery ] && VAR= ||   VAR=`/usr/bin/galera_recovery`; [ $? -eq 0 ]   && systemctl set-environment _WSREP_START_POSITION=$VAR || exit 1 (code=exited, status=0/SUCCESS)
  Process: 931 ExecStartPre=/bin/sh -c systemctl unset-environment _WSREP_START_POSITION (code=exited, status=0/SUCCESS)
Main PID: 1068 (mysqld)
   Status: "Taking your SQL requests now..."
   CGroup: /system.slice/mariadb.service
           └─1068 /usr/sbin/mysqld

okt 08 13:18:48 srv1.bcoin.nl mysqld[1068]: 2018-10-08 13:18:48 140254624643328 [Note] InnoDB: Highest supported file format is Barracuda.
okt 08 13:18:57 srv1.bcoin.nl mysqld[1068]: 2018-10-08 13:18:57 140254624643328 [Note] InnoDB: 128 rollback segment(s) are active.
okt 08 13:18:57 srv1.bcoin.nl mysqld[1068]: 2018-10-08 13:18:57 140254624643328 [Note] InnoDB: Waiting for purge to start
okt 08 13:18:57 srv1.bcoin.nl mysqld[1068]: 2018-10-08 13:18:57 140254624643328 [Note] InnoDB:  Percona XtraDB (http://www.percona.com) 5.6.39-83.1 started; log sequence number 53883522243                                                                                                                           
okt 08 13:18:58 srv1.bcoin.nl mysqld[1068]: 2018-10-08 13:18:58 140254624643328 [Note] Plugin 'FEEDBACK' is disabled.                                       
okt 08 13:18:58 srv1.bcoin.nl mysqld[1068]: 2018-10-08 13:18:58 140253843154688 [Note] InnoDB: Dumping buffer pool(s) not yet started                       
okt 08 13:18:58 srv1.bcoin.nl mysqld[1068]: 2018-10-08 13:18:58 140254624643328 [Note] Server socket created on IP: '::'.                                   
okt 08 13:19:01 srv1.bcoin.nl mysqld[1068]: 2018-10-08 13:19:01 140254624643328 [Note] /usr/sbin/mysqld: ready for connections.                             
okt 08 13:19:01 srv1.bcoin.nl mysqld[1068]: Version: '10.1.36-MariaDB'  socket: '/var/lib/mysql/mysql.sock'  port: 3306  MariaDB Server                     
okt 08 13:19:01 srv1.bcoin.nl systemd[1]: Started MariaDB 10.1.36 database server.                     

bullten

I see it started successfully. What issue you are facing then?

htsanders

thank you for the reply.  :D

I have to restart the server after a short time again because it loses mysql connection.

bullten

whenever its down run the command below and paste here the output

systemctl status mariadb.service -l

htsanders

system acting weird again.
very much io activity and high memory usage.

systemctl status mariadb.service -l
● mariadb.service - MariaDB 10.1.36 database server
   Loaded: loaded (/usr/lib/systemd/system/mariadb.service; enabled; vendor preset: disabled)
  Drop-In: /etc/systemd/system/mariadb.service.d
           └─migrated-from-my.cnf-settings.conf
   Active: active (running) since ma 2018-10-08 19:15:43 CEST; 1h 1min ago
     Docs: man:mysqld(8)
           https://mariadb.com/kb/en/library/systemd/
  Process: 30600 ExecStartPost=/bin/sh -c systemctl unset-environment _WSREP_START_POSITION (code=exited, status=0/SUCCESS)
  Process: 30533 ExecStartPre=/bin/sh -c [ ! -e /usr/bin/galera_recovery ] && VAR= ||   VAR=`/usr/bin/galera_recovery`; [ $? -eq 0 ]   && systemctl set-environment _WSREP_START_POSITION=$VAR || exit 1 (code=exited, status=0/SUCCESS)
  Process: 30529 ExecStartPre=/bin/sh -c systemctl unset-environment _WSREP_START_POSITION (code=exited, status=0/SUCCESS)
Main PID: 30548 (mysqld)
   Status: "InnoDB: Error: Database page corruption on disk or a failed file read of tablespace bcoin_wp/wp_posts page  [page id: space=10422, page number=42776]. You may have to recover from a backup."
   CGroup: /system.slice/mariadb.service
           └─30548 /usr/sbin/mysqld

okt 08 20:09:41 srv1.bcoin.nl mysqld[30548]: 2018-10-08 20:09:41 140492795878144 [ERROR] Got error 180 when reading table './bcoin_wp/wp_posts'
okt 08 20:11:01 srv1.bcoin.nl mysqld[30548]: 2018-10-08 20:11:01 140492392348416 [ERROR] Got error 180 when reading table './bcoin_wp/wp_posts'
okt 08 20:11:02 srv1.bcoin.nl mysqld[30548]: 2018-10-08 20:11:02 140492392348416 [ERROR] Got error 180 when reading table './bcoin_wp/wp_posts'
okt 08 20:11:02 srv1.bcoin.nl mysqld[30548]: 2018-10-08 20:11:02 140492392348416 [ERROR] Got error 180 when reading table './bcoin_wp/wp_posts'
okt 08 20:11:02 srv1.bcoin.nl mysqld[30548]: 2018-10-08 20:11:02 140492392348416 [ERROR] Got error 180 when reading table './bcoin_wp/wp_posts'
okt 08 20:12:13 srv1.bcoin.nl mysqld[30548]: 2018-10-08 20:12:13 140492392348416 [ERROR] Got error 180 when reading table './bcoin_wp/wp_posts'
okt 08 20:12:13 srv1.bcoin.nl mysqld[30548]: 2018-10-08 20:12:13 140492392348416 [ERROR] Got error 180 when reading table './bcoin_wp/wp_posts'
okt 08 20:12:14 srv1.bcoin.nl mysqld[30548]: 2018-10-08 20:12:14 140492392348416 [ERROR] Got error 180 when reading table './bcoin_wp/wp_posts'
okt 08 20:12:14 srv1.bcoin.nl mysqld[30548]: 2018-10-08 20:12:14 140492392348416 [ERROR] Got error 180 when reading table './bcoin_wp/wp_posts'
okt 08 20:12:14 srv1.bcoin.nl mysqld[30548]: 2018-10-08 20:12:14 140492392348416 [ERROR] Got error 180 when reading table './bcoin_wp/wp_posts'

bullten

Looks like tables gets corrupted. You can set innodb recovery to automatic. Also you should contact your hosting provider to look into the issue. It may be caused because of lack of i/o or resources

htsanders

thank you for the reply.

I guess its a wordpress table issue causing the problems.
I shut down the websites plugins and everything looks fine.

how to prevent one website from taking down the server?



bullten

Well you should look for cloudlinux. They have MySQL Governor to protect MySQL operations.

https://docs.cloudlinux.com/index.html?mysql_governor.html