MARIADB crash problem on low-distribution VPS

Source: Internet
Author: User
Tags socket vps percona

Introduction

Recently, the blog and ventilation, open the home page prompts the error establishing a Database Connection. Think about it, it should be the database server mariadb hung up, and have encountered similar problems before. After the analysis of the log, and combined with the information on the net finally solved the problem.

Log

The following is the key log information when the MARIADB server hangs, and it is easy to see from the log information below that the database server crashes because of 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)
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.
160919 2:47:35 [ERROR] mysqld:out of memory (Needed 128917504)
160919 2:47:35 [ERROR] mysqld:out of memory (Needed 96681984)
160919 2:47:35 [ERROR] mysqld:out of memory (Needed 72499200)
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
Solve

When viewing memory information using FREE-M, the swap partition size is found to be 0. No wonder that the database server can not start, in the case of insufficient memory, and can not use the swap partition, natural collapse. Because the VPS uses SSD, the performance is naturally good. Let's add a 1024M swap partition to the server system CentOS 7 by creating a swap file:
Use the following command to create the Swapfile:
# 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 that you do not have to wait until the next reboot to automatically enable:
Swapon/swapfile
Finally, we add the following line to the/etc/fstab, which automatically takes effect when the system is restarted the next time it is created Swapfile:
/swapfile Swap Defaults 0 0
Use Cat/proc/swaps or free-m to view the effect of swapfile, as shown in the following illustration:

After completing the above steps, we can also add some configuration information in the/ETC/MY.CNF configuration file to reduce the MARIADB resource requirements, please refer to the link given at the end of the article.

Start

Start Apache server: Systemctl start httpd.service;
Start MARIADB server: Systemctl start Mariadb.service.
After startup completes, again opens the website homepage, bingo, the problem solves!

Summarize

Low-match VPS is best to increase the swap size, especially for the use of SSDs VPS, swap partition performance is also very good;
after the database server crashes, be sure to remember to parse the log. The easiest thing to do is to use the tail command to look at the latest crash logs and find a way to solve the problem based on the crash information;
The WordPress program itself is more of a resource, so running a VPS with a low profile still needs to do some optimization work. Please refer to the link given at the end of this article.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.