<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Hotplug on OHTLY Blog</title>
    <link>https://blog.ohtly.com/tags/hotplug/</link>
    <description>Recent content in Hotplug on OHTLY Blog</description>
    <generator>Hugo</generator>
    <language>zh-cn</language>
    <lastBuildDate>Sun, 05 Jul 2026 11:06:34 +0800</lastBuildDate>
    <atom:link href="https://blog.ohtly.com/tags/hotplug/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>Proxmox VE 内存热插拔与动态回收配置</title>
      <link>https://blog.ohtly.com/posts/2026-07-05-pve-memory-hotplug-balloon/</link>
      <pubDate>Sun, 05 Jul 2026 11:03:00 +0800</pubDate>
      <guid>https://blog.ohtly.com/posts/2026-07-05-pve-memory-hotplug-balloon/</guid>
      <description>&lt;h2 id=&#34;背景&#34;&gt;&#xA;  背景&#xA;  &lt;a class=&#34;heading-link&#34; href=&#34;#%e8%83%8c%e6%99%af&#34;&gt;&#xA;    &lt;i class=&#34;fa-solid fa-link&#34; aria-hidden=&#34;true&#34; title=&#34;链接到标题&#34;&gt;&lt;/i&gt;&#xA;    &lt;span class=&#34;sr-only&#34;&gt;链接到标题&lt;/span&gt;&#xA;  &lt;/a&gt;&#xA;&lt;/h2&gt;&#xA;&lt;p&gt;PVE 虚拟机调整内存有两种常见场景：&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;strong&gt;扩容&lt;/strong&gt;：虚拟机需要更多内存，希望不停机直接添加&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;宿主机压力回收&lt;/strong&gt;：宿主机内存不足时，临时压缩虚拟机内存&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;传统方式需要关机修改再开机，导致服务中断。通过 Hotplug 和 Ballooning 可以解决这两个问题。&lt;/p&gt;&#xA;&lt;h2 id=&#34;内存热添加hotplug&#34;&gt;&#xA;  内存热添加（Hotplug）&#xA;  &lt;a class=&#34;heading-link&#34; href=&#34;#%e5%86%85%e5%ad%98%e7%83%ad%e6%b7%bb%e5%8a%a0hotplug&#34;&gt;&#xA;    &lt;i class=&#34;fa-solid fa-link&#34; aria-hidden=&#34;true&#34; title=&#34;链接到标题&#34;&gt;&lt;/i&gt;&#xA;    &lt;span class=&#34;sr-only&#34;&gt;链接到标题&lt;/span&gt;&#xA;  &lt;/a&gt;&#xA;&lt;/h2&gt;&#xA;&lt;h3 id=&#34;原理&#34;&gt;&#xA;  原理&#xA;  &lt;a class=&#34;heading-link&#34; href=&#34;#%e5%8e%9f%e7%90%86&#34;&gt;&#xA;    &lt;i class=&#34;fa-solid fa-link&#34; aria-hidden=&#34;true&#34; title=&#34;链接到标题&#34;&gt;&lt;/i&gt;&#xA;    &lt;span class=&#34;sr-only&#34;&gt;链接到标题&lt;/span&gt;&#xA;  &lt;/a&gt;&#xA;&lt;/h3&gt;&#xA;&lt;p&gt;QEMU 在启动时可以预留内存槽位（slots）和最大内存上限（maxmem），运行中通过 &lt;code&gt;device_add&lt;/code&gt; 命令插入 pc-dimm 设备来增加内存。&lt;/p&gt;&#xA;&lt;h3 id=&#34;配置步骤&#34;&gt;&#xA;  配置步骤&#xA;  &lt;a class=&#34;heading-link&#34; href=&#34;#%e9%85%8d%e7%bd%ae%e6%ad%a5%e9%aa%a4&#34;&gt;&#xA;    &lt;i class=&#34;fa-solid fa-link&#34; aria-hidden=&#34;true&#34; title=&#34;链接到标题&#34;&gt;&lt;/i&gt;&#xA;    &lt;span class=&#34;sr-only&#34;&gt;链接到标题&lt;/span&gt;&#xA;  &lt;/a&gt;&#xA;&lt;/h3&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#75715e&#34;&gt;# 1. 启用 memory hotplug 和 numa&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;qm set &amp;lt;vmid&amp;gt; --hotplug &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;memory&amp;#34;&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;qm set &amp;lt;vmid&amp;gt; --numa &lt;span style=&#34;color:#ae81ff&#34;&gt;1&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#75715e&#34;&gt;# 2. 首次需要 shutdown + start（让 QEMU 带上 slots/maxmem 参数）&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;qm shutdown &amp;lt;vmid&amp;gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;qm start &amp;lt;vmid&amp;gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;首次启动后 QEMU 命令行会变为类似：&lt;/p&gt;</description>
    </item>
  </channel>
</rss>
