Mysql2::Error: Out of sort memory, consider increasing server sort buffer size using docker-compose.yml
Mysql2::Error: Out of sort memory, consider increasing server sort buffer size using docker-compose.yml
您好,我正在构建一个 rails 应用程序,我导入了大量数据并插入到数据库中。有些表没问题,有些表有一些错误,说内存不足。
SQL 错误
Mysql2::Error: Out of sort memory, consider increasing server sort buffer size
如何使用 docker-compose.yml
命令增加服务器排序缓冲区大小?
我试过这个:
version: '3'
services:
db:
image: mysql:latest
command:
- --default-authentication-plugin=mysql_native_password
- --innodb-buffer-pool-size=402653184
我确实添加了这个命令:
--innodb-buffer-pool-size=402653184
但我仍然收到内存不足的相同错误。有什么方法可以使用 docker-compose.yml
增加缓冲区大小
首先,402653184 (byte)
大约是 400 MB,如果您不确定这个内存限制,那么再增加一点
command:
- --default-authentication-plugin=mysql_native_password
- --innodb-buffer-pool-size=1G
然后验证容器内的更改。
SELECT @@innodb_buffer_pool_size/1024/1024/1024;
#it should return 1GB
此外,也有可能是其他原因导致的问题,您可以检查CPU、内存和慢查询日志
SHOW ENGINE INNODB STATUS
然后您可以根据当前缓冲池大小分析输出
BUFFER POOL AND MEMORY
----------------------
BUFFER POOL AND MEMORY
----------------------
Total large memory allocated 412090368
Dictionary memory allocated 380237
Buffer pool size 24576
Free buffers 23618
Database pages 954
Old database pages 372
Modified db pages 0
Pending reads 0
事实证明,当我对此进行测试时,这解决了我在 docker 中的 mysql container
中的错误。
在 db
服务下的 docker-compose.yml
中添加此命令以增加内存。
--sort_buffer_size=1073741824
当您的应用程序在 docker 上 运行 时删除错误。
Error "1038 Out of sort memory, consider increasing server sort buffer size
请注意 1073741824
等于字节,将导致 1GB
内存分配。
您好,我正在构建一个 rails 应用程序,我导入了大量数据并插入到数据库中。有些表没问题,有些表有一些错误,说内存不足。
SQL 错误
Mysql2::Error: Out of sort memory, consider increasing server sort buffer size
如何使用 docker-compose.yml
命令增加服务器排序缓冲区大小?
我试过这个:
version: '3'
services:
db:
image: mysql:latest
command:
- --default-authentication-plugin=mysql_native_password
- --innodb-buffer-pool-size=402653184
我确实添加了这个命令:
--innodb-buffer-pool-size=402653184
但我仍然收到内存不足的相同错误。有什么方法可以使用 docker-compose.yml
首先,402653184 (byte)
大约是 400 MB,如果您不确定这个内存限制,那么再增加一点
command:
- --default-authentication-plugin=mysql_native_password
- --innodb-buffer-pool-size=1G
然后验证容器内的更改。
SELECT @@innodb_buffer_pool_size/1024/1024/1024;
#it should return 1GB
此外,也有可能是其他原因导致的问题,您可以检查CPU、内存和慢查询日志
SHOW ENGINE INNODB STATUS
然后您可以根据当前缓冲池大小分析输出
BUFFER POOL AND MEMORY
----------------------
BUFFER POOL AND MEMORY
----------------------
Total large memory allocated 412090368
Dictionary memory allocated 380237
Buffer pool size 24576
Free buffers 23618
Database pages 954
Old database pages 372
Modified db pages 0
Pending reads 0
事实证明,当我对此进行测试时,这解决了我在 docker 中的 mysql container
中的错误。
在 db
服务下的 docker-compose.yml
中添加此命令以增加内存。
--sort_buffer_size=1073741824
当您的应用程序在 docker 上 运行 时删除错误。
Error "1038 Out of sort memory, consider increasing server sort buffer size
请注意 1073741824
等于字节,将导致 1GB
内存分配。