zoukankan      html  css  js  c++  java
  • docker虚拟机动态扩展内存

    需求:将一台docker虚拟机的内存从6G扩展到8G。

    关于资源限制,docker使用的是cgroup,这里就不细说原理了,只记录一下操作方法。

    1、先找到容器ID

    # docker ps
    

    2、进入对应的cgroup目录

    # cd /sys/fs/cgroup/memory/docker/d14e1a6182eeed7c8f2a7c0a315a790a16bfbab1fdc7a73813cdeee494e8050a/
    # ll
    total 0
    -rw-r--r-- 1 root root 0 Sep 25 09:21 cgroup.clone_children
    --w--w--w- 1 root root 0 Sep 25 06:40 cgroup.event_control
    -rw-r--r-- 1 root root 0 Sep 25 06:40 cgroup.procs
    -rw-r--r-- 1 root root 0 Sep 25 09:21 memory.failcnt
    --w------- 1 root root 0 Sep 25 09:21 memory.force_empty
    -rw-r--r-- 1 root root 0 Sep 25 06:40 memory.limit_in_bytes
    -rw-r--r-- 1 root root 0 Sep 25 09:21 memory.max_usage_in_bytes
    -rw-r--r-- 1 root root 0 Sep 25 09:21 memory.memsw.failcnt
    -rw-r--r-- 1 root root 0 Sep 25 06:40 memory.memsw.limit_in_bytes
    -rw-r--r-- 1 root root 0 Sep 25 09:21 memory.memsw.max_usage_in_bytes
    -r--r--r-- 1 root root 0 Sep 25 09:21 memory.memsw.usage_in_bytes
    -rw-r--r-- 1 root root 0 Sep 25 09:21 memory.move_charge_at_immigrate
    -r--r--r-- 1 root root 0 Sep 25 09:21 memory.numa_stat
    -rw-r--r-- 1 root root 0 Sep 25 06:40 memory.oom_control
    ---------- 1 root root 0 Sep 25 09:21 memory.pressure_level
    -rw-r--r-- 1 root root 0 Sep 25 09:21 memory.soft_limit_in_bytes
    -r--r--r-- 1 root root 0 Sep 25 06:44 memory.stat
    -rw-r--r-- 1 root root 0 Sep 25 09:21 memory.swappiness
    -r--r--r-- 1 root root 0 Sep 25 09:21 memory.usage_in_bytes
    -rw-r--r-- 1 root root 0 Sep 25 09:21 memory.use_hierarchy
    -rw-r--r-- 1 root root 0 Sep 25 09:21 notify_on_release
    -rw-r--r-- 1 root root 0 Sep 25 09:21 tasks
    

    3、修改相应的值即可

    # echo 8589934592 > memory.limit_in_bytes
    # echo 17179869184 > memory.memsw.limit_in_bytes
    
  • 相关阅读:
    jQuery火箭图标返回顶部代码
    jQuery火箭图标返回顶部代码
    Rng(求逆元)
    P1306 斐波那契公约数(ksm+结论)
    sort(桶排序+hash)
    牛客多校训练AFJ(签到)
    Educational Codeforces Round 68 (Rated for Div. 2)-D. 1-2-K Game
    Educational Codeforces Round 68 (Rated for Div. 2)-C-From S To T
    The Unique MST(最小生成树的唯一性判断)
    飞跃原野(三维bfs)
  • 原文地址:https://www.cnblogs.com/keithtt/p/7590835.html
Copyright © 2011-2022 走看看