在 CentOS 7 中,有没有办法指定应该使用调度程序(或电梯)调整哪些块设备?

Lev*_*ike 2 linux block scheduler grub2 block-device

在 CentOS 6 中,有/etc/tune-profiles/my-server/ktune.sysconfig这样的文字(我指的是解释代码正在做什么的注释):

# This is the I/O scheduler ktune will use.  This will *not* override anything
# explicitly set on the kernel command line, nor will it change the scheduler
# for any block device that is using a non-default scheduler when ktune starts.
# You should probably leave this on "deadline", but "as", "cfq", and "noop" are
# also legal values.  Comment this out to prevent ktune from changing I/O
# scheduler settings.
ELEVATOR="deadline"

# These are the devices, that should be tuned with the ELEVATOR
ELEVATOR_TUNE_DEVS="/sys/block/{sd,cciss,vd,dasd,xvd}*/queue/scheduler"
Run Code Online (Sandbox Code Playgroud)

但似乎 CentOS 7 已经ktune落后了。我看到了一种更改默认 I/O 调度程序的替代方法

elevator参数添加到文件中的GRUB_CMDLINE_LINUX/etc/default/grub

# cat /etc/default/grub
...
GRUB_CMDLINE_LINUX="crashkernel=auto rd.lvm.lv=vg00/lvroot rd.lvm.lv=vg00/lvswap elevator=noop"
...
Run Code Online (Sandbox Code Playgroud)

它继续。但这将是一个系统范围的变化。我正在寻找一种类似于 CentOS 6 中的解决方案,我可以在其中指定哪些块设备将获得由ELEVATOR参数指定的 I/O 调度程序。我希望我可以将elevator_tune_devs参数添加到GRUB_CMDLINE_LINUX行中,但根据this,没有这样的内核参数。我知道我可以这样做:

echo 'noop' > /sys/block/hda/queue/scheduler
Run Code Online (Sandbox Code Playgroud)

例如,但我希望能在重启后持续下去。迄今为止最好的解决方案是将该echo命令保留在一次性服务中,以便每次启动时都运行它,但我希望有一种类似于 CentOS 6 解决方案的更简洁的方法。

sho*_*hok 5

你至少有两种方法:

  • 使用带有正确选项的自定义调整配置文件disk
  • 将“echo noop”命令插入/etc/rc.local或创建特定的 systemd 服务。

编辑:在这里你可以找到一个示例tuned.conf文件:

# tuned configuration

[main]
summary=ZFS General non-specialized tuned profile
include=balanced

[disk]
# Comma separated list of devices, all devices if commented out.
type=disk
devices=sda,sdb
elevator=noop
Run Code Online (Sandbox Code Playgroud)

正如我在上面链接的 RHEL 调优指南中所述,您有不同的可能性来定义设备列表:

  • 通过昏迷分隔列表(如上例所示);
  • 通过通配符(例如:)sd*
  • 所有磁盘,不指定任何内容(如上面文件中包含的注释)。