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
    • 最新
    • 标签
主页 / server / 问题 / 623814
Accepted
Programster
Programster
Asked: 2014-08-26 05:47:58 +0800 CST2014-08-26 05:47:58 +0800 CST 2014-08-26 05:47:58 +0800 CST

KVM - 改变客人生活的记忆

  • 772

我有一个 KVM 来宾,我想动态更改其内存分配。

目前,要改变客人的记忆,我必须运行:

sudo virsh edit $GUEST_DOMAIN

然后从配置中更改以下部分中显示的第一行

...
<memory unit='KiB'>512000</memory>
  <currentMemory unit='KiB'>512000</currentMemory>
  <memtune>
    <hard_limit unit='KiB'>256000</hard_limit>
  </memtune>
...

然后用virsh shutdownand重启来宾virsh start。

我一直在尝试使用virsh memtune --hard-limit 512000 --domain $GUEST_ID(参考),但它似乎没有效果。

我还尝试使用此处的文档从客人内部“膨胀” ,但我不断收到错误消息 balloon: command not found

问题

有没有办法使用来自主机的命令动态调整 KVM 来宾的大小。如果没有,是否至少有一种方法可以使用命令调整内存大小,而不必编辑配置文件(或者可以使用 sed 编辑 virsh 文件)?

额外信息

来宾正在使用 qcow2 稀疏文件。

以下是来自的完整配置sudo virsh edit $GUEST

<domain type='kvm'>
  <name>svn.mydomain.com</name>
  <uuid>8463ab11-628a-c07c-4366-4f768247934a</uuid>
  <memory unit='KiB'>512000</memory>
  <currentMemory unit='KiB'>512000</currentMemory>
  <memtune>
    <hard_limit unit='KiB'>256000</hard_limit>
  </memtune>
  <vcpu placement='static'>4</vcpu>
  <os>
    <type arch='x86_64' machine='pc-i440fx-trusty'>hvm</type>
    <boot dev='hd'/>
  </os>
  <features>
    <acpi/>
    <apic/>
    <pae/>
  </features>
  <clock offset='utc'/>
  <on_poweroff>destroy</on_poweroff>
  <on_reboot>restart</on_reboot>
  <on_crash>restart</on_crash>
  <devices>
    <emulator>/usr/bin/kvm-spice</emulator>
    <disk type='file' device='disk'>
      <driver name='qemu' type='raw'/>
      <source file='/media/storage/kvm/vms/svn.mydomain.com.img'/>
      <target dev='vda' bus='virtio'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
    </disk>
    <disk type='block' device='cdrom'>
      <driver name='qemu' type='raw'/>
      <target dev='hdc' bus='ide'/>
      <readonly/>
      <address type='drive' controller='0' bus='1' target='0' unit='0'/>
    </disk>
    <controller type='usb' index='0'>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/>
    </controller>
    <controller type='pci' index='0' model='pci-root'/>
    <controller type='ide' index='0'>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/>
    </controller>
    <interface type='bridge'>
      <mac address='52:54:00:a2:4a:f6'/>
      <source bridge='kvmbr0'/>
      <model type='virtio'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
    </interface>
    <serial type='pty'>
      <target port='0'/>
    </serial>
    <console type='pty'>
      <target type='serial' port='0'/>
    </console>
    <memballoon model='virtio'>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
    </memballoon>
  </devices>
</domain>
kvm-virtualization
  • 1 1 个回答
  • 2514 Views

1 个回答

  • Voted
  1. Best Answer
    Michael Hampton
    2014-08-26T06:10:35+08:002014-08-26T06:10:35+08:00

    你不需要搞砸<memtune><hard_limit>。当应用于 KVM 来宾时,这实际上是一个相当危险的设置。我会立即删除该部分。

    但是,强烈建议 QEMU 和 KVM 的用户不要设置此限制,因为如果猜测太低,域可能会被内核杀死。确定一个进程运行所需的内存是一个无法确定的问题。

    要减少 KVM 来宾现在可以访问的内存量,请更改<currentMemory>. 来宾可以拥有的最大值由 指定<memory>,更改它需要关闭来宾。

    • 1

相关问题

  • Xen 与 KVM 的性能对比

  • 什么是bridge_fd?

  • 如何在 kvm-linux 中登录除 ssh、vnc 之外的控制台

  • Linux 内核虚拟机

  • Vista 上的 VNC

Sidebar

Stats

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

    新安装后 postgres 的默认超级用户用户名/密码是什么?

    • 5 个回答
  • Marko Smith

    SFTP 使用什么端口?

    • 6 个回答
  • Marko Smith

    命令行列出 Windows Active Directory 组中的用户?

    • 9 个回答
  • Marko Smith

    什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同?

    • 3 个回答
  • Marko Smith

    如何确定bash变量是否为空?

    • 15 个回答
  • Martin Hope
    Tom Feiner 如何按大小对 du -h 输出进行排序 2009-02-26 05:42:42 +0800 CST
  • Martin Hope
    Noah Goodrich 什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同? 2009-05-19 18:24:42 +0800 CST
  • Martin Hope
    Brent 如何确定bash变量是否为空? 2009-05-13 09:54:48 +0800 CST
  • Martin Hope
    cletus 您如何找到在 Windows 中打开文件的进程? 2009-05-01 16:47:16 +0800 CST

热门标签

linux nginx windows networking ubuntu domain-name-system amazon-web-services active-directory apache-2.4 ssh

Explore

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

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve