MySQL 性能优化配置
InnoDB类型数据的缓存配置,这个配置可减少磁盘读取,最多可配置物理内存大小的80%。此配置在my.ini文件中,配置项为innodb_buffer_pool_size,例:
# 默认为128M innodb_buffer_pool_size=3072M # innodb_buffer_pool_chunk_size * innodb_buffer_pool_instances = innodb_buffer_pool_size # 即1024 * 3 = 3072 # innodb_buffer_pool_chunk_size默认为128M # innodb_buffer_pool_instances默认为1 innodb_buffer_pool_chunk_size=1024M innodb_buffer_pool_instances=3
可在不重启的情况下,修改innodb_buffer_pool_size,登录mysql执行
# 单位为字节,1073741824为1024M SET GLOBAL innodb_buffer_pool_size = 1073741824;
查看配置和内存占用情况
-- 查看当前连接的线程数 SHOW STATUS LIKE 'Threads_connected'; -- 查看InnoDB缓冲池中数据占用的内存大小,即innodb_buffer_pool_size用了多少 SHOW STATUS LIKE 'Innodb_buffer_pool_bytes_data'; -- 查看InnoDB缓冲池的总内存大小 SHOW STATUS LIKE 'Innodb_buffer_pool_bytes_total'; -- 查看配置 SHOW variables LIKE 'innodb_buffer_pool_size'; SHOW variables LIKE 'innodb_buffer_pool%';