MYSQL,innodb_buffer_pool_size=8G,为何内存使用上看到只使用了3G呢?

笑天居士 发布于 2014/08/07 17:09
阅读 5K+
收藏 0

Serverless 架构就不要服务器了?>>>

Server version: 5.5.18-log Source distribution

innodb设置:

# of RAM but beware of setting memory usage too high
innodb_buffer_pool_size         = 8G
innodb_additional_mem_pool_size = 80M
# Set .._log_file_size to 25 % of buffer pool size
innodb_log_file_size            = 500M
innodb_log_buffer_size          = 8M
innodb_flush_log_at_trx_commit  = 0
innodb_lock_wait_timeout        = 50
#innodb_flush_method             = O_DIRECT

查看innodb状态变量:

| innodb_buffer_pool_instances              | 1                        |
| innodb_buffer_pool_restore_at_startup     | 0                        |
| innodb_buffer_pool_shm_checksum           | ON                       |
| innodb_buffer_pool_shm_key                | 0                        |
| innodb_buffer_pool_size                   | 8589934592               |
| innodb_change_buffering                   | all                      |

查看innodb status:

----------------------

BUFFER POOL AND MEMORY
----------------------
Total memory allocated 8824815616; in additional pool allocated 0
Internal hash tables (constant factor + variable factor)
    Adaptive hash index 141610832       (141606616 + 4216)
    Page hash           8851208 (buffer pool 0 only)
    Dictionary cache    35440940        (35403184 + 37756)
    File system         126232  (82672 + 43560)
    Lock system         21250944        (21250568 + 376)
    Recovery system     0       (0 + 0)
Dictionary memory allocated 37756
Buffer pool size        524287
Buffer pool size, bytes 8589918208
Free buffers            524032

Database pages          255

mysql日志:

140807 16:44:54 InnoDB: Initializing buffer pool, size = 8.0G
140807 16:44:55 InnoDB: Completed initialization of buffer pool
140807 16:44:55 InnoDB: highest supported file format is Barracuda.
140807 16:44:55  InnoDB: Waiting for the background threads to start
140807 16:44:56 Percona XtraDB (http://www.percona.com) 1.1.8-20.1 started; log sequence number 41875501

从几个方面来看,innodb_buffer_pool_size都是8G,可是为啥TOP内存只使用了3G呢:

top - 17:07:25 up 1 day,  8:51,  7 users,  load average: 0.00, 0.00, 0.00
Tasks: 256 total,   1 running, 255 sleeping,   0 stopped,   0 zombie
Cpu(s):  0.1%us,  0.1%sy,  0.0%ni, 99.8%id,  0.0%wa,  0.0%hi,  0.0%si,  0.0%st
Mem:  16424784k total,  2991160k used, 13433624k free,   176528k buffers
Swap:  8191992k total,        0k used,  8191992k free,  1019024k cached

加载中
0
笑天居士
笑天居士

这个我明白了,因为malloc分配内存是先在虚拟内存中分配地址的,到实际使用时才真正的映射到物理内存

因此这个地方,如果由于机器内存使用不当,到了MySQL真正要映射物理内存时,如果物理内存不足了,就会出错甚至退出

返回顶部
顶部