mariadb crash solution on low configuration VPS
introduction
Recently, the blog has gone into a funk again, and when I open the homepage, the message Error Establishing a Database Connection is displayed. If you think about it, mariadb, the database server, is down; We've had similar problems before. After analyzing the logs and combining the data on the Internet, the problem was finally solved.
Logs
The following is the more critical log information when the mariadb server was down. From the following log information, it is easy to see that the database server crashed at startup due to insufficient memory.
InnoDB: Starting crash recovery.
InnoDB: Reading tablespace information from the .ibd files...
InnoDB: Restoring possible half-written data pages from the doublewrite
InnoDB: buffer...
160919 2:47:12 InnoDB: Waiting for the background threads to start
160919 2:47:13 Percona XtraDB (http://www.percona.com) 5.5.46-MariaDB-37.6 started; log sequence number 352718445
160919 2:47:13 [ERROR] mysqld: Out of memory (Needed 128917504 bytes)
160919 2:47:13 [Note] Plugin 'FEEDBACK' is disabled.
160919 2:47:13 [Note] Server socket created on IP: '0.0.0.0'.
160919 2:47:13 [Note] Event Scheduler: Loaded 0 events
160919 2:47:13 [Note] /usr/libexec/mysqld: ready for connections.
Version: '5.5.47-MariaDB' socket: '/var/lib/mysql/mysql.sock' port: 3306 MariaDB Server
160919 02:47:35 mysqld_safe Number of processes running now: 0
160919 02:47:35 mysqld_safe mysqld restarted
160919 2:47:35 [Note] /usr/libexec/mysqld (mysqld 5.5.47-MariaDB) starting as process 28614 ...
160919 2:47:35 InnoDB: The InnoDB memory heap is disabled
160919 2:47:35 InnoDB: Mutexes and rw_locks use GCC atomic builtins
160919 2:47:35 InnoDB: Compressed tables use zlib 1.2.7
160919 2:47:35 InnoDB: Using Linux native AIO
160919 2:47:35 InnoDB: Initializing buffer pool, size = 128.0M
InnoDB: mmap(137756672 bytes) failed; errno 12
160919 2:47:35 InnoDB: Completed initialization of buffer pool
160919 2:47:35 InnoDB: Fatal error: cannot allocate memory for the buffer pool
160919 2:47:35 [ERROR] Plugin 'InnoDB' init function returned error.
160919 2:47:35 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
160919 2:47:35 [ERROR] mysqld: Out of memory (Needed 128917504 bytes)
160919 2:47:35 [ERROR] mysqld: Out of memory (Needed 96681984 bytes)
160919 2:47:35 [ERROR] mysqld: Out of memory (Needed 72499200 bytes)
160919 2:47:35 [Note] Plugin 'FEEDBACK' is disabled.
160919 2:47:35 [ERROR] Unknown/unsupported storage engine: InnoDB
160919 2:47:35 [ERROR] Aborting
Work out
Symptom When the free -m command is used to view memory information, the swap partition size is 0. No wonder the database server can't start, and when it runs out of memory and can't use the swap partition, it naturally crashes. Since VPS uses SSDS, performance is naturally good. Here we add 1024M swap partition to the server system CentOS 7 by creating a swap file:
Create swapfile with the following command:
# 1048576 = 1024 * 1024 dd if=/dev/zero of=/swapfile bs=1024 count=1048576
Use the following command to configure the swap file:
mkswap /swapfile
Next, use the following command to enable swapfile immediately, so you don't have to wait until the next reboot to automatically enable it:
swapon /swapfile
Finally, we add the following line in /etc/fstab so that the swapfile created automatically takes effect the next time the system restarts:
/swapfile swap swap defaults 0 0
Use cat /proc/swaps or free -m to see if the swapfile is in effect, as shown below:
After completing the above steps, you can also add some configuration information to the /etc/my.cnf configuration file to reduce mariadb resource requirements. For details, see the link at the end of the article.
activate
To start the apache server: systemctl start httpd.service; start the mariadb server: systemctl start mariadb.service. Once the startup is complete, open the home page again, bingo, problem solved!
Sum up
Low VPS is best to increase the size of swap partition, especially for the use of SSD VPS, swap partition performance is also very good; After a database server crashes, it is important to remember to analyze logs. The simplest way to do this is to use the tail command to look at the most recent crash log and look for a solution based on the crash information.
The WordPress program itself is relatively resource-intensive, so when running in low-configuration VPS, you still need to do some optimization work. Please refer to the link at the end of the article.
- MariaDB(Mysql branch)my.cnf configuration file Chinese annotation version
- On the difference between MySQL and mariadb
- MySQL branch selection reference: Percona or MariaDB
- C# connection mariadb(MYSQL branch) code sample sharing
- CMake Error at MariaDB
- thread pool in MariaDB is introduced in detail and how to use it
Related article
-
Details Centos uses YUM to install MariaDB
This article mainly introduces the details of Centos using YUM to install MariaDB related information, need friends can refer to the next2015-09-09 -
Exchange Method of enabling anonymous relaying on the receive connector
This article mainly introduces the Exchange in the receive connector enable anonymous relay method, the need for friends can refer to2018-08-08 -
MariaDB Spider database sorting practice records
MariaDB Server is open source, one of the most popular relational databases, MariaDB is developed from a branch of Mysql, and has always maintained compatibility with Mysql. This article mainly introduces the practice of the MariaDB Spider database, the need of friends can refer to it2022-02-02 -
Commands for installing mysql5.5 and mariadb on centos 7
Most of the databases in the previous Linux system are mysql, but since the acquisition of sun, it has not been integrated in centos these open source Linux systems, so if you want to use it, you need to install it yourself, in the installation process will certainly use some commands, This article introduces the commands used to install mysql5.5 and mariadb on centos 72015-09-09 -
debian10 mariadb installation process details
This article mainly introduces the debian10 mariadb installation process detailed, this article gives you a very detailed introduction to everyone's study or work has a certain reference value, the need of friends can refer to the next2020-11-11 -
Setup method of MariaDB database environment in Windows Server 2016 Server Configuration Guide
This article mainly introduces the MariaDB database environment construction method of Windows Server 2016 server configuration guide, the need of friends can refer to the next2017-08-08 -
About mongoose connection mongodb repeated access error solution
This article mainly introduces the relevant information about the solution of mongoose's repeated access to mongodb, and the friends who need it can refer to it2016-01-01 -
How did I speed up MariaDB SQL with 2 Unix commands
I tried to run a simple join query on MariaDB (MySQL), but the performance was terrible. The following will introduce how I can reduce the query time from 380 hours to less than 12 hours through two simple Unix commands, and the friends who need it can refer to it2018-08-08 -
Tutorial for installing MariaDB database in Ubuntu system
This article mainly introduces the tutorial of installing MariaDB database in Ubuntu system, but also applies to other Debian system of Linux system, need friends can refer to the next2015-06-06 -
Example of Mariadb database master/Slave replication synchronization configuration process
This article mainly introduces the detailed explanation of the master/slave replication synchronization configuration process of Mariadb database. If you need it, you can use it for reference. I hope it can be helpful2022-11-11
Latest comments