AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / ubuntu / 问题

问题[cgroup](ubuntu)

Martin Hope
doraemon
Asked: 2021-11-18 04:34:04 +0800 CST

是使用 cgroup v1 或 v2 的 `cgroup-tools`

  • 3

我安装了 ubuntu 21.10。我通过运行确认我正在使用 cgroup v2 mount,这表明cgrup2 on /sys/fs/cgroup type cgroup2。

当我想使用cgcreatefromcgroup-tools创建一个新组时cpu:

sudo cgcreate -g cpu:newgroup  # or
sudo cgcreate -g all:newgroup 

它失败并出现错误:

cgcreate: libcgroup initialization failed: Cgroup is not mounted

我有几个问题:

  • 这是因为cgroup-tools是针对 cgroup v1 的吗?
  • 我应该使用什么来为 cgroup v2 创建新的 cgroup?
  • 如何使用 cgroup v2 的配置文件创建持久性 cgroup(在引导时)?
cgroup
  • 1 个回答
  • 1669 Views
Martin Hope
user1689430
Asked: 2021-09-22 20:24:59 +0800 CST

Cgroups 内存限制 - 脚本在达到限制之前被杀死

  • 0

我正在尝试一个简单的示例来了解如何限制进程的内存消耗。

我创建了一个测试内存组,将 memory.limit_in_bytes 和 memory.memsw.limit_in_bytes 的限制设置为 5 MB。

我有一个非常简单的程序,它以 1 MB 的增量分配内存(通过从随机设备读取)。

我本来希望我的脚本在被杀死之前达到接近 5 MB 的大小,但它在读取 1 MB 后立即被杀死。

当我将 cgroup 限制提高到 8 MB 时,它会在消耗 3 MB 后被杀死。

我尝试了不同的限制,并注意到它在达到分配限制的一半之前一直被杀死。

如果我还缺少其他东西,有人可以告诉我吗?

将不胜感激一些指导。

cgroup
  • 1 个回答
  • 86 Views
Martin Hope
Weyder Ferreira
Asked: 2020-06-03 17:40:42 +0800 CST

rootstrap:找不到命令

  • 0

我正在尝试创建一个系统根来使用监狱进行一些测试,并且我正在尝试安装rootstrap whitout 成功。

$ rootstrap
rootstrap: command not found

尝试安装时:

$ sudo apt-get install -y rootstrap
Reading package lists... Done
Building dependency tree       
Reading state information... Done
E: Unable to locate package rootstrap

我的操作系统版本:

                    ./+o+-       
                  yyyyy- -yyyyyy+      OS: Ubuntu 20.04 focal
               ://+//////-yyyyyyo      Kernel: x86_64 Linux 5.4.0-33-generic
           .++ .:/++++++/-.+sss/`      Uptime: 13h 40m
         .:++o:  /++++++++/:--:/-      Packages: 2190
        o:+o+:++.`..```.-/oo+++++/     Shell: bash 5.0.16
       .:+o:+o/.          `+sssoo+/    Resolution: 1920x1080
  .++/+:+oo+o:`             /sssooo.   DE: Xfce
 /+++//+:`oo+o               /::--:.   WM: Xfwm4
 \+/+o+++`o++o               ++////.   WM Theme: Qogir-win-dark
  .++.o+++oo+:`             /dddhhh.   GTK Theme: Qogir-win-dark [GTK2]
       .+.o+oo:.          `oddhhhh+    Icon Theme: Qogir-ubuntu-dark
        \+.++o+o``-````.:ohdhhhhh+     Font: Noto Sans 9
         `:o+++ `ohhhhhhhhyo++os:      Disk: 17G / 156G (11%)
           .o:`.syhhhhhhh/.oo++o`      CPU: Intel Core i7-4790K @ 8x 4.6GHz [28.0°C]
               /osyyyyyyo++ooo+++/     GPU: GeForce GTX 1060 6GB
                   ````` +oo+++o\:     RAM: 5672MiB / 15919MiB

这个包是另一个包的替代品吗?

root chroot cgroup
  • 1 个回答
  • 65 Views
Martin Hope
samirbajaj
Asked: 2020-04-22 15:28:55 +0800 CST

引导期间的错误消息

  • 1

我最近对我的 18.04 LTS 安装应用了一些软件更新,现在我在重新启动期间看到以下内容:

$ cat /var/log/boot.log  Scanning for Btrfs filesystems UBUNTU: clean, 700970/30883840 files, 21610032/123523840 blocks [  OK  ] Found device /sys/subsystem/net/devices/br0. [  OK  ] Started ifup for br0.
         Starting Network Manager Script Dispatcher Service... [  OK  ]
         Starting Virtualization daemon...
         Starting Permit User Sessions...
         Starting containerd container runtime...
         Starting OpenBSD Secure Shell server... [  OK  ] 
         Reached target Network is Online.
         Starting Message of the Day...
         Starting Docker Application Container Engine...
         Starting Hold until boot process finishes up...
         Starting GNOME Display Manager... 

         [  OK  ] Created slice User Slice of root. 
         [FAILED] Failed to start Session c2 of user root. See 'systemctl status session-c2.scope' for details. 
         [FAILED] Failed to start Session c7 of user root. See 'systemctl status session-c7.scope' for details. 
         [FAILED] Failed to start Session c4 of user root. See 'systemctl status session-c4.scope' for details. 
         [FAILED] Failed to start Session c3 of user root. See 'systemctl status session-c3.scope' for details. 
         [  OK  ] Started Session c11 of user root.
         Starting User Manager for UID 0... 
         [FAILED] Failed to start Session c5 of user root. See ....

systemctl 有以下说法:

$ systemctl status session-c2.scope
● session-c2.scope - Session c2 of user root
   Loaded: loaded (/run/systemd/transient/session-c2.scope; transient)
Transient: yes
   Active: failed (Result: resources)

Apr 21 15:50:53 dell systemd[1]: session-c2.scope: Failed to add PIDs to scope's control group: No such process
Apr 21 15:50:53 dell systemd[1]: session-c2.scope: Failed with result 'resources'.
Apr 21 15:50:53 dell systemd[1]: Failed to start Session c2 of user root.

其他有用信息:

$ uname -a
Linux dell 4.15.0-96-generic #97-Ubuntu SMP Wed Apr 1 03:25:46 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux

$ cat /proc/version_signature 
Ubuntu 4.15.0-96.97-generic 4.15.18

和这个:

$ systemctl --version
systemd 237
+PAM +AUDIT +SELINUX +IMA +APPARMOR +SMACK +SYSVINIT +UTMP +LIBCRYPTSETUP +GCRYPT +GNUTLS +ACL +XZ +LZ4 +SECCOMP +BLKID +ELFUTILS +KMOD -IDN2 +IDN -PCRE2 default-hierarchy=hybrid

我对 cgroups 的了解不够,无法自行进行更改...寻求帮助以尝试了解这里发生了什么。

非常感谢您的帮助,拜托!

编辑:根据要求:

$ cat /etc/default/grub
# If you change this file, run 'update-grub' afterwards to update
# /boot/grub/grub.cfg.
# For full documentation of the options in this file, see:
#   info -f grub -n 'Simple configuration'

GRUB_DEFAULT=0
GRUB_TIMEOUT_STYLE=hidden
GRUB_TIMEOUT=0
GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian`
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"
GRUB_CMDLINE_LINUX="locale=en_US intel_iommu=on"

# Uncomment to enable BadRAM filtering, modify to suit your needs
# This works with Linux (no patch required) and with any kernel that obtains
# the memory map information from GRUB (GNU Mach, kernel of FreeBSD ...)
#GRUB_BADRAM="0x01234567,0xfefefefe,0x89abcdef,0xefefefef"

# Uncomment to disable graphical terminal (grub-pc only)
#GRUB_TERMINAL=console

# The resolution used on graphical terminal
# note that you can use only modes which your graphic card supports via VBE
# you can see them in real GRUB with the command `vbeinfo'
#GRUB_GFXMODE=640x480

# Uncomment if you don't want GRUB to pass "root=UUID=xxx" parameter to Linux
#GRUB_DISABLE_LINUX_UUID=true

# Uncomment to disable generation of recovery mode menu entries
#GRUB_DISABLE_RECOVERY="true"

# Uncomment to get a beep at grub start
#GRUB_INIT_TUNE="480 440 1"

编辑 2:将“systemd.legacy_systemd_cgroup_controller=true”添加到 GRUB_CMDLINE_LINUX_DEFAULT 后(更新 grub,然后重新启动):

$ grep cgroup /proc/filesystems
nodev   cgroup
nodev   cgroup2
boot systemd 18.04 cgroup
  • 1 个回答
  • 3582 Views
Martin Hope
Christopher
Asked: 2020-02-07 10:23:29 +0800 CST

限制 Snap 包的内存

  • 2

一些快照(咳嗽 Slack)将有机会消耗几乎无限量的内存。在 pre-slack post systemd 世界中,我可以创建一个命名空间,限制它的内存/cpu 等......并通过在该命名空间内执行它来强制 slack 不吃这个世界。

向 Snap 包添加类似限制的正确方法是什么?由于快照已经在某些 cgroup 魔法中执行,我希望它像 asnap modify <snappackage> -addmemlimit 1G或其他东西一样简单。

snap slack cgroup
  • 1 个回答
  • 574 Views
Martin Hope
Sam Van den Eynde
Asked: 2014-12-08 15:39:59 +0800 CST

寻找在 Ubuntu 14.04 桌面上配置 cgroups 的一致方法

  • 7

我正在寻找一种一致的方法来在资源有限的 Ubuntu 14.04 桌面系统上配置 cgroups。

我想做什么:

  • 创建一些分配给特定任务的内存和 CPU 有限的组
  • 重新启动时自动启用这些组
  • 将某些命令/程序分配给每个组

我了解 cgroup 配置,以及如何使用 cgexec 为特定组启动进程。问题是下一步。

我已经构建了一个工作的 /etc/cgconfig.conf 文件,我能够使用 cgconfigparser 成功解析和激活以获取配置的 cgroup。然而,据我所知。

  • 我找不到在系统启动时正确读取和解析 /etc/cgconfig.conf 的服务。当前的 cgroup 包似乎不包括这样的服务。
  • 据我了解,/etc/cgconfig.conf 附带一个 /etc/cgrules.conf 文件,该文件描述了在某个组中默认情况下进程是如何启动的。我无法识别解析它的服务或机制。如果没有此功能,我需要使用 cgexec 启动所有进程以将它们放入 cgroup。

我曾尝试使用 cgmanager,但该服务似乎也没有从 /etc/cgconfig.conf 配置。总的来说,我发现很难找到有关如何在 Ubuntu 桌面系统上配置和使用 cgroups 的信息。

那么,有人能指出我正确的方向吗?我需要安装什么服务,它遵循什么配置文件?

需要明确的是:我不是在寻找容器。它是在单个专用系统上构建资源处理。

非常感谢 :)

cgroup
  • 1 个回答
  • 2872 Views

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    如何运行 .sh 脚本?

    • 16 个回答
  • Marko Smith

    如何安装 .tar.gz(或 .tar.bz2)文件?

    • 14 个回答
  • Marko Smith

    如何列出所有已安装的软件包

    • 24 个回答
  • Marko Smith

    无法锁定管理目录 (/var/lib/dpkg/) 是另一个进程在使用它吗?

    • 25 个回答
  • Martin Hope
    Flimm 如何在没有 sudo 的情况下使用 docker? 2014-06-07 00:17:43 +0800 CST
  • Martin Hope
    Ivan 如何列出所有已安装的软件包 2010-12-17 18:08:49 +0800 CST
  • Martin Hope
    La Ode Adam Saputra 无法锁定管理目录 (/var/lib/dpkg/) 是另一个进程在使用它吗? 2010-11-30 18:12:48 +0800 CST
  • Martin Hope
    David Barry 如何从命令行确定目录(文件夹)的总大小? 2010-08-06 10:20:23 +0800 CST
  • Martin Hope
    jfoucher “以下软件包已被保留:”为什么以及如何解决? 2010-08-01 13:59:22 +0800 CST
  • Martin Hope
    David Ashford 如何删除 PPA? 2010-07-30 01:09:42 +0800 CST

热门标签

10.10 10.04 gnome networking server command-line package-management software-recommendation sound xorg

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve