更多: zhilu jiaocheng
编辑 /etc/security/limits.conf
为 MySQL 打开文件描述符:
#[domain] [type] [item] [value] mysql hard nofile 10000
编辑 /etc/my.cnf
innodb_buffer_pool_size - If you use Innodb, 70% to 80% of main memory is adequate. key_buffer_size - If you use MyISAM, approx 30% of main memory is adequate. sort_buffer_size - 256KB to 1MB read_buffer_size - 128KB to 512KB read_rnd_buffer_size - 256KB to 1MB
操作系统的内核提供了服务器运行所需的基本组件。
对于基于 Unix 的系统,有时需要通过更改各种参数值来进行优化,以针对特定配置进行优化。
以下是 CentOS/RHEL 系统上 MySQL 数据库的一些最常用的系统调优。
信号量
建议的信号量最低设置:
kernel.sem = 250 32000 100 128
- The first value, SEMMSL, is the maximum number of semaphores per semaphore set - The second value, SEMMNS, defines the total number of semaphores for the system - The third value, SEMOPM, defines the maximum number of semaphore operations per semaphore call - The last value, SEMMNI, defines the number of entire semaphore sets for the system
I/O 调度器
默认的 CFQ I/O 调度程序适用于大多数工作负载,但不能为数据库环境提供最佳性能。
- 物理系统推荐使用deadline scheduler
- 虚拟系统推荐使用 noop 调度器
/etc/sysctl.conf 中的内存设置
交换对于数据库来说并不理想,应该尽可能避免。
vm.swappiness = 10
可以是脏页的活动内存的最大百分比:
vm.dirty_background_ratio = 3
可以有脏页的总内存的最大百分比:
vm.dirty_ratio = 40
数据在过期前保留在页面缓存中的时间:
vm.dirty_expire_centisecs = 500
pdflush 在百分之几秒内激活以清理脏页面的频率:
vm.dirty_writeback_centisecs = 100
日期:2020-09-17 00:11:15 来源:oir作者:oir