Further optimize the reference documentation for problem cause resolution
Cause of the problem
Last night, I modified the database and added a “FULLTEXT” index for the field. However, this morning, I found that the database could not be connected and could not be restarted. So I checked the log file:
cat /var/log/mysqld.log
The following error log was found:
130728 6:50:14 InnoDB: Initializing buffer pool, size = 128.0M
InnoDB: mmap(137363456 bytes) failed; errno 12
130728 6:50:14 InnoDB: Completed initialization of buffer pool
130728 6:50:14 InnoDB: Fatal error: cannot allocate memory for the buffer pool
The short answer is that there is no way to allocate 128M memory for mysql’s Buffer pool.
reason is obvious, the lack of memory, after looking up data found that the original parameter is mainly used to cache innodb table index, data, the buffer when inserting data. My server only has 1 gb of memory, so this parameter crashed mysql when it started allocating the cache for the index.
The solution
The configurations for mysql are inside /ect/ mysqlt.cnf (the Ubuntu directory is slightly different, where you can find it using whereis my.cnf
).
vim /etc/my.cnf
You can see the fourth line:
#innodb_buffer_pool_size = 128M
The default configuration shown here is 128M, which is the annotation status. We just need to remove the annotation and change 128 to a smaller size (depending on your personal situation). I will change it to:
innodb_buffer_pool_size = 50M
That’s about it.
Further optimization
Generally appear this kind of problem students, the memory is certainly not large, so we can set swap partition, which is often said virtual memory.
is illustrated the role of the swap here won’t do, simply means can assist Mem points of memory.
direct code:
dd if=/dev/zero of=/swapfile bs=1M count=1024
mkswap /swapfile
swapon /swapfile
Finally, add the code /swapfile swap swap defaults 0 0
to the /etc/fstab
file.
free
If you can see Mem and SWAP, it’s successful.
and finally restart mysql.
Reference documentation
http://hongjiang.info/aliyun-vps-mysql-aborting/
Read More:
- Kvm internal error: process exited :cannot set up guest memory ‘pc.ram‘:Cannot allocate memory
- os::commit_memory(0x0000000538000000, 11408506880, 0) failed; error=‘Cannot allocate memory‘
- Swap off failed: cannot allocate memory
- [Solved] Android compile error: cannot allocate memory
- Remember a virtual machine expansion swapoff failed: cannot allocate memory
- Server composer install error: proc_open(): fork failed-Cannot allocate memory
- RuntimeError: CUDA out of memory. Tried to allocate 600.00 MiB (GPU 0; 23.69 GiB total capacity)
- CentOS execution command error: – bash: fork: cannot allocate memory processing / viewing process number
- The docker installation es reported an error of failed; error = – cannot allocate memory ‘(errno = 12)
- The difference, cause and solution of memory overflow and memory leak
- CUDA error 11-cannot write buffer for DAG error solution
- Solution pandas.errors.ParserError : Error tokenizing data. C error: Buffer overflow caught
- After installing MySQL again under Linux, the solution of ‘MySQL module failed to start’ appears
- MySQL Workbench: Error Code: 2013. Lost connection to MySQL server during query solution
- Golang MySQL error SQL: unknown driver “MySQL” (Forgotten import?) solution
- RuntimeError: CUDA error: out of memory solution (valid for pro-test)
- Error: cannot allocate vector of size 88.1 MB
- MySQL local connection Error 1130_ The solution of MySQL 1130 error report when remote connection through Navicat for MySQL
- Tomcat memory overflow in Eclipse: Java. Lang. outofmemoryerror: permgen space solution:
- Error: The size of the connection buffer (131072) was not large enough