<rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0">
    <channel>
        <title>小源的博客</title>
        <link>https://www.liuxiaoyuan.info/</link>
        <description>This is my cool site</description>
        <generator>Hugo -- gohugo.io</generator><language>zh-CN</language><lastBuildDate>Thu, 29 Jan 2026 16:00:00 &#43;0800</lastBuildDate>
            <atom:link href="https://www.liuxiaoyuan.info/index.xml" rel="self" type="application/rss+xml" />
        <item>
    <title>基于 KVM 的 Cloudbase-init 使用教程（01）：Windows 镜像模板制作</title>
    <link>https://www.liuxiaoyuan.info/posts/cloudbase-init-tutorial-01/</link>
    <pubDate>Mon, 26 Jan 2026 16:00:00 &#43;0800</pubDate>
    <author>lxyqwer</author>
    <guid>https://www.liuxiaoyuan.info/posts/cloudbase-init-tutorial-01/</guid>
    <description><![CDATA[<p>最近在研发 KVM 虚拟化管理平台，需要在新建实例时自动初始化主机名、实例 ID、IP 等配置。本来打算自己开发一套初始化流程，调研后发现社区已有成熟方案：</p>
<ul>
<li>Linux：使用 <a href="https://cloudinit.readthedocs.io/en/latest/" target="_blank" rel="noopener noreffer ">cloud-init</a></li>
<li>Windows：使用 <a href="https://cloudbase-init.readthedocs.io/en/latest/" target="_blank" rel="noopener noreffer ">cloudbase-init</a></li>
</ul>
<p>两者在配置模型上高度兼容（尤其是 NoCloud/ConfigDrive 这类场景），能显著降低维护成本。</p>
<p>本篇（01）主要讲 <strong>Windows 模板镜像制作</strong>；下一篇会基于该模板演示如何创建实例并下发初始化数据。</p>
<h2 id="准备">准备</h2>
<h3 id="你将得到什么">你将得到什么</h3>
<ul>
<li>一个可复用的 Windows Server 2022 模板镜像（qcow2）</li>
<li>模板内已安装并配置好 cloudbase-init（后续可通过 ConfigDrive/NoCloud 注入初始化信息）</li>
</ul>
<h3 id="环境与材料">环境与材料</h3>
<ul>
<li><strong>宿主机</strong>：已安装 KVM + libvirt，并可使用 <code>virt-install</code></li>
<li><strong>网络</strong>：示例使用 Linux bridge <code>br0</code>（请按你的实际环境替换）</li>
<li><strong>Windows ISO</strong>：Windows Server 2022 Standard（示例为中文 ISO）</li>
<li><strong>VirtIO 驱动 ISO</strong>：<a href="https://fedorapeople.org/groups/virt/virtio-win/direct-downloads/archive-virtio/" target="_blank" rel="noopener noreffer ">VirtIO Windows Drivers ISO</a>（示例使用 <code>virtio-win-0.1.285.iso</code>）</li>
<li><strong>cloudbase-init 安装包</strong>：<a href="https://github.com/cloudbase/cloudbase-init/releases" target="_blank" rel="noopener noreffer ">cloudbase-init Releases</a>（示例使用 <code>1.1.6</code>）</li>
</ul>
<div class="details admonition tip open">
        <div class="details-summary admonition-title">
            <i class="icon fas fa-lightbulb fa-fw" aria-hidden="true"></i>提示<i class="details-icon fas fa-angle-right fa-fw" aria-hidden="true"></i>
        </div>
        <div class="details-content">
            <div class="admonition-content">如果你希望 cloudbase-init 输出日志到串口（便于宿主机采集），请确保虚拟机设备里存在 <strong>COM1</strong>（serial port）。没有也不影响功能，只是少了串口日志。</div>
        </div>
    </div>
<h2 id="1-创建-windows-模板虚拟机">1. 创建 Windows 模板虚拟机</h2>
<p>在宿主机创建一个用于制作模板的虚拟机。我这里使用 <code>virt-install</code>，Windows 安装过程（分区/账号等）请按你的习惯完成即可。</p>]]></description>
</item>
<item>
    <title>环境定义</title>
    <link>https://www.liuxiaoyuan.info/posts/environment_definition/</link>
    <pubDate>Wed, 07 Aug 2024 14:17:31 &#43;0800</pubDate>
    <author>lxyqwer</author>
    <guid>https://www.liuxiaoyuan.info/posts/environment_definition/</guid>
    <description><![CDATA[<p>本文档用于说明企业常见的各类系统环境，包括 <strong>Dev、SIT、UAT、Beta、Pre-Prod、Prod</strong>，方便研发、测试、运维等团队统一理解和使用。</p>
<hr>
<h2 id="1-环境对比总览">1. 环境对比总览</h2>
<table>
  <thead>
      <tr>
          <th>环境</th>
          <th>全称</th>
          <th>面向对象</th>
          <th>数据库策略</th>
          <th>风险等级</th>
          <th>部署频率</th>
          <th>主要用途</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td>Dev</td>
          <td>Development/开发环境</td>
          <td>开发人员</td>
          <td>开发库，数据可随时清空</td>
          <td>★</td>
          <td>高频（随时）</td>
          <td>功能研发、自测</td>
      </tr>
      <tr>
          <td>SIT</td>
          <td>System Integration Test/系统集成测试环境</td>
          <td>/开发人员测试人员</td>
          <td>独立测试库，常用伪造数据</td>
          <td>★★</td>
          <td>高频</td>
          <td>接口联调、系统集成测试</td>
      </tr>
      <tr>
          <td>UAT</td>
          <td>User Acceptance Test/用户验收测试环境</td>
          <td>业务方/测试人员</td>
          <td>独立数据库，接近生产结构</td>
          <td>★★★</td>
          <td>中等</td>
          <td>用户验收测试</td>
      </tr>
      <tr>
          <td>Beta</td>
          <td>Beta Test/公测环境</td>
          <td>内测/小部分用户</td>
          <td>可能访问脱敏的生产数据</td>
          <td>★★★★</td>
          <td>中等</td>
          <td>内测、公测、用户灰度</td>
      </tr>
      <tr>
          <td>Pre/Staging</td>
          <td>Pre-Production/Staging/预发布</td>
          <td>内部核心用户</td>
          <td>镜像生产，数据通常脱敏</td>
          <td>★★★★★</td>
          <td>较低</td>
          <td>回归测试、演练、上线前验证</td>
      </tr>
      <tr>
          <td>Prod</td>
          <td>Production/生产环境</td>
          <td>所有真实用户</td>
          <td><strong>真实生产数据库</strong></td>
          <td>★★★★★★</td>
          <td>严格管控</td>
          <td>对外正式服务</td>
      </tr>
  </tbody>
</table>
<hr>
<h2 id="2-各环境详解">2. 各环境详解</h2>
<h3 id="21-dev-环境开发环境">2.1 Dev 环境（开发环境）</h3>
<ul>
<li><strong>定位</strong>：供开发人员本地或共享环境进行日常开发。</li>
<li><strong>数据库</strong>：独立的开发库，数据无敏感性，可频繁清空或重置。</li>
<li><strong>风险</strong>：最低，允许频繁改动和试验。</li>
<li><strong>权限</strong>：开发全权限，无需严格控制。</li>
</ul>
<hr>
<h3 id="22-sit-环境系统集成测试环境">2.2 SIT 环境（系统集成测试环境）</h3>
<ul>
<li><strong>定位</strong>：主要用于多模块联调和系统集成测试。</li>
<li><strong>数据库</strong>：独立测试数据库，通常含有伪造或部分真实脱敏数据。</li>
<li><strong>风险</strong>：低，但需保证数据结构与生产一致。</li>
<li><strong>权限</strong>：开发可维护，测试可读写。</li>
</ul>
<hr>
<h3 id="23-uat-环境用户验收测试环境">2.3 UAT 环境（用户验收测试环境）</h3>
<ul>
<li><strong>定位</strong>：由业务方或测试人员进行验收。</li>
<li><strong>数据库</strong>：独立数据库，数据结构接近生产，可使用部分脱敏真实数据。</li>
<li><strong>风险</strong>：中等，需保证与生产版本一致。</li>
<li><strong>权限</strong>：测试和业务方只读/有限写权限，运维负责管理。</li>
</ul>
<hr>
<h3 id="24-beta-环境灰度--公测环境">2.4 Beta 环境（灰度 / 公测环境）</h3>
<ul>
<li><strong>定位</strong>：对部分用户开放，验证真实用户行为。</li>
<li><strong>数据库</strong>：
<ul>
<li>一般使用<strong>独立库 + 脱敏生产数据</strong></li>
<li>或者<strong>直连生产库</strong>（风险大，需严格控制）</li>
</ul>
</li>
<li><strong>风险</strong>：较高，用户数据可能涉及隐私。</li>
<li><strong>权限</strong>：运维严格管控，开发只读。</li>
</ul>
<hr>
<h3 id="25-pre-prodstaging-环境预发布环境">2.5 Pre-Prod/Staging 环境（预发布环境）</h3>
<ul>
<li><strong>定位</strong>：生产前的最终验证环境。</li>
<li><strong>数据库</strong>：与生产<strong>完全一致的结构</strong>，但一般使用<strong>脱敏数据</strong>，部分企业采用生产影子库。</li>
<li><strong>风险</strong>：接近生产，需严格保护。</li>
<li><strong>权限</strong>：只允许少数人有写权限，尽量模拟真实场景。</li>
</ul>
<hr>
<h3 id="26-prod-环境生产环境">2.6 Prod 环境（生产环境）</h3>
<ul>
<li><strong>定位</strong>：对外提供服务的正式环境。</li>
<li><strong>数据库</strong>：<strong>真实生产数据库</strong>。</li>
<li><strong>风险</strong>：最高，影响直接面向真实用户。</li>
<li><strong>权限</strong>：运维极少数人可写，开发通常无写权限。</li>
</ul>
<hr>
<h2 id="3-环境风险等级">3. 环境风险等级</h2>
<p>Dev (★) &lt; SIT (★★) &lt; UAT (★★★) &lt; Beta (★★★★) &lt; Pre-Prod (★★★★★) &lt; Prod (★★★★★★)</p>]]></description>
</item>
</channel>
</rss>
