Today found that the site is a bit slow, found that the MySQL log prompts mysqld-nt:out of memory (Needed 1677720 bytes), after the investigation is due to the recent adjustment of some of the MySQL parameters caused by the memory is not afraid of the big, 32-bit system true content utilization is very low, it is said that no more than 4G, our 32G memory is really wasted, later or use win2008 R2 or CentOS system to do the server it. No more nonsense. Here's to share the solution:
Because the MySQL version may be configured slightly differently, the main thing is to set the following parameters
Key_buffer, Key_buffer_size, Read_buffer_size, sort_buffer_size Remember to have this parameter on the change, no and do not add. After the modification is generally reduced, and then restart the MySQL service.
Core tip: Check mysqld configuration my.conf, focus on Key_buffer_size, Max_heap_table_size, tmp_table_size several parameters, recommended set key_buffer_size value for Max_heap _table_size's 1/4.
Because the server memory and large surplus more, some days ago my.conf several parameters of a considerable, 1G or even 2G, but not stable, MYSQLD reported several times out of memory (Needed xxx bytes) Such a mistake, analysis of the reasons, The idea is that Linux on the 32-bit Linux system does not support PAE, can not use more than 3G of memory, so the changes to the large number of parameters appropriate to change the small point, the largest is only hundreds of m, but there have been several out of memory errors. So the online query, and then by the formula
Key_buffer_size + (read_buffer_size + sort_buffer_size) *max_connections
The inspiration, two times check the key_buffer_size, Max_heap_table_size, tmp_table_size several parameters, found that the setting of these three values is the same, unexpectedly are 512m!
Then change the small key_buffer_size to 128M, restart mysqld the next 5 hours of monitoring, no recurrence of similar errors.
Changed these several parameters, or there is an out of the memory, continue to check, found innodb_buffer_pool_size = 1512M, so I changed to 1000M, restart MySQL incredibly good.
Note: This server has a total of 3G memory: The final large to the following
Key_buffer = 200M
Key_buffer_size = 1294963200
#max_join_size = 4294967295
Max_join_size = 1294967295
Max_allowed_packet = 1M
#table_open_cache = 512
Table_cache = 512
Sort_buffer_size = 2294967295
Read_buffer_size = 2147479552
#write_buffer_size = 4294967295
Read_rnd_buffer_size = 4M
Myisam_sort_buffer_size = 64M
Thread_cache_size = 8
Query_cache_size= 16M
PHP error fatal Error:out of memory (allocated 262144) (tried to allocate 19456
PHP has been running for some time after an error:
PHP error fatal Error:out of memory (allocated 262144) (tried to allocate 19456
It means: fatal error, beyond memory, has been allocated allocated 262144, trying to allocate 19456 bytes.
The solution is to modify php.ini and increase Memory_limit
Just really scared me, HTML can be normal access, PHP is not, I thought it was under attack.
Later see www.blogguy.cn on the fatal error:out of memory (allocated 262144) (tried to allocate 19456, know that the memory is not enough, but the VPS can not even go up, Also see who is in the memory, can only go back to the site in the background restart VPS, do not know where the problem. Write it down for filing!
Modify method
Modify PHP.ini
such as the following area
Max_execution_time = 120; Maximum execution time of each script, in seconds
Max_input_time = 60; Maximum amount of time each script may spend parsing request data
Memory_limit = 64M; Maximum amount of memory a script may consume (64MB)
Adjusted as needed.
You can restart Apache.