之路教程 https://onitr oad .com
检查确认
以下命令显示进程的 CPU 亲和性:
# taskset -p [process ID]
# ps --ppid 2 -p 2 -o uname,pid,ppid,cmd,cls,psr --deselect
CPUAffinity 是控制 systemd 执行进程的 CPU 亲和性的指令之一。
从 systemd.exec 的手册页:
# man systemd.exec CPUAffinity= Controls the CPU affinity of the executed processes. Takes a list of CPU indices or ranges separated by either whitespace or commas. CPU ranges are specified by the lower and upper CPU indices separated by a dash. This option may be specified more than once in which case the specified CPU affinity masks are merged. If the empty string is assigned, the mask is reset, all assignments prior to this will have no effect. See sched_setaffinity(2) for details. 控制已执行进程的 CPU 亲和性。 获取由空格或者逗号分隔的 CPU 索引或者范围列表。 CPU 范围由以破折号分隔的低 CPU 索引和高 CPU 索引指定。 可以多次指定此选项,在这种情况下,指定的 CPU 关联掩码将被合并。 如果分配了空字符串,则掩码被重置,在此之前的所有分配都将无效。 有关详细信息,请参阅 sched_setaffinity(2)。
配置 CPU affinity
- 编辑文件“/etc/systemd/system.conf”:
# vi /etc/systemd/system.conf
- 取消注释“CPUAffinity”行并添加 CPU 编号。
CPUAffinity=2,3
- 重新启动服务器并验证 CPU 亲和性状态。
日期:2020-09-17 00:13:52 来源:oir作者:oir