kvm 가상 머신에 메모리가 너무 많으면 어떤 문제가 있나요?

kvm 가상 머신에 메모리가 너무 많으면 어떤 문제가 있나요?

kvm 가상 머신이 더 많은 메모리를 할당하는 것이 정상입니까? 메모리가 많지 않을 때 "오버 커밋된" 메모리가 "통제되지 않는 요인"이 되어 끔찍한 메모리 부족 종료를 유발할 수 있다는 점이 걱정됩니다.

libvirt를 사용하여 kvm 가상 머신을 생성했는데 내가 설정한 것보다 가상 메모리가 훨씬 많아지는 이상한 증상이 나타났습니다. "ps" 명령의 "SZ" 부분은 1GiB보다 작은 양으로 시작합니다. 하지만 시간이 지나면 더 커질 수도 있다. "SZ"가 작은 숫자를 나타내더라도 "numastat"의 출력은 항상 큰 숫자를 나타냅니다. - VM에 1GiB RAM을 할당했는데 numastat에서는 1.5+라고 말했습니다.

root@peta-0001-02:~#   ps -elfww | sed -ne '1p; /qemu-system/p'
F S UID        PID  PPID  C PRI  NI ADDR SZ WCHAN  STIME TTY          TIME CMD
6 S oneadmin 26811     1  1  80   0 - 812801 poll_s 15:42 ?       00:00:12 /usr/bin/qemu-system-x86_64 -name one-35 -S -machine pc-i440fx-xenial,accel=kvm,usb=off,mem-merge=off -m 1024 -realtime mlock=on -smp 2,sockets=2,cores=1,threads=1 -object memory-backend-file,id=ram-node0,prealloc=yes,mem-path=/dev/hugepages/libvirt/qemu,share=no,size=1073741824,host-nodes=0,policy=bind -numa node,nodeid=0,cpus=0-1,memdev=ram-node0 -uuid df4830f6-5a0d-42d0-b04a-192115d2512e -no-user-config -nodefaults -chardev socket,id=charmonitor,path=/var/lib/libvirt/qemu/domain-one-35/monitor.sock,server,nowait -mon chardev=charmonitor,id=monitor,mode=control -rtc base=utc -no-shutdown -boot strict=on -device usb-ehci,id=usb1,bus=pci.0,addr=0x5 -device nec-usb-xhci,id=usb2,bus=pci.0,addr=0x6 -device piix3-usb-uhci,id=usb,bus=pci.0,addr=0x1.0x2 -device virtio-scsi-pci,id=scsi0,num_queues=2,bus=pci.0,addr=0x4 -device virtio-serial-pci,id=virtio-serial0,bus=pci.0,addr=0x7 -drive file=/var/lib/one//datastores/104/35/disk.0,format=raw,if=none,id=drive-scsi0-0-0-0,cache=none,discard=unmap -device scsi-hd,bus=scsi0.0,channel=0,scsi-id=0,lun=0,drive=drive-scsi0-0-0-0,id=scsi0-0-0-0,bootindex=1 -drive file=/var/lib/one//datastores/104/35/disk.1,format=raw,if=none,id=drive-ide0-0-0,readonly=on -device ide-cd,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0 -netdev tap,fd=28,id=hostnet0,vhost=on,vhostfd=30 -device virtio-net-pci,netdev=hostnet0,id=net0,mac=02:00:c0:a8:04:0c,bus=pci.0,addr=0x3 -chardev pty,id=charserial0 -device isa-serial,chardev=charserial0,id=serial0 -chardev socket,id=charchannel0,path=/var/lib/libvirt/qemu/channel/target/domain-one-35/org.qemu.guest_agent.0,server,nowait -device virtserialport,bus=virtio-serial0.0,nr=1,chardev=charchannel0,id=channel0,name=org.qemu.guest_agent.0 -vnc 0.0.0.0:35,password -device cirrus-vga,id=video0,bus=pci.0,addr=0x2 -msg timestamp=on
0 S root     31260 27986  0  80   0 -  3755 pipe_w 15:53 pts/0    00:00:00 sed -ne 1p; /qemu-system/p
root@peta-0001-02:~#  numastat 26811

Per-node process memory usage (in MBs) for PID 26811 (qemu-system-x86)
                           Node 0           Total
                  --------------- ---------------
Huge                      1024.00         1024.00
Heap                        21.88           21.88
Stack                        0.13            0.13
Private                    628.00          628.00
----------------  --------------- ---------------
Total                     1674.01         1674.01

...멤벌룬 기능을 비활성화해도 같은 일이 발생합니다. -예, 저는 libvirt를 사용합니다-

<devices>   <memballoon model='none'/> </devices>

...큰 페이지를 사용하지 않는 것은 실제로 큰 차이를 가져오지 않습니다.

root@peta-0001-02:~#  ps -elfww | sed -ne '1p; /qemu-system/p'
F S UID        PID  PPID  C PRI  NI ADDR SZ WCHAN  STIME TTY          TIME CMD
6 S oneadmin  3800     1  1  80   0 - 1021714 poll_s 14:44 ?      00:00:13 /usr/bin/qemu-system-x86_64 -name one-35 -S -machine pc-i440fx-xenial,accel=kvm,usb=off,mem-merge=off -m 1024 -realtime mlock=on -smp 2,sockets=2,cores=1,threads=1 -uuid 530a2e87-6426-497a-b7bb-4e0d49ed1e26 -no-user-config -nodefaults -chardev socket,id=charmonitor,path=/var/lib/libvirt/qemu/domain-one-35/monitor.sock,server,nowait -mon chardev=charmonitor,id=monitor,mode=control -rtc base=utc -no-shutdown -boot strict=on -device usb-ehci,id=usb1,bus=pci.0,addr=0x5 -device nec-usb-xhci,id=usb2,bus=pci.0,addr=0x6 -device piix3-usb-uhci,id=usb,bus=pci.0,addr=0x1.0x2 -device virtio-scsi-pci,id=scsi0,num_queues=2,bus=pci.0,addr=0x4 -device virtio-serial-pci,id=virtio-serial0,bus=pci.0,addr=0x7 -drive file=/var/lib/one//datastores/104/35/disk.0,format=raw,if=none,id=drive-scsi0-0-0-0,cache=none,discard=unmap -device scsi-hd,bus=scsi0.0,channel=0,scsi-id=0,lun=0,drive=drive-scsi0-0-0-0,id=scsi0-0-0-0,bootindex=1 -drive file=/var/lib/one//datastores/104/35/disk.1,format=raw,if=none,id=drive-ide0-0-0,readonly=on -device ide-cd,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0 -netdev tap,fd=28,id=hostnet0,vhost=on,vhostfd=30 -device virtio-net-pci,netdev=hostnet0,id=net0,mac=02:00:c0:a8:04:0c,bus=pci.0,addr=0x3 -chardev pty,id=charserial0 -device isa-serial,chardev=charserial0,id=serial0 -chardev socket,id=charchannel0,path=/var/lib/libvirt/qemu/channel/target/domain-one-35/org.qemu.guest_agent.0,server,nowait -device virtserialport,bus=virtio-serial0.0,nr=1,chardev=charchannel0,id=channel0,name=org.qemu.guest_agent.0 -vnc 0.0.0.0:35,password -device cirrus-vga,id=video0,bus=pci.0,addr=0x2 -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x8 -msg timestamp=on
0 S root     11005 27986  0  80   0 -  3755 pipe_w 15:02 pts/0    00:00:00 sed -ne 1p; /qemu-system/p


root@peta-0001-02:~#  numastat 3800

Per-node process memory usage (in MBs) for PID 3800 (qemu-system-x86)
                           Node 0           Total
                  --------------- ---------------
Huge                         0.00            0.00
Heap                        21.76           21.76
Stack                        0.13            0.13
Private                   1701.06         1701.06
----------------  --------------- ---------------
Total                     1722.95         1722.95

...테스트 환경은 우분투 박스입니다.

root@peta-0001-02:~#  uname -a
Linux peta-0001-02 4.10.0-42-generic #46~16.04.1-Ubuntu SMP Mon Dec 4 15:57:59 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux

root@peta-0001-02:~#  cat /proc/cmdline 
BOOT_IMAGE=/boot/vmlinuz-4.10.0-42-generic root=UUID=371a1314-677a-4b88-b804-b1278ff4ac6e ro isolcpus=1,2,3,8,9,10,11 hugepagesz=1G hugepages=0 hugepagesz=2M hugepages=2048

...여기에는 2개의 NUMA 노드가 있는 시스템의 각 노드에서 메모리 오버커밋이 발생하여 심각한 오버커밋이 발생하는 또 다른 흥미로운 사례가 있습니다.

root@peta-0001-06:~#  ps -elfww | sed -ne '1p; /qemu/p'
F S UID        PID  PPID  C PRI  NI ADDR SZ WCHAN  STIME TTY          TIME CMD
6 S oneadmin 24960     1 27  80   0 - 1648605 poll_s 13:51 ?      00:03:25 /usr/bin/qemu-system-x86_64 -name one-38 -S -machine pc-i440fx-xenial,accel=kvm,usb=off,mem-merge=off -m 1024 -realtime mlock=on -smp 2,sockets=2,cores=1,threads=1 -object memory-backend-file,id=ram-node0,prealloc=yes,mem-path=/dev/hugepages/libvirt/qemu,share=no,size=1073741824,host-nodes=1,policy=bind -numa node,nodeid=0,cpus=0-1,memdev=ram-node0 -uuid 87a23172-daf3-4605-92f2-50055f9370b9 -no-user-config -nodefaults -chardev socket,id=charmonitor,path=/var/lib/libvirt/qemu/domain-one-38/monitor.sock,server,nowait -mon chardev=charmonitor,id=monitor,mode=control -rtc base=utc -no-shutdown -boot strict=on -device usb-ehci,id=usb1,bus=pci.0,addr=0x5 -device nec-usb-xhci,id=usb2,bus=pci.0,addr=0x6 -device piix3-usb-uhci,id=usb,bus=pci.0,addr=0x1.0x2 -device virtio-scsi-pci,id=scsi0,num_queues=2,bus=pci.0,addr=0x4 -device virtio-serial-pci,id=virtio-serial0,bus=pci.0,addr=0x7 -drive file=/var/lib/one//datastores/0/38/disk.0,format=raw,if=none,id=drive-scsi0-0-0-0,cache=none,discard=unmap -device scsi-hd,bus=scsi0.0,channel=0,scsi-id=0,lun=0,drive=drive-scsi0-0-0-0,id=scsi0-0-0-0,bootindex=1 -drive file=/var/lib/one//datastores/0/38/disk.1,format=raw,if=none,id=drive-ide0-0-0,readonly=on -device ide-cd,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0 -netdev tap,fd=28,id=hostnet0,vhost=on,vhostfd=30 -device virtio-net-pci,netdev=hostnet0,id=net0,mac=02:00:c0:a8:04:0b,bus=pci.0,addr=0x3 -chardev pty,id=charserial0 -device isa-serial,chardev=charserial0,id=serial0 -chardev socket,id=charchannel0,path=/var/lib/libvirt/qemu/channel/target/domain-one-38/org.qemu.guest_agent.0,server,nowait -device virtserialport,bus=virtio-serial0.0,nr=1,chardev=charchannel0,id=channel0,name=org.qemu.guest_agent.0 -vnc 0.0.0.0:38,password -device cirrus-vga,id=video0,bus=pci.0,addr=0x2 -msg timestamp=on
0 R root     32103 26834  0  80   0 -  4075 -      14:04 pts/2    00:00:00 sed -ne 1p; /qemu/p

root@peta-0001-06:~#  numastat 24960

Per-node process memory usage (in MBs) for PID 24960 (qemu-system-x86)
                           Node 0          Node 1           Total
                  --------------- --------------- ---------------
Huge                         0.00         1024.00         1024.00
Heap                        15.97            5.91           21.88
Stack                        0.13            0.00            0.13
Private                    676.95          595.42         1272.37
----------------  --------------- --------------- ---------------
Total                      693.05         1625.34         2318.38

root@peta-0001-06:~#  free -h
              total        used        free      shared  buff/cache   available
Mem:           5.8G        5.0G        483M        104K        310M        407M

관련 정보