1

我对在 postgres 单元文件中设置资源感到困惑。我设置了以下文件:

cat /etc/systemd/system/postgresql.service.d/50-BlockIOWeight.conf
[Service]
BlockIOWeight=10
cat /etc/systemd/system/postgresql.service.d/50-CPUShares.conf
[Service]
CPUShares=10

然后我做:

systemctl daemon-reload
systemctl restart postgresql.service

现在我想我可以通过以下方式获得服务的实际值:

systemctl show postgres.service | grep CPUShares
CPUShares=18446744073709551615
StartupCPUShares=18446744073709551615

以下内容也一无所获:

cat /sys/fs/cgroup/blkio/system.slice/postgresql.service/blkio.weight
cat: /sys/fs/cgroup/blkio/system.slice/postgresql.service/blkio.weight: Datei oder Verzeichnis nicht gefunden

但是,如果我删除我的配置并重新启动服务,然后立即设置属性,我可以在 /sys/fs/ 中设置配置 .... 请参见此处:

rm -rf /etc/systemd/system/postgresql.service.d/50-*
systemctl daemon-reload
systemctl restart postgresql.service
cat /sys/fs/cgroup/cpu,cpuacct/system.slice/postgresql.service/cpu.shares
cat: /sys/fs/cgroup/cpu,cpuacct/system.slice/postgresql.service/cpu.shares: Datei oder Verzeichnis nicht gefunden

systemctl set-property postgresql.service CPUShares=10 BlockIOWeight=10
cat /sys/fs/cgroup/cpu,cpuacct/system.slice/postgresql.service/cpu.shares
10

但 systemd show 仍然没有显示 cpushares 值:

systemctl show postgres.service | grep CPUShares
CPUShares=18446744073709551615
StartupCPUShares=18446744073709551615

还创建了 /etc/systemd 中的文件

ls -la /etc/systemd/system/postgresql.service.d/
insgesamt 16
drwxr-xr-x  2 root root 4096 Jul  4 08:28 .
drwxr-xr-x 19 root root 4096 Jul  3 11:47 ..
-rw-r--r--  1 root root   27 Jul  4 08:28 50-BlockIOWeight.conf
-rw-r--r--  1 root root   23 Jul  4 08:28 50-CPUShares.conf

所以通过 set-property 设置运行服务有效吗?但是在简单的重启之后服务就全部消失了,尽管配置仍然存在于 /etc/systemd/system/postgresql.service.d/

这里有什么问题?

4

0 回答 0