2.15. 使用 TuneD 设置磁盘调度程序

此流程创建并启用 TuneD 配置集,该配置集为所选块设备设置给定磁盘调度程序。这个设置会在系统重启后保留。

在以下命令和配置中替换:

  • 带有块设备名称的 device,如 sdf
  • 带有您要为该设备设置的磁盘调度程序的 selected-scheduler,例如 bfq

先决条件

流程

  1. 可选:选择一个您的配置集将要基于的现有 Tuned 配置集。有关可用配置集列表,请参阅 RHEL 提供的 TuneD 配置集

    要查看哪个配置集当前处于活跃状态,请使用:

    $ tuned-adm active
  2. 创建一个新目录来保存 TuneD 配置集:

    # mkdir /etc/tuned/my-profile
  3. 查找所选块设备系统唯一标识符:

    $ udevadm info --query=property --name=/dev/device | grep -E '(WWN|SERIAL)'
    
    ID_WWN=0x5002538d00000000_
    ID_SERIAL=Generic-_SD_MMC_20120501030900000-0:0
    ID_SERIAL_SHORT=20120501030900000
    注意

    本例中的命令将返回以 World Wide Name (WWN) 或与指定块设备关联的序列号的所有值。虽然最好使用 WWN,但给定设备始终不能使用 WWN,但 example 命令返回的任何值都可以接受用作 device system unique ID

  4. 创建 /etc/tuned/my-profile/tuned.conf 配置文件。在该文件中设置以下选项:

    1. 可选:包含现有配置集:

      [main]
      include=existing-profile
    2. 为与 WWN 标识符匹配的设备设置所选磁盘调度程序:

      [disk]
      devices_udev_regex=IDNAME=device system unique id
      elevator=selected-scheduler

      在这里:

      • 使用要使用的标识符的名称替换 IDNAME (如 ID_WWN)。
      • device system unique id 替换为所选标识符的值(如 0x5002538d00000000)。

        要匹配 devices_udev_regex 选项中的多个设备,将标识符放在括号中,并使用垂直栏来分离它们:

        devices_udev_regex=(ID_WWN=0x5002538d00000000)|(ID_WWN=0x1234567800000000)
  5. 启用您的配置集:

    # tuned-adm profile my-profile

验证步骤

  1. 验证 TuneD 配置集是否活跃并应用:

    $ tuned-adm active
    
    Current active profile: my-profile
    $ tuned-adm verify
    
    Verification succeeded, current system settings match the preset profile.
    See TuneD log file ('/var/log/tuned/tuned.log') for details.
  2. 读取 /sys/block/设备/queue/scheduler 文件的内容:

    # cat /sys/block/device/queue/scheduler
    
    [mq-deadline] kyber bfq none

    在文件名中,将 device 替换为块设备名称,如 sdc

    活跃的调度程序列在方括号中 ([]) 。

其他资源