diff --git a/docs-2.0-en/5.configurations-and-logs/1.configurations/6.kernel-config.md b/docs-2.0-en/5.configurations-and-logs/1.configurations/6.kernel-config.md index 1d8bc369d36..57c77ca7e25 100644 --- a/docs-2.0-en/5.configurations-and-logs/1.configurations/6.kernel-config.md +++ b/docs-2.0-en/5.configurations-and-logs/1.configurations/6.kernel-config.md @@ -47,17 +47,50 @@ You can run `man limits.conf` for more helpful information. These values control the dirty data cache for the system. For write-intensive scenarios, you can make adjustments based on your needs (throughput priority or delay priority). We recommend that you use the system default value. -### Transparent huge page +### Transparent Huge Pages -For better delay performance, you must run the following commands to disable the transparent huge pages (THP). +Transparent Huge Pages (THP) is a memory management feature of the Linux kernel, which enhances the system's ability to use large pages. In most database systems, Transparent Huge Pages can degrade performance, so it is recommended to disable it. -```bash -root# echo never > /sys/kernel/mm/transparent_hugepage/enabled -root# echo never > /sys/kernel/mm/transparent_hugepage/defrag -root# swapoff -a && swapon -a -``` +Perform the following steps: + +1. Edit the GRUB configuration file `/etc/default/grub`. + + ```bash + sudo vi /etc/default/grub + ``` + +2. Add `transparent_hugepage=never` to the `GRUB_CMDLINE_LINUX` option, and then save and exit. + + ```bash + GRUB_CMDLINE_LINUX="... transparent_hugepage=never" + ``` + +3. Update the GRUB configuration. -To prevent THP from being enabled again after the system restarts, you can modify the GRUB configuration file or `/etc/rc.local` to disable THP automatically upon system startup. + - For CentOS: + + ```bash + sudo grub2-mkconfig -o /boot/grub2/grub.cfg + ``` + + - For Ubuntu: + + ```bash + sudo update-grub + ``` + +5. Reboot the computer. + + ```bash + sudo reboot + ``` + + If you don't want to reboot, you can run the following commands to temporarily disable THP until the next reboot. + + ```bash + echo 'never' > /sys/kernel/mm/transparent_hugepage/enabled + echo 'never' > /sys/kernel/mm/transparent_hugepage/defrag + ``` ## Networking diff --git a/docs-2.0-zh/5.configurations-and-logs/1.configurations/6.kernel-config.md b/docs-2.0-zh/5.configurations-and-logs/1.configurations/6.kernel-config.md index ddaab65e679..2d8294e9b93 100644 --- a/docs-2.0-zh/5.configurations-and-logs/1.configurations/6.kernel-config.md +++ b/docs-2.0-zh/5.configurations-and-logs/1.configurations/6.kernel-config.md @@ -47,16 +47,50 @@ `vm.dirty_*`是一系列控制系统脏数据缓存的参数。对于写密集型场景,用户可以根据需要进行调整(吞吐量优先或延迟优先),建议使用系统默认值。 -### Transparent huge page +### 透明大页 -为了降低延迟,用户必须关闭 THP(transparent huge page)。命令如下: +透明大页(Transparent Huge Pages, THP)是一种 Linux 内核的内存管理特性,可以提高系统使用大页的能力。在多数数据库系统中,透明大页会降低性能,建议关闭。 -```bash -root# echo never > /sys/kernel/mm/transparent_hugepage/enabled -root# echo never > /sys/kernel/mm/transparent_hugepage/defrag -root# swapoff -a && swapon -a -``` -为了防止系统重启后该配置失效,可以在GRUB配置文件或`/etc/rc.local`中添加相关配置,使系统启动时自动关闭 THP。 +操作如下: + +1. 编辑 GRUB 配置文件`/etc/default/grub`。 + + ```bash + sudo vi /etc/default/grub + ``` + +2. 在`GRUB_CMDLINE_LINUX`选项中添加`transparent_hugepage=never`,然后保存并退出。 + + ```bash + GRUB_CMDLINE_LINUX="... transparent_hugepage=never" + ``` + +3. 更新 GRUB 配置。 + + - CentOS + + ```bash + sudo grub2-mkconfig -o /boot/grub2/grub.cfg + ``` + + - Ubuntu + + ```bash + sudo update-grub + ``` + +4. 重启操作系统。 + + ```bash + sudo reboot + ``` + + 如果不重启可临时关闭透明大页,直到下次重启。 + + ```bash + echo 'never' > /sys/kernel/mm/transparent_hugepage/enabled + echo 'never' > /sys/kernel/mm/transparent_hugepage/defrag + ``` ## 网络