Rechercher dans le manuel MySQL

15.8.3.1 Configuring InnoDB Buffer Pool Size

You can configure InnoDB buffer pool size offline (at startup) or online, while the server is running. Behavior described in this section applies to both methods. For additional information about configuring buffer pool size online, see Configuring InnoDB Buffer Pool Size Online.

When increasing or decreasing innodb_buffer_pool_size, the operation is performed in chunks. Chunk size is defined by the innodb_buffer_pool_chunk_size configuration option, which has a default of 128M. For more information, see Configuring InnoDB Buffer Pool Chunk Size.

Buffer pool size must always be equal to or a multiple of innodb_buffer_pool_chunk_size * innodb_buffer_pool_instances. If you configure innodb_buffer_pool_size to a value that is not equal to or a multiple of innodb_buffer_pool_chunk_size * innodb_buffer_pool_instances, buffer pool size is automatically adjusted to a value that is equal to or a multiple of innodb_buffer_pool_chunk_size * innodb_buffer_pool_instances.

In the following example, innodb_buffer_pool_size is set to 8G, and innodb_buffer_pool_instances is set to 16. innodb_buffer_pool_chunk_size is 128M, which is the default value.

8G is a valid innodb_buffer_pool_size value because 8G is a multiple of innodb_buffer_pool_instances=16 * innodb_buffer_pool_chunk_size=128M, which is 2G.

shell> mysqld --innodb-buffer-pool-size=8G --innodb-buffer-pool-instances=16
  1. mysql> SELECT @@innodb_buffer_pool_size/1024/1024/1024;
  2. +------------------------------------------+
  3. | @@innodb_buffer_pool_size/1024/1024/1024 |
  4. +------------------------------------------+
  5. |                           8.000000000000 |
  6. +------------------------------------------+

In this example, innodb_buffer_pool_size is set to 9G, and innodb_buffer_pool_instances is set to 16. innodb_buffer_pool_chunk_size is 128M, which is the default value. In this case, 9G is not a multiple of innodb_buffer_pool_instances=16 * innodb_buffer_pool_chunk_size=128M, so innodb_buffer_pool_size is adjusted to 10G, which is a multiple of innodb_buffer_pool_chunk_size * innodb_buffer_pool_instances.

shell> mysqld --innodb-buffer-pool-size=9G --innodb-buffer-pool-instances=16
  1. mysql> SELECT @@innodb_buffer_pool_size/1024/1024/1024;
  2. +------------------------------------------+
  3. | @@innodb_buffer_pool_size/1024/1024/1024 |
  4. +------------------------------------------+
  5. |                          10.000000000000 |
  6. +------------------------------------------+
Configuring InnoDB Buffer Pool Chunk Size

innodb_buffer_pool_chunk_size can be increased or decreased in 1MB (1048576 byte) units but can only be modified at startup, in a command line string or in a MySQL configuration file.

Command line:

shell> mysqld --innodb-buffer-pool-chunk-size=134217728

Configuration file:

[mysqld]
innodb_buffer_pool_chunk_size=134217728

The following conditions apply when altering innodb_buffer_pool_chunk_size:

  • If the new innodb_buffer_pool_chunk_size value * innodb_buffer_pool_instances is larger than the current buffer pool size when the buffer pool is initialized, innodb_buffer_pool_chunk_size is truncated to innodb_buffer_pool_size / innodb_buffer_pool_instances.

    For example, if the buffer pool is initialized with a size of 2GB (2147483648 bytes), 4 buffer pool instances, and a chunk size of 1GB (1073741824 bytes), chunk size is truncated to a value equal to innodb_buffer_pool_size / innodb_buffer_pool_instances, as shown below:

    shell> mysqld --innodb-buffer-pool-size=2147483648 --innodb-buffer-pool-instances=4
    --innodb-buffer-pool-chunk-size=1073741824;
    1. mysql> SELECT @@innodb_buffer_pool_size;
    2. +---------------------------+
    3. | @@innodb_buffer_pool_size |
    4. +---------------------------+
    5. |                2147483648 |
    6. +---------------------------+
    7.  
    8. mysql> SELECT @@innodb_buffer_pool_instances;
    9. +--------------------------------+
    10. | @@innodb_buffer_pool_instances |
    11. +--------------------------------+
    12. |                              4 |
    13. +--------------------------------+
    14.  
    15. # Chunk size was set to 1GB (1073741824 bytes) on startup but was
    16. # truncated to innodb_buffer_pool_size / innodb_buffer_pool_instances
    17.  
    18. mysql> SELECT @@innodb_buffer_pool_chunk_size;
    19. +---------------------------------+
    20. | @@innodb_buffer_pool_chunk_size |
    21. +---------------------------------+
    22. |                       536870912 |
    23. +---------------------------------+
  • Buffer pool size must always be equal to or a multiple of innodb_buffer_pool_chunk_size * innodb_buffer_pool_instances. If you alter innodb_buffer_pool_chunk_size, innodb_buffer_pool_size is automatically adjusted to a value that is equal to or a multiple of innodb_buffer_pool_chunk_size * innodb_buffer_pool_instances. The adjustment occurs when the buffer pool is initialized. This behavior is demonstrated in the following example:

    1. # The buffer pool has a default size of 128MB (134217728 bytes)
    2.  
    3. mysql> SELECT @@innodb_buffer_pool_size;
    4. +---------------------------+
    5. | @@innodb_buffer_pool_size |
    6. +---------------------------+
    7. |                 134217728 |
    8. +---------------------------+
    9.  
    10. # The chunk size is also 128MB (134217728 bytes)
    11.  
    12. mysql> SELECT @@innodb_buffer_pool_chunk_size;
    13. +---------------------------------+
    14. | @@innodb_buffer_pool_chunk_size |
    15. +---------------------------------+
    16. |                       134217728 |
    17. +---------------------------------+
    18.  
    19. # There is a single buffer pool instance
    20.  
    21. mysql> SELECT @@innodb_buffer_pool_instances;
    22. +--------------------------------+
    23. | @@innodb_buffer_pool_instances |
    24. +--------------------------------+
    25. |                              1 |
    26. +--------------------------------+
    27.  
    28. # Chunk size is decreased by 1MB (1048576 bytes) at startup
    29. # (134217728 - 1048576 = 133169152):
    30.  
    31. shell> mysqld --innodb-buffer-pool-chunk-size=133169152
    32.  
    33. mysql> SELECT @@innodb_buffer_pool_chunk_size;
    34. +---------------------------------+
    35. | @@innodb_buffer_pool_chunk_size |
    36. +---------------------------------+
    37. |                       133169152 |
    38. +---------------------------------+
    39.  
    40. # Buffer pool size increases from 134217728 to 266338304
    41. # Buffer pool size is automatically adjusted to a value that is equal to
    42. # or a multiple of innodb_buffer_pool_chunk_size * innodb_buffer_pool_instances
    43.  
    44. mysql> SELECT @@innodb_buffer_pool_size;
    45. +---------------------------+
    46. | @@innodb_buffer_pool_size |
    47. +---------------------------+
    48. |                 266338304 |
    49. +---------------------------+

    This example demonstrates the same behavior but with multiple buffer pool instances:

    1. # The buffer pool has a default size of 2GB (2147483648 bytes)
    2.  
    3. mysql> SELECT @@innodb_buffer_pool_size;
    4. +---------------------------+
    5. | @@innodb_buffer_pool_size |
    6. +---------------------------+
    7. |                2147483648 |
    8. +---------------------------+
    9.  
    10. # The chunk size is .5 GB (536870912 bytes)
    11.  
    12. mysql> SELECT @@innodb_buffer_pool_chunk_size;
    13. +---------------------------------+
    14. | @@innodb_buffer_pool_chunk_size |
    15. +---------------------------------+
    16. |                       536870912 |
    17. +---------------------------------+
    18.  
    19. # There are 4 buffer pool instances
    20.  
    21. mysql> SELECT @@innodb_buffer_pool_instances;
    22. +--------------------------------+
    23. | @@innodb_buffer_pool_instances |
    24. +--------------------------------+
    25. |                              4 |
    26. +--------------------------------+
    27.  
    28. # Chunk size is decreased by 1MB (1048576 bytes) at startup
    29. # (536870912 - 1048576 = 535822336):
    30.  
    31. shell> mysqld --innodb-buffer-pool-chunk-size=535822336
    32.  
    33. mysql> SELECT @@innodb_buffer_pool_chunk_size;
    34. +---------------------------------+
    35. | @@innodb_buffer_pool_chunk_size |
    36. +---------------------------------+
    37. |                       535822336 |
    38. +---------------------------------+
    39.  
    40. # Buffer pool size increases from 2147483648 to 4286578688
    41. # Buffer pool size is automatically adjusted to a value that is equal to
    42. # or a multiple of innodb_buffer_pool_chunk_size * innodb_buffer_pool_instances
    43.  
    44. mysql> SELECT @@innodb_buffer_pool_size;
    45. +---------------------------+
    46. | @@innodb_buffer_pool_size |
    47. +---------------------------+
    48. |                4286578688 |
    49. +---------------------------+

    Care should be taken when changing innodb_buffer_pool_chunk_size, as changing this value can increase the size of the buffer pool, as shown in the examples above. Before you change innodb_buffer_pool_chunk_size, calculate the effect on innodb_buffer_pool_size to ensure that the resulting buffer pool size is acceptable.

Note

To avoid potential performance issues, the number of chunks (innodb_buffer_pool_size / innodb_buffer_pool_chunk_size) should not exceed 1000.

Inhaltsverzeichnis Haut

Configuring InnoDB Buffer Pool Size Online

The innodb_buffer_pool_size configuration option can be set dynamically using a SET statement, allowing you to resize the buffer pool without restarting the server. For example:

  1. mysql> SET GLOBAL innodb_buffer_pool_size=402653184;

Active transactions and operations performed through InnoDB APIs should be completed before resizing the buffer pool. When initiating a resizing operation, the operation does not start until all active transactions are completed. Once the resizing operation is in progress, new transactions and operations that require access to the buffer pool must wait until the resizing operation finishes. The exception to the rule is that concurrent access to the buffer pool is permitted while the buffer pool is defragmented and pages are withdrawn when buffer pool size is decreased. A drawback of allowing concurrent access is that it could result in a temporary shortage of available pages while pages are being withdrawn.

Note

Nested transactions could fail if initiated after the buffer pool resizing operation begins.

Inhaltsverzeichnis Haut

Monitoring Online Buffer Pool Resizing Progress

The Innodb_buffer_pool_resize_status reports buffer pool resizing progress. For example:

  1. mysql> SHOW STATUS WHERE Variable_name='InnoDB_buffer_pool_resize_status';
  2. +----------------------------------+----------------------------------+
  3. | Variable_name                    | Value                            |
  4. +----------------------------------+----------------------------------+
  5. | Innodb_buffer_pool_resize_status | Resizing also other hash tables. |
  6. +----------------------------------+----------------------------------+

Buffer pool resizing progress is also logged in the server error log. This example shows notes that are logged when increasing the size of the buffer pool:

[Note] InnoDB: Resizing buffer pool from 134217728 to 4294967296. (unit=134217728)
[Note] InnoDB: disabled adaptive hash index.
[Note] InnoDB: buffer pool 0 : 31 chunks (253952 blocks) was added.
[Note] InnoDB: buffer pool 0 : hash tables were resized.
[Note] InnoDB: Resized hash tables at lock_sys, adaptive hash index, dictionary.
[Note] InnoDB: completed to resize buffer pool from 134217728 to 4294967296.
[Note] InnoDB: re-enabled adaptive hash index.

This example shows notes that are logged when decreasing the size of the buffer pool:

[Note] InnoDB: Resizing buffer pool from 4294967296 to 134217728. (unit=134217728)
[Note] InnoDB: disabled adaptive hash index.
[Note] InnoDB: buffer pool 0 : start to withdraw the last 253952 blocks.
[Note] InnoDB: buffer pool 0 : withdrew 253952 blocks from free list. tried to relocate 0 pages.
(253952/253952)
[Note] InnoDB: buffer pool 0 : withdrawn target 253952 blocks.
[Note] InnoDB: buffer pool 0 : 31 chunks (253952 blocks) was freed.
[Note] InnoDB: buffer pool 0 : hash tables were resized.
[Note] InnoDB: Resized hash tables at lock_sys, adaptive hash index, dictionary.
[Note] InnoDB: completed to resize buffer pool from 4294967296 to 134217728.
[Note] InnoDB: re-enabled adaptive hash index.

Inhaltsverzeichnis Haut

Online Buffer Pool Resizing Internals

The resizing operation is performed by a background thread. When increasing the size of the buffer pool, the resizing operation:

  • Adds pages in chunks (chunk size is defined by innodb_buffer_pool_chunk_size)

  • Coverts hash tables, lists, and pointers to use new addresses in memory

  • Adds new pages to the free list

While these operations are in progress, other threads are blocked from accessing the buffer pool.

When decreasing the size of the buffer pool, the resizing operation:

  • Defragments the buffer pool and withdraws (frees) pages

  • Removes pages in chunks (chunk size is defined by innodb_buffer_pool_chunk_size)

  • Converts hash tables, lists, and pointers to use new addresses in memory

Of these operations, only defragmenting the buffer pool and withdrawing pages allow other threads to access to the buffer pool concurrently.


Suchen Sie im MySQL-Handbuch

Deutsche Übersetzung

Sie haben gebeten, diese Seite auf Deutsch zu besuchen. Momentan ist nur die Oberfläche übersetzt, aber noch nicht der gesamte Inhalt.

Wenn Sie mir bei Übersetzungen helfen wollen, ist Ihr Beitrag willkommen. Alles, was Sie tun müssen, ist, sich auf der Website zu registrieren und mir eine Nachricht zu schicken, in der Sie gebeten werden, Sie der Gruppe der Übersetzer hinzuzufügen, die Ihnen die Möglichkeit gibt, die gewünschten Seiten zu übersetzen. Ein Link am Ende jeder übersetzten Seite zeigt an, dass Sie der Übersetzer sind und einen Link zu Ihrem Profil haben.

Vielen Dank im Voraus.

Dokument erstellt 26/06/2006, zuletzt geändert 26/10/2018
Quelle des gedruckten Dokuments:https://www.gaudry.be/de/mysql-rf-innodb-buffer-pool-resize.html

Die Infobro ist eine persönliche Seite, deren Inhalt in meiner alleinigen Verantwortung liegt. Der Text ist unter der CreativeCommons-Lizenz (BY-NC-SA) verfügbar. Weitere Informationen auf die Nutzungsbedingungen und dem Autor.

Referenzen

  1. Zeigen Sie - html-Dokument Sprache des Dokuments:en Manuel MySQL : https://dev.mysql.com/

Diese Verweise und Links verweisen auf Dokumente, die während des Schreibens dieser Seite konsultiert wurden, oder die zusätzliche Informationen liefern können, aber die Autoren dieser Quellen können nicht für den Inhalt dieser Seite verantwortlich gemacht werden.
Der Autor Diese Website ist allein dafür verantwortlich, wie die verschiedenen Konzepte und Freiheiten, die mit den Nachschlagewerken gemacht werden, hier dargestellt werden. Denken Sie daran, dass Sie mehrere Quellinformationen austauschen müssen, um das Risiko von Fehlern zu reduzieren.

Inhaltsverzeichnis Haut