账号密码登录
微信安全登录
微信扫描二维码登录

登录后绑定QQ、微信即可实现信息互通

手机验证码登录
找回密码返回
邮箱找回 手机找回
注册账号返回
其他登录方式
分享
  • 收藏
    X
    cgroup 限制内存写入文件memory.limit_in_bytes I/O error?
    39
    0

    问题描述

    系统: Ubuntu 18.04.2 LTS
    内核版本: 4.15.0-50-generic
    /sys/fs/cgroup/memory建了一个目录my-test,然后想设置内存限额,写文件sh -c "echo 1M > memory.limit_in_bytes",发生错误

    sh: echo: I/O error

    my-test目录列表

    ls -al
    总用量 0
    drwxr-xr-x 2 root root 0 7月   4 12:31 .
    dr-xr-xr-x 6 root root 0 7月   4 12:31 ..
    -rw-r--r-- 1 root root 0 7月   4 12:31 cgroup.clone_children
    --w--w--w- 1 root root 0 7月   4 12:31 cgroup.event_control
    -rw-r--r-- 1 root root 0 7月   4 12:31 cgroup.procs
    -rw-r--r-- 1 root root 0 7月   4 12:31 memory.failcnt
    --w------- 1 root root 0 7月   4 12:31 memory.force_empty
    -rw-r--r-- 1 root root 0 7月   4 12:31 memory.kmem.failcnt
    -rw-r--r-- 1 root root 0 7月   4 12:31 memory.kmem.limit_in_bytes
    -rw-r--r-- 1 root root 0 7月   4 12:31 memory.kmem.max_usage_in_bytes
    -r--r--r-- 1 root root 0 7月   4 12:31 memory.kmem.slabinfo
    -rw-r--r-- 1 root root 0 7月   4 12:31 memory.kmem.tcp.failcnt
    -rw-r--r-- 1 root root 0 7月   4 12:31 memory.kmem.tcp.limit_in_bytes
    -rw-r--r-- 1 root root 0 7月   4 12:31 memory.kmem.tcp.max_usage_in_bytes
    -r--r--r-- 1 root root 0 7月   4 12:31 memory.kmem.tcp.usage_in_bytes
    -r--r--r-- 1 root root 0 7月   4 12:31 memory.kmem.usage_in_bytes
    -rw-r--r-- 1 root root 0 7月   4 12:38 memory.limit_in_bytes
    -rw-r--r-- 1 root root 0 7月   4 12:31 memory.max_usage_in_bytes
    -rw-r--r-- 1 root root 0 7月   4 12:31 memory.move_charge_at_immigrate
    -r--r--r-- 1 root root 0 7月   4 12:31 memory.numa_stat
    -rw-r--r-- 1 root root 0 7月   4 12:31 memory.oom_control
    ---------- 1 root root 0 7月   4 12:31 memory.pressure_level
    -rw-r--r-- 1 root root 0 7月   4 12:31 memory.soft_limit_in_bytes
    -r--r--r-- 1 root root 0 7月   4 12:31 memory.stat
    -rw-r--r-- 1 root root 0 7月   4 12:31 memory.swappiness
    -r--r--r-- 1 root root 0 7月   4 12:31 memory.usage_in_bytes
    -rw-r--r-- 1 root root 0 7月   4 12:31 memory.use_hierarchy
    -rw-r--r-- 1 root root 0 7月   4 12:31 notify_on_release
    -rw-r--r-- 1 root root 0 7月   4 12:31 tasks
    
    0
    打赏
    收藏
    点击回答
    您的回答被采纳后将获得:提问者悬赏的 11 元积分
        全部回答
    • 0
    • 热血无赖 普通会员 1楼

      cgroup(控制组)是Linux内核的一种机制,用于控制进程在内存使用上的一些限制。当你使用cgroup来限制内存的使用时,你需要在每个进程的启动脚本中添加一个--limit-file-mem选项,例如:

      bash --limit-file-mem=256M mem不限制

      在这个例子中,--limit-file-mem=256M告诉内核,希望每个进程的内存使用不超过256MB。如果你尝试使用超过这个限制的内存,那么就会出现I/O error

      此外,你还可以在--limit-file-mem选项中设置-m选项,例如:

      bash --limit-file-mem=-m 256M mem不限制

      在这个例子中,-m选项告诉内核,希望每个进程的内存使用不超过256MB。如果你尝试使用超过这个限制的内存,那么就会出现I/O error

      请注意,cgroup的内存限制可能会随着系统的负载和资源使用情况而变化。如果你发现你的进程在使用大量内存时仍然出现I/O error,那么可能需要进一步检查你的系统设置或资源使用情况。

    更多回答
    扫一扫访问手机版
    • 回到顶部
    • 回到顶部