Игорь Олемской — практические заметки по системному администрированию Linux CentOS

Архив тега ‘memory’

EDAC — Error Detection And Correction (перепечатка)

Комментариев нет

The 'edac' kernel module goal is to detect and report errors that occur
within the computer system running under linux.

Original news source

How to Tell Your OpenVZ VPS is Swapping (перепечатка)

Комментариев нет

So you think your OpenVZ VPS really has “guaranteed memory”? Well. Not quite. I have got an OpenVZ VPS from one of the providers listed here — 256MB guaranteed and 512MB burstable memory. When I run free it shows... 512MB total memory and 0 swap? After all I am only using 65MB of memory so well below my “guaranteed” amount. Zero swap because it is just how OpenVZ does its memory account. But is it really the case that all my processes reside in physical RAM?

Let’s dig out the good ol’ user_beancounters...

Original news source

MySQL: The total number of locks exceeds the lock table size (перепечатка)

Комментариев нет

If you're running an operation on a large number of rows within a table that uses the InnoDB storage engine, you might see this error:

ERROR 1206 (HY000): The total number of locks exceeds the lock table size

MySQL is trying to tell you that it doesn't have enough room to store all of the row locks that it would need to execute your query. The only way to fix it for sure is to adjust innodb_buffer_pool_size and restart MySQL. By default, this is set to only 8MB, which is too small for anyone who is using InnoDB to do anything.

If you need a temporary workaround, reduce the amount of rows you're manipulating in one query. For example, if you need to delete a million rows from a table, try to delete the records in chunks of 50,000 or 100,000 rows. If you're inserting many rows, try to insert portions of the data at a single time.

Further reading:

©2010 Racker Hacker. All Rights Reserved.

.

MySQL: The total number of locks exceeds the lock table size (перепечатка)

Комментариев нет

This problem has cropped up for me a few times, but I've always forgotten to make a post about it. If you're working with a large InnoDB table and you're updating, inserting, or deleting a large volume of rows, you may stumble upon this error:

ERROR 1206 (HY000): The total number of locks exceeds the lock table size

InnoDB stores its lock tables in the main buffer pool. This means that the number of locks you can have at the same time is limited by the innodb_buffer_pool_size variable that was set when MySQL was started. By default, MySQL leaves this at 8MB, which is pretty useless if you're doing anything with InnoDB on your server.

Luckily, the fix for this issue is very easy: adjust innodb_buffer_pool_size to a more reasonable value. However, that fix does require a restart of the MySQL daemon. There's simply no way to adjust this variable on the fly (with the current stable MySQL versions as of this post's writing).

Before you adjust the variable, make sure that your server can handle the additional memory usage. The innodb_buffer_pool_size variable is a server wide variable, not a per-thread variable, so it's shared between all of the connections to the MySQL server (like the query cache). If you set it to something like 1GB, MySQL won't use all of that up front. As MySQL finds more things to put in the buffer, the memory usage will gradually increase until it reaches 1GB. At that point, the oldest and least used data begins to get pruned when new data needs to be present.

So, you need a workaround without a MySQL restart?

If you're in a pinch, and you need a workaround, break up your statements into chunks. If you need to delete a million rows, try deleting 5-10% of those rows per transaction. This may allow you to sneak under the lock table size limitations and clear out some data without restarting MySQL.

To learn more about InnoDB's parameters, visit the MySQL documentation.

©2010 Racker Hacker. All Rights Reserved.

.

Уменьшение потребления памяти MySQL (перепечатка)

Комментариев нет

В основном это касается Virtual Dedicated Server (VDS/VPS), т.к. дефолтная установка MySQL на CeontOS/Fedora/RHEL с дефолтным my.cnf делает malloc на сотню с лишним мегабайт.

Конечно на потребляемую память MySQL влияют такие параметры как key_buffer, query_cache_size и т.п. Но они по дефолту идут минимальные, а кеш запросов вообще по моему отключен по дефолту.

Так вот все очень просто. Добавляем в my.cnf:

skip-innodb
skip-bdb

Это выключит хандлеры InnoDB и BerkeleyDB и всю потребляемую ими память. Ну конечно делать это нужно если вы не используете вышеприведенные типы таблиц.

Далее рестартуем мускуль и видим в топе что он занимает десяток-другой мегабайт.

PS: в большинстве случаев не помешает опция и skip-networking. А вот thread_cache_size я советую поставить в значение 5-15 (в зависимости от нагрузки) :)