<?xml version="1.0" encoding="utf-8"?><?xml-stylesheet type="text/xsl" href="https://blog.checo.cc/atom.xsl"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="zh-CN">
  <id>https://blog.checo.cc/</id>
  <title>Checo的博客</title>
  <subtitle>Checo的博客</subtitle>
  <updated>2026-06-06T16:13:01.224Z</updated>
  <generator>@vuepress/plugin-feed</generator>
  <link rel="self" href="https://blog.checo.cc/atom.xml"/>
  <link rel="alternate" href="https://blog.checo.cc/"/>
  <category term="运维"/>
  <category term="数据库"/>
  <category term="AWS"/>
  <category term="Windows"/>
  <category term="安全"/>
  <category term="Linux"/>
  <category term="macOS"/>
  <category term="硬件"/>
  <category term="工具"/>
  <category term="摄影"/>
  <category term="VPS"/>
  <category term="首页"/>
  <category term="AI"/>
  <category term="博客"/>
  <category term="白嫖"/>
  <entry>
    <title type="text">1Panel 服务器 Docker 与 new-api 迁移 MySQL 全记录</title>
    <id>https://blog.checo.cc/posts/DevOps/1.html</id>
    <link href="https://blog.checo.cc/posts/DevOps/1.html"/>
    <updated>2026-06-06T15:23:57.000Z</updated>
    <summary type="html"><![CDATA[
<p>这次迁移主要做了两件事：先修复 Debian 12 上 Docker 端口映射失败的问题，再把 new-api 从 SQLite 迁移到 MySQL。过程里踩到的坑不少，尤其是 iptables/nftables 兼容性和 SQLite 到 MySQL 的语法差异。</p>
]]></summary>
    <content type="html"><![CDATA[
<p>这次迁移主要做了两件事：先修复 Debian 12 上 Docker 端口映射失败的问题，再把 new-api 从 SQLite 迁移到 MySQL。过程里踩到的坑不少，尤其是 iptables/nftables 兼容性和 SQLite 到 MySQL 的语法差异。</p>
<!-- more -->
<h2>背景</h2>
<p>new-api 原本运行在 Docker 中，默认使用 SQLite 数据库。随着日志、用户和渠道数据越来越多，SQLite 数据库体积已经接近 200MB，继续放在容器数据卷里不太适合长期维护。</p>
<p>我的目标是：</p>
<ul>
<li>在 1Panel 管理的服务器上启动 MySQL 容器</li>
<li>把 new-api 的 SQLite 数据完整导入 MySQL</li>
<li>使用新容器先测试，再切换反向代理流量</li>
<li>尽量不影响线上服务</li>
</ul>
<p>生产迁移里最重要的一点是：不要直接停旧服务。先把新环境跑起来，确认没问题以后再切流量。</p>
<h2>iptables 与 Docker 端口映射问题</h2>
<h3>报错现象</h3>
<p>在 1Panel 安装 MySQL 容器时，容器可以创建成功，但启动阶段失败，错误类似：</p>
<div class="language-bash line-numbers-mode" data-highlighter="shiki" data-ext="bash" style="--shiki-light:#383A42;--shiki-dark:#abb2bf;--shiki-light-bg:#FAFAFA;--shiki-dark-bg:#282c34"><pre class="shiki shiki-themes one-light one-dark-pro vp-code"><code class="language-bash"><span class="line"><span style="--shiki-light:#4078F2;--shiki-dark:#61AFEF">iptables:</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379"> No</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379"> chain/target/match</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379"> by</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379"> that</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379"> name.</span></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div></div></div><p>进一步看 Docker 相关日志，可以看到 nftables 后端不兼容的问题：</p>
<div class="language-bash line-numbers-mode" data-highlighter="shiki" data-ext="bash" style="--shiki-light:#383A42;--shiki-dark:#abb2bf;--shiki-light-bg:#FAFAFA;--shiki-dark-bg:#282c34"><pre class="shiki shiki-themes one-light one-dark-pro vp-code"><code class="language-bash"><span class="line"><span style="--shiki-light:#4078F2;--shiki-dark:#61AFEF">iptables</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379"> v1.8.9</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF"> (nf_tables): chain </span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379">`</span><span style="--shiki-light:#4078F2;--shiki-dark:#61AFEF">DOCKER' in table `filter'</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379"> is incompatible, use 'nft' tool.</span></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div></div></div><h3>根因</h3>
<p>Debian 12 bookworm 默认使用 <code>iptables-nft</code>，也就是 nftables 后端。Docker 需要维护自己的 <code>DOCKER</code> 链做端口映射，但当前环境下 filter 表里的链状态和 nft 后端不兼容。</p>
<p>这个问题有个容易误判的地方：已有容器的端口映射可能仍然正常，因为 NAT 表没有立即受影响；真正失败的是新建容器或新增端口映射。</p>
<h3>修复方式</h3>
<p>先备份当前 iptables 规则：</p>
<div class="language-bash line-numbers-mode" data-highlighter="shiki" data-ext="bash" style="--shiki-light:#383A42;--shiki-dark:#abb2bf;--shiki-light-bg:#FAFAFA;--shiki-dark-bg:#282c34"><pre class="shiki shiki-themes one-light one-dark-pro vp-code"><code class="language-bash"><span class="line"><span style="--shiki-light:#4078F2;--shiki-dark:#61AFEF">mkdir</span><span style="--shiki-light:#986801;--shiki-dark:#D19A66"> -p</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379"> /root/backup-iptables-</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF">$(</span><span style="--shiki-light:#4078F2;--shiki-dark:#61AFEF">date</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379"> +%Y%m%d</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF">)</span></span>
<span class="line"><span style="--shiki-light:#4078F2;--shiki-dark:#61AFEF">iptables-save</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF"> > </span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379">/root/backup-iptables-</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF">$(</span><span style="--shiki-light:#4078F2;--shiki-dark:#61AFEF">date</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379"> +%Y%m%d</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF">)</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379">/iptables-all.txt</span></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div><div class="line-number"></div></div></div><p>然后把 iptables 和 ip6tables 切换到 legacy 模式：</p>
<div class="language-bash line-numbers-mode" data-highlighter="shiki" data-ext="bash" style="--shiki-light:#383A42;--shiki-dark:#abb2bf;--shiki-light-bg:#FAFAFA;--shiki-dark-bg:#282c34"><pre class="shiki shiki-themes one-light one-dark-pro vp-code"><code class="language-bash"><span class="line"><span style="--shiki-light:#4078F2;--shiki-dark:#61AFEF">update-alternatives</span><span style="--shiki-light:#986801;--shiki-dark:#D19A66"> --set</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379"> iptables</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379"> /usr/sbin/iptables-legacy</span></span>
<span class="line"><span style="--shiki-light:#4078F2;--shiki-dark:#61AFEF">update-alternatives</span><span style="--shiki-light:#986801;--shiki-dark:#D19A66"> --set</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379"> ip6tables</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379"> /usr/sbin/ip6tables-legacy</span></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div><div class="line-number"></div></div></div><p>最后重启 Docker：</p>
<div class="language-bash line-numbers-mode" data-highlighter="shiki" data-ext="bash" style="--shiki-light:#383A42;--shiki-dark:#abb2bf;--shiki-light-bg:#FAFAFA;--shiki-dark-bg:#282c34"><pre class="shiki shiki-themes one-light one-dark-pro vp-code"><code class="language-bash"><span class="line"><span style="--shiki-light:#4078F2;--shiki-dark:#61AFEF">systemctl</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379"> restart</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379"> docker</span></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div></div></div><p>如果容器设置了 <code>restart: always</code> 或 <code>unless-stopped</code>，Docker 重启后容器会自动恢复。使用 host 网络模式的容器，例如 openresty，一般不受这个端口映射问题影响。</p>
<h2>SQLite 到 MySQL 的迁移难点</h2>
<p>new-api 使用 GORM，首次连接 MySQL 时可以自动建表，但这不等于会自动迁移 SQLite 数据。真实迁移还需要把 SQLite dump 转成 MySQL 可导入的 SQL。</p>
<p>直接转换会遇到几类问题：</p>
<ol>
<li>SQLite 允许 <code>TEXT</code> 字段参与主键或索引，MySQL 会报 <code>ERROR 1170</code>。</li>
<li>SQLite 支持部分索引，例如 <code>WHERE deleted_at IS NULL</code>，MySQL 不能直接照搬。</li>
<li>SQLite 的 BLOB 字节串可能写成 <code>X'...'</code>，MySQL 的 JSON 列无法直接接受。</li>
<li>MySQL 不允许 <code>TEXT</code> 或 <code>BLOB</code> 字段设置默认值。</li>
<li>SQLite 默认大小写敏感，MySQL 默认排序规则通常大小写不敏感，唯一键可能产生冲突。</li>
</ol>
<p>所以这一步不能只靠简单的搜索替换，更适合写转换脚本处理结构和数据。</p>
<h2>转换脚本处理策略</h2>
<p>我最后使用脚本生成了一份 MySQL 可导入 SQL，主要做了这些处理：</p>
<ul>
<li>索引、主键、唯一键涉及的 <code>TEXT</code> 字段改成 <code>VARCHAR(191)</code></li>
<li>非索引大文本字段改成 <code>LONGTEXT</code></li>
<li>SQLite 部分索引转换为 MySQL 可接受的表达式索引</li>
<li>BLOB JSON 字节串转换为 UTF-8 JSON 字符串</li>
<li>带时区的 SQLite 时间转换为 MySQL <code>DATETIME(6)</code> 字面量</li>
<li>全部使用 <code>utf8mb4_bin</code> 排序规则，尽量保持 SQLite 的大小写敏感行为</li>
</ul>
<p>迁移时不要把真实数据库密码、root 密码和 DSN 明文写进公开文章或仓库。下面命令里的敏感字段都用占位符代替。</p>
<h2>蓝绿部署流程</h2>
<p>整体流程是先导入数据，再启动新容器测试，最后切换反向代理。</p>
<h3>1. 导入 MySQL 数据</h3>
<p>先创建目标数据库和用户，并授予权限：</p>
<div class="language-sql line-numbers-mode" data-highlighter="shiki" data-ext="sql" style="--shiki-light:#383A42;--shiki-dark:#abb2bf;--shiki-light-bg:#FAFAFA;--shiki-dark-bg:#282c34"><pre class="shiki shiki-themes one-light one-dark-pro vp-code"><code class="language-sql"><span class="line"><span style="--shiki-light:#A626A4;--shiki-dark:#C678DD">CREATE</span><span style="--shiki-light:#A626A4;--shiki-dark:#C678DD"> DATABASE</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379"> `one-api`</span><span style="--shiki-light:#A626A4;--shiki-dark:#C678DD"> CHARACTER</span><span style="--shiki-light:#A626A4;--shiki-dark:#C678DD"> SET</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF"> utf8mb4 </span><span style="--shiki-light:#A626A4;--shiki-dark:#C678DD">COLLATE</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF"> utf8mb4_bin;</span></span>
<span class="line"><span style="--shiki-light:#A626A4;--shiki-dark:#C678DD">CREATE</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF"> USER </span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379">'one-api'</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF">@</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379">'%'</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF"> IDENTIFIED </span><span style="--shiki-light:#A626A4;--shiki-dark:#C678DD">BY</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379"> '&#x3C;mysql-user-password>'</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF">;</span></span>
<span class="line"><span style="--shiki-light:#A626A4;--shiki-dark:#C678DD">GRANT</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF"> ALL PRIVILEGES </span><span style="--shiki-light:#A626A4;--shiki-dark:#C678DD">ON</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379"> `one-api`</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF">.* </span><span style="--shiki-light:#A626A4;--shiki-dark:#C678DD">TO</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379"> 'one-api'</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF">@</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379">'%'</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF">;</span></span>
<span class="line"><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF">FLUSH PRIVILEGES;</span></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p>然后导入转换后的 SQL：</p>
<div class="language-bash line-numbers-mode" data-highlighter="shiki" data-ext="bash" style="--shiki-light:#383A42;--shiki-dark:#abb2bf;--shiki-light-bg:#FAFAFA;--shiki-dark-bg:#282c34"><pre class="shiki shiki-themes one-light one-dark-pro vp-code"><code class="language-bash"><span class="line"><span style="--shiki-light:#4078F2;--shiki-dark:#61AFEF">mysql</span><span style="--shiki-light:#986801;--shiki-dark:#D19A66"> -u</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379"> one-api</span><span style="--shiki-light:#986801;--shiki-dark:#D19A66"> -p</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379"> one-api</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF"> &#x3C; </span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379">/root/one-api-mysql-importable.sql</span></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div></div></div><p>如果已经让 new-api 连接过空 MySQL，GORM 可能已经插入默认数据。这种情况下需要先清空默认数据，避免导入时出现主键或唯一键冲突。</p>
<h3>2. 启动 MySQL 版 new-api 容器</h3>
<p>新容器先监听 <code>3001</code>，旧容器继续监听 <code>3000</code>：</p>
<div class="language-bash line-numbers-mode" data-highlighter="shiki" data-ext="bash" style="--shiki-light:#383A42;--shiki-dark:#abb2bf;--shiki-light-bg:#FAFAFA;--shiki-dark-bg:#282c34"><pre class="shiki shiki-themes one-light one-dark-pro vp-code"><code class="language-bash"><span class="line"><span style="--shiki-light:#4078F2;--shiki-dark:#61AFEF">docker</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379"> run</span><span style="--shiki-light:#986801;--shiki-dark:#D19A66"> -d</span><span style="--shiki-light:#986801;--shiki-dark:#D19A66"> --name</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379"> new-api-mysql</span><span style="--shiki-light:#0184BC;--shiki-dark:#56B6C2"> \</span></span>
<span class="line"><span style="--shiki-light:#986801;--shiki-dark:#D19A66">  --network</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379"> 1panel-network</span><span style="--shiki-light:#0184BC;--shiki-dark:#56B6C2"> \</span></span>
<span class="line"><span style="--shiki-light:#986801;--shiki-dark:#D19A66">  --restart</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379"> unless-stopped</span><span style="--shiki-light:#0184BC;--shiki-dark:#56B6C2"> \</span></span>
<span class="line"><span style="--shiki-light:#986801;--shiki-dark:#D19A66">  -p</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379"> 3001:3000</span><span style="--shiki-light:#0184BC;--shiki-dark:#56B6C2"> \</span></span>
<span class="line"><span style="--shiki-light:#986801;--shiki-dark:#D19A66">  -e</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379"> SQL_DSN="one-api:&#x3C;mysql-user-password>@tcp(&#x3C;mysql-host>:3306)/one-api?charset=utf8mb4&#x26;parseTime=True&#x26;loc=Local"</span><span style="--shiki-light:#0184BC;--shiki-dark:#56B6C2"> \</span></span>
<span class="line"><span style="--shiki-light:#986801;--shiki-dark:#D19A66">  -e</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379"> TZ=Asia/Shanghai</span><span style="--shiki-light:#0184BC;--shiki-dark:#56B6C2"> \</span></span>
<span class="line"><span style="--shiki-light:#986801;--shiki-dark:#D19A66">  -e</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379"> ERROR_LOG_ENABLED=</span><span style="--shiki-light:#986801;--shiki-dark:#D19A66">true</span><span style="--shiki-light:#0184BC;--shiki-dark:#56B6C2"> \</span></span>
<span class="line"><span style="--shiki-light:#986801;--shiki-dark:#D19A66">  -e</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379"> BATCH_UPDATE_ENABLED=</span><span style="--shiki-light:#986801;--shiki-dark:#D19A66">true</span><span style="--shiki-light:#0184BC;--shiki-dark:#56B6C2"> \</span></span>
<span class="line"><span style="--shiki-light:#986801;--shiki-dark:#D19A66">  -v</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379"> /home/ubuntu/data/new-api-mysql:/app/data</span><span style="--shiki-light:#0184BC;--shiki-dark:#56B6C2"> \</span></span>
<span class="line"><span style="--shiki-light:#50A14F;--shiki-dark:#98C379">  calciumion/new-api:latest</span><span style="--shiki-light:#986801;--shiki-dark:#D19A66"> --log-dir</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379"> /app/logs</span></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p>这里要注意两点：</p>
<ul>
<li>new-api 容器必须加入能访问 MySQL 的 Docker 网络</li>
<li><code>SQL_DSN</code> 里建议带上 <code>charset=utf8mb4&amp;parseTime=True&amp;loc=Local</code></li>
</ul>
<h3>3. 测试新容器</h3>
<p>先用接口确认服务状态：</p>
<div class="language-bash line-numbers-mode" data-highlighter="shiki" data-ext="bash" style="--shiki-light:#383A42;--shiki-dark:#abb2bf;--shiki-light-bg:#FAFAFA;--shiki-dark-bg:#282c34"><pre class="shiki shiki-themes one-light one-dark-pro vp-code"><code class="language-bash"><span class="line"><span style="--shiki-light:#4078F2;--shiki-dark:#61AFEF">curl</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379"> http://localhost:3001/api/status</span></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div></div></div><p>正常情况下会返回 <code>success: true</code>。然后再检查用户、渠道、配置项、日志等核心表的数据量是否和 SQLite 对得上。</p>
<p>我这次迁移后的数据量大致如下：</p>
<p>| 表 | 行数 |<br>
|</p>
]]></content>
    <category term="运维"/>
    <category term="数据库"/>
    <published>2026-06-03T00:00:00.000Z</published>
  </entry>
  <entry>
    <title type="text">Docker iptables 与 nftables 兼容性问题排查</title>
    <id>https://blog.checo.cc/posts/DevOps/2.html</id>
    <link href="https://blog.checo.cc/posts/DevOps/2.html"/>
    <updated>2026-06-04T13:54:51.000Z</updated>
    <summary type="html"><![CDATA[
<p>在 Debian 12 服务器上用 1Panel 安装 Docker 应用时，遇到过一个很典型的问题：容器可以创建成功，但启动时端口映射失败。表面看是 Docker 报错，实际原因是 iptables 后端和 Docker 链不兼容。</p>
]]></summary>
    <content type="html"><![CDATA[
<p>在 Debian 12 服务器上用 1Panel 安装 Docker 应用时，遇到过一个很典型的问题：容器可以创建成功，但启动时端口映射失败。表面看是 Docker 报错，实际原因是 iptables 后端和 Docker 链不兼容。</p>
<!-- more -->
<h2>症状</h2>
<p>Docker 容器创建完成后，启动阶段报错：</p>
<div class="language-bash line-numbers-mode" data-highlighter="shiki" data-ext="bash" style="--shiki-light:#383A42;--shiki-dark:#abb2bf;--shiki-light-bg:#FAFAFA;--shiki-dark-bg:#282c34"><pre class="shiki shiki-themes one-light one-dark-pro vp-code"><code class="language-bash"><span class="line"><span style="--shiki-light:#4078F2;--shiki-dark:#61AFEF">Error</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379"> response</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379"> from</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379"> daemon:</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379"> failed</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379"> to</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379"> set</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379"> up</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379"> container</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379"> networking:</span></span>
<span class="line"><span style="--shiki-light:#4078F2;--shiki-dark:#61AFEF">driver</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379"> failed</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379"> programming</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379"> external</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379"> connectivity</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379"> on</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379"> endpoint</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379"> ...</span></span>
<span class="line"><span style="--shiki-light:#4078F2;--shiki-dark:#61AFEF">Unable</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379"> to</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379"> enable</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379"> OPEN</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379"> PORT</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379"> rule:</span></span>
<span class="line"><span style="--shiki-light:#4078F2;--shiki-dark:#61AFEF">iptables:</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379"> No</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379"> chain/target/match</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379"> by</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379"> that</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379"> name.</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF"> (exit </span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379">status</span><span style="--shiki-light:#986801;--shiki-dark:#D19A66"> 1</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF">)</span></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p>这个报错容易误导人。容器本身不是不能创建，而是在 <code>Starting</code> 阶段设置端口映射失败。</p>
<h2>根因</h2>
<p>Debian 12 bookworm 默认使用 <code>iptables-nft</code>，也就是 nftables 后端。Docker 会在 iptables 里维护自己的 <code>DOCKER</code> 链，用于 bridge 网络和端口映射。</p>
<p>当 filter 表中的 <code>DOCKER</code> 链与 nft 后端状态不兼容时，就会出现类似错误：</p>
<div class="language-bash line-numbers-mode" data-highlighter="shiki" data-ext="bash" style="--shiki-light:#383A42;--shiki-dark:#abb2bf;--shiki-light-bg:#FAFAFA;--shiki-dark-bg:#282c34"><pre class="shiki shiki-themes one-light one-dark-pro vp-code"><code class="language-bash"><span class="line"><span style="--shiki-light:#4078F2;--shiki-dark:#61AFEF">iptables</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379"> v1.8.9</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF"> (nf_tables): chain </span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379">`</span><span style="--shiki-light:#4078F2;--shiki-dark:#61AFEF">DOCKER' in table `filter'</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379"> is incompatible, use 'nft' tool.</span></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div></div></div><p>一个关键细节是：NAT 表里的 <code>DOCKER</code> 链可能还是正常的，所以已有端口映射不一定会立刻坏。真正受影响的是新建容器或新增端口映射。</p>
<h2>快速诊断</h2>
<p>先看当前 iptables 使用的后端：</p>
<div class="language-bash line-numbers-mode" data-highlighter="shiki" data-ext="bash" style="--shiki-light:#383A42;--shiki-dark:#abb2bf;--shiki-light-bg:#FAFAFA;--shiki-dark-bg:#282c34"><pre class="shiki shiki-themes one-light one-dark-pro vp-code"><code class="language-bash"><span class="line"><span style="--shiki-light:#4078F2;--shiki-dark:#61AFEF">update-alternatives</span><span style="--shiki-light:#986801;--shiki-dark:#D19A66"> --query</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379"> iptables</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF"> | </span><span style="--shiki-light:#4078F2;--shiki-dark:#61AFEF">grep</span><span style="--shiki-light:#986801;--shiki-dark:#D19A66"> -E</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379"> 'Status|Value'</span></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div></div></div><p>再检查 filter 表里的 Docker 链：</p>
<div class="language-bash line-numbers-mode" data-highlighter="shiki" data-ext="bash" style="--shiki-light:#383A42;--shiki-dark:#abb2bf;--shiki-light-bg:#FAFAFA;--shiki-dark-bg:#282c34"><pre class="shiki shiki-themes one-light one-dark-pro vp-code"><code class="language-bash"><span class="line"><span style="--shiki-light:#4078F2;--shiki-dark:#61AFEF">iptables</span><span style="--shiki-light:#986801;--shiki-dark:#D19A66"> -L</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379"> DOCKER</span><span style="--shiki-light:#986801;--shiki-dark:#D19A66"> -n</span></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div></div></div><p>如果这里出现 <code>incompatible</code> 或链不存在，再看 NAT 表状态：</p>
<div class="language-bash line-numbers-mode" data-highlighter="shiki" data-ext="bash" style="--shiki-light:#383A42;--shiki-dark:#abb2bf;--shiki-light-bg:#FAFAFA;--shiki-dark-bg:#282c34"><pre class="shiki shiki-themes one-light one-dark-pro vp-code"><code class="language-bash"><span class="line"><span style="--shiki-light:#4078F2;--shiki-dark:#61AFEF">iptables</span><span style="--shiki-light:#986801;--shiki-dark:#D19A66"> -t</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379"> nat</span><span style="--shiki-light:#986801;--shiki-dark:#D19A66"> -L</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379"> DOCKER</span><span style="--shiki-light:#986801;--shiki-dark:#D19A66"> -n</span></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div></div></div><p>最后确认当前容器和端口映射：</p>
<div class="language-bash line-numbers-mode" data-highlighter="shiki" data-ext="bash" style="--shiki-light:#383A42;--shiki-dark:#abb2bf;--shiki-light-bg:#FAFAFA;--shiki-dark-bg:#282c34"><pre class="shiki shiki-themes one-light one-dark-pro vp-code"><code class="language-bash"><span class="line"><span style="--shiki-light:#4078F2;--shiki-dark:#61AFEF">docker</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379"> ps</span><span style="--shiki-light:#986801;--shiki-dark:#D19A66"> --format</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379"> 'table {{.Names}}\t{{.Status}}\t{{.Ports}}'</span></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div></div></div><p>如果已有容器还在正常运行，但新容器起不来，基本就可以锁定在 Docker 端口映射和 iptables 后端兼容性上。</p>
<h2>修复步骤</h2>
<h3>1. 备份现有规则</h3>
<p>修网络规则前先备份，后面出问题才有回滚依据：</p>
<div class="language-bash line-numbers-mode" data-highlighter="shiki" data-ext="bash" style="--shiki-light:#383A42;--shiki-dark:#abb2bf;--shiki-light-bg:#FAFAFA;--shiki-dark-bg:#282c34"><pre class="shiki shiki-themes one-light one-dark-pro vp-code"><code class="language-bash"><span class="line"><span style="--shiki-light:#4078F2;--shiki-dark:#61AFEF">mkdir</span><span style="--shiki-light:#986801;--shiki-dark:#D19A66"> -p</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379"> /root/backup-iptables-</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF">$(</span><span style="--shiki-light:#4078F2;--shiki-dark:#61AFEF">date</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379"> +%Y%m%d</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF">)</span></span>
<span class="line"><span style="--shiki-light:#4078F2;--shiki-dark:#61AFEF">iptables-save</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF"> > </span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379">/root/backup-iptables-</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF">$(</span><span style="--shiki-light:#4078F2;--shiki-dark:#61AFEF">date</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379"> +%Y%m%d</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF">)</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379">/iptables-all.txt</span></span>
<span class="line"><span style="--shiki-light:#4078F2;--shiki-dark:#61AFEF">iptables-save</span><span style="--shiki-light:#986801;--shiki-dark:#D19A66"> -t</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379"> nat</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF"> > </span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379">/root/backup-iptables-</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF">$(</span><span style="--shiki-light:#4078F2;--shiki-dark:#61AFEF">date</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379"> +%Y%m%d</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF">)</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379">/iptables-nat.txt</span></span>
<span class="line"><span style="--shiki-light:#4078F2;--shiki-dark:#61AFEF">docker</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379"> ps</span><span style="--shiki-light:#986801;--shiki-dark:#D19A66"> --format</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379"> '{{.Names}} {{.Image}} {{.Status}}'</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF"> > </span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379">/root/backup-iptables-</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF">$(</span><span style="--shiki-light:#4078F2;--shiki-dark:#61AFEF">date</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379"> +%Y%m%d</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF">)</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379">/containers.txt</span></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h3>2. 切换到 legacy 模式</h3>
<p>把 IPv4 和 IPv6 的 iptables 都切到 legacy：</p>
<div class="language-bash line-numbers-mode" data-highlighter="shiki" data-ext="bash" style="--shiki-light:#383A42;--shiki-dark:#abb2bf;--shiki-light-bg:#FAFAFA;--shiki-dark-bg:#282c34"><pre class="shiki shiki-themes one-light one-dark-pro vp-code"><code class="language-bash"><span class="line"><span style="--shiki-light:#4078F2;--shiki-dark:#61AFEF">update-alternatives</span><span style="--shiki-light:#986801;--shiki-dark:#D19A66"> --set</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379"> iptables</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379"> /usr/sbin/iptables-legacy</span></span>
<span class="line"><span style="--shiki-light:#4078F2;--shiki-dark:#61AFEF">update-alternatives</span><span style="--shiki-light:#986801;--shiki-dark:#D19A66"> --set</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379"> ip6tables</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379"> /usr/sbin/ip6tables-legacy</span></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div><div class="line-number"></div></div></div><h3>3. 重启 Docker</h3>
<div class="language-bash line-numbers-mode" data-highlighter="shiki" data-ext="bash" style="--shiki-light:#383A42;--shiki-dark:#abb2bf;--shiki-light-bg:#FAFAFA;--shiki-dark-bg:#282c34"><pre class="shiki shiki-themes one-light one-dark-pro vp-code"><code class="language-bash"><span class="line"><span style="--shiki-light:#4078F2;--shiki-dark:#61AFEF">systemctl</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379"> restart</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379"> docker</span></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div></div></div><p>如果容器配置了 <code>restart: always</code> 或 <code>unless-stopped</code>，Docker 重启后会自动拉起。</p>
<h3>4. 验证</h3>
<p>检查 <code>DOCKER</code> 链是否能正常显示：</p>
<div class="language-bash line-numbers-mode" data-highlighter="shiki" data-ext="bash" style="--shiki-light:#383A42;--shiki-dark:#abb2bf;--shiki-light-bg:#FAFAFA;--shiki-dark-bg:#282c34"><pre class="shiki shiki-themes one-light one-dark-pro vp-code"><code class="language-bash"><span class="line"><span style="--shiki-light:#4078F2;--shiki-dark:#61AFEF">iptables</span><span style="--shiki-light:#986801;--shiki-dark:#D19A66"> -L</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379"> DOCKER</span><span style="--shiki-light:#986801;--shiki-dark:#D19A66"> -n</span></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div></div></div><p>确认容器状态：</p>
<div class="language-bash line-numbers-mode" data-highlighter="shiki" data-ext="bash" style="--shiki-light:#383A42;--shiki-dark:#abb2bf;--shiki-light-bg:#FAFAFA;--shiki-dark-bg:#282c34"><pre class="shiki shiki-themes one-light one-dark-pro vp-code"><code class="language-bash"><span class="line"><span style="--shiki-light:#4078F2;--shiki-dark:#61AFEF">docker</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379"> ps</span></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div></div></div><p>检查关键端口是否监听：</p>
<div class="language-bash line-numbers-mode" data-highlighter="shiki" data-ext="bash" style="--shiki-light:#383A42;--shiki-dark:#abb2bf;--shiki-light-bg:#FAFAFA;--shiki-dark-bg:#282c34"><pre class="shiki shiki-themes one-light one-dark-pro vp-code"><code class="language-bash"><span class="line"><span style="--shiki-light:#4078F2;--shiki-dark:#61AFEF">ss</span><span style="--shiki-light:#986801;--shiki-dark:#D19A66"> -tlnp</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF"> | </span><span style="--shiki-light:#4078F2;--shiki-dark:#61AFEF">grep</span><span style="--shiki-light:#986801;--shiki-dark:#D19A66"> -E</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379"> ':80 |:443 |:3000 '</span></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div></div></div><p>如果是 1Panel 里安装失败的应用，这时重新安装或重新启动应用，一般就可以恢复。</p>
<h2>注意事项</h2>
<ul>
<li>host 网络模式的容器通常不受这个问题影响，例如 openresty 直接监听宿主机端口。</li>
<li>bridge 网络模式的容器依赖 iptables 做端口映射，MySQL、new-api 这类容器会受影响。</li>
<li>修复前确认重要容器有 restart policy，避免重启 Docker 后服务没有自动恢复。</li>
<li>如果系统启用了 firewalld，可能还要检查它是否改写了规则。</li>
<li>生产环境不要直接清空 iptables 规则，先备份再操作。</li>
</ul>
<h2>环境记录</h2>
<p>这次遇到问题的环境大致如下：</p>
<p>| 项目 | 值 |<br>
|</p>
]]></content>
    <category term="运维"/>
    <published>2026-06-03T00:00:00.000Z</published>
  </entry>
  <entry>
    <title type="text">SSM Patch Manager 扫描 Windows 补丁失败：微软更新服务 503</title>
    <id>https://blog.checo.cc/posts/AWS/10.html</id>
    <link href="https://blog.checo.cc/posts/AWS/10.html"/>
    <updated>2026-06-06T15:23:57.000Z</updated>
    <summary type="html"><![CDATA[
<p>使用 Systems Manager Patch Manager 扫描 Windows Server 2019 补丁时，如果 SSM Agent、网络和权限都正常，但 WindowsUpdate.log 里显示微软更新服务返回 503，根因可能在微软侧，而不是 AWS 侧。</p>
]]></summary>
    <content type="html"><![CDATA[
<p>使用 Systems Manager Patch Manager 扫描 Windows Server 2019 补丁时，如果 SSM Agent、网络和权限都正常，但 WindowsUpdate.log 里显示微软更新服务返回 503，根因可能在微软侧，而不是 AWS 侧。</p>
<!-- more -->
<h2>现象</h2>
<p>执行 <code>AWS-RunPatchBaseline</code> 扫描失败，返回类似：</p>
<div class="language-text line-numbers-mode" data-highlighter="shiki" data-ext="text" style="--shiki-light:#383A42;--shiki-dark:#abb2bf;--shiki-light-bg:#FAFAFA;--shiki-dark-bg:#282c34"><pre class="shiki shiki-themes one-light one-dark-pro vp-code"><code class="language-text"><span class="line"><span>The find operation did not complete successfully</span></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div></div></div><p>HResult 可能是：</p>
<div class="language-text line-numbers-mode" data-highlighter="shiki" data-ext="text" style="--shiki-light:#383A42;--shiki-dark:#abb2bf;--shiki-light-bg:#FAFAFA;--shiki-dark-bg:#282c34"><pre class="shiki shiki-themes one-light one-dark-pro vp-code"><code class="language-text"><span class="line"><span>-2145107934</span></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div></div></div><p>同一网络环境下 Windows Server 2016 正常，Windows Server 2019 失败。</p>
<h2>排查过程</h2>
<h3>1. 验证 SSM 相关端点</h3>
<div class="language-powershell line-numbers-mode" data-highlighter="shiki" data-ext="powershell" style="--shiki-light:#383A42;--shiki-dark:#abb2bf;--shiki-light-bg:#FAFAFA;--shiki-dark-bg:#282c34"><pre class="shiki shiki-themes one-light one-dark-pro vp-code"><code class="language-powershell"><span class="line"><span style="--shiki-light:#0184BC;--shiki-dark:#56B6C2">Test-NetConnection</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF"> ssm.&#x3C;region>.</span><span style="--shiki-light:#0184BC;--shiki-dark:#56B6C2">amazonaws.com</span><span style="--shiki-light:#383A42;--shiki-dark:#56B6C2"> -</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF">Port </span><span style="--shiki-light:#986801;--shiki-dark:#D19A66">443</span></span>
<span class="line"><span style="--shiki-light:#0184BC;--shiki-dark:#56B6C2">Test-NetConnection</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF"> ssmmessages.&#x3C;region>.</span><span style="--shiki-light:#0184BC;--shiki-dark:#56B6C2">amazonaws.com</span><span style="--shiki-light:#383A42;--shiki-dark:#56B6C2"> -</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF">Port </span><span style="--shiki-light:#986801;--shiki-dark:#D19A66">443</span></span>
<span class="line"><span style="--shiki-light:#0184BC;--shiki-dark:#56B6C2">Test-NetConnection</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF"> ec2messages.&#x3C;region>.</span><span style="--shiki-light:#0184BC;--shiki-dark:#56B6C2">amazonaws.com</span><span style="--shiki-light:#383A42;--shiki-dark:#56B6C2"> -</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF">Port </span><span style="--shiki-light:#986801;--shiki-dark:#D19A66">443</span></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p>如果使用中国区或 VPC Endpoint，需要替换为对应域名。</p>
<h3>2. 验证 Windows Update 网络</h3>
<div class="language-powershell line-numbers-mode" data-highlighter="shiki" data-ext="powershell" style="--shiki-light:#383A42;--shiki-dark:#abb2bf;--shiki-light-bg:#FAFAFA;--shiki-dark-bg:#282c34"><pre class="shiki shiki-themes one-light one-dark-pro vp-code"><code class="language-powershell"><span class="line"><span style="--shiki-light:#0184BC;--shiki-dark:#56B6C2">Test-NetConnection</span><span style="--shiki-light:#0184BC;--shiki-dark:#56B6C2"> sls.update.microsoft.com</span><span style="--shiki-light:#383A42;--shiki-dark:#56B6C2"> -</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF">Port </span><span style="--shiki-light:#986801;--shiki-dark:#D19A66">443</span></span>
<span class="line"><span style="--shiki-light:#0184BC;--shiki-dark:#56B6C2">Test-NetConnection</span><span style="--shiki-light:#0184BC;--shiki-dark:#56B6C2"> download.windowsupdate.com</span><span style="--shiki-light:#383A42;--shiki-dark:#56B6C2"> -</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF">Port </span><span style="--shiki-light:#986801;--shiki-dark:#D19A66">80</span></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div><div class="line-number"></div></div></div><p>同时检查是否配置 WSUS：</p>
<div class="language-powershell line-numbers-mode" data-highlighter="shiki" data-ext="powershell" style="--shiki-light:#383A42;--shiki-dark:#abb2bf;--shiki-light-bg:#FAFAFA;--shiki-dark-bg:#282c34"><pre class="shiki shiki-themes one-light one-dark-pro vp-code"><code class="language-powershell"><span class="line"><span style="--shiki-light:#0184BC;--shiki-dark:#56B6C2">Get-ItemProperty</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379"> "HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate"</span><span style="--shiki-light:#383A42;--shiki-dark:#56B6C2"> -</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF">ErrorAction SilentlyContinue</span></span>
<span class="line"><span style="--shiki-light:#0184BC;--shiki-dark:#56B6C2">Get-ItemProperty</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379"> "HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU"</span><span style="--shiki-light:#383A42;--shiki-dark:#56B6C2"> -</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF">ErrorAction SilentlyContinue</span></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div><div class="line-number"></div></div></div><h3>3. 导出 Windows Update 日志</h3>
<div class="language-powershell line-numbers-mode" data-highlighter="shiki" data-ext="powershell" style="--shiki-light:#383A42;--shiki-dark:#abb2bf;--shiki-light-bg:#FAFAFA;--shiki-dark-bg:#282c34"><pre class="shiki shiki-themes one-light one-dark-pro vp-code"><code class="language-powershell"><span class="line"><span style="--shiki-light:#0184BC;--shiki-dark:#56B6C2">Get-WindowsUpdateLog</span></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div></div></div><p>如果日志出现：</p>
<div class="language-text line-numbers-mode" data-highlighter="shiki" data-ext="text" style="--shiki-light:#383A42;--shiki-dark:#abb2bf;--shiki-light-bg:#FAFAFA;--shiki-dark-bg:#282c34"><pre class="shiki shiki-themes one-light one-dark-pro vp-code"><code class="language-text"><span class="line"><span>The server returned HTTP status code '503'</span></span>
<span class="line"><span>The service is temporarily overloaded</span></span>
<span class="line"><span>*FAILED* [80244022] Web service call</span></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p>说明 Windows Update 客户端已经连到微软服务，但服务端返回不可用。</p>
<h2>根因</h2>
<p>Windows Server 2019 可能访问的是某个特定微软更新服务域名，例如：</p>
<div class="language-text line-numbers-mode" data-highlighter="shiki" data-ext="text" style="--shiki-light:#383A42;--shiki-dark:#abb2bf;--shiki-light-bg:#FAFAFA;--shiki-dark-bg:#282c34"><pre class="shiki shiki-themes one-light one-dark-pro vp-code"><code class="language-text"><span class="line"><span>fe3.delivery.mp.microsoft.com</span></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div></div></div><p>如果该服务端临时过载，就会返回 HTTP 503，对应错误码：</p>
<div class="language-text line-numbers-mode" data-highlighter="shiki" data-ext="text" style="--shiki-light:#383A42;--shiki-dark:#abb2bf;--shiki-light-bg:#FAFAFA;--shiki-dark-bg:#282c34"><pre class="shiki shiki-themes one-light one-dark-pro vp-code"><code class="language-text"><span class="line"><span>0x80244022</span></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div></div></div><p>同一时间 Windows Server 2016 正常，可能是因为它访问的是另一组更新服务域名，未受影响。</p>
<h2>规避方案</h2>
<h3>1. 等待微软服务恢复</h3>
<p>如果确认网络、SSM、WSUS 配置都正常，且错误明确是 503，最直接的方式是等待服务恢复后重试。</p>
<h3>2. 手动下载补丁</h3>
<p>从 Microsoft Update Catalog 下载 <code>.msu</code>，再通过脚本或 SSM Run Command 安装：</p>
<div class="language-text line-numbers-mode" data-highlighter="shiki" data-ext="text" style="--shiki-light:#383A42;--shiki-dark:#abb2bf;--shiki-light-bg:#FAFAFA;--shiki-dark-bg:#282c34"><pre class="shiki shiki-themes one-light one-dark-pro vp-code"><code class="language-text"><span class="line"><span>https://www.catalog.update.microsoft.com/</span></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div></div></div><h3>3. 提前缓存补丁</h3>
<p>Patch Manager 本身不提供“只下载不安装”的标准模式。可以使用自定义 SSM 文档提前下载补丁，在维护窗口再执行安装。</p>
<h3>4. 部署 WSUS</h3>
<p>对补丁窗口要求严格的环境，可以部署内网 WSUS，把补丁提前同步到本地服务器，降低对公网微软更新服务的依赖。</p>
<h2>总结</h2>
<p>SSM Patch Manager 扫描失败不一定是 SSM 问题。排查时要分层：</p>
<ol>
<li>SSM Agent 是否在线。</li>
<li>AWS 端点是否可达。</li>
<li>Windows Update 端点是否可达。</li>
<li>WindowsUpdate.log 是否显示微软服务端 503。</li>
</ol>
<p>如果日志已经明确 <code>0x80244022</code> 和 HTTP 503，通常应按微软更新服务临时不可用处理，考虑重试、手动补丁、提前缓存或 WSUS。</p>
]]></content>
    <category term="AWS"/>
    <category term="Windows"/>
    <published>2026-06-04T00:00:00.000Z</published>
  </entry>
  <entry>
    <title type="text">Windows Server 2016 安装补丁后反复回滚</title>
    <id>https://blog.checo.cc/posts/AWS/11.html</id>
    <link href="https://blog.checo.cc/posts/AWS/11.html"/>
    <updated>2026-06-04T13:54:51.000Z</updated>
    <summary type="html"><![CDATA[
<p>Windows Server 2016 安装累积更新后，如果重启阶段提示 “We couldn't complete the updates”，并反复回滚，根因不一定是磁盘空间或组件存储损坏，也可能是历史用户配置文件异常导致 per-user registry 阶段失败。</p>
]]></summary>
    <content type="html"><![CDATA[
<p>Windows Server 2016 安装累积更新后，如果重启阶段提示 “We couldn't complete the updates”，并反复回滚，根因不一定是磁盘空间或组件存储损坏，也可能是历史用户配置文件异常导致 per-user registry 阶段失败。</p>
<!-- more -->
<h2>现象</h2>
<p>补丁安装阶段看似成功，重启时出现：</p>
<div class="language-text line-numbers-mode" data-highlighter="shiki" data-ext="text" style="--shiki-light:#383A42;--shiki-dark:#abb2bf;--shiki-light-bg:#FAFAFA;--shiki-dark-bg:#282c34"><pre class="shiki shiki-themes one-light one-dark-pro vp-code"><code class="language-text"><span class="line"><span>We couldn't complete the updates</span></span>
<span class="line"><span>Undoing changes</span></span>
<span class="line"><span>Don't turn off your computer</span></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p>进入系统后发现 OS Build 没有提升，再次安装仍然重复回滚。</p>
<p>WindowsUpdate.log 可能出现：</p>
<div class="language-text line-numbers-mode" data-highlighter="shiki" data-ext="text" style="--shiki-light:#383A42;--shiki-dark:#abb2bf;--shiki-light-bg:#FAFAFA;--shiki-dark-bg:#282c34"><pre class="shiki shiki-themes one-light one-dark-pro vp-code"><code class="language-text"><span class="line"><span>Post-reboot status ... 0x800f0922</span></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div></div></div><p>CBS.log 中可见：</p>
<div class="language-text line-numbers-mode" data-highlighter="shiki" data-ext="text" style="--shiki-light:#383A42;--shiki-dark:#abb2bf;--shiki-light-bg:#FAFAFA;--shiki-dark-bg:#282c34"><pre class="shiki shiki-themes one-light one-dark-pro vp-code"><code class="language-text"><span class="line"><span>CBS_E_INSTALLERS_FAILED</span></span>
<span class="line"><span>Per-User Registry Installer ... 0x80070002</span></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div><div class="line-number"></div></div></div><p>CSI 日志里还能看到历史用户 <code>NTUSER.DAT</code> 卸载失败。</p>
<h2>排查思路</h2>
<p>先排除常规原因：</p>
<div class="language-powershell line-numbers-mode" data-highlighter="shiki" data-ext="powershell" style="--shiki-light:#383A42;--shiki-dark:#abb2bf;--shiki-light-bg:#FAFAFA;--shiki-dark-bg:#282c34"><pre class="shiki shiki-themes one-light one-dark-pro vp-code"><code class="language-powershell"><span class="line"><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF">sfc </span><span style="--shiki-light:#383A42;--shiki-dark:#56B6C2">/</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF">scannow</span></span>
<span class="line"><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF">DISM </span><span style="--shiki-light:#383A42;--shiki-dark:#56B6C2">/</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF">Online </span><span style="--shiki-light:#383A42;--shiki-dark:#56B6C2">/</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF">Cleanup</span><span style="--shiki-light:#383A42;--shiki-dark:#56B6C2">-</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF">Image </span><span style="--shiki-light:#383A42;--shiki-dark:#56B6C2">/</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF">RestoreHealth</span></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div><div class="line-number"></div></div></div><p>同时检查：</p>
<ul>
<li>SSU 是否已安装。</li>
<li>C 盘是否有足够空间。</li>
<li>SoftwareDistribution / catroot2 重置后是否仍失败。</li>
</ul>
<p>如果这些都正常，就要看 CBS/CSI 日志中是否集中出现在 Per-User Registry Installer 阶段。</p>
<h2>根因</h2>
<p>案例中问题集中在历史用户配置文件。服务器上存在多个历史用户目录、Unknown Profile，甚至体积异常大的用户配置文件。更新在重启阶段需要加载或卸载用户注册表 hive，某些 <code>NTUSER.DAT</code> 无法正常卸载，导致补丁事务失败并触发回滚。</p>
<h2>处理方案</h2>
<h3>1. 先备份</h3>
<p>生产环境操作前先创建 AMI 或快照。用户 Profile 清理有数据风险，不能直接在生产上盲删。</p>
<h3>2. 清理 Unknown Profile</h3>
<p>图形界面方式：</p>
<ol>
<li>运行 <code>sysdm.cpl</code>。</li>
<li>进入“高级”选项卡。</li>
<li>在“用户配置文件”区域点击“设置”。</li>
<li>删除状态为 Unknown 或确认不再使用的历史用户配置文件。</li>
</ol>
<h3>3. 必要时清理注册表 ProfileList</h3>
<p>谨慎打开注册表：</p>
<div class="language-text line-numbers-mode" data-highlighter="shiki" data-ext="text" style="--shiki-light:#383A42;--shiki-dark:#abb2bf;--shiki-light-bg:#FAFAFA;--shiki-dark-bg:#282c34"><pre class="shiki shiki-themes one-light one-dark-pro vp-code"><code class="language-text"><span class="line"><span>HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList</span></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div></div></div><p>对照 <code>C:\Users</code> 目录和 ProfileList 中的 SID，清理失效项。执行前应导出注册表备份。</p>
<h3>4. 重新安装补丁</h3>
<p>清理后重启，再重新安装目标累积更新。</p>
<h3>5. 临时规避</h3>
<p>如果不能立即清理 Profile，且后续月度补丁已发布，可以测试直接安装更新的累积补丁。Windows 累积更新通常包含前月安全内容，但这只能作为临时规避，根本问题仍应清理。</p>
<h2>总结</h2>
<p>Windows 补丁重启阶段回滚时，不要只盯着 Windows Update。CBS/CSI 里如果指向 Per-User Registry Installer 和用户 hive 卸载失败，就要重点检查历史用户配置文件。</p>
<p>服务器长期多人登录后，Profile 堆积很常见。建议定期清理废弃 Profile，避免在补丁窗口才暴露问题。</p>
]]></content>
    <category term="AWS"/>
    <category term="Windows"/>
    <published>2026-05-13T00:00:00.000Z</published>
  </entry>
  <entry>
    <title type="text">FSx ONTAP SMB 共享权限排查</title>
    <id>https://blog.checo.cc/posts/AWS/12.html</id>
    <link href="https://blog.checo.cc/posts/AWS/12.html"/>
    <updated>2026-06-04T13:54:51.000Z</updated>
    <summary type="html"><![CDATA[
<p>给 FSx ONTAP SMB 共享添加了 NTFS 安全权限后，用户仍然无法访问共享。这个问题的关键是：Windows SMB 最终权限是共享权限和 NTFS 权限的交集，而且 Kerberos 票据不会在用户保持登录时自动刷新组成员关系。</p>
]]></summary>
    <content type="html"><![CDATA[
<p>给 FSx ONTAP SMB 共享添加了 NTFS 安全权限后，用户仍然无法访问共享。这个问题的关键是：Windows SMB 最终权限是共享权限和 NTFS 权限的交集，而且 Kerberos 票据不会在用户保持登录时自动刷新组成员关系。</p>
<!-- more -->
<h2>现象</h2>
<p>用户访问 SMB 共享路径时提示没有权限。管理员已经在“安全”选项卡里给目标域组添加了权限，但访问仍失败。</p>
<h2>关键概念</h2>
<p>SMB 共享访问同时受两层权限控制：</p>
<ul>
<li>共享权限（Share Permissions）</li>
<li>安全权限 / NTFS 权限（Security Permissions）</li>
</ul>
<p>最终生效权限是两者交集。只配置 NTFS 权限，不配置共享权限，用户仍可能被拒绝。</p>
<h2>排查步骤</h2>
<h3>1. 检查共享权限</h3>
<p>使用域管理员登录一台已加入域的 Windows 机器，打开：</p>
<div class="language-text line-numbers-mode" data-highlighter="shiki" data-ext="text" style="--shiki-light:#383A42;--shiki-dark:#abb2bf;--shiki-light-bg:#FAFAFA;--shiki-dark-bg:#282c34"><pre class="shiki shiki-themes one-light one-dark-pro vp-code"><code class="language-text"><span class="line"><span>compmgmt.msc</span></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div></div></div><p>连接到 FSx SVM DNS 名称，然后进入：</p>
<div class="language-text line-numbers-mode" data-highlighter="shiki" data-ext="text" style="--shiki-light:#383A42;--shiki-dark:#abb2bf;--shiki-light-bg:#FAFAFA;--shiki-dark-bg:#282c34"><pre class="shiki shiki-themes one-light one-dark-pro vp-code"><code class="language-text"><span class="line"><span>系统工具 -> 共享文件夹 -> 共享</span></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div></div></div><p>找到目标共享，打开属性，检查“共享权限”选项卡。确认目标用户或组至少有读取权限。</p>
<h3>2. 检查 NTFS 权限</h3>
<p>再检查“安全”选项卡，确认文件系统权限也包含目标用户或组。</p>
<h3>3. 刷新 Kerberos 票据</h3>
<p>如果用户刚刚被加入某个域组，当前登录会话里的 Kerberos TGT 可能仍是旧组成员信息。</p>
<p>最稳妥方式是让用户完全注销后重新登录，而不是锁屏或断开 RDP。</p>
<p>也可以尝试清票：</p>
<div class="language-cmd line-numbers-mode" data-highlighter="shiki" data-ext="cmd" style="--shiki-light:#383A42;--shiki-dark:#abb2bf;--shiki-light-bg:#FAFAFA;--shiki-dark-bg:#282c34"><pre class="shiki shiki-themes one-light one-dark-pro vp-code"><code class="language-cmd"><span class="line"><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF">klist purge</span></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div></div></div><p>但生产排障中，完整注销重登更直观可靠。</p>
<h2>为什么会这样</h2>
<p>Windows 用户登录后会拿到包含组成员关系的 Kerberos 票据。如果管理员在用户登录期间修改组成员关系，用户现有票据不会立刻自动变成新权限。FSx 看到的仍然是旧身份信息，导致权限判断失败。</p>
<h2>总结</h2>
<p>FSx ONTAP SMB 共享访问被拒时，建议按这个顺序查：</p>
<ol>
<li>共享权限是否放行。</li>
<li>NTFS 权限是否放行。</li>
<li>用户是否注销重登刷新 Kerberos 票据。</li>
</ol>
<p>只看“安全”选项卡是不够的，这是 SMB 权限排查里最常见的误区。</p>
]]></content>
    <category term="AWS"/>
    <category term="Windows"/>
    <published>2026-04-06T00:00:00.000Z</published>
  </entry>
  <entry>
    <title type="text">FSx for Windows 创建失败：自建 AD 的 TCP 9389 不通</title>
    <id>https://blog.checo.cc/posts/AWS/13.html</id>
    <link href="https://blog.checo.cc/posts/AWS/13.html"/>
    <updated>2026-06-06T15:23:57.000Z</updated>
    <summary type="html"><![CDATA[
<p>使用自建 Active Directory 创建 FSx for Windows File Server 时，如果 Single-AZ 2 或 Multi-AZ 文件系统创建失败，并且报 <code>Get-ADComputer: Unable to contact the server</code>，要重点检查 FSx 子网到域控 TCP 9389 的连通性。</p>
]]></summary>
    <content type="html"><![CDATA[
<p>使用自建 Active Directory 创建 FSx for Windows File Server 时，如果 Single-AZ 2 或 Multi-AZ 文件系统创建失败，并且报 <code>Get-ADComputer: Unable to contact the server</code>，要重点检查 FSx 子网到域控 TCP 9389 的连通性。</p>
<!-- more -->
<h2>现象</h2>
<p>FSx 创建失败，后台或错误信息中出现：</p>
<div class="language-text line-numbers-mode" data-highlighter="shiki" data-ext="text" style="--shiki-light:#383A42;--shiki-dark:#abb2bf;--shiki-light-bg:#FAFAFA;--shiki-dark-bg:#282c34"><pre class="shiki shiki-themes one-light one-dark-pro vp-code"><code class="language-text"><span class="line"><span>setupFileServerRole failed</span></span>
<span class="line"><span>Get-ADComputer : Unable to contact the server.</span></span>
<span class="line"><span>This may be because this server does not exist, it is currently down,</span></span>
<span class="line"><span>or it does not have the Active Directory Web Services running.</span></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p>这个错误通常发生在 FSx 设置文件服务器角色、加入或查询 AD 对象的阶段。</p>
<h2>根因</h2>
<p><code>Get-ADComputer</code> 依赖 Active Directory Web Services，也就是 ADWS。ADWS 默认使用：</p>
<div class="language-text line-numbers-mode" data-highlighter="shiki" data-ext="text" style="--shiki-light:#383A42;--shiki-dark:#abb2bf;--shiki-light-bg:#FAFAFA;--shiki-dark-bg:#282c34"><pre class="shiki shiki-themes one-light one-dark-pro vp-code"><code class="language-text"><span class="line"><span>TCP 9389</span></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div></div></div><p>对于 FSx for Windows 的 Single-AZ 2 和 Multi-AZ 类型，FSx 需要能访问域控制器的 TCP 9389。如果该端口被安全组、NACL、企业防火墙或跨区域网络策略阻断，文件系统创建会失败。</p>
<h2>验证方法</h2>
<p>在与 FSx 相同子网、相同安全组的加域 EC2 Windows 实例上运行 AD 验证工具。</p>
<div class="language-powershell line-numbers-mode" data-highlighter="shiki" data-ext="powershell" style="--shiki-light:#383A42;--shiki-dark:#abb2bf;--shiki-light-bg:#FAFAFA;--shiki-dark-bg:#282c34"><pre class="shiki shiki-themes one-light one-dark-pro vp-code"><code class="language-powershell"><span class="line"><span style="--shiki-light:#0184BC;--shiki-dark:#56B6C2">Install-WindowsFeature</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF"> RSAT</span><span style="--shiki-light:#383A42;--shiki-dark:#56B6C2">-</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF">AD</span><span style="--shiki-light:#383A42;--shiki-dark:#56B6C2">-</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF">PowerShell</span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#0184BC;--shiki-dark:#56B6C2">Invoke-WebRequest</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF"> `</span></span>
<span class="line"><span style="--shiki-light:#50A14F;--shiki-dark:#98C379">  "https://docs.aws.amazon.com/fsx/latest/WindowsGuide/samples/AmazonFSxADValidation.zip"</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF"> `</span></span>
<span class="line"><span style="--shiki-light:#383A42;--shiki-dark:#56B6C2">  -</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF">OutFile </span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379">"AmazonFSxADValidation.zip"</span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#0184BC;--shiki-dark:#56B6C2">Expand-Archive</span><span style="--shiki-light:#383A42;--shiki-dark:#56B6C2"> -</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF">Path </span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379">"AmazonFSxADValidation.zip"</span></span>
<span class="line"><span style="--shiki-light:#0184BC;--shiki-dark:#56B6C2">Import-Module</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF"> .\AmazonFSxADValidation</span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#E45649;--shiki-dark:#E06C75">$Credential</span><span style="--shiki-light:#383A42;--shiki-dark:#56B6C2"> =</span><span style="--shiki-light:#0184BC;--shiki-dark:#56B6C2"> Get-Credential</span></span>
<span class="line"><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF">$Args </span><span style="--shiki-light:#383A42;--shiki-dark:#56B6C2">=</span><span style="--shiki-light:#A626A4;--shiki-dark:#C678DD"> @</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF">{</span></span>
<span class="line"><span style="--shiki-light:#E45649;--shiki-dark:#E06C75">  DomainDNSRoot</span><span style="--shiki-light:#383A42;--shiki-dark:#56B6C2">  =</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379"> "example.com"</span></span>
<span class="line"><span style="--shiki-light:#E45649;--shiki-dark:#E06C75">  DnsIpAddresses</span><span style="--shiki-light:#383A42;--shiki-dark:#56B6C2"> =</span><span style="--shiki-light:#A626A4;--shiki-dark:#C678DD"> @</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF">(</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379">"DC_IP_1"</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF">, </span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379">"DC_IP_2"</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF">)</span></span>
<span class="line"><span style="--shiki-light:#E45649;--shiki-dark:#E06C75">  SubnetIds</span><span style="--shiki-light:#383A42;--shiki-dark:#56B6C2">      =</span><span style="--shiki-light:#A626A4;--shiki-dark:#C678DD"> @</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF">(</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379">"subnet-xxxxxxxx"</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF">)</span></span>
<span class="line"><span style="--shiki-light:#E45649;--shiki-dark:#E06C75">  Credential</span><span style="--shiki-light:#383A42;--shiki-dark:#56B6C2">     =</span><span style="--shiki-light:#E45649;--shiki-dark:#E06C75"> $Credential</span></span>
<span class="line"><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF">}</span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#E45649;--shiki-dark:#E06C75">$Result</span><span style="--shiki-light:#383A42;--shiki-dark:#56B6C2"> =</span><span style="--shiki-light:#0184BC;--shiki-dark:#56B6C2"> Test-FSxADConfiguration</span><span style="--shiki-light:#E45649;--shiki-dark:#E06C75"> @Args</span></span>
<span class="line"><span style="--shiki-light:#E45649;--shiki-dark:#E06C75">$Result.Failures</span></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p>如果输出中有 TCP 9389 失败项，就能确认是 ADWS 端口连通性问题。</p>
<h2>Single-AZ 1 为什么可能成功</h2>
<p>Single-AZ 1 对 TCP 9389 的要求不同，可能在同一环境下创建成功。这可以帮助判断服务账号权限、DNS 和基础 AD 端口是否正常。</p>
<p>如果 Single-AZ 1 成功，而 Single-AZ 2 / Multi-AZ 失败，排查重点应转向 TCP 9389。</p>
<h2>解决方案</h2>
<p>放行 FSx 子网到全部域控的 TCP 9389：</p>
<ul>
<li>FSx 安全组出站。</li>
<li>域控安全组入站。</li>
<li>网络 ACL 双向规则。</li>
<li>本地或跨区域防火墙策略。</li>
<li>企业网络中的中间防火墙。</li>
</ul>
<p>放行后重新运行验证工具，确认没有失败项，再重新创建 FSx。</p>
<h2>总结</h2>
<p>FSx for Windows 加入自建 AD 失败时，不要只查 389、445、88 这些常见端口。对于 Single-AZ 2 和 Multi-AZ，TCP 9389 同样关键。</p>
<p>看到 <code>Get-ADComputer</code> 或 ADWS 相关错误时，优先验证 FSx 子网到全部 DC 的 9389 连通性。</p>
]]></content>
    <category term="AWS"/>
    <category term="Windows"/>
    <published>2026-06-04T00:00:00.000Z</published>
  </entry>
  <entry>
    <title type="text">EC2 SQL Server HA 备用节点许可费用减免要点</title>
    <id>https://blog.checo.cc/posts/AWS/14.html</id>
    <link href="https://blog.checo.cc/posts/AWS/14.html"/>
    <updated>2026-06-04T13:54:51.000Z</updated>
    <summary type="html"><![CDATA[
<p>Amazon EC2 High Availability for SQL Server 可以为符合条件的 SQL Server HA 备用节点减免许可费用。但这个减免有严格前提，尤其是备用节点不能承载活动工作负载，也不能作为可读辅助副本提供查询。</p>
]]></summary>
    <content type="html"><![CDATA[
<p>Amazon EC2 High Availability for SQL Server 可以为符合条件的 SQL Server HA 备用节点减免许可费用。但这个减免有严格前提，尤其是备用节点不能承载活动工作负载，也不能作为可读辅助副本提供查询。</p>
<!-- more -->
<h2>适用前提</h2>
<p>启用 SQL Server HA 许可节省前，先确认环境满足要求：</p>
<ul>
<li>Windows Server 2019 或更高版本。</li>
<li>SQL Server 2017 或更高版本。</li>
<li>一个 HA 集群只支持两个 EC2 节点。</li>
<li>实例需要运行 SSM Agent。</li>
<li>实例 IAM Role 需要具备 EC2 SQL HA 和 SSM 相关权限。</li>
</ul>
<p>如果环境还是 Windows Server 2016，或集群超过两个节点，就不满足该功能前提。</p>
<h2>备用节点的限制</h2>
<p>备用节点要获得许可减免，必须保持被动：</p>
<ul>
<li>不处理传入业务流量。</li>
<li>不运行活动 SQL Server 工作负载。</li>
<li>不能作为可读辅助副本承担读查询。</li>
<li>不应在可用性组外运行独立数据库。</li>
</ul>
<p>核心判断很简单：只要这个节点在提供数据服务，就不再是纯 standby。</p>
<h2>可读辅助副本会影响减免</h2>
<p>Always On 可用性组里启用 Readable Secondary 后，辅助副本可以被应用、报表或人工查询访问。按许可逻辑，这已经属于活动使用，需要完整 SQL Server 授权。</p>
<p>因此，如果目标是拿 standby 节点许可减免，不应启用可读辅助副本。</p>
<h2>备份是否需要可读辅助</h2>
<p>不需要。SQL Server 支持在不可读的辅助副本上执行某些备份场景。也就是说，为了全量备份和日志备份，不必把辅助副本设置为 readable。</p>
<p>实际配置前应结合 SQL Server 版本和可用性组备份首选项验证。</p>
<h2>启用步骤概览</h2>
<h3>1. 确认 SSM Agent 在线</h3>
<div class="language-bash line-numbers-mode" data-highlighter="shiki" data-ext="bash" style="--shiki-light:#383A42;--shiki-dark:#abb2bf;--shiki-light-bg:#FAFAFA;--shiki-dark-bg:#282c34"><pre class="shiki shiki-themes one-light one-dark-pro vp-code"><code class="language-bash"><span class="line"><span style="--shiki-light:#4078F2;--shiki-dark:#61AFEF">aws</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379"> ssm</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379"> describe-instance-information</span></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div></div></div><p>实例应显示 <code>PingStatus: Online</code>。</p>
<h3>2. 配置 IAM 权限</h3>
<p>给实例配置文件附加：</p>
<ul>
<li><code>AmazonSSMManagedInstanceCore</code></li>
<li><code>AWSEC2SqlHaInstancePolicy</code></li>
</ul>
<h3>3. 准备 SQL 凭证</h3>
<p>默认可以使用 <code>NT AUTHORITY\SYSTEM</code> 读取 SQL Server HA 元数据。如果环境限制了该账户，则需要把 SQL Server 凭证放入 Secrets Manager，并在启用时指定。</p>
<h3>4. 在 EC2 控制台启用</h3>
<p>在 EC2 控制台选择 HA 集群相关实例，进入：</p>
<div class="language-text line-numbers-mode" data-highlighter="shiki" data-ext="text" style="--shiki-light:#383A42;--shiki-dark:#abb2bf;--shiki-light-bg:#FAFAFA;--shiki-dark-bg:#282c34"><pre class="shiki shiki-themes one-light one-dark-pro vp-code"><code class="language-text"><span class="line"><span>Actions -> Instance settings -> Modify SQL High Availability settings</span></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div></div></div><p>检查前置条件，通过后启用 license savings。</p>
<p>启用后应能看到：</p>
<ul>
<li>主节点：<code>Active / Full license included</code></li>
<li>备用节点：<code>Standby / Waived</code></li>
</ul>
<h2>总结</h2>
<p>SQL Server HA 备用节点许可减免不是简单开关。真正关键的是 standby 节点必须保持被动。</p>
<p>如果为了查询、报表或应用读取启用 readable secondary，就会失去减免资格。备份场景应优先使用 SQL Server 支持的辅助副本备份能力，而不是把备用节点变成可读工作负载节点。</p>
]]></content>
    <category term="AWS"/>
    <category term="Windows"/>
    <published>2026-06-03T00:00:00.000Z</published>
  </entry>
  <entry>
    <title type="text">EC2 Windows 卸载 .NET 后 Server Manager 失效恢复</title>
    <id>https://blog.checo.cc/posts/AWS/15.html</id>
    <link href="https://blog.checo.cc/posts/AWS/15.html"/>
    <updated>2026-06-04T13:54:51.000Z</updated>
    <summary type="html"><![CDATA[
<p>Windows Server 上不要把 “.NET Framework 4 Features” 当成普通应用卸载。它是很多管理组件的依赖，包括 Server Manager、PowerShell 模块、IIS/WCF 相关功能。误关后可能导致 Server Manager 和 <code>Install-WindowsFeature</code> 一起失效。</p>
]]></summary>
    <content type="html"><![CDATA[
<p>Windows Server 上不要把 “.NET Framework 4 Features” 当成普通应用卸载。它是很多管理组件的依赖，包括 Server Manager、PowerShell 模块、IIS/WCF 相关功能。误关后可能导致 Server Manager 和 <code>Install-WindowsFeature</code> 一起失效。</p>
<!-- more -->
<h2>现象</h2>
<p>在 Server Manager 的 “Remove Roles and Features” 中取消 <code>.NET Framework 4</code> 后，重启实例出现：</p>
<ul>
<li>Server Manager 打不开。</li>
<li>PowerShell 执行 <code>ServerManager</code> 提示命令不存在。</li>
<li><code>Install-WindowsFeature</code> 报 feature 名称不存在。</li>
<li>部分 PowerShell 管理能力失效。</li>
</ul>
<p>示例错误：</p>
<div class="language-text line-numbers-mode" data-highlighter="shiki" data-ext="text" style="--shiki-light:#383A42;--shiki-dark:#abb2bf;--shiki-light-bg:#FAFAFA;--shiki-dark-bg:#282c34"><pre class="shiki shiki-themes one-light one-dark-pro vp-code"><code class="language-text"><span class="line"><span>ServerManager : The term 'ServerManager' is not recognized</span></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div></div></div><h2>根因</h2>
<p>Windows Server 的 Server Manager 和相关 PowerShell 模块依赖 <code>NetFx4-OC-Package</code>。在图形界面取消 <code>.NET Framework 4 Features</code>，实际会把一批依赖 NetFx4 的 OC 包一起 disable。</p>
<p>这和 <code>.NET Framework 4.8</code> 运行时版本不是一回事。注册表里仍可能显示 .NET 4.8 存在，但 Windows 可选组件层面的 <code>NetFx4</code> 已被关闭。</p>
<p>另外，<code>NetFx3</code> 不能替代 <code>NetFx4</code>。执行：</p>
<div class="language-powershell line-numbers-mode" data-highlighter="shiki" data-ext="powershell" style="--shiki-light:#383A42;--shiki-dark:#abb2bf;--shiki-light-bg:#FAFAFA;--shiki-dark-bg:#282c34"><pre class="shiki shiki-themes one-light one-dark-pro vp-code"><code class="language-powershell"><span class="line"><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF">DISM </span><span style="--shiki-light:#383A42;--shiki-dark:#56B6C2">/</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF">Online </span><span style="--shiki-light:#383A42;--shiki-dark:#56B6C2">/</span><span style="--shiki-light:#0184BC;--shiki-dark:#56B6C2">Enable-Feature</span><span style="--shiki-light:#383A42;--shiki-dark:#56B6C2"> /</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF">FeatureName:NetFx3 </span><span style="--shiki-light:#383A42;--shiki-dark:#56B6C2">/</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF">All</span></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div></div></div><p>无法恢复依赖 .NET 4 的 Server Manager。</p>
<h2>恢复步骤</h2>
<p>操作前建议创建 AMI 备份，所有命令以管理员身份运行。</p>
<h3>1. 启用 NetFx4</h3>
<div class="language-powershell line-numbers-mode" data-highlighter="shiki" data-ext="powershell" style="--shiki-light:#383A42;--shiki-dark:#abb2bf;--shiki-light-bg:#FAFAFA;--shiki-dark-bg:#282c34"><pre class="shiki shiki-themes one-light one-dark-pro vp-code"><code class="language-powershell"><span class="line"><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF">DISM </span><span style="--shiki-light:#383A42;--shiki-dark:#56B6C2">/</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF">Online </span><span style="--shiki-light:#383A42;--shiki-dark:#56B6C2">/</span><span style="--shiki-light:#0184BC;--shiki-dark:#56B6C2">Enable-Feature</span><span style="--shiki-light:#383A42;--shiki-dark:#56B6C2"> /</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF">FeatureName:NetFx4 </span><span style="--shiki-light:#383A42;--shiki-dark:#56B6C2">/</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF">All</span></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div></div></div><h3>2. 启用 Server Manager 图形管理组件</h3>
<div class="language-powershell line-numbers-mode" data-highlighter="shiki" data-ext="powershell" style="--shiki-light:#383A42;--shiki-dark:#abb2bf;--shiki-light-bg:#FAFAFA;--shiki-dark-bg:#282c34"><pre class="shiki shiki-themes one-light one-dark-pro vp-code"><code class="language-powershell"><span class="line"><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF">DISM </span><span style="--shiki-light:#383A42;--shiki-dark:#56B6C2">/</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF">Online </span><span style="--shiki-light:#383A42;--shiki-dark:#56B6C2">/</span><span style="--shiki-light:#0184BC;--shiki-dark:#56B6C2">Enable-Feature</span><span style="--shiki-light:#383A42;--shiki-dark:#56B6C2"> /</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF">FeatureName:Server</span><span style="--shiki-light:#383A42;--shiki-dark:#56B6C2">-</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF">Gui</span><span style="--shiki-light:#383A42;--shiki-dark:#56B6C2">-</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF">Mgmt </span><span style="--shiki-light:#383A42;--shiki-dark:#56B6C2">/</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF">All</span></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div></div></div><h3>3. 重启实例</h3>
<div class="language-powershell line-numbers-mode" data-highlighter="shiki" data-ext="powershell" style="--shiki-light:#383A42;--shiki-dark:#abb2bf;--shiki-light-bg:#FAFAFA;--shiki-dark-bg:#282c34"><pre class="shiki shiki-themes one-light one-dark-pro vp-code"><code class="language-powershell"><span class="line"><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF">shutdown </span><span style="--shiki-light:#383A42;--shiki-dark:#56B6C2">/</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF">r </span><span style="--shiki-light:#383A42;--shiki-dark:#56B6C2">/</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF">t </span><span style="--shiki-light:#986801;--shiki-dark:#D19A66">0</span></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div></div></div><p>重启后再验证。</p>
<h3>4. 按需恢复其它依赖组件</h3>
<p>如果业务用到 IIS、WCF、PowerShell ISE 或 DSC，可以按需启用：</p>
<div class="language-powershell line-numbers-mode" data-highlighter="shiki" data-ext="powershell" style="--shiki-light:#383A42;--shiki-dark:#abb2bf;--shiki-light-bg:#FAFAFA;--shiki-dark-bg:#282c34"><pre class="shiki shiki-themes one-light one-dark-pro vp-code"><code class="language-powershell"><span class="line"><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF">DISM </span><span style="--shiki-light:#383A42;--shiki-dark:#56B6C2">/</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF">Online </span><span style="--shiki-light:#383A42;--shiki-dark:#56B6C2">/</span><span style="--shiki-light:#0184BC;--shiki-dark:#56B6C2">Enable-Feature</span><span style="--shiki-light:#383A42;--shiki-dark:#56B6C2"> /</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF">FeatureName:NetFx4Extended</span><span style="--shiki-light:#383A42;--shiki-dark:#56B6C2">-</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF">ASPNET45 </span><span style="--shiki-light:#383A42;--shiki-dark:#56B6C2">/</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF">All</span></span>
<span class="line"><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF">DISM </span><span style="--shiki-light:#383A42;--shiki-dark:#56B6C2">/</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF">Online </span><span style="--shiki-light:#383A42;--shiki-dark:#56B6C2">/</span><span style="--shiki-light:#0184BC;--shiki-dark:#56B6C2">Enable-Feature</span><span style="--shiki-light:#383A42;--shiki-dark:#56B6C2"> /</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF">FeatureName:WCF</span><span style="--shiki-light:#383A42;--shiki-dark:#56B6C2">-</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF">HTTP</span><span style="--shiki-light:#383A42;--shiki-dark:#56B6C2">-</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF">Activation45 </span><span style="--shiki-light:#383A42;--shiki-dark:#56B6C2">/</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF">All</span></span>
<span class="line"><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF">DISM </span><span style="--shiki-light:#383A42;--shiki-dark:#56B6C2">/</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF">Online </span><span style="--shiki-light:#383A42;--shiki-dark:#56B6C2">/</span><span style="--shiki-light:#0184BC;--shiki-dark:#56B6C2">Enable-Feature</span><span style="--shiki-light:#383A42;--shiki-dark:#56B6C2"> /</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF">FeatureName:WCF</span><span style="--shiki-light:#383A42;--shiki-dark:#56B6C2">-</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF">TCP</span><span style="--shiki-light:#383A42;--shiki-dark:#56B6C2">-</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF">PortSharing45 </span><span style="--shiki-light:#383A42;--shiki-dark:#56B6C2">/</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF">All</span></span>
<span class="line"><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF">DISM </span><span style="--shiki-light:#383A42;--shiki-dark:#56B6C2">/</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF">Online </span><span style="--shiki-light:#383A42;--shiki-dark:#56B6C2">/</span><span style="--shiki-light:#0184BC;--shiki-dark:#56B6C2">Enable-Feature</span><span style="--shiki-light:#383A42;--shiki-dark:#56B6C2"> /</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF">FeatureName:IIS</span><span style="--shiki-light:#383A42;--shiki-dark:#56B6C2">-</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF">ASPNET45 </span><span style="--shiki-light:#383A42;--shiki-dark:#56B6C2">/</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF">All</span></span>
<span class="line"><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF">DISM </span><span style="--shiki-light:#383A42;--shiki-dark:#56B6C2">/</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF">Online </span><span style="--shiki-light:#383A42;--shiki-dark:#56B6C2">/</span><span style="--shiki-light:#0184BC;--shiki-dark:#56B6C2">Enable-Feature</span><span style="--shiki-light:#383A42;--shiki-dark:#56B6C2"> /</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF">FeatureName:IIS</span><span style="--shiki-light:#383A42;--shiki-dark:#56B6C2">-</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF">NetFxExtensibility45 </span><span style="--shiki-light:#383A42;--shiki-dark:#56B6C2">/</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF">All</span></span>
<span class="line"><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF">DISM </span><span style="--shiki-light:#383A42;--shiki-dark:#56B6C2">/</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF">Online </span><span style="--shiki-light:#383A42;--shiki-dark:#56B6C2">/</span><span style="--shiki-light:#0184BC;--shiki-dark:#56B6C2">Enable-Feature</span><span style="--shiki-light:#383A42;--shiki-dark:#56B6C2"> /</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF">FeatureName:MicrosoftWindowsPowerShellISE </span><span style="--shiki-light:#383A42;--shiki-dark:#56B6C2">/</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF">All</span></span>
<span class="line"><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF">DISM </span><span style="--shiki-light:#383A42;--shiki-dark:#56B6C2">/</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF">Online </span><span style="--shiki-light:#383A42;--shiki-dark:#56B6C2">/</span><span style="--shiki-light:#0184BC;--shiki-dark:#56B6C2">Enable-Feature</span><span style="--shiki-light:#383A42;--shiki-dark:#56B6C2"> /</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF">FeatureName:DSC</span><span style="--shiki-light:#383A42;--shiki-dark:#56B6C2">-</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF">Service </span><span style="--shiki-light:#383A42;--shiki-dark:#56B6C2">/</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF">All</span></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h2>验证</h2>
<div class="language-powershell line-numbers-mode" data-highlighter="shiki" data-ext="powershell" style="--shiki-light:#383A42;--shiki-dark:#abb2bf;--shiki-light-bg:#FAFAFA;--shiki-dark-bg:#282c34"><pre class="shiki shiki-themes one-light one-dark-pro vp-code"><code class="language-powershell"><span class="line"><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF">ServerManager</span></span>
<span class="line"><span style="--shiki-light:#0184BC;--shiki-dark:#56B6C2">Get-Command</span><span style="--shiki-light:#0184BC;--shiki-dark:#56B6C2"> Install-WindowsFeature</span></span>
<span class="line"><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF">DISM </span><span style="--shiki-light:#383A42;--shiki-dark:#56B6C2">/</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF">Online </span><span style="--shiki-light:#383A42;--shiki-dark:#56B6C2">/</span><span style="--shiki-light:#0184BC;--shiki-dark:#56B6C2">Get-Features</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF"> | findstr </span><span style="--shiki-light:#383A42;--shiki-dark:#56B6C2">/</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF">I </span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379">"NetFx4 Server-Gui PowerShell"</span></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h2>总结</h2>
<p>为了满足 .NET 版本合规，正确方式是安装 .NET 累积更新，而不是关闭 <code>.NET Framework 4 Features</code>。后者不会让 .NET 从系统中“安全消失”，反而会破坏 Windows Server 管理工具链。</p>
<p>恢复时仅启用 <code>NetFx4</code> 还不够，必须同时启用 <code>Server-Gui-Mgmt</code> 并重启。</p>
]]></content>
    <category term="AWS"/>
    <category term="Windows"/>
    <published>2026-06-03T00:00:00.000Z</published>
  </entry>
  <entry>
    <title type="text">EC2 Windows 实例部署 BitLocker 注意事项</title>
    <id>https://blog.checo.cc/posts/AWS/16.html</id>
    <link href="https://blog.checo.cc/posts/AWS/16.html"/>
    <updated>2026-06-04T13:54:51.000Z</updated>
    <summary type="html"><![CDATA[
<p>在 EC2 Windows 实例上启用 BitLocker 系统盘加密是可行的，但风险比物理机更高。关键问题是 EC2 通常没有传统 TPM，系统盘加密后启动阶段需要输入密码，而普通控制台未必能提供可靠输入通道。</p>
]]></summary>
    <content type="html"><![CDATA[
<p>在 EC2 Windows 实例上启用 BitLocker 系统盘加密是可行的，但风险比物理机更高。关键问题是 EC2 通常没有传统 TPM，系统盘加密后启动阶段需要输入密码，而普通控制台未必能提供可靠输入通道。</p>
<!-- more -->
<h2>风险点</h2>
<p>如果直接对 C 盘启用 BitLocker 并重启，可能出现：</p>
<ul>
<li>实例状态显示 running，但 RDP 无法连接。</li>
<li>启动阶段等待 BitLocker 密码或恢复密钥。</li>
<li>控制台黑屏或无法输入。</li>
<li>业务长时间不可用，只能通过快照/AMI 回滚。</li>
</ul>
<p>因此必须先验证 EC2 串行控制台可用。</p>
<h2>操作前准备</h2>
<ul>
<li>创建 AMI 或 EBS 快照。</li>
<li>在测试实例完整演练。</li>
<li>记录并离线保存恢复密钥。</li>
<li>确认可接受重启和短暂停机窗口。</li>
</ul>
<h2>启用串行控制台 SAC</h2>
<p>在管理员 PowerShell 中执行：</p>
<div class="language-powershell line-numbers-mode" data-highlighter="shiki" data-ext="powershell" style="--shiki-light:#383A42;--shiki-dark:#abb2bf;--shiki-light-bg:#FAFAFA;--shiki-dark-bg:#282c34"><pre class="shiki shiki-themes one-light one-dark-pro vp-code"><code class="language-powershell"><span class="line"><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF">bcdedit </span><span style="--shiki-light:#383A42;--shiki-dark:#56B6C2">/</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF">ems </span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379">'{current}'</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF"> on</span></span>
<span class="line"><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF">bcdedit </span><span style="--shiki-light:#383A42;--shiki-dark:#56B6C2">/</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF">emssettings EMSPORT:</span><span style="--shiki-light:#986801;--shiki-dark:#D19A66">1</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF"> EMSBAUDRATE:</span><span style="--shiki-light:#986801;--shiki-dark:#D19A66">115200</span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF">bcdedit </span><span style="--shiki-light:#383A42;--shiki-dark:#56B6C2">/</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF">set </span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379">'{bootmgr}'</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF"> displaybootmenu yes</span></span>
<span class="line"><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF">bcdedit </span><span style="--shiki-light:#383A42;--shiki-dark:#56B6C2">/</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF">set </span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379">'{bootmgr}'</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF"> timeout </span><span style="--shiki-light:#986801;--shiki-dark:#D19A66">15</span></span>
<span class="line"><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF">bcdedit </span><span style="--shiki-light:#383A42;--shiki-dark:#56B6C2">/</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF">set </span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379">'{bootmgr}'</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF"> bootems yes</span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF">shutdown </span><span style="--shiki-light:#383A42;--shiki-dark:#56B6C2">-</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF">r </span><span style="--shiki-light:#383A42;--shiki-dark:#56B6C2">-</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF">t </span><span style="--shiki-light:#986801;--shiki-dark:#D19A66">0</span></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p>重启后，在 EC2 控制台通过“连接 -&gt; EC2 串行控制台”确认可以进入启动界面。如果串行控制台不可用，不要继续加密系统盘。</p>
<h2>安装 BitLocker 功能</h2>
<p>通过 Server Manager 添加 BitLocker，或使用 PowerShell：</p>
<div class="language-powershell line-numbers-mode" data-highlighter="shiki" data-ext="powershell" style="--shiki-light:#383A42;--shiki-dark:#abb2bf;--shiki-light-bg:#FAFAFA;--shiki-dark-bg:#282c34"><pre class="shiki shiki-themes one-light one-dark-pro vp-code"><code class="language-powershell"><span class="line"><span style="--shiki-light:#0184BC;--shiki-dark:#56B6C2">Install-WindowsFeature</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF"> BitLocker </span><span style="--shiki-light:#383A42;--shiki-dark:#56B6C2">-</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF">IncludeAllSubFeature </span><span style="--shiki-light:#383A42;--shiki-dark:#56B6C2">-</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF">IncludeManagementTools</span></span>
<span class="line"><span style="--shiki-light:#0184BC;--shiki-dark:#56B6C2">Restart-Computer</span></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div><div class="line-number"></div></div></div><h2>配置无 TPM 启动</h2>
<p>运行 <code>gpedit.msc</code>，进入：</p>
<div class="language-text line-numbers-mode" data-highlighter="shiki" data-ext="text" style="--shiki-light:#383A42;--shiki-dark:#abb2bf;--shiki-light-bg:#FAFAFA;--shiki-dark-bg:#282c34"><pre class="shiki shiki-themes one-light one-dark-pro vp-code"><code class="language-text"><span class="line"><span>计算机配置 -> 管理模板 -> Windows 组件 -> BitLocker 驱动器加密 -> 操作系统驱动器</span></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div></div></div><p>启用“启动时需要附加身份验证”，并勾选“没有兼容的 TPM 时允许 BitLocker”。</p>
<h2>加密数据盘</h2>
<p>数据盘建议先测试：</p>
<ol>
<li>右键数据盘启用 BitLocker。</li>
<li>选择密码解锁。</li>
<li>保存恢复密钥。</li>
<li>加密完成后配置自动解锁。</li>
</ol>
<p>如果没有自动解锁，每次重启后业务可能因为数据盘锁定而不可用。</p>
<h2>加密系统盘</h2>
<p>启用 C 盘 BitLocker，选择密码解锁，保存恢复密钥，并运行 BitLocker 系统检查。</p>
<p>重启后：</p>
<ol>
<li>RDP 暂时不可用。</li>
<li>进入 EC2 串行控制台。</li>
<li>在黑屏阶段输入 BitLocker 密码并回车。</li>
<li>Windows 解锁后继续启动。</li>
<li>系统启动完成后再恢复 RDP。</li>
</ol>
<h2>总结</h2>
<p>EC2 Windows 上做 BitLocker 的关键不是点击“启用加密”，而是启动阶段能否解锁。</p>
<p>必须做到：</p>
<ul>
<li>加密前创建 AMI/快照。</li>
<li>先启用并验证 EC2 串行控制台。</li>
<li>保存恢复密钥。</li>
<li>数据盘配置自动解锁。</li>
<li>先在测试环境演练完整重启流程。</li>
</ul>
<p>如果只是为了云上 EBS 静态加密，优先使用 EBS encryption；BitLocker 更适合 BYOL 或特定合规场景。</p>
]]></content>
    <category term="AWS"/>
    <category term="Windows"/>
    <published>2026-03-28T00:00:00.000Z</published>
  </entry>
  <entry>
    <title type="text">EC2 Windows 无法通过 RDP 登录：内存耗尽导致 Winlogon 异常</title>
    <id>https://blog.checo.cc/posts/AWS/17.html</id>
    <link href="https://blog.checo.cc/posts/AWS/17.html"/>
    <updated>2026-06-04T13:54:51.000Z</updated>
    <summary type="html"><![CDATA[
<p>EC2 Windows 实例状态检查正常、能 ping 通，但 RDP 连接不上，Stop &amp; Start 后又恢复。遇到这种情况不要只看网络，Windows 内部资源耗尽也可能让 Winlogon 等关键进程崩溃。</p>
]]></summary>
    <content type="html"><![CDATA[
<p>EC2 Windows 实例状态检查正常、能 ping 通，但 RDP 连接不上，Stop &amp; Start 后又恢复。遇到这种情况不要只看网络，Windows 内部资源耗尽也可能让 Winlogon 等关键进程崩溃。</p>
<!-- more -->
<h2>现象</h2>
<ul>
<li>实例处于 running。</li>
<li>系统状态检查和实例状态检查正常。</li>
<li>安全组允许 3389。</li>
<li>实例可 ping。</li>
<li>RDP 无法登录。</li>
<li>Stop &amp; Start 后恢复。</li>
</ul>
<p>这种现象很像网络问题，但日志可能指向系统资源不足。</p>
<h2>关键日志</h2>
<p>事件日志中可能出现：</p>
<div class="language-text line-numbers-mode" data-highlighter="shiki" data-ext="text" style="--shiki-light:#383A42;--shiki-dark:#abb2bf;--shiki-light-bg:#FAFAFA;--shiki-dark-bg:#282c34"><pre class="shiki shiki-themes one-light one-dark-pro vp-code"><code class="language-text"><span class="line"><span>Not enough storage is available to process this command.</span></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div></div></div><p>以及：</p>
<div class="language-text line-numbers-mode" data-highlighter="shiki" data-ext="text" style="--shiki-light:#383A42;--shiki-dark:#abb2bf;--shiki-light-bg:#FAFAFA;--shiki-dark-bg:#282c34"><pre class="shiki shiki-themes one-light one-dark-pro vp-code"><code class="language-text"><span class="line"><span>System.OutOfMemoryException</span></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div></div></div><p>还可能看到 Winlogon 相关事件，例如 Winlogon 崩溃或无法正常创建登录会话。</p>
<p>这里的 “storage” 不一定指磁盘，Windows 错误码上下文中也可能指内存或系统资源不足。</p>
<h2>根因</h2>
<p>实例内存和分页文件资源耗尽后，系统无法为关键进程分配资源。RDP 登录依赖的 Winlogon、LSASS、远程桌面服务等组件可能无法正常工作。</p>
<p>Stop &amp; Start 会清空内存状态，所以故障临时消失，但如果实例规格或应用内存占用不解决，问题还会复发。</p>
<h2>排查方向</h2>
<h3>1. 查看事件日志</h3>
<p>重点看故障发生前后的：</p>
<ul>
<li>Application.evtx</li>
<li>System.evtx</li>
<li>Setup.evtx</li>
</ul>
<p>关注：</p>
<ul>
<li><code>OutOfMemoryException</code></li>
<li><code>Not enough storage is available</code></li>
<li>Winlogon 错误</li>
<li>安全软件或监控代理异常</li>
<li>Windows Update 相关异常</li>
</ul>
<h3>2. 检查实例规格</h3>
<p>确认当前实例内存是否满足业务峰值。如果长期接近上限，应升级实例规格或优化应用。</p>
<h3>3. 部署 OS 指标监控</h3>
<p>CloudWatch 默认不采集 Windows 内存指标。需要安装 CloudWatch Agent，采集：</p>
<ul>
<li>Memory 使用率</li>
<li>Pagefile 使用率</li>
<li>Disk 使用率</li>
<li>关键进程指标</li>
</ul>
<p>并设置告警，例如内存使用率超过 85% 提醒。</p>
<h2>处理建议</h2>
<h3>短期恢复</h3>
<p>Stop &amp; Start 可以释放内存，临时恢复登录能力。但这不是根治。</p>
<h3>中期优化</h3>
<p>排查占用内存高的应用、监控代理、安全软件，确认是否存在内存泄漏或配置过重。</p>
<h3>长期方案</h3>
<p>如果业务峰值确实需要更多内存，应升级到更大规格。升级前先创建 AMI，确认实例类型兼容 ENA/NVMe。</p>
<h2>总结</h2>
<p>RDP 登录失败不一定是 3389、安全组或 NACL 问题。只要实例仍可 ping、状态检查通过，就应同时查看 Windows 事件日志。</p>
<p>如果日志里出现 OOM、系统资源不足和 Winlogon 异常，根因很可能是内存耗尽。Stop &amp; Start 只能临时恢复，长期需要监控内存并调整实例规格或应用配置。</p>
]]></content>
    <category term="AWS"/>
    <category term="Windows"/>
    <published>2026-04-25T00:00:00.000Z</published>
  </entry>
  <entry>
    <title type="text">EC2 Windows 无法挂载 SMB：EDR 拦截与 Workgroup 认证</title>
    <id>https://blog.checo.cc/posts/AWS/18.html</id>
    <link href="https://blog.checo.cc/posts/AWS/18.html"/>
    <updated>2026-06-04T13:54:51.000Z</updated>
    <summary type="html"><![CDATA[
<p>两台同 VPC 的 EC2 Windows 实例通过 SMB 访问共享失败，安全组和 NACL 都放行，Windows 防火墙也关闭，但 <code>net use</code> 报 1792，抓包看到 <code>STATUS_NETLOGON_NOT_STARTED</code>。最终根因不是 VPC 网络，而是安全软件拦截了 SMB 认证流程。</p>
]]></summary>
    <content type="html"><![CDATA[
<p>两台同 VPC 的 EC2 Windows 实例通过 SMB 访问共享失败，安全组和 NACL 都放行，Windows 防火墙也关闭，但 <code>net use</code> 报 1792，抓包看到 <code>STATUS_NETLOGON_NOT_STARTED</code>。最终根因不是 VPC 网络，而是安全软件拦截了 SMB 认证流程。</p>
<!-- more -->
<h2>现象</h2>
<p>客户端访问：</p>
<div class="language-text line-numbers-mode" data-highlighter="shiki" data-ext="text" style="--shiki-light:#383A42;--shiki-dark:#abb2bf;--shiki-light-bg:#FAFAFA;--shiki-dark-bg:#282c34"><pre class="shiki shiki-themes one-light one-dark-pro vp-code"><code class="language-text"><span class="line"><span>\\&#x3C;server-private-ip>\share</span></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div></div></div><p>无法打开，也不弹出认证窗口。命令行执行：</p>
<div class="language-cmd line-numbers-mode" data-highlighter="shiki" data-ext="cmd" style="--shiki-light:#383A42;--shiki-dark:#abb2bf;--shiki-light-bg:#FAFAFA;--shiki-dark-bg:#282c34"><pre class="shiki shiki-themes one-light one-dark-pro vp-code"><code class="language-cmd"><span class="line"><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF">net use Z: \\&#x3C;</span><span style="--shiki-light:#C18401;--shiki-dark:#E5C07B">server</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF">-</span><span style="--shiki-light:#A626A4;--shiki-dark:#C678DD">private</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF">-</span><span style="--shiki-light:#E45649;--shiki-dark:#E06C75">ip</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF">>\</span><span style="--shiki-light:#E45649;--shiki-dark:#E06C75">share</span></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div></div></div><p>报错：</p>
<div class="language-text line-numbers-mode" data-highlighter="shiki" data-ext="text" style="--shiki-light:#383A42;--shiki-dark:#abb2bf;--shiki-light-bg:#FAFAFA;--shiki-dark-bg:#282c34"><pre class="shiki shiki-themes one-light one-dark-pro vp-code"><code class="language-text"><span class="line"><span>发生系统错误 1792</span></span>
<span class="line"><span>试图登录，但是网络登录服务没有启动</span></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div><div class="line-number"></div></div></div><p>之后甚至出现 445 端口连接超时、ping 不通等现象。</p>
<h2>排查过程</h2>
<h3>1. 先排除 AWS 网络</h3>
<p>确认：</p>
<ul>
<li>两台实例在同 VPC 或路由可达。</li>
<li>安全组放行 TCP 445。</li>
<li>NACL 未拦截。</li>
<li>路由表有 local 或正确路由。</li>
<li>Windows Defender 防火墙策略不拦截。</li>
</ul>
<h3>2. 双端抓包</h3>
<p>抓包可以看到 SMB 协议已经开始协商：</p>
<div class="language-text line-numbers-mode" data-highlighter="shiki" data-ext="text" style="--shiki-light:#383A42;--shiki-dark:#abb2bf;--shiki-light-bg:#FAFAFA;--shiki-dark-bg:#282c34"><pre class="shiki shiki-themes one-light one-dark-pro vp-code"><code class="language-text"><span class="line"><span>SMB2 Negotiate Protocol Request</span></span>
<span class="line"><span>SMB2 Negotiate Protocol Response</span></span>
<span class="line"><span>SMB2 Session Setup Request</span></span>
<span class="line"><span>SMB2 Session Setup Response: STATUS_NETLOGON_NOT_STARTED</span></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p>这说明流量已经到达服务端，不是 AWS 底层网络丢包。</p>
<h3>3. 理解 Netlogon</h3>
<p>Workgroup 环境下，<code>Netlogon</code> 服务默认不运行是正常的。本地账户 SMB 认证通常通过本地 SAM + NTLM 完成，不应该因为 Netlogon stopped 就必然失败。</p>
<p>如果返回 <code>STATUS_NETLOGON_NOT_STARTED</code> 后又出现所有流量被阻断，应该怀疑安全软件或 EDR 对 SMB 认证流量做了拦截。</p>
<h2>解决方法</h2>
<h3>1. 临时停用 EDR 验证</h3>
<p>在变更窗口内临时停用安全软件，验证 SMB 是否恢复。如果停用后 445 和 ping 都恢复，基本可以确认根因。</p>
<h3>2. 使用本地账户显式认证</h3>
<p>在 Workgroup 环境中，不要依赖隐式凭据。使用服务器本地账户：</p>
<div class="language-cmd line-numbers-mode" data-highlighter="shiki" data-ext="cmd" style="--shiki-light:#383A42;--shiki-dark:#abb2bf;--shiki-light-bg:#FAFAFA;--shiki-dark-bg:#282c34"><pre class="shiki shiki-themes one-light one-dark-pro vp-code"><code class="language-cmd"><span class="line"><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF">net use Z: \\&#x3C;</span><span style="--shiki-light:#C18401;--shiki-dark:#E5C07B">server</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF">-</span><span style="--shiki-light:#A626A4;--shiki-dark:#C678DD">private</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF">-</span><span style="--shiki-light:#E45649;--shiki-dark:#E06C75">ip</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF">>\</span><span style="--shiki-light:#E45649;--shiki-dark:#E06C75">share</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF"> /</span><span style="--shiki-light:#E45649;--shiki-dark:#E06C75">user</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF">:&#x3C;</span><span style="--shiki-light:#C18401;--shiki-dark:#E5C07B">server</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF">-</span><span style="--shiki-light:#E45649;--shiki-dark:#E06C75">computer</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF">-</span><span style="--shiki-light:#E45649;--shiki-dark:#E06C75">name</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF">>\</span><span style="--shiki-light:#E45649;--shiki-dark:#E06C75">Administrator</span></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div></div></div><p>注意 <code>&lt;server-computer-name&gt;</code> 必须是服务端计算机名，不是客户端。</p>
<h3>3. 调整 EDR 策略</h3>
<p>联系安全软件厂商或安全团队，把正常 SMB/NTLM 认证流量加入白名单，避免误拦截。</p>
<h3>4. 长期建议加入域</h3>
<p>如果多台 Windows 实例频繁共享文件，建议加入 Active Directory，使用域账户和组权限统一管理，减少 Workgroup + 本地账户认证的复杂度。</p>
<h2>总结</h2>
<p>EC2 Windows SMB 不通时，不能只看安全组。抓包如果已经看到 SMB 协议协商和认证阶段错误，就说明问题进入 OS 或安全软件层。</p>
<p><code>STATUS_NETLOGON_NOT_STARTED</code> 在 Workgroup 场景下不一定代表 Netlogon 本身是根因。结合后续流量被阻断，EDR 或安全软件拦截是重点排查方向。</p>
]]></content>
    <category term="AWS"/>
    <category term="Windows"/>
    <published>2026-06-03T00:00:00.000Z</published>
  </entry>
  <entry>
    <title type="text">EC2 Windows 根盘导出为 VMDK 并在 VMware 启动</title>
    <id>https://blog.checo.cc/posts/AWS/19.html</id>
    <link href="https://blog.checo.cc/posts/AWS/19.html"/>
    <updated>2026-06-04T13:54:51.000Z</updated>
    <summary type="html"><![CDATA[
<p>从 AWS 公有 Windows AMI 启动的 EC2 实例不能直接通过 VM Import/Export 导出为 VMDK，因为包含 AWS 授权软件。替代方案是停机后块级读取 EBS 根卷，用 <code>qemu-img</code> 转换，并离线启用 Windows 通用存储驱动，避免在 VMware 中蓝屏。</p>
]]></summary>
    <content type="html"><![CDATA[
<p>从 AWS 公有 Windows AMI 启动的 EC2 实例不能直接通过 VM Import/Export 导出为 VMDK，因为包含 AWS 授权软件。替代方案是停机后块级读取 EBS 根卷，用 <code>qemu-img</code> 转换，并离线启用 Windows 通用存储驱动，避免在 VMware 中蓝屏。</p>
<!-- more -->
<h2>VM Export 为什么失败</h2>
<p>执行 <code>create-instance-export-task</code> 时可能报：</p>
<div class="language-text line-numbers-mode" data-highlighter="shiki" data-ext="text" style="--shiki-light:#383A42;--shiki-dark:#abb2bf;--shiki-light-bg:#FAFAFA;--shiki-dark-bg:#282c34"><pre class="shiki shiki-themes one-light one-dark-pro vp-code"><code class="language-text"><span class="line"><span>An error occurred (NotExportable) when calling the CreateInstanceExportTask operation:</span></span>
<span class="line"><span>The image ID (ami-xxxxxxxx) provided contains AWS-licensed software and is not exportable.</span></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div><div class="line-number"></div></div></div><p>这是产品限制，不是 IAM 权限问题。从 AWS 公有 AMI 启动的 Windows / SQL Server / Marketplace 镜像通常不可导出。</p>
<h2>替代方案</h2>
<p>可选方案：</p>
<ul>
<li>实例能登录：用 Disk2vhd。</li>
<li>不想起救援实例：用 coldsnap + qemu-img。</li>
<li>可以停机或系统已崩溃：用救援实例块级读取 EBS，再 qemu-img 转换。</li>
</ul>
<p>本文记录第三种方案。</p>
<h2>关键坑：存储控制器驱动</h2>
<p>EC2 Windows 通常运行在 NVMe 设备上。导出到 VMware 后，控制器可能变成 LSI Logic SAS、SATA 或 IDE。如果 Windows 注册表中这些驱动没有设置为 Boot 加载，启动时会蓝屏：</p>
<div class="language-text line-numbers-mode" data-highlighter="shiki" data-ext="text" style="--shiki-light:#383A42;--shiki-dark:#abb2bf;--shiki-light-bg:#FAFAFA;--shiki-dark-bg:#282c34"><pre class="shiki shiki-themes one-light one-dark-pro vp-code"><code class="language-text"><span class="line"><span>UNMOUNTABLE_BOOT_VOLUME</span></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div></div></div><p>所以转换前要离线修改 SYSTEM hive，把常见存储驱动 Start 值设为 0。</p>
<h2>操作步骤</h2>
<h3>1. 停机并摘卷</h3>
<div class="language-bash line-numbers-mode" data-highlighter="shiki" data-ext="bash" style="--shiki-light:#383A42;--shiki-dark:#abb2bf;--shiki-light-bg:#FAFAFA;--shiki-dark-bg:#282c34"><pre class="shiki shiki-themes one-light one-dark-pro vp-code"><code class="language-bash"><span class="line"><span style="--shiki-light:#4078F2;--shiki-dark:#61AFEF">aws</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379"> ec2</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379"> stop-instances</span><span style="--shiki-light:#986801;--shiki-dark:#D19A66"> --instance-ids</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF"> &#x3C;</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379">instance-i</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF">d></span></span>
<span class="line"><span style="--shiki-light:#4078F2;--shiki-dark:#61AFEF">aws</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379"> ec2</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379"> wait</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379"> instance-stopped</span><span style="--shiki-light:#986801;--shiki-dark:#D19A66"> --instance-ids</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF"> &#x3C;</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379">instance-i</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF">d></span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#4078F2;--shiki-dark:#61AFEF">aws</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379"> ec2</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379"> detach-volume</span><span style="--shiki-light:#986801;--shiki-dark:#D19A66"> --volume-id</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF"> &#x3C;</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379">volume-i</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF">d></span></span>
<span class="line"><span style="--shiki-light:#4078F2;--shiki-dark:#61AFEF">aws</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379"> ec2</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379"> wait</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379"> volume-available</span><span style="--shiki-light:#986801;--shiki-dark:#D19A66"> --volume-ids</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF"> &#x3C;</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379">volume-i</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF">d></span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#4078F2;--shiki-dark:#61AFEF">aws</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379"> ec2</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379"> attach-volume</span><span style="--shiki-light:#0184BC;--shiki-dark:#56B6C2"> \</span></span>
<span class="line"><span style="--shiki-light:#986801;--shiki-dark:#D19A66">  --volume-id</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF"> &#x3C;</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379">volume-i</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF">d> </span><span style="--shiki-light:#0184BC;--shiki-dark:#56B6C2">\</span></span>
<span class="line"><span style="--shiki-light:#986801;--shiki-dark:#D19A66">  --instance-id</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF"> &#x3C;</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379">helper-instance-i</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF">d> </span><span style="--shiki-light:#0184BC;--shiki-dark:#56B6C2">\</span></span>
<span class="line"><span style="--shiki-light:#986801;--shiki-dark:#D19A66">  --device</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379"> /dev/sdg</span></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p>操作前建议先给卷创建快照。</p>
<h3>2. 在救援实例识别磁盘</h3>
<div class="language-bash line-numbers-mode" data-highlighter="shiki" data-ext="bash" style="--shiki-light:#383A42;--shiki-dark:#abb2bf;--shiki-light-bg:#FAFAFA;--shiki-dark-bg:#282c34"><pre class="shiki shiki-themes one-light one-dark-pro vp-code"><code class="language-bash"><span class="line"><span style="--shiki-light:#4078F2;--shiki-dark:#61AFEF">sudo</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379"> lsblk</span><span style="--shiki-light:#986801;--shiki-dark:#D19A66"> -o</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379"> NAME,SIZE,SERIAL,MOUNTPOINT,FSTYPE</span></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div></div></div><p>Nitro 实例上 EBS 会显示为 <code>/dev/nvmeXn1</code>，可以通过 SERIAL 对应卷 ID。</p>
<h3>3. 挂载工作盘</h3>
<div class="language-bash line-numbers-mode" data-highlighter="shiki" data-ext="bash" style="--shiki-light:#383A42;--shiki-dark:#abb2bf;--shiki-light-bg:#FAFAFA;--shiki-dark-bg:#282c34"><pre class="shiki shiki-themes one-light one-dark-pro vp-code"><code class="language-bash"><span class="line"><span style="--shiki-light:#4078F2;--shiki-dark:#61AFEF">sudo</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379"> mkfs.xfs</span><span style="--shiki-light:#986801;--shiki-dark:#D19A66"> -f</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379"> /dev/nvme1n1</span></span>
<span class="line"><span style="--shiki-light:#4078F2;--shiki-dark:#61AFEF">sudo</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379"> mkdir</span><span style="--shiki-light:#986801;--shiki-dark:#D19A66"> -p</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379"> /mnt/work</span></span>
<span class="line"><span style="--shiki-light:#4078F2;--shiki-dark:#61AFEF">sudo</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379"> mount</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379"> /dev/nvme1n1</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379"> /mnt/work</span></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p>工作盘大小要大于目标卷实际输出大小。</p>
<h3>4. 安装工具</h3>
<div class="language-bash line-numbers-mode" data-highlighter="shiki" data-ext="bash" style="--shiki-light:#383A42;--shiki-dark:#abb2bf;--shiki-light-bg:#FAFAFA;--shiki-dark-bg:#282c34"><pre class="shiki shiki-themes one-light one-dark-pro vp-code"><code class="language-bash"><span class="line"><span style="--shiki-light:#4078F2;--shiki-dark:#61AFEF">sudo</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379"> dnf</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379"> install</span><span style="--shiki-light:#986801;--shiki-dark:#D19A66"> -y</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379"> qemu-img</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379"> gcc</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379"> make</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379"> perl</span></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div></div></div><p>如果仓库没有 hivex，需要从源码安装，用于编辑 Windows 注册表 hive。</p>
<h3>5. 挂载 NTFS 并备份 SYSTEM hive</h3>
<div class="language-bash line-numbers-mode" data-highlighter="shiki" data-ext="bash" style="--shiki-light:#383A42;--shiki-dark:#abb2bf;--shiki-light-bg:#FAFAFA;--shiki-dark-bg:#282c34"><pre class="shiki shiki-themes one-light one-dark-pro vp-code"><code class="language-bash"><span class="line"><span style="--shiki-light:#4078F2;--shiki-dark:#61AFEF">sudo</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379"> modprobe</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379"> ntfs3</span></span>
<span class="line"><span style="--shiki-light:#4078F2;--shiki-dark:#61AFEF">sudo</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379"> mkdir</span><span style="--shiki-light:#986801;--shiki-dark:#D19A66"> -p</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379"> /mnt/windows</span></span>
<span class="line"><span style="--shiki-light:#4078F2;--shiki-dark:#61AFEF">sudo</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379"> mount</span><span style="--shiki-light:#986801;--shiki-dark:#D19A66"> -t</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379"> ntfs3</span><span style="--shiki-light:#986801;--shiki-dark:#D19A66"> -o</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379"> rw</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379"> /dev/nvme2n1p1</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379"> /mnt/windows</span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#4078F2;--shiki-dark:#61AFEF">sudo</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379"> cp</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379"> /mnt/windows/Windows/System32/config/SYSTEM</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379"> /mnt/work/SYSTEM_BACKUP</span></span>
<span class="line"><span style="--shiki-light:#4078F2;--shiki-dark:#61AFEF">sudo</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379"> cp</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379"> /mnt/windows/Windows/System32/config/SYSTEM</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379"> /tmp/SYSTEM_EDIT</span></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h3>6. 启用通用存储驱动</h3>
<p>需要把这些服务的 <code>Start</code> 设置为 <code>0</code>：</p>
<p>| 服务 | 用途 |<br>
|</p>
]]></content>
    <category term="AWS"/>
    <category term="Windows"/>
    <published>2026-06-03T00:00:00.000Z</published>
  </entry>
  <entry>
    <title type="text">ALB 证书链断裂导致 curl 报 unable to get local issuer certificate</title>
    <id>https://blog.checo.cc/posts/AWS/3.html</id>
    <link href="https://blog.checo.cc/posts/AWS/3.html"/>
    <updated>2026-06-04T13:54:51.000Z</updated>
    <summary type="html"><![CDATA[
<p>在内网 ALB 上配置 HTTPS 后，客户端访问域名时报 <code>curl: (60) SSL certificate problem: unable to get local issuer certificate</code>。这个错误不一定是网络问题，更常见的是 ALB 绑定的 ACM 证书链不完整，或者证书 SAN 没覆盖访问域名。</p>
]]></summary>
    <content type="html"><![CDATA[
<p>在内网 ALB 上配置 HTTPS 后，客户端访问域名时报 <code>curl: (60) SSL certificate problem: unable to get local issuer certificate</code>。这个错误不一定是网络问题，更常见的是 ALB 绑定的 ACM 证书链不完整，或者证书 SAN 没覆盖访问域名。</p>
<!-- more -->
<h2>现象</h2>
<p>访问内网服务时报错：</p>
<div class="language-bash line-numbers-mode" data-highlighter="shiki" data-ext="bash" style="--shiki-light:#383A42;--shiki-dark:#abb2bf;--shiki-light-bg:#FAFAFA;--shiki-dark-bg:#282c34"><pre class="shiki shiki-themes one-light one-dark-pro vp-code"><code class="language-bash"><span class="line"><span style="--shiki-light:#4078F2;--shiki-dark:#61AFEF">curl</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379"> https://service.example.internal/api/v1/health</span></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div></div></div><div class="language-text line-numbers-mode" data-highlighter="shiki" data-ext="text" style="--shiki-light:#383A42;--shiki-dark:#abb2bf;--shiki-light-bg:#FAFAFA;--shiki-dark-bg:#282c34"><pre class="shiki shiki-themes one-light one-dark-pro vp-code"><code class="language-text"><span class="line"><span>curl: (60) SSL certificate problem: unable to get local issuer certificate</span></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div></div></div><p>架构大致是：</p>
<div class="language-text line-numbers-mode" data-highlighter="shiki" data-ext="text" style="--shiki-light:#383A42;--shiki-dark:#abb2bf;--shiki-light-bg:#FAFAFA;--shiki-dark-bg:#282c34"><pre class="shiki shiki-themes one-light one-dark-pro vp-code"><code class="language-text"><span class="line"><span>客户端 -> 内网 ALB 443 -> 后端目标 443</span></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div></div></div><p>如果绕过 ALB，直接访问后端目标可以成功，就说明后端服务本身大概率不是根因。</p>
<h2>排查思路</h2>
<h3>1. 不要用公网 SSL 检查结果下结论</h3>
<p>如果域名在 Route 53 私有托管区里解析到内网 ALB，公网 SSL checker 看到的可能是另一条公网解析记录。公网检查结果无法代表内网 ALB 实际下发的证书。</p>
<h3>2. 用 openssl 看 ALB 实际证书</h3>
<p>在内网客户端执行：</p>
<div class="language-bash line-numbers-mode" data-highlighter="shiki" data-ext="bash" style="--shiki-light:#383A42;--shiki-dark:#abb2bf;--shiki-light-bg:#FAFAFA;--shiki-dark-bg:#282c34"><pre class="shiki shiki-themes one-light one-dark-pro vp-code"><code class="language-bash"><span class="line"><span style="--shiki-light:#4078F2;--shiki-dark:#61AFEF">openssl</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379"> s_client</span><span style="--shiki-light:#986801;--shiki-dark:#D19A66"> -showcerts</span><span style="--shiki-light:#0184BC;--shiki-dark:#56B6C2"> \</span></span>
<span class="line"><span style="--shiki-light:#986801;--shiki-dark:#D19A66">  -connect</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF"> &#x3C;</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379">alb-dns-nam</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF">e></span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379">:443</span><span style="--shiki-light:#0184BC;--shiki-dark:#56B6C2"> \</span></span>
<span class="line"><span style="--shiki-light:#986801;--shiki-dark:#D19A66">  -servername</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379"> service.example.internal</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF"> &#x3C;</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379">/dev/null</span></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p>重点看两件事：</p>
<ul>
<li>证书 SAN/CN 是否覆盖访问域名。</li>
<li>ALB 下发的中间证书是否和站点证书签发链匹配。</li>
</ul>
<h3>3. 区分两个问题</h3>
<p>证书链断裂和域名不匹配是两个不同问题：</p>
<ul>
<li>链断裂会导致客户端找不到可信上级 CA。</li>
<li>SAN 不覆盖域名会导致主机名校验失败。</li>
</ul>
<p>两者任何一个存在，HTTPS 都可能失败。</p>
<h2>根因</h2>
<p>案例中站点证书由某个 DV 中间 CA 签发，但导入 ACM 时附带的是另一个 OV 中间 CA。ALB 因此向客户端下发了不匹配的中间证书链，curl 无法构建完整信任链。</p>
<p>同时，ALB 绑定证书的 SAN 也没有覆盖实际访问域名。也就是说，即使证书链修好，仍然会因为域名不匹配继续失败。</p>
<h2>解决方案</h2>
<h3>1. 修正 ACM 证书链</h3>
<p>重新导入原 ACM 证书，上传正确的中间证书链：</p>
<div class="language-bash line-numbers-mode" data-highlighter="shiki" data-ext="bash" style="--shiki-light:#383A42;--shiki-dark:#abb2bf;--shiki-light-bg:#FAFAFA;--shiki-dark-bg:#282c34"><pre class="shiki shiki-themes one-light one-dark-pro vp-code"><code class="language-bash"><span class="line"><span style="--shiki-light:#4078F2;--shiki-dark:#61AFEF">aws</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379"> acm</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379"> import-certificate</span><span style="--shiki-light:#0184BC;--shiki-dark:#56B6C2"> \</span></span>
<span class="line"><span style="--shiki-light:#986801;--shiki-dark:#D19A66">  --certificate-arn</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF"> &#x3C;</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379">certificate-ar</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF">n> </span><span style="--shiki-light:#0184BC;--shiki-dark:#56B6C2">\</span></span>
<span class="line"><span style="--shiki-light:#986801;--shiki-dark:#D19A66">  --certificate</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379"> fileb://site.crt</span><span style="--shiki-light:#0184BC;--shiki-dark:#56B6C2"> \</span></span>
<span class="line"><span style="--shiki-light:#986801;--shiki-dark:#D19A66">  --private-key</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379"> fileb://site.key</span><span style="--shiki-light:#0184BC;--shiki-dark:#56B6C2"> \</span></span>
<span class="line"><span style="--shiki-light:#986801;--shiki-dark:#D19A66">  --certificate-chain</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379"> fileb://correct-chain.crt</span></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p>使用 reimport 的好处是保留原 ARN，ALB 侦听器不需要重新选择证书。</p>
<h3>2. 确保证书覆盖访问域名</h3>
<p>检查证书 SAN 是否包含实际使用的域名：</p>
<div class="language-bash line-numbers-mode" data-highlighter="shiki" data-ext="bash" style="--shiki-light:#383A42;--shiki-dark:#abb2bf;--shiki-light-bg:#FAFAFA;--shiki-dark-bg:#282c34"><pre class="shiki shiki-themes one-light one-dark-pro vp-code"><code class="language-bash"><span class="line"><span style="--shiki-light:#4078F2;--shiki-dark:#61AFEF">openssl</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379"> x509</span><span style="--shiki-light:#986801;--shiki-dark:#D19A66"> -in</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379"> site.crt</span><span style="--shiki-light:#986801;--shiki-dark:#D19A66"> -noout</span><span style="--shiki-light:#986801;--shiki-dark:#D19A66"> -text</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF"> | </span><span style="--shiki-light:#4078F2;--shiki-dark:#61AFEF">grep</span><span style="--shiki-light:#986801;--shiki-dark:#D19A66"> -A1</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379"> "Subject Alternative Name"</span></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div></div></div><p>如果不包含，需要申请或导入一张覆盖目标域名的新证书，并绑定到 ALB HTTPS 侦听器。</p>
<h3>3. 清理 ALB 侦听器证书</h3>
<p>如果 ALB 上挂了多张证书，建议清理不再使用的证书，避免 SNI 匹配和运维判断混乱。</p>
<h2>总结</h2>
<p>ALB HTTPS 报 <code>unable to get local issuer certificate</code> 时，排查重点是 ALB 实际下发的证书链，而不是后端 Nginx 或公网 SSL 检查结果。</p>
<p>推荐固定排查顺序：</p>
<ol>
<li>在内网用 <code>openssl s_client -showcerts</code> 看 ALB 下发证书。</li>
<li>检查 SAN/CN 是否覆盖访问域名。</li>
<li>检查中间证书是否与站点证书签发链匹配。</li>
<li>用 ACM reimport 修正证书链，必要时更换侦听器证书。</li>
</ol>
]]></content>
    <category term="AWS"/>
    <published>2026-06-03T00:00:00.000Z</published>
  </entry>
  <entry>
    <title type="text">统计 S3 桶内特定扩展名对象数量与容量</title>
    <id>https://blog.checo.cc/posts/AWS/4.html</id>
    <link href="https://blog.checo.cc/posts/AWS/4.html"/>
    <updated>2026-06-04T13:54:51.000Z</updated>
    <summary type="html"><![CDATA[
<p>有时需要临时统计一个 S3 桶中某类文件的数量和容量，例如 <code>.jpg</code>、<code>.png</code> 图片对象。如果桶开启了版本控制，还要把历史版本也算进去。这种需求不一定适合等 S3 Inventory，AWS CLI 直接流式统计更快。</p>
]]></summary>
    <content type="html"><![CDATA[
<p>有时需要临时统计一个 S3 桶中某类文件的数量和容量，例如 <code>.jpg</code>、<code>.png</code> 图片对象。如果桶开启了版本控制，还要把历史版本也算进去。这种需求不一定适合等 S3 Inventory，AWS CLI 直接流式统计更快。</p>
<!-- more -->
<h2>场景</h2>
<p>目标是统计某个开启版本控制的 S3 桶内：</p>
<ul>
<li>指定扩展名对象数量。</li>
<li>指定扩展名对象总容量。</li>
<li>包含所有历史版本，而不只是当前版本。</li>
</ul>
<p>如果业务要求“现在就要结果”，S3 Inventory 不一定合适，因为它是异步报表，首次生成通常有延迟。</p>
<h2>为什么用 list-object-versions</h2>
<p>普通 <code>list-objects</code> 只看当前对象版本，不能覆盖历史版本。开启版本控制的桶应使用：</p>
<div class="language-bash line-numbers-mode" data-highlighter="shiki" data-ext="bash" style="--shiki-light:#383A42;--shiki-dark:#abb2bf;--shiki-light-bg:#FAFAFA;--shiki-dark-bg:#282c34"><pre class="shiki shiki-themes one-light one-dark-pro vp-code"><code class="language-bash"><span class="line"><span style="--shiki-light:#4078F2;--shiki-dark:#61AFEF">aws</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379"> s3api</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379"> list-object-versions</span></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div></div></div><p>再通过 <code>--query 'Versions[*].[Key, Size]'</code> 只取对象 Key 和 Size，减少后续处理成本。</p>
<h2>统计命令</h2>
<p>下面示例统计 <code>.jpg</code> 和 <code>.png</code>：</p>
<div class="language-bash line-numbers-mode" data-highlighter="shiki" data-ext="bash" style="--shiki-light:#383A42;--shiki-dark:#abb2bf;--shiki-light-bg:#FAFAFA;--shiki-dark-bg:#282c34"><pre class="shiki shiki-themes one-light one-dark-pro vp-code"><code class="language-bash"><span class="line"><span style="--shiki-light:#4078F2;--shiki-dark:#61AFEF">aws</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379"> s3api</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379"> list-object-versions</span><span style="--shiki-light:#0184BC;--shiki-dark:#56B6C2"> \</span></span>
<span class="line"><span style="--shiki-light:#986801;--shiki-dark:#D19A66">  --bucket</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF"> &#x3C;</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379">bucket-nam</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF">e> </span><span style="--shiki-light:#0184BC;--shiki-dark:#56B6C2">\</span></span>
<span class="line"><span style="--shiki-light:#986801;--shiki-dark:#D19A66">  --region</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF"> &#x3C;</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379">regio</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF">n> </span><span style="--shiki-light:#0184BC;--shiki-dark:#56B6C2">\</span></span>
<span class="line"><span style="--shiki-light:#986801;--shiki-dark:#D19A66">  --query</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379"> 'Versions[*].[Key, Size]'</span><span style="--shiki-light:#0184BC;--shiki-dark:#56B6C2"> \</span></span>
<span class="line"><span style="--shiki-light:#986801;--shiki-dark:#D19A66">  --output</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379"> text</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF"> |</span></span>
<span class="line"><span style="--shiki-light:#4078F2;--shiki-dark:#61AFEF">grep</span><span style="--shiki-light:#986801;--shiki-dark:#D19A66"> -Ei</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379"> "\.(jpg|png)[[:space:]]+[0-9]+$"</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF"> |</span></span>
<span class="line"><span style="--shiki-light:#4078F2;--shiki-dark:#61AFEF">awk</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379"> '</span></span>
<span class="line"><span style="--shiki-light:#50A14F;--shiki-dark:#98C379">BEGIN {</span></span>
<span class="line"><span style="--shiki-light:#50A14F;--shiki-dark:#98C379">  fmt = "图片对象总数（含历史版本）: %d\n"</span></span>
<span class="line"><span style="--shiki-light:#50A14F;--shiki-dark:#98C379">}</span></span>
<span class="line"><span style="--shiki-light:#50A14F;--shiki-dark:#98C379">{</span></span>
<span class="line"><span style="--shiki-light:#50A14F;--shiki-dark:#98C379">  count++;</span></span>
<span class="line"><span style="--shiki-light:#50A14F;--shiki-dark:#98C379">  size += $NF;</span></span>
<span class="line"><span style="--shiki-light:#50A14F;--shiki-dark:#98C379">}</span></span>
<span class="line"><span style="--shiki-light:#50A14F;--shiki-dark:#98C379">END {</span></span>
<span class="line"><span style="--shiki-light:#50A14F;--shiki-dark:#98C379">  print "======================";</span></span>
<span class="line"><span style="--shiki-light:#50A14F;--shiki-dark:#98C379">  printf fmt, count;</span></span>
<span class="line"><span style="--shiki-light:#50A14F;--shiki-dark:#98C379">  printf "总容量（含历史版本）: %.2f GB\n", size/1024/1024/1024;</span></span>
<span class="line"><span style="--shiki-light:#50A14F;--shiki-dark:#98C379">  print "======================";</span></span>
<span class="line"><span style="--shiki-light:#50A14F;--shiki-dark:#98C379">}'</span></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p>示例输出：</p>
<div class="language-text line-numbers-mode" data-highlighter="shiki" data-ext="text" style="--shiki-light:#383A42;--shiki-dark:#abb2bf;--shiki-light-bg:#FAFAFA;--shiki-dark-bg:#282c34"><pre class="shiki shiki-themes one-light one-dark-pro vp-code"><code class="language-text"><span class="line"><span>======================</span></span>
<span class="line"><span>图片对象总数（含历史版本）: 120446</span></span>
<span class="line"><span>总容量（含历史版本）: 56.33 GB</span></span>
<span class="line"><span>======================</span></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h2>注意事项</h2>
<ul>
<li>建议在同区域 EC2 上执行，减少网络延迟。</li>
<li>如果对象很多，CLI 调用会产生 List 请求费用。</li>
<li>如果要统计当前版本，不要用 <code>list-object-versions</code>，改用 <code>list-objects-v2</code>。</li>
<li>如果对象规模特别大、可接受延迟，S3 Inventory 更适合做周期性报表。</li>
<li>如果 Key 中包含换行等特殊字符，文本管道处理会有边界问题，严谨场景建议用 JSON + jq。</li>
</ul>
<h2>总结</h2>
<p>紧急统计 S3 桶中特定扩展名对象时，<code>list-object-versions + grep + awk</code> 是一个简单有效的方案。它的优点是实时、轻量、无需等待 Inventory；缺点是更偏一次性统计，不适合长期周期报表。</p>
]]></content>
    <category term="AWS"/>
    <published>2026-04-25T00:00:00.000Z</published>
  </entry>
  <entry>
    <title type="text">SAML 联合登录后限制特定用户通过控制台登录 EC2</title>
    <id>https://blog.checo.cc/posts/AWS/5.html</id>
    <link href="https://blog.checo.cc/posts/AWS/5.html"/>
    <updated>2026-06-04T13:54:51.000Z</updated>
    <summary type="html"><![CDATA[
<p>在 AD + SAML 联合身份场景下，用户可能通过同一个高权限 IAM Role 登录 AWS 控制台。如果只想限制其中一部分用户不能使用 Session Manager 或 EC2 Instance Connect 登录实例，可以用 <code>aws:userid</code> 条件键做显式 Deny。</p>
]]></summary>
    <content type="html"><![CDATA[
<p>在 AD + SAML 联合身份场景下，用户可能通过同一个高权限 IAM Role 登录 AWS 控制台。如果只想限制其中一部分用户不能使用 Session Manager 或 EC2 Instance Connect 登录实例，可以用 <code>aws:userid</code> 条件键做显式 Deny。</p>
<!-- more -->
<h2>场景</h2>
<p>客户环境中大量域用户通过 SAML AssumeRole 登录 AWS 控制台，使用的可能是 <code>PowerUser</code> 或 <code>Administrator</code> 这类高权限 Role。</p>
<p>出于合规要求，需要限制某些用户不能通过控制台进入 EC2 实例，主要涉及两类能力：</p>
<ul>
<li>SSM Session Manager：<code>ssm:StartSession</code></li>
<li>EC2 Instance Connect：<code>ec2-instance-connect:SendSSHPublicKey</code></li>
</ul>
<h2>为什么不用 RoleSessionName</h2>
<p>SAML 联合登录后，IAM 会生成会话标识。策略判断时更稳定可用的是全局条件键 <code>aws:userid</code>。它通常包含角色 ID 和会话名称，形式类似：</p>
<div class="language-text line-numbers-mode" data-highlighter="shiki" data-ext="text" style="--shiki-light:#383A42;--shiki-dark:#abb2bf;--shiki-light-bg:#FAFAFA;--shiki-dark-bg:#282c34"><pre class="shiki shiki-themes one-light one-dark-pro vp-code"><code class="language-text"><span class="line"><span>&#x3C;role-id>:&#x3C;session-name></span></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div></div></div><p>因为 role ID 部分会随 Role 变化，不适合硬编码，所以可以用通配符匹配会话后缀：</p>
<div class="language-text line-numbers-mode" data-highlighter="shiki" data-ext="text" style="--shiki-light:#383A42;--shiki-dark:#abb2bf;--shiki-light-bg:#FAFAFA;--shiki-dark-bg:#282c34"><pre class="shiki shiki-themes one-light one-dark-pro vp-code"><code class="language-text"><span class="line"><span>*:user-or-ou-id</span></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div></div></div><h2>示例策略</h2>
<p>在目标 IAM Role 上增加一个显式 Deny：</p>
<div class="language-json line-numbers-mode" data-highlighter="shiki" data-ext="json" style="--shiki-light:#383A42;--shiki-dark:#abb2bf;--shiki-light-bg:#FAFAFA;--shiki-dark-bg:#282c34"><pre class="shiki shiki-themes one-light one-dark-pro vp-code"><code class="language-json"><span class="line"><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF">{</span></span>
<span class="line"><span style="--shiki-light:#E45649;--shiki-dark:#E06C75">  "Version"</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF">: </span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379">"2012-10-17"</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF">,</span></span>
<span class="line"><span style="--shiki-light:#E45649;--shiki-dark:#E06C75">  "Statement"</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF">: [</span></span>
<span class="line"><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF">    {</span></span>
<span class="line"><span style="--shiki-light:#E45649;--shiki-dark:#E06C75">      "Sid"</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF">: </span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379">"DenyEC2LoginForSpecificFederatedUsers"</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF">,</span></span>
<span class="line"><span style="--shiki-light:#E45649;--shiki-dark:#E06C75">      "Effect"</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF">: </span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379">"Deny"</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF">,</span></span>
<span class="line"><span style="--shiki-light:#E45649;--shiki-dark:#E06C75">      "Action"</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF">: [</span></span>
<span class="line"><span style="--shiki-light:#50A14F;--shiki-dark:#98C379">        "ssm:StartSession"</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF">,</span></span>
<span class="line"><span style="--shiki-light:#50A14F;--shiki-dark:#98C379">        "ec2-instance-connect:SendSSHPublicKey"</span></span>
<span class="line"><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF">      ],</span></span>
<span class="line"><span style="--shiki-light:#E45649;--shiki-dark:#E06C75">      "Resource"</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF">: </span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379">"*"</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF">,</span></span>
<span class="line"><span style="--shiki-light:#E45649;--shiki-dark:#E06C75">      "Condition"</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF">: {</span></span>
<span class="line"><span style="--shiki-light:#E45649;--shiki-dark:#E06C75">        "StringLike"</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF">: {</span></span>
<span class="line"><span style="--shiki-light:#E45649;--shiki-dark:#E06C75">          "aws:userid"</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF">: [</span></span>
<span class="line"><span style="--shiki-light:#50A14F;--shiki-dark:#98C379">            "*:&#x3C;user-or-ou-id>"</span></span>
<span class="line"><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF">          ]</span></span>
<span class="line"><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF">        }</span></span>
<span class="line"><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF">      }</span></span>
<span class="line"><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF">    }</span></span>
<span class="line"><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF">  ]</span></span>
<span class="line"><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF">}</span></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p>显式 Deny 优先级高于 Allow，所以即使 Role 里已有高权限策略，匹配条件的用户仍会被拦截。</p>
<h2>验证方式</h2>
<ol>
<li>使用目标 SAML 用户登录控制台。</li>
<li>尝试通过 Session Manager 连接 EC2。</li>
<li>尝试使用 EC2 Instance Connect。</li>
<li>再用非受限用户验证不受影响。</li>
</ol>
<p>如果 Deny 生效，目标用户会在调用相关 API 时被拒绝。</p>
<h2>更推荐的长期方案</h2>
<p>基于 <code>aws:userid</code> 硬编码用户后缀能快速解决问题，但维护成本高。更好的方式是从身份源层面拆分权限：</p>
<ul>
<li>在 AD 中建立受限用户组，例如 <code>AWS-No-EC2-Login</code>。</li>
<li>在 IdP 中把不同用户组映射到不同 IAM Role。</li>
<li>创建专门的受限 Role，不授予 EC2 登录能力。</li>
</ul>
<p>这样权限边界更清晰，也更容易审计和自动化管理。</p>
<h2>总结</h2>
<p>如果需要临时限制部分 SAML 用户通过控制台登录 EC2，可以用 <code>aws:userid</code> + 显式 Deny 精准拦截 <code>ssm:StartSession</code> 和 <code>ec2-instance-connect:SendSSHPublicKey</code>。</p>
<p>长期来看，建议把用户分组和 Role 映射放到身份源侧管理，而不是在一个高权限 Role 里维护越来越复杂的条件策略。</p>
]]></content>
    <category term="AWS"/>
    <category term="安全"/>
    <published>2026-04-06T00:00:00.000Z</published>
  </entry>
  <entry>
    <title type="text">Amazon Linux 2 扩容 EBS 后 growpart 失败</title>
    <id>https://blog.checo.cc/posts/AWS/6.html</id>
    <link href="https://blog.checo.cc/posts/AWS/6.html"/>
    <updated>2026-06-04T13:54:51.000Z</updated>
    <summary type="html"><![CDATA[
<p>EBS 卷在控制台扩容后，还需要在操作系统内扩展分区和文件系统。如果根分区已经 100% 满了，<code>growpart</code> 可能会因为无法写临时文件而失败，错误看起来像是 <code>sfdisk</code> 问题。</p>
]]></summary>
    <content type="html"><![CDATA[
<p>EBS 卷在控制台扩容后，还需要在操作系统内扩展分区和文件系统。如果根分区已经 100% 满了，<code>growpart</code> 可能会因为无法写临时文件而失败，错误看起来像是 <code>sfdisk</code> 问题。</p>
<!-- more -->
<h2>现象</h2>
<p>执行分区扩容：</p>
<div class="language-bash line-numbers-mode" data-highlighter="shiki" data-ext="bash" style="--shiki-light:#383A42;--shiki-dark:#abb2bf;--shiki-light-bg:#FAFAFA;--shiki-dark-bg:#282c34"><pre class="shiki shiki-themes one-light one-dark-pro vp-code"><code class="language-bash"><span class="line"><span style="--shiki-light:#4078F2;--shiki-dark:#61AFEF">sudo</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379"> growpart</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379"> /dev/nvme0n1</span><span style="--shiki-light:#986801;--shiki-dark:#D19A66"> 1</span></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div></div></div><p>返回类似错误：</p>
<div class="language-text line-numbers-mode" data-highlighter="shiki" data-ext="text" style="--shiki-light:#383A42;--shiki-dark:#abb2bf;--shiki-light-bg:#FAFAFA;--shiki-dark-bg:#282c34"><pre class="shiki shiki-themes one-light one-dark-pro vp-code"><code class="language-text"><span class="line"><span>failed [sfd_list:1] sfdisk --list --unit=S /dev/nvme0n1</span></span>
<span class="line"><span>FAILED: failed: sfdisk --list /dev/nvme0n1</span></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div><div class="line-number"></div></div></div><p>环境通常是：</p>
<ul>
<li>Nitro 架构实例。</li>
<li>Amazon Linux 2。</li>
<li>根文件系统为 XFS。</li>
<li>设备名为 <code>/dev/nvme0n1</code>，根分区是 <code>/dev/nvme0n1p1</code>。</li>
<li><code>/</code> 已经接近或达到 100%。</li>
</ul>
<h2>根因</h2>
<p><code>growpart</code> 执行时需要在系统目录中创建临时文件并重写分区表。如果根文件系统已经满到只剩几十 KB，底层 <code>sfdisk</code> 调用可能无法正常完成，于是表现为分区扩容失败。</p>
<p>这时首要任务不是继续反复执行 <code>growpart</code>，而是先释放一点根分区空间。</p>
<h2>处理步骤</h2>
<h3>1. 清理 yum 缓存</h3>
<p>Amazon Linux 2 上可以先清理 yum 缓存：</p>
<div class="language-bash line-numbers-mode" data-highlighter="shiki" data-ext="bash" style="--shiki-light:#383A42;--shiki-dark:#abb2bf;--shiki-light-bg:#FAFAFA;--shiki-dark-bg:#282c34"><pre class="shiki shiki-themes one-light one-dark-pro vp-code"><code class="language-bash"><span class="line"><span style="--shiki-light:#4078F2;--shiki-dark:#61AFEF">sudo</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379"> yum</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379"> clean</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379"> all</span></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div></div></div><p>确认根分区至少有几 MB 可用空间：</p>
<div class="language-bash line-numbers-mode" data-highlighter="shiki" data-ext="bash" style="--shiki-light:#383A42;--shiki-dark:#abb2bf;--shiki-light-bg:#FAFAFA;--shiki-dark-bg:#282c34"><pre class="shiki shiki-themes one-light one-dark-pro vp-code"><code class="language-bash"><span class="line"><span style="--shiki-light:#4078F2;--shiki-dark:#61AFEF">df</span><span style="--shiki-light:#986801;--shiki-dark:#D19A66"> -h</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379"> /</span></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div></div></div><h3>2. 扩展分区</h3>
<div class="language-bash line-numbers-mode" data-highlighter="shiki" data-ext="bash" style="--shiki-light:#383A42;--shiki-dark:#abb2bf;--shiki-light-bg:#FAFAFA;--shiki-dark-bg:#282c34"><pre class="shiki shiki-themes one-light one-dark-pro vp-code"><code class="language-bash"><span class="line"><span style="--shiki-light:#4078F2;--shiki-dark:#61AFEF">sudo</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379"> growpart</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379"> /dev/nvme0n1</span><span style="--shiki-light:#986801;--shiki-dark:#D19A66"> 1</span></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div></div></div><h3>3. 扩展 XFS 文件系统</h3>
<p>XFS 需要用挂载点扩容：</p>
<div class="language-bash line-numbers-mode" data-highlighter="shiki" data-ext="bash" style="--shiki-light:#383A42;--shiki-dark:#abb2bf;--shiki-light-bg:#FAFAFA;--shiki-dark-bg:#282c34"><pre class="shiki shiki-themes one-light one-dark-pro vp-code"><code class="language-bash"><span class="line"><span style="--shiki-light:#4078F2;--shiki-dark:#61AFEF">sudo</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379"> xfs_growfs</span><span style="--shiki-light:#986801;--shiki-dark:#D19A66"> -d</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379"> /</span></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div></div></div><p>如果是 ext4，则应使用：</p>
<div class="language-bash line-numbers-mode" data-highlighter="shiki" data-ext="bash" style="--shiki-light:#383A42;--shiki-dark:#abb2bf;--shiki-light-bg:#FAFAFA;--shiki-dark-bg:#282c34"><pre class="shiki shiki-themes one-light one-dark-pro vp-code"><code class="language-bash"><span class="line"><span style="--shiki-light:#4078F2;--shiki-dark:#61AFEF">sudo</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379"> resize2fs</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379"> /dev/nvme0n1p1</span></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div></div></div><h3>4. 验证</h3>
<div class="language-bash line-numbers-mode" data-highlighter="shiki" data-ext="bash" style="--shiki-light:#383A42;--shiki-dark:#abb2bf;--shiki-light-bg:#FAFAFA;--shiki-dark-bg:#282c34"><pre class="shiki shiki-themes one-light one-dark-pro vp-code"><code class="language-bash"><span class="line"><span style="--shiki-light:#4078F2;--shiki-dark:#61AFEF">df</span><span style="--shiki-light:#986801;--shiki-dark:#D19A66"> -hT</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379"> /</span></span>
<span class="line"><span style="--shiki-light:#4078F2;--shiki-dark:#61AFEF">lsblk</span></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div><div class="line-number"></div></div></div><p>确认根分区大小和可用空间已经更新。</p>
<h2>注意事项</h2>
<ul>
<li>EBS 控制台修改卷大小后，需要等待状态完成再进系统扩容。</li>
<li>单个 EBS 卷有修改频率限制，不要频繁试错扩容。</li>
<li>根分区快满时，建议优先清理缓存、旧日志和临时文件。</li>
<li>长期建议用 CloudWatch Agent 采集磁盘使用率，提前告警。</li>
</ul>
<h2>总结</h2>
<p><code>growpart</code> 报 <code>sfdisk</code> 失败不一定是分区表坏了，也可能只是根文件系统没有空间让工具运行。对 Amazon Linux 2 + XFS 的根卷扩容，可以按这个顺序处理：</p>
<ol>
<li>清理出少量空间。</li>
<li><code>growpart</code> 扩分区。</li>
<li><code>xfs_growfs</code> 扩文件系统。</li>
<li><code>df -hT</code> 验证。</li>
</ol>
]]></content>
    <category term="AWS"/>
    <category term="Linux"/>
    <published>2026-04-25T00:00:00.000Z</published>
  </entry>
  <entry>
    <title type="text">RHEL EC2 启动失败与实例状态检查异常排查</title>
    <id>https://blog.checo.cc/posts/AWS/7.html</id>
    <link href="https://blog.checo.cc/posts/AWS/7.html"/>
    <updated>2026-06-04T13:54:51.000Z</updated>
    <summary type="html"><![CDATA[
<p>EC2 Linux 实例无法启动或实例状态检查失败时，问题可能同时存在于 AWS 控制面和操作系统内部。这个案例里，一部分是 KMS 权限导致加密 EBS 无法解密，另一部分是 <code>/etc/fstab</code> 使用不稳定设备名导致系统进入维护模式。</p>
]]></summary>
    <content type="html"><![CDATA[
<p>EC2 Linux 实例无法启动或实例状态检查失败时，问题可能同时存在于 AWS 控制面和操作系统内部。这个案例里，一部分是 KMS 权限导致加密 EBS 无法解密，另一部分是 <code>/etc/fstab</code> 使用不稳定设备名导致系统进入维护模式。</p>
<!-- more -->
<h2>现象</h2>
<p>故障分成两类：</p>
<ol>
<li>实例启动失败，CloudTrail 中能看到 KMS <code>CreateGrant</code> 或 <code>Decrypt</code> 权限不足。</li>
<li>实例可以尝试启动，但系统日志卡在：</li>
</ol>
<div class="language-text line-numbers-mode" data-highlighter="shiki" data-ext="text" style="--shiki-light:#383A42;--shiki-dark:#abb2bf;--shiki-light-bg:#FAFAFA;--shiki-dark-bg:#282c34"><pre class="shiki shiki-themes one-light one-dark-pro vp-code"><code class="language-text"><span class="line"><span>Give root password for maintenance</span></span>
<span class="line"><span>(or press Control-D to continue):</span></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div><div class="line-number"></div></div></div><p>第二种情况会导致 OS 无法完整启动，实例无法响应底层健康检查，最终表现为实例状态检查异常。</p>
<h2>问题一：KMS 权限不足</h2>
<p>如果 EBS 卷使用 KMS CMK 加密，启动实例的 IAM 角色必须具备使用该 KMS key 的权限。至少需要：</p>
<div class="language-json line-numbers-mode" data-highlighter="shiki" data-ext="json" style="--shiki-light:#383A42;--shiki-dark:#abb2bf;--shiki-light-bg:#FAFAFA;--shiki-dark-bg:#282c34"><pre class="shiki shiki-themes one-light one-dark-pro vp-code"><code class="language-json"><span class="line"><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF">{</span></span>
<span class="line"><span style="--shiki-light:#E45649;--shiki-dark:#E06C75">  "Effect"</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF">: </span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379">"Allow"</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF">,</span></span>
<span class="line"><span style="--shiki-light:#E45649;--shiki-dark:#E06C75">  "Action"</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF">: [</span></span>
<span class="line"><span style="--shiki-light:#50A14F;--shiki-dark:#98C379">    "kms:Decrypt"</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF">,</span></span>
<span class="line"><span style="--shiki-light:#50A14F;--shiki-dark:#98C379">    "kms:GenerateDataKey"</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF">,</span></span>
<span class="line"><span style="--shiki-light:#50A14F;--shiki-dark:#98C379">    "kms:CreateGrant"</span></span>
<span class="line"><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF">  ],</span></span>
<span class="line"><span style="--shiki-light:#E45649;--shiki-dark:#E06C75">  "Resource"</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF">: </span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379">"arn:aws-cn:kms:&#x3C;region>:&#x3C;account-id>:key/&#x3C;key-id>"</span></span>
<span class="line"><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF">}</span></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p>如果角色没有权限，EC2 在启动阶段无法解密系统盘或数据盘，实例就会启动失败。</p>
<h2>问题二：fstab 阻塞启动</h2>
<p>Linux 上 NVMe 设备名可能随重启或底层变化改变。如果 <code>/etc/fstab</code> 中写死了类似：</p>
<div class="language-text line-numbers-mode" data-highlighter="shiki" data-ext="text" style="--shiki-light:#383A42;--shiki-dark:#abb2bf;--shiki-light-bg:#FAFAFA;--shiki-dark-bg:#282c34"><pre class="shiki shiki-themes one-light one-dark-pro vp-code"><code class="language-text"><span class="line"><span>/dev/nvme2n1p1 /data ext4 defaults 1 2</span></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div></div></div><p>当设备名变化或卷不存在时，系统会在启动阶段等待挂载，最终进入 emergency / maintenance 模式。</p>
<p>更稳的写法是用 UUID 并加 <code>nofail</code>：</p>
<div class="language-text line-numbers-mode" data-highlighter="shiki" data-ext="text" style="--shiki-light:#383A42;--shiki-dark:#abb2bf;--shiki-light-bg:#FAFAFA;--shiki-dark-bg:#282c34"><pre class="shiki shiki-themes one-light one-dark-pro vp-code"><code class="language-text"><span class="line"><span>UUID=&#x3C;volume-uuid> /data ext4 defaults,nofail 1 2</span></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div></div></div><p>网络文件系统还应加 <code>_netdev</code>：</p>
<div class="language-text line-numbers-mode" data-highlighter="shiki" data-ext="text" style="--shiki-light:#383A42;--shiki-dark:#abb2bf;--shiki-light-bg:#FAFAFA;--shiki-dark-bg:#282c34"><pre class="shiki shiki-themes one-light one-dark-pro vp-code"><code class="language-text"><span class="line"><span>server:/share /mnt/share nfs defaults,_netdev,nofail 0 0</span></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div></div></div><h2>通过救援实例修复 fstab</h2>
<h3>1. 准备救援实例</h3>
<p>在同可用区启动一台 Linux 救援实例。停止原实例后，分离原根卷并挂载到救援实例。</p>
<h3>2. 挂载原系统根分区</h3>
<p>如果原系统使用 LVM，先安装工具并激活卷组：</p>
<div class="language-bash line-numbers-mode" data-highlighter="shiki" data-ext="bash" style="--shiki-light:#383A42;--shiki-dark:#abb2bf;--shiki-light-bg:#FAFAFA;--shiki-dark-bg:#282c34"><pre class="shiki shiki-themes one-light one-dark-pro vp-code"><code class="language-bash"><span class="line"><span style="--shiki-light:#4078F2;--shiki-dark:#61AFEF">sudo</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379"> dnf</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379"> install</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379"> lvm2</span><span style="--shiki-light:#986801;--shiki-dark:#D19A66"> -y</span></span>
<span class="line"><span style="--shiki-light:#4078F2;--shiki-dark:#61AFEF">sudo</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379"> vgscan</span></span>
<span class="line"><span style="--shiki-light:#4078F2;--shiki-dark:#61AFEF">sudo</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379"> vgchange</span><span style="--shiki-light:#986801;--shiki-dark:#D19A66"> -ay</span></span>
<span class="line"><span style="--shiki-light:#4078F2;--shiki-dark:#61AFEF">sudo</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379"> lvs</span></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p>挂载原根分区：</p>
<div class="language-bash line-numbers-mode" data-highlighter="shiki" data-ext="bash" style="--shiki-light:#383A42;--shiki-dark:#abb2bf;--shiki-light-bg:#FAFAFA;--shiki-dark-bg:#282c34"><pre class="shiki shiki-themes one-light one-dark-pro vp-code"><code class="language-bash"><span class="line"><span style="--shiki-light:#4078F2;--shiki-dark:#61AFEF">sudo</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379"> mkdir</span><span style="--shiki-light:#986801;--shiki-dark:#D19A66"> -p</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379"> /mnt/rescue</span></span>
<span class="line"><span style="--shiki-light:#4078F2;--shiki-dark:#61AFEF">sudo</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379"> mount</span><span style="--shiki-light:#986801;--shiki-dark:#D19A66"> -o</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379"> nouuid</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379"> /dev/</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF">&#x3C;</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379">vg-nam</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF">e></span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379">/</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF">&#x3C;</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379">root-l</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF">v> </span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379">/mnt/rescue</span></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div><div class="line-number"></div></div></div><h3>3. 修改 fstab</h3>
<div class="language-bash line-numbers-mode" data-highlighter="shiki" data-ext="bash" style="--shiki-light:#383A42;--shiki-dark:#abb2bf;--shiki-light-bg:#FAFAFA;--shiki-dark-bg:#282c34"><pre class="shiki shiki-themes one-light one-dark-pro vp-code"><code class="language-bash"><span class="line"><span style="--shiki-light:#4078F2;--shiki-dark:#61AFEF">sudo</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379"> vi</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379"> /mnt/rescue/etc/fstab</span></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div></div></div><p>先把有风险的数据盘挂载项注释掉，让系统能启动。启动后再用 <code>lsblk -f</code> 获取 UUID，改成稳定配置。</p>
<h3>4. 卸载并挂回原实例</h3>
<div class="language-bash line-numbers-mode" data-highlighter="shiki" data-ext="bash" style="--shiki-light:#383A42;--shiki-dark:#abb2bf;--shiki-light-bg:#FAFAFA;--shiki-dark-bg:#282c34"><pre class="shiki shiki-themes one-light one-dark-pro vp-code"><code class="language-bash"><span class="line"><span style="--shiki-light:#4078F2;--shiki-dark:#61AFEF">sudo</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379"> umount</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379"> /mnt/rescue</span></span>
<span class="line"><span style="--shiki-light:#4078F2;--shiki-dark:#61AFEF">sudo</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379"> vgchange</span><span style="--shiki-light:#986801;--shiki-dark:#D19A66"> -an</span></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div><div class="line-number"></div></div></div><p>然后在控制台把根卷挂回原实例，启动并验证。</p>
<h2>验证</h2>
<p>实例启动后执行：</p>
<div class="language-bash line-numbers-mode" data-highlighter="shiki" data-ext="bash" style="--shiki-light:#383A42;--shiki-dark:#abb2bf;--shiki-light-bg:#FAFAFA;--shiki-dark-bg:#282c34"><pre class="shiki shiki-themes one-light one-dark-pro vp-code"><code class="language-bash"><span class="line"><span style="--shiki-light:#4078F2;--shiki-dark:#61AFEF">lsblk</span><span style="--shiki-light:#986801;--shiki-dark:#D19A66"> -f</span></span>
<span class="line"><span style="--shiki-light:#4078F2;--shiki-dark:#61AFEF">sudo</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379"> systemctl</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379"> daemon-reload</span></span>
<span class="line"><span style="--shiki-light:#4078F2;--shiki-dark:#61AFEF">sudo</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379"> mount</span><span style="--shiki-light:#986801;--shiki-dark:#D19A66"> -a</span></span>
<span class="line"><span style="--shiki-light:#4078F2;--shiki-dark:#61AFEF">df</span><span style="--shiki-light:#986801;--shiki-dark:#D19A66"> -h</span></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p><code>mount -a</code> 无报错，说明 fstab 配置基本正常。</p>
<h2>总结</h2>
<p>EC2 Linux 启动失败要区分两层：</p>
<ul>
<li>AWS 控制面：KMS、IAM、EBS 状态、卷挂载关系。</li>
<li>OS 内部：fstab、LVM、文件系统、网络挂载。</li>
</ul>
<p>加密卷启动失败优先查 CloudTrail 和 KMS 权限；系统卡维护模式优先查控制台系统日志和 <code>/etc/fstab</code>。数据盘挂载建议统一使用 UUID + <code>nofail</code>，避免设备名变化把系统启动卡死。</p>
]]></content>
    <category term="AWS"/>
    <category term="Linux"/>
    <published>2026-04-06T00:00:00.000Z</published>
  </entry>
  <entry>
    <title type="text">EC2 Windows 2019 安装累积更新提示不适用</title>
    <id>https://blog.checo.cc/posts/AWS/8.html</id>
    <link href="https://blog.checo.cc/posts/AWS/8.html"/>
    <updated>2026-06-04T13:54:51.000Z</updated>
    <summary type="html"><![CDATA[
<p>手动安装 Windows Server 2019 累积更新时，如果提示 “The update is not applicable to your computer”，不一定代表缺少前置 SSU。很多时候是系统已经安装了更高版本累积更新，但还没重启完成版本号更新。</p>
]]></summary>
    <content type="html"><![CDATA[
<p>手动安装 Windows Server 2019 累积更新时，如果提示 “The update is not applicable to your computer”，不一定代表缺少前置 SSU。很多时候是系统已经安装了更高版本累积更新，但还没重启完成版本号更新。</p>
<!-- more -->
<h2>现象</h2>
<p>手动安装某个 Windows Server 2019 累积更新时，安装器返回：</p>
<div class="language-text line-numbers-mode" data-highlighter="shiki" data-ext="text" style="--shiki-light:#383A42;--shiki-dark:#abb2bf;--shiki-light-bg:#FAFAFA;--shiki-dark-bg:#282c34"><pre class="shiki shiki-themes one-light one-dark-pro vp-code"><code class="language-text"><span class="line"><span>The update is not applicable to your computer</span></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div></div></div><p>CBS 日志中可能出现：</p>
<div class="language-text line-numbers-mode" data-highlighter="shiki" data-ext="text" style="--shiki-light:#383A42;--shiki-dark:#abb2bf;--shiki-light-bg:#FAFAFA;--shiki-dark-bg:#282c34"><pre class="shiki shiki-themes one-light one-dark-pro vp-code"><code class="language-text"><span class="line"><span>Higher version found for package ..., superseded.</span></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div></div></div><p>WindowsUpdate.log 中可能看到：</p>
<div class="language-text line-numbers-mode" data-highlighter="shiki" data-ext="text" style="--shiki-light:#383A42;--shiki-dark:#abb2bf;--shiki-light-bg:#FAFAFA;--shiki-dark-bg:#282c34"><pre class="shiki shiki-themes one-light one-dark-pro vp-code"><code class="language-text"><span class="line"><span>The volatile RebootRequired key exists</span></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div></div></div><h2>分析思路</h2>
<h3>1. 比对 OS Build</h3>
<p>先看当前系统版本：</p>
<div class="language-powershell line-numbers-mode" data-highlighter="shiki" data-ext="powershell" style="--shiki-light:#383A42;--shiki-dark:#abb2bf;--shiki-light-bg:#FAFAFA;--shiki-dark-bg:#282c34"><pre class="shiki shiki-themes one-light one-dark-pro vp-code"><code class="language-powershell"><span class="line"><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF">winver</span></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div></div></div><p>或者读取注册表：</p>
<div class="language-powershell line-numbers-mode" data-highlighter="shiki" data-ext="powershell" style="--shiki-light:#383A42;--shiki-dark:#abb2bf;--shiki-light-bg:#FAFAFA;--shiki-dark-bg:#282c34"><pre class="shiki shiki-themes one-light one-dark-pro vp-code"><code class="language-powershell"><span class="line"><span style="--shiki-light:#0184BC;--shiki-dark:#56B6C2">Get-ItemProperty</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379"> "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion"</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF"> |</span></span>
<span class="line"><span style="--shiki-light:#0184BC;--shiki-dark:#56B6C2">  Select-Object</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF"> CurrentBuildNumber, UBR</span></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div><div class="line-number"></div></div></div><p>如果当前 Build 已高于目标 KB 对应版本，说明该 KB 内容已经被更高版本累积更新覆盖，安装“不适用”是正常结果。</p>
<h3>2. 看 CBS 是否已安装更高包</h3>
<p>CBS.log 里的 <code>Higher version found</code> 很关键。Windows 累积更新之间存在取代关系，较新的 LCU 已包含旧 LCU 的内容。</p>
<h3>3. 检查是否需要重启</h3>
<p>如果 WindowsUpdate.log 出现 <code>RebootRequired</code>，说明系统可能已经完成阶段性安装，但注册表中的 Build/UBR 还没在重启过程中更新。</p>
<p>这会导致 <code>winver</code> 看起来仍是旧版本，而 CBS 已经显示更高版本包存在。</p>
<h2>解决方案</h2>
<h3>1. 不要重复安装旧 KB</h3>
<p>如果 CBS 已显示系统存在更高版本包，应停止继续安装旧 KB，避免浪费维护窗口。</p>
<h3>2. 在维护窗口重启</h3>
<p>生产环境建议先创建 AMI 备份，再重启实例：</p>
<div class="language-powershell line-numbers-mode" data-highlighter="shiki" data-ext="powershell" style="--shiki-light:#383A42;--shiki-dark:#abb2bf;--shiki-light-bg:#FAFAFA;--shiki-dark-bg:#282c34"><pre class="shiki shiki-themes one-light one-dark-pro vp-code"><code class="language-powershell"><span class="line"><span style="--shiki-light:#0184BC;--shiki-dark:#56B6C2">Restart-Computer</span></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div></div></div><p>重启后再次检查：</p>
<div class="language-powershell line-numbers-mode" data-highlighter="shiki" data-ext="powershell" style="--shiki-light:#383A42;--shiki-dark:#abb2bf;--shiki-light-bg:#FAFAFA;--shiki-dark-bg:#282c34"><pre class="shiki shiki-themes one-light one-dark-pro vp-code"><code class="language-powershell"><span class="line"><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF">winver</span></span>
<span class="line"><span style="--shiki-light:#0184BC;--shiki-dark:#56B6C2">Get-HotFix</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF"> | </span><span style="--shiki-light:#0184BC;--shiki-dark:#56B6C2">Sort-Object</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF"> InstalledOn </span><span style="--shiki-light:#383A42;--shiki-dark:#56B6C2">-</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF">Descending | </span><span style="--shiki-light:#0184BC;--shiki-dark:#56B6C2">Select-Object</span><span style="--shiki-light:#383A42;--shiki-dark:#56B6C2"> -</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF">First </span><span style="--shiki-light:#986801;--shiki-dark:#D19A66">10</span></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div><div class="line-number"></div></div></div><h3>3. 优先安装最新累积更新</h3>
<p>如果没有必须安装某个旧 KB 的合规要求，建议直接安装最新 LCU。Windows 累积更新通常包含此前更新内容。</p>
<h2>总结</h2>
<p>“此更新不适用于您的计算机”不一定是失败。排查时不要只看 <code>winver</code>，还要结合：</p>
<ul>
<li>目标 KB 对应的 OS Build。</li>
<li>CBS.log 中是否已有更高版本包。</li>
<li>WindowsUpdate.log 中是否存在 <code>RebootRequired</code>。</li>
</ul>
<p>如果系统已经安装更高版本更新但尚未重启，正确动作通常是安排维护窗口重启，而不是反复手动安装旧补丁。</p>
]]></content>
    <category term="AWS"/>
    <category term="Windows"/>
    <published>2026-04-25T00:00:00.000Z</published>
  </entry>
  <entry>
    <title type="text">Windows Server 2019 .NET 累积更新安装失败：绕过 WUA 使用 DISM</title>
    <id>https://blog.checo.cc/posts/AWS/9.html</id>
    <link href="https://blog.checo.cc/posts/AWS/9.html"/>
    <updated>2026-06-04T13:54:51.000Z</updated>
    <summary type="html"><![CDATA[
<p>在 Windows Server 2019 上安装 .NET Framework 累积更新时，如果双击 <code>.msu</code> 或 <code>wusa.exe</code> 路径一直失败，并且 WindowsUpdate.log 出现 <code>0xC8000402 PopulateDataStore failed</code>，问题可能不是 CBS 安装失败，而是 WUA 扫描层已经坏了。</p>
]]></summary>
    <content type="html"><![CDATA[
<p>在 Windows Server 2019 上安装 .NET Framework 累积更新时，如果双击 <code>.msu</code> 或 <code>wusa.exe</code> 路径一直失败，并且 WindowsUpdate.log 出现 <code>0xC8000402 PopulateDataStore failed</code>，问题可能不是 CBS 安装失败，而是 WUA 扫描层已经坏了。</p>
<!-- more -->
<h2>背景</h2>
<p>某些 .NET 累积更新是容器包，里面包含多个真正适用的 <code>.msu</code>。例如一个总 KB 可能内嵌：</p>
<ul>
<li>.NET 3.5 + 4.7.2 的 MSU。</li>
<li>.NET 3.5 + 4.8 的 MSU。</li>
</ul>
<p>如果系统已经是 .NET 4.8，只需要安装对应 4.8 的那份。</p>
<h2>关键日志</h2>
<p>WindowsUpdate.log 反复出现：</p>
<div class="language-text line-numbers-mode" data-highlighter="shiki" data-ext="text" style="--shiki-light:#383A42;--shiki-dark:#abb2bf;--shiki-light-bg:#FAFAFA;--shiki-dark-bg:#282c34"><pre class="shiki shiki-themes one-light one-dark-pro vp-code"><code class="language-text"><span class="line"><span>ProtocolTalker  *FAILED* [C8000402] PopulateDataStore failed</span></span>
<span class="line"><span>ProtocolTalker  *FAILED* [C8000402] Sync of Updates</span></span>
<span class="line"><span>Agent           * END * Finding updates ... Exit code = 0xC8000402</span></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p>CBS.log 中却搜不到目标 KB 的痕迹。</p>
<p>这说明补丁还没有进入 CBS 安装引擎，失败发生在更早的 WUA 扫描阶段。</p>
<h2>根因判断</h2>
<p><code>wusa.exe</code> 安装 <code>.msu</code> 的流程大致是：</p>
<div class="language-text line-numbers-mode" data-highlighter="shiki" data-ext="text" style="--shiki-light:#383A42;--shiki-dark:#abb2bf;--shiki-light-bg:#FAFAFA;--shiki-dark-bg:#282c34"><pre class="shiki shiki-themes one-light one-dark-pro vp-code"><code class="language-text"><span class="line"><span>双击 .msu -> wusa.exe -> WUA 适用性扫描 -> CBS 安装</span></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div></div></div><p>如果 WUA 的 DataStore 损坏，或者离线扫描源反复注册导致元数据污染，WUA 可能在 <code>PopulateDataStore</code> 阶段失败，最终返回 “0 updates found” 或安装失败。</p>
<p>此时继续双击 <code>.msu</code> 没意义，因为永远到不了 CBS。</p>
<h2>解决方案：解包后用 DISM 注入 cab</h2>
<p>核心思路是绕过 WUA，直接让 CBS 处理 CAB 包。</p>
<h3>1. 解压 MSU</h3>
<div class="language-powershell line-numbers-mode" data-highlighter="shiki" data-ext="powershell" style="--shiki-light:#383A42;--shiki-dark:#abb2bf;--shiki-light-bg:#FAFAFA;--shiki-dark-bg:#282c34"><pre class="shiki shiki-themes one-light one-dark-pro vp-code"><code class="language-powershell"><span class="line"><span style="--shiki-light:#E45649;--shiki-dark:#E06C75">$msu</span><span style="--shiki-light:#383A42;--shiki-dark:#56B6C2"> =</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379"> "C:\Patches\windows10.0-kbxxxxx-x64-ndp48.msu"</span></span>
<span class="line"><span style="--shiki-light:#E45649;--shiki-dark:#E06C75">$dst</span><span style="--shiki-light:#383A42;--shiki-dark:#56B6C2"> =</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379"> "C:\Patches\Extract"</span></span>
<span class="line"><span style="--shiki-light:#0184BC;--shiki-dark:#56B6C2">New-Item</span><span style="--shiki-light:#383A42;--shiki-dark:#56B6C2"> -</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF">ItemType Directory </span><span style="--shiki-light:#383A42;--shiki-dark:#56B6C2">-</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF">Force </span><span style="--shiki-light:#383A42;--shiki-dark:#56B6C2">-</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF">Path </span><span style="--shiki-light:#E45649;--shiki-dark:#E06C75">$dst</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF"> | </span><span style="--shiki-light:#0184BC;--shiki-dark:#56B6C2">Out-Null</span></span>
<span class="line"><span style="--shiki-light:#0184BC;--shiki-dark:#56B6C2">expand.exe</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF"> -F</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF">:</span><span style="--shiki-light:#383A42;--shiki-dark:#56B6C2">*</span><span style="--shiki-light:#E45649;--shiki-dark:#E06C75"> $msu</span><span style="--shiki-light:#E45649;--shiki-dark:#E06C75"> $dst</span></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h3>2. 用 DISM 安装 CAB</h3>
<div class="language-powershell line-numbers-mode" data-highlighter="shiki" data-ext="powershell" style="--shiki-light:#383A42;--shiki-dark:#abb2bf;--shiki-light-bg:#FAFAFA;--shiki-dark-bg:#282c34"><pre class="shiki shiki-themes one-light one-dark-pro vp-code"><code class="language-powershell"><span class="line"><span style="--shiki-light:#E45649;--shiki-dark:#E06C75">$cab</span><span style="--shiki-light:#383A42;--shiki-dark:#56B6C2"> =</span><span style="--shiki-light:#0184BC;--shiki-dark:#56B6C2"> Get-ChildItem</span><span style="--shiki-light:#E45649;--shiki-dark:#E06C75"> $dst</span><span style="--shiki-light:#383A42;--shiki-dark:#56B6C2"> -</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF">Filter </span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379">"Windows10.0-KB*.cab"</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF"> | </span><span style="--shiki-light:#0184BC;--shiki-dark:#56B6C2">Select-Object</span><span style="--shiki-light:#383A42;--shiki-dark:#56B6C2"> -</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF">First </span><span style="--shiki-light:#986801;--shiki-dark:#D19A66">1</span></span>
<span class="line"><span style="--shiki-light:#0184BC;--shiki-dark:#56B6C2">DISM.exe</span><span style="--shiki-light:#383A42;--shiki-dark:#56B6C2"> /</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF">Online </span><span style="--shiki-light:#383A42;--shiki-dark:#56B6C2">/</span><span style="--shiki-light:#0184BC;--shiki-dark:#56B6C2">Add-Package</span><span style="--shiki-light:#383A42;--shiki-dark:#56B6C2"> /</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF">PackagePath:</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379">"</span><span style="--shiki-light:#CA1243;--shiki-dark:#C678DD">$(</span><span style="--shiki-light:#50A14F;--shiki-dark:#E06C75">$</span><span style="--shiki-light:#E45649;--shiki-dark:#E06C75">cab.FullName</span><span style="--shiki-light:#CA1243;--shiki-dark:#C678DD">)</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379">"</span><span style="--shiki-light:#383A42;--shiki-dark:#56B6C2"> /</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF">NoRestart </span><span style="--shiki-light:#383A42;--shiki-dark:#56B6C2">/</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF">LogPath:C:\Patches\dism.log</span></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div><div class="line-number"></div></div></div><h3>3. 重启</h3>
<div class="language-powershell line-numbers-mode" data-highlighter="shiki" data-ext="powershell" style="--shiki-light:#383A42;--shiki-dark:#abb2bf;--shiki-light-bg:#FAFAFA;--shiki-dark-bg:#282c34"><pre class="shiki shiki-themes one-light one-dark-pro vp-code"><code class="language-powershell"><span class="line"><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF">shutdown </span><span style="--shiki-light:#383A42;--shiki-dark:#56B6C2">/</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF">r </span><span style="--shiki-light:#383A42;--shiki-dark:#56B6C2">/</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF">t </span><span style="--shiki-light:#986801;--shiki-dark:#D19A66">30</span></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div></div></div><h3>4. 验证</h3>
<div class="language-powershell line-numbers-mode" data-highlighter="shiki" data-ext="powershell" style="--shiki-light:#383A42;--shiki-dark:#abb2bf;--shiki-light-bg:#FAFAFA;--shiki-dark-bg:#282c34"><pre class="shiki shiki-themes one-light one-dark-pro vp-code"><code class="language-powershell"><span class="line"><span style="--shiki-light:#0184BC;--shiki-dark:#56B6C2">Get-HotFix</span><span style="--shiki-light:#383A42;--shiki-dark:#56B6C2"> -</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF">Id KBxxxxx</span></span>
<span class="line"><span style="--shiki-light:#0184BC;--shiki-dark:#56B6C2">DISM.exe</span><span style="--shiki-light:#383A42;--shiki-dark:#56B6C2"> /</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF">Online </span><span style="--shiki-light:#383A42;--shiki-dark:#56B6C2">/</span><span style="--shiki-light:#0184BC;--shiki-dark:#56B6C2">Get-Packages</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF"> | findstr </span><span style="--shiki-light:#383A42;--shiki-dark:#56B6C2">/</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF">I </span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379">"DotNetRollup"</span></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div><div class="line-number"></div></div></div><p>如果是 .NET 更新，还可以检查关键 .NET 文件版本是否更新。</p>
<h2>可选：修复 WUA 扫描通道</h2>
<p>如果后续还需要 Windows Update 正常扫描，可以重置 WUA 数据库：</p>
<div class="language-powershell line-numbers-mode" data-highlighter="shiki" data-ext="powershell" style="--shiki-light:#383A42;--shiki-dark:#abb2bf;--shiki-light-bg:#FAFAFA;--shiki-dark-bg:#282c34"><pre class="shiki shiki-themes one-light one-dark-pro vp-code"><code class="language-powershell"><span class="line"><span style="--shiki-light:#0184BC;--shiki-dark:#56B6C2">Stop-Service</span><span style="--shiki-light:#383A42;--shiki-dark:#56B6C2"> -</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF">Name wuauserv, BITS, cryptSvc </span><span style="--shiki-light:#383A42;--shiki-dark:#56B6C2">-</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF">Force</span></span>
<span class="line"><span style="--shiki-light:#0184BC;--shiki-dark:#56B6C2">Rename-Item</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF"> C:\Windows\SoftwareDistribution C:\Windows\SoftwareDistribution.old</span></span>
<span class="line"><span style="--shiki-light:#0184BC;--shiki-dark:#56B6C2">Rename-Item</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF"> C:\Windows\System32\catroot2 C:\Windows\System32\catroot2.old</span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#E45649;--shiki-dark:#E06C75">$svc</span><span style="--shiki-light:#383A42;--shiki-dark:#56B6C2"> =</span><span style="--shiki-light:#0184BC;--shiki-dark:#56B6C2"> New-Object</span><span style="--shiki-light:#383A42;--shiki-dark:#56B6C2"> -</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF">ComObject Microsoft.Update.ServiceManager</span></span>
<span class="line"><span style="--shiki-light:#E45649;--shiki-dark:#E06C75">$svc.Services</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF"> | </span><span style="--shiki-light:#0184BC;--shiki-dark:#56B6C2">Where-Object</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF"> { $_</span><span style="--shiki-light:#E45649;--shiki-dark:#E06C75">.IsScanPackageService</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF"> } |</span></span>
<span class="line"><span style="--shiki-light:#0184BC;--shiki-dark:#56B6C2">  ForEach-Object</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF"> { </span><span style="--shiki-light:#E45649;--shiki-dark:#E06C75">$svc.RemoveService</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF">($_</span><span style="--shiki-light:#E45649;--shiki-dark:#E06C75">.ServiceID</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF">) }</span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#0184BC;--shiki-dark:#56B6C2">Start-Service</span><span style="--shiki-light:#383A42;--shiki-dark:#56B6C2"> -</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF">Name wuauserv, BITS, cryptSvc</span></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p>这不是安装补丁的必要步骤，只是恢复 WUA 扫描能力。</p>
<h2>总结</h2>
<p>如果目标 KB 在 CBS.log 中完全没有痕迹，而 WindowsUpdate.log 指向 <code>0xC8000402 PopulateDataStore failed</code>，就要把问题定位在 WUA 扫描层。</p>
<p>处理方式是：</p>
<ol>
<li>确认实际适用的内嵌 MSU。</li>
<li>解压 MSU 得到 CAB。</li>
<li>用 <code>DISM /Add-Package</code> 直接注入。</li>
<li>重启并验证。</li>
</ol>
<p>这个方法适合 WUA 损坏但 CBS 仍正常的场景。</p>
]]></content>
    <category term="AWS"/>
    <category term="Windows"/>
    <published>2026-06-03T00:00:00.000Z</published>
  </entry>
  <entry>
    <title type="text">Mac mini M4 硬件深度检测指南</title>
    <id>https://blog.checo.cc/posts/Mac/1.html</id>
    <link href="https://blog.checo.cc/posts/Mac/1.html"/>
    <updated>2026-06-06T16:08:40.000Z</updated>
    <summary type="html"><![CDATA[
<figure><img src="/assets/images/posts/mac-mini-m4-cutaway.png" alt="Mac mini M4 透明俯视内部构造图" tabindex="0" loading="lazy"><figcaption>Mac mini M4 透明俯视内部构造图</figcaption></figure>
<p>新 Mac 到手后，我习惯先做一次系统化检测：硬件信息、SSD 健康、接口状态、安全配置、系统稳定性都过一遍。这样后面如果遇到异常，可以知道是机器本身的问题，还是后续使用环境造成的。</p>
]]></summary>
    <content type="html"><![CDATA[
<figure><img src="/assets/images/posts/mac-mini-m4-cutaway.png" alt="Mac mini M4 透明俯视内部构造图" tabindex="0" loading="lazy"><figcaption>Mac mini M4 透明俯视内部构造图</figcaption></figure>
<p>新 Mac 到手后，我习惯先做一次系统化检测：硬件信息、SSD 健康、接口状态、安全配置、系统稳定性都过一遍。这样后面如果遇到异常，可以知道是机器本身的问题，还是后续使用环境造成的。</p>
<!-- more -->
<p>本文基于 Mac mini M4 的实际检测流程整理，命令主要适用于 Apple Silicon Mac。</p>
<h2>基本信息</h2>
<p>查看硬件概况：</p>
<div class="language-bash line-numbers-mode" data-highlighter="shiki" data-ext="bash" style="--shiki-light:#383A42;--shiki-dark:#abb2bf;--shiki-light-bg:#FAFAFA;--shiki-dark-bg:#282c34"><pre class="shiki shiki-themes one-light one-dark-pro vp-code"><code class="language-bash"><span class="line"><span style="--shiki-light:#4078F2;--shiki-dark:#61AFEF">system_profiler</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379"> SPHardwareDataType</span></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div></div></div><p>重点看这些字段：</p>
<ul>
<li>机型和型号</li>
<li>芯片型号</li>
<li>统一内存容量</li>
<li>序列号</li>
<li>系统固件版本</li>
</ul>
<p>查看 macOS 版本：</p>
<div class="language-bash line-numbers-mode" data-highlighter="shiki" data-ext="bash" style="--shiki-light:#383A42;--shiki-dark:#abb2bf;--shiki-light-bg:#FAFAFA;--shiki-dark-bg:#282c34"><pre class="shiki shiki-themes one-light one-dark-pro vp-code"><code class="language-bash"><span class="line"><span style="--shiki-light:#4078F2;--shiki-dark:#61AFEF">sw_vers</span></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div></div></div><p>查看系统运行时间：</p>
<div class="language-bash line-numbers-mode" data-highlighter="shiki" data-ext="bash" style="--shiki-light:#383A42;--shiki-dark:#abb2bf;--shiki-light-bg:#FAFAFA;--shiki-dark-bg:#282c34"><pre class="shiki shiki-themes one-light one-dark-pro vp-code"><code class="language-bash"><span class="line"><span style="--shiki-light:#4078F2;--shiki-dark:#61AFEF">uptime</span></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div></div></div><p>查看首次设置日期：</p>
<div class="language-bash line-numbers-mode" data-highlighter="shiki" data-ext="bash" style="--shiki-light:#383A42;--shiki-dark:#abb2bf;--shiki-light-bg:#FAFAFA;--shiki-dark-bg:#282c34"><pre class="shiki shiki-themes one-light one-dark-pro vp-code"><code class="language-bash"><span class="line"><span style="--shiki-light:#4078F2;--shiki-dark:#61AFEF">ls</span><span style="--shiki-light:#986801;--shiki-dark:#D19A66"> -la</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379"> /var/db/.AppleSetupDone</span></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div></div></div><p><code>.AppleSetupDone</code> 的修改时间通常可以作为首次开机设置时间的参考。</p>
<h2>存储系统检测</h2>
<h3>内置 SSD 信息</h3>
<div class="language-bash line-numbers-mode" data-highlighter="shiki" data-ext="bash" style="--shiki-light:#383A42;--shiki-dark:#abb2bf;--shiki-light-bg:#FAFAFA;--shiki-dark-bg:#282c34"><pre class="shiki shiki-themes one-light one-dark-pro vp-code"><code class="language-bash"><span class="line"><span style="--shiki-light:#4078F2;--shiki-dark:#61AFEF">system_profiler</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379"> SPNVMeDataType</span></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div></div></div><p>也可以看 <code>diskutil</code> 输出：</p>
<div class="language-bash line-numbers-mode" data-highlighter="shiki" data-ext="bash" style="--shiki-light:#383A42;--shiki-dark:#abb2bf;--shiki-light-bg:#FAFAFA;--shiki-dark-bg:#282c34"><pre class="shiki shiki-themes one-light one-dark-pro vp-code"><code class="language-bash"><span class="line"><span style="--shiki-light:#4078F2;--shiki-dark:#61AFEF">diskutil</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379"> info</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379"> disk0</span></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div></div></div><p>重点关注：</p>
<ul>
<li>SSD 型号</li>
<li>协议</li>
<li>TRIM 是否支持</li>
<li>SMART 状态</li>
<li>APFS 容器和卷状态</li>
</ul>
<h3>SMART 健康数据</h3>
<p>需要先安装 smartmontools：</p>
<div class="language-bash line-numbers-mode" data-highlighter="shiki" data-ext="bash" style="--shiki-light:#383A42;--shiki-dark:#abb2bf;--shiki-light-bg:#FAFAFA;--shiki-dark-bg:#282c34"><pre class="shiki shiki-themes one-light one-dark-pro vp-code"><code class="language-bash"><span class="line"><span style="--shiki-light:#4078F2;--shiki-dark:#61AFEF">brew</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379"> install</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379"> smartmontools</span></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div></div></div><p>查看内置 SSD 的完整 SMART 数据：</p>
<div class="language-bash line-numbers-mode" data-highlighter="shiki" data-ext="bash" style="--shiki-light:#383A42;--shiki-dark:#abb2bf;--shiki-light-bg:#FAFAFA;--shiki-dark-bg:#282c34"><pre class="shiki shiki-themes one-light one-dark-pro vp-code"><code class="language-bash"><span class="line"><span style="--shiki-light:#4078F2;--shiki-dark:#61AFEF">sudo</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379"> smartctl</span><span style="--shiki-light:#986801;--shiki-dark:#D19A66"> -a</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379"> /dev/disk0</span></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div></div></div><p>常用指标可以这样理解：</p>
<p>| 指标 | 含义 | 正常参考 |<br>
|</p>
]]></content>
    <category term="macOS"/>
    <category term="硬件"/>
    <published>2026-06-03T00:00:00.000Z</published>
  </entry>
  <entry>
    <title type="text">macOS 上的 VS Code 为什么会神秘消失？</title>
    <id>https://blog.checo.cc/posts/Mac/2.html</id>
    <link href="https://blog.checo.cc/posts/Mac/2.html"/>
    <updated>2026-06-04T13:54:51.000Z</updated>
    <summary type="html"><![CDATA[
<p>一次很离谱的经历：Dock 里的 VS Code 图标突然变成通用应用图标，Finder 里原本的 <code>Visual Studio Code.app</code> 也不见了。最后排查下来，问题出在 VS Code 自动更新、ShipIt 后台进程和跨 APFS 卷移动之间。</p>
]]></summary>
    <content type="html"><![CDATA[
<p>一次很离谱的经历：Dock 里的 VS Code 图标突然变成通用应用图标，Finder 里原本的 <code>Visual Studio Code.app</code> 也不见了。最后排查下来，问题出在 VS Code 自动更新、ShipIt 后台进程和跨 APFS 卷移动之间。</p>
<!-- more -->
<h2>起因</h2>
<p>凌晨打开 Mac mini 准备工作，习惯性点击 Dock 上的 VS Code 图标，结果图标变成了空白的 macOS 通用应用图标。</p>
<figure><img src="/assets/images/vscode/vscode-generic-icon.png" alt="Dock 或 Finder 中 VS Code 显示为通用图标" tabindex="0" loading="lazy"><figcaption>Dock 或 Finder 中 VS Code 显示为通用图标</figcaption></figure>
<p>打开 Finder 到应用所在目录，也能看到 VS Code 状态异常：</p>
<figure><img src="/assets/images/vscode/vscode-missing-finder.png" alt="Finder 中 VS Code 无法正常识别" tabindex="0" loading="lazy"><figcaption>Finder 中 VS Code 无法正常识别</figcaption></figure>
<p>我的 VS Code 没装在系统默认的 <code>/Applications/</code>，而是在外置 APFS 卷的应用目录里。</p>
<h2>第一反应：app 去哪了？</h2>
<p>先检查应用目录：</p>
<div class="language-bash line-numbers-mode" data-highlighter="shiki" data-ext="bash" style="--shiki-light:#383A42;--shiki-dark:#abb2bf;--shiki-light-bg:#FAFAFA;--shiki-dark-bg:#282c34"><pre class="shiki shiki-themes one-light one-dark-pro vp-code"><code class="language-bash"><span class="line"><span style="--shiki-light:#4078F2;--shiki-dark:#61AFEF">ls</span><span style="--shiki-light:#986801;--shiki-dark:#D19A66"> -la</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379"> "/Volumes/&#x3C;external-volume>/applications/"</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF"> | </span><span style="--shiki-light:#4078F2;--shiki-dark:#61AFEF">grep</span><span style="--shiki-light:#986801;--shiki-dark:#D19A66"> -i</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379"> "code\|visual"</span></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div></div></div><p>没有任何输出。也就是说，<code>Visual Studio Code.app</code> 目录已经不存在。</p>
<p>但 Dock 里还保留着旧路径：</p>
<div class="language-bash line-numbers-mode" data-highlighter="shiki" data-ext="bash" style="--shiki-light:#383A42;--shiki-dark:#abb2bf;--shiki-light-bg:#FAFAFA;--shiki-dark-bg:#282c34"><pre class="shiki shiki-themes one-light one-dark-pro vp-code"><code class="language-bash"><span class="line"><span style="--shiki-light:#4078F2;--shiki-dark:#61AFEF">defaults</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379"> read</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379"> com.apple.dock</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379"> persistent-apps</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF"> | </span><span style="--shiki-light:#4078F2;--shiki-dark:#61AFEF">grep</span><span style="--shiki-light:#986801;--shiki-dark:#D19A66"> -A2</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379"> "Visual Studio Code"</span></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div></div></div><p>输出里还能看到类似路径：</p>
<div class="language-text line-numbers-mode" data-highlighter="shiki" data-ext="text" style="--shiki-light:#383A42;--shiki-dark:#abb2bf;--shiki-light-bg:#FAFAFA;--shiki-dark-bg:#282c34"><pre class="shiki shiki-themes one-light one-dark-pro vp-code"><code class="language-text"><span class="line"><span>file:///Volumes/&#x3C;external-volume>/applications/Visual%20Studio%20Code.app/</span></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div></div></div><p>Dock 记住了一个已经不存在的 app，所以 macOS 只能显示通用图标。</p>
<h2>真凶：VS Code 自动更新</h2>
<p>继续查系统临时目录，发现了 VS Code 的更新器痕迹：</p>
<div class="language-bash line-numbers-mode" data-highlighter="shiki" data-ext="bash" style="--shiki-light:#383A42;--shiki-dark:#abb2bf;--shiki-light-bg:#FAFAFA;--shiki-dark-bg:#282c34"><pre class="shiki shiki-themes one-light one-dark-pro vp-code"><code class="language-bash"><span class="line"><span style="--shiki-light:#4078F2;--shiki-dark:#61AFEF">find</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379"> /private/var/folders</span><span style="--shiki-light:#986801;--shiki-dark:#D19A66"> -name</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379"> "*.ShipIt*"</span><span style="--shiki-light:#986801;--shiki-dark:#D19A66"> -maxdepth</span><span style="--shiki-light:#986801;--shiki-dark:#D19A66"> 4</span></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div></div></div><p>能看到多个类似目录：</p>
<div class="language-text line-numbers-mode" data-highlighter="shiki" data-ext="text" style="--shiki-light:#383A42;--shiki-dark:#abb2bf;--shiki-light-bg:#FAFAFA;--shiki-dark-bg:#282c34"><pre class="shiki shiki-themes one-light one-dark-pro vp-code"><code class="language-text"><span class="line"><span>/private/var/folders/.../T/com.microsoft.VSCode.ShipIt.xxxxxxxx</span></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div></div></div><p>进入其中一个目录，可以看到完整的 <code>Visual Studio Code.app</code> 包。也就是说，旧版本已经从目标目录删除，新版本却停在了临时目录里，没有成功回到安装位置。</p>
<p>查看临时目录里 app 的版本：</p>
<div class="language-bash line-numbers-mode" data-highlighter="shiki" data-ext="bash" style="--shiki-light:#383A42;--shiki-dark:#abb2bf;--shiki-light-bg:#FAFAFA;--shiki-dark-bg:#282c34"><pre class="shiki shiki-themes one-light one-dark-pro vp-code"><code class="language-bash"><span class="line"><span style="--shiki-light:#4078F2;--shiki-dark:#61AFEF">defaults</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379"> read</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379"> "/private/var/folders/.../ShipIt.xxxxxxxx/Visual Studio Code.app/Contents/Info.plist"</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379"> CFBundleShortVersionString</span></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div></div></div><p>确认它就是更新后的新版本。</p>
<p>结论很明确：VS Code 自动更新器删除了旧版本，但新版本移动回原位置时失败了。</p>
<h2>为什么会失败？</h2>
<p>VS Code 使用 Electron 的 Squirrel.Mac 做自动更新，核心辅助进程叫 ShipIt。大致流程是：</p>
<div class="language-text line-numbers-mode" data-highlighter="shiki" data-ext="text" style="--shiki-light:#383A42;--shiki-dark:#abb2bf;--shiki-light-bg:#FAFAFA;--shiki-dark-bg:#282c34"><pre class="shiki shiki-themes one-light one-dark-pro vp-code"><code class="language-text"><span class="line"><span>1. 检查更新并下载新版本</span></span>
<span class="line"><span>2. 解压到 /private/var/folders/.../T/</span></span>
<span class="line"><span>3. 启动 ShipIt 辅助进程</span></span>
<span class="line"><span>4. ShipIt 等待 VS Code 退出</span></span>
<span class="line"><span>5. 删除旧的 Visual Studio Code.app</span></span>
<span class="line"><span>6. 把新 app 移动到原安装位置</span></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p>问题出在临时目录和安装目录不在同一个卷。</p>
<p>macOS 的临时目录通常在启动卷：</p>
<div class="language-text line-numbers-mode" data-highlighter="shiki" data-ext="text" style="--shiki-light:#383A42;--shiki-dark:#abb2bf;--shiki-light-bg:#FAFAFA;--shiki-dark-bg:#282c34"><pre class="shiki shiki-themes one-light one-dark-pro vp-code"><code class="language-text"><span class="line"><span>/private/var/folders/&#x3C;hash>/T/</span></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div></div></div><p>而我的 VS Code 在外置 APFS 卷：</p>
<div class="language-text line-numbers-mode" data-highlighter="shiki" data-ext="text" style="--shiki-light:#383A42;--shiki-dark:#abb2bf;--shiki-light-bg:#FAFAFA;--shiki-dark-bg:#282c34"><pre class="shiki shiki-themes one-light one-dark-pro vp-code"><code class="language-text"><span class="line"><span>/Volumes/&#x3C;external-volume>/applications/Visual Studio Code.app</span></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div></div></div><p>同卷移动通常只是改目录项，速度很快；跨卷移动则会变成复制再删除。这个过程不是原子的，只要复制中断、目标卷权限异常、磁盘空间不足、卷短暂不可用，就可能出现“旧的删了，新的没到”的状态。</p>
<p>这不是 VS Code 独有的问题。只要更新器把新版本放在启动卷临时目录，再把 app 移到另一个卷，就有类似风险。</p>
<h2>为什么重装后又消失？</h2>
<p>第一次我从临时目录把 app 移回去：</p>
<div class="language-bash line-numbers-mode" data-highlighter="shiki" data-ext="bash" style="--shiki-light:#383A42;--shiki-dark:#abb2bf;--shiki-light-bg:#FAFAFA;--shiki-dark-bg:#282c34"><pre class="shiki shiki-themes one-light one-dark-pro vp-code"><code class="language-bash"><span class="line"><span style="--shiki-light:#4078F2;--shiki-dark:#61AFEF">mv</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379"> "/private/var/folders/.../T/com.microsoft.VSCode.ShipIt.xxxxxxxx/Visual Studio Code.app"</span><span style="--shiki-light:#0184BC;--shiki-dark:#56B6C2"> \</span></span>
<span class="line"><span style="--shiki-light:#50A14F;--shiki-dark:#98C379">   "/Volumes/&#x3C;external-volume>/applications/"</span></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div><div class="line-number"></div></div></div><p>然后在 VS Code 设置里禁用自动更新：</p>
<div class="language-json line-numbers-mode" data-highlighter="shiki" data-ext="json" style="--shiki-light:#383A42;--shiki-dark:#abb2bf;--shiki-light-bg:#FAFAFA;--shiki-dark-bg:#282c34"><pre class="shiki shiki-themes one-light one-dark-pro vp-code"><code class="language-json"><span class="line"><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF">{</span></span>
<span class="line"><span style="--shiki-light:#E45649;--shiki-dark:#E06C75">  "update.mode"</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF">: </span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379">"none"</span></span>
<span class="line"><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF">}</span></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p>本以为问题结束了，结果用 DMG 重装后，VS Code 又被删了一次。</p>
<p>原因是 ShipIt 是独立后台进程。旧版 VS Code 之前已经触发过更新，ShipIt 可能还在后台排队等待执行。<code>update.mode: &quot;none&quot;</code> 只在 VS Code 主进程读取配置时生效，挡不住已经启动的 ShipIt。</p>
<h2>最终修复</h2>
<h3>1. 杀掉 ShipIt 进程</h3>
<div class="language-bash line-numbers-mode" data-highlighter="shiki" data-ext="bash" style="--shiki-light:#383A42;--shiki-dark:#abb2bf;--shiki-light-bg:#FAFAFA;--shiki-dark-bg:#282c34"><pre class="shiki shiki-themes one-light one-dark-pro vp-code"><code class="language-bash"><span class="line"><span style="--shiki-light:#4078F2;--shiki-dark:#61AFEF">pkill</span><span style="--shiki-light:#986801;--shiki-dark:#D19A66"> -f</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379"> "ShipIt"</span></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div></div></div><h3>2. 从最新临时目录恢复 app</h3>
<div class="language-bash line-numbers-mode" data-highlighter="shiki" data-ext="bash" style="--shiki-light:#383A42;--shiki-dark:#abb2bf;--shiki-light-bg:#FAFAFA;--shiki-dark-bg:#282c34"><pre class="shiki shiki-themes one-light one-dark-pro vp-code"><code class="language-bash"><span class="line"><span style="--shiki-light:#4078F2;--shiki-dark:#61AFEF">mv</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379"> "/private/var/folders/.../T/com.microsoft.VSCode.ShipIt.xxxxxxxx/Visual Studio Code.app"</span><span style="--shiki-light:#0184BC;--shiki-dark:#56B6C2"> \</span></span>
<span class="line"><span style="--shiki-light:#50A14F;--shiki-dark:#98C379">   "/Volumes/&#x3C;external-volume>/applications/"</span></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div><div class="line-number"></div></div></div><h3>3. 禁用自动更新器执行权限</h3>
<p>关键是让 ShipIt 二进制无法继续运行：</p>
<div class="language-bash line-numbers-mode" data-highlighter="shiki" data-ext="bash" style="--shiki-light:#383A42;--shiki-dark:#abb2bf;--shiki-light-bg:#FAFAFA;--shiki-dark-bg:#282c34"><pre class="shiki shiki-themes one-light one-dark-pro vp-code"><code class="language-bash"><span class="line"><span style="--shiki-light:#4078F2;--shiki-dark:#61AFEF">chmod</span><span style="--shiki-light:#986801;--shiki-dark:#D19A66"> -x</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379"> "/Volumes/&#x3C;external-volume>/applications/Visual Studio Code.app/Contents/Frameworks/Squirrel.framework/Versions/A/Resources/ShipIt"</span></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div></div></div><p>确认执行权限已经去掉：</p>
<div class="language-bash line-numbers-mode" data-highlighter="shiki" data-ext="bash" style="--shiki-light:#383A42;--shiki-dark:#abb2bf;--shiki-light-bg:#FAFAFA;--shiki-dark-bg:#282c34"><pre class="shiki shiki-themes one-light one-dark-pro vp-code"><code class="language-bash"><span class="line"><span style="--shiki-light:#4078F2;--shiki-dark:#61AFEF">ls</span><span style="--shiki-light:#986801;--shiki-dark:#D19A66"> -la</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379"> "/Volumes/&#x3C;external-volume>/applications/Visual Studio Code.app/Contents/Frameworks/Squirrel.framework/Versions/A/Resources/ShipIt"</span></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div></div></div><p>如果权限里没有 <code>x</code>，说明它已经不能直接执行。</p>
<h3>4. 清理临时更新目录</h3>
<div class="language-bash line-numbers-mode" data-highlighter="shiki" data-ext="bash" style="--shiki-light:#383A42;--shiki-dark:#abb2bf;--shiki-light-bg:#FAFAFA;--shiki-dark-bg:#282c34"><pre class="shiki shiki-themes one-light one-dark-pro vp-code"><code class="language-bash"><span class="line"><span style="--shiki-light:#4078F2;--shiki-dark:#61AFEF">rm</span><span style="--shiki-light:#986801;--shiki-dark:#D19A66"> -rf</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379"> /private/var/folders/.../T/com.microsoft.VSCode.ShipIt.</span><span style="--shiki-light:#E45649;--shiki-dark:#E5C07B">*</span></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div></div></div><p>这一步要小心路径，确认只删除 VS Code 的 ShipIt 临时目录。</p>
<h2>修复效果</h2>
<ul>
<li>VS Code 可以正常启动。</li>
<li>Dock 图标恢复正常。</li>
<li>退出后可以重新打开。</li>
<li>自动更新不会再启动 ShipIt。</li>
<li>以后需要手动下载 DMG 或用包管理器更新。</li>
</ul>
<h2>经验教训</h2>
<h3><code>update.mode: &quot;none&quot;</code> 不够</h3>
<p>它只能阻止 VS Code 主进程后续触发更新。对已经运行的 ShipIt 后台进程无效。</p>
<h3>App 装在非系统卷会增加更新风险</h3>
<p>如果必须把 app 放在外置卷，建议禁用自动更新，改成手动更新。否则每次自动更新都可能触发跨卷复制。</p>
<h3>临时目录经常能救命</h3>
<p>更新失败时，新版本 app 往往还完整地躺在：</p>
<div class="language-text line-numbers-mode" data-highlighter="shiki" data-ext="text" style="--shiki-light:#383A42;--shiki-dark:#abb2bf;--shiki-light-bg:#FAFAFA;--shiki-dark-bg:#282c34"><pre class="shiki shiki-themes one-light one-dark-pro vp-code"><code class="language-text"><span class="line"><span>/private/var/folders/.../T/com.microsoft.VSCode.ShipIt.xxxxxxxx/</span></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div></div></div><p>不要急着重新下载，先找临时目录。</p>
<h3>ShipIt 是独立进程</h3>
<p>关掉 VS Code 不代表更新器已经停止。排查这类问题时，要单独检查和清理 ShipIt。</p>
<h2>技术备忘</h2>
<p>| 项目 | 内容 |<br>
|</p>
]]></content>
    <category term="macOS"/>
    <category term="工具"/>
    <published>2026-05-01T00:00:00.000Z</published>
  </entry>
  <entry>
    <title type="text">Windows 10安装Kali WSL</title>
    <id>https://blog.checo.cc/posts/Windows/kali-wsl.html</id>
    <link href="https://blog.checo.cc/posts/Windows/kali-wsl.html"/>
    <updated>2026-06-06T15:23:57.000Z</updated>
    <summary type="html"><![CDATA[
<p>众所周知，Kali有很多自带的渗透测试工具。今天心血来潮想要在WSL中安装一个并且迁移到E盘，避免占用所剩无几的C盘空间</p>
<h2>准备工作</h2>
<p>Windows系统需要开启WSL</p>
<p>如果之前有装过WSL，默认是Ubuntu，可以使用以下命令进行卸载</p>
<div class="language- line-numbers-mode" data-highlighter="shiki" data-ext style="--shiki-light:#383A42;--shiki-dark:#abb2bf;--shiki-light-bg:#FAFAFA;--shiki-dark-bg:#282c34"><pre class="shiki shiki-themes one-light one-dark-pro vp-code"><code class="language-"><span class="line"><span>wsl --unregister kali-linux</span></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div></div></div>]]></summary>
    <content type="html"><![CDATA[
<p>众所周知，Kali有很多自带的渗透测试工具。今天心血来潮想要在WSL中安装一个并且迁移到E盘，避免占用所剩无几的C盘空间</p>
<h2>准备工作</h2>
<p>Windows系统需要开启WSL</p>
<p>如果之前有装过WSL，默认是Ubuntu，可以使用以下命令进行卸载</p>
<div class="language- line-numbers-mode" data-highlighter="shiki" data-ext style="--shiki-light:#383A42;--shiki-dark:#abb2bf;--shiki-light-bg:#FAFAFA;--shiki-dark-bg:#282c34"><pre class="shiki shiki-themes one-light one-dark-pro vp-code"><code class="language-"><span class="line"><span>wsl --unregister kali-linux</span></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div></div></div><h2>操作步骤</h2>
<ol>
<li>安装Kali，并根据提示创建用户密码，进入系统</li>
</ol>
<div class="language- line-numbers-mode" data-highlighter="shiki" data-ext style="--shiki-light:#383A42;--shiki-dark:#abb2bf;--shiki-light-bg:#FAFAFA;--shiki-dark-bg:#282c34"><pre class="shiki shiki-themes one-light one-dark-pro vp-code"><code class="language-"><span class="line"><span>wsl --install -d kali-linux</span></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div></div></div><figure><img src="https://picgo.checo.cc/20251211022031.png" alt tabindex="0" loading="lazy"><figcaption></figcaption></figure>
<ol start="2">
<li>打包当前的Kali系统，暂存至中间位置</li>
</ol>
<div class="language- line-numbers-mode" data-highlighter="shiki" data-ext style="--shiki-light:#383A42;--shiki-dark:#abb2bf;--shiki-light-bg:#FAFAFA;--shiki-dark-bg:#282c34"><pre class="shiki shiki-themes one-light one-dark-pro vp-code"><code class="language-"><span class="line"><span>wsl --export kali-linux D:\kali-backup.tar</span></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div></div></div><figure><img src="https://picgo.checo.cc/20251211022321.png" alt tabindex="0" loading="lazy"><figcaption></figcaption></figure>
<ol start="3">
<li>删除当前Kali系统</li>
</ol>
<div class="language- line-numbers-mode" data-highlighter="shiki" data-ext style="--shiki-light:#383A42;--shiki-dark:#abb2bf;--shiki-light-bg:#FAFAFA;--shiki-dark-bg:#282c34"><pre class="shiki shiki-themes one-light one-dark-pro vp-code"><code class="language-"><span class="line"><span>wsl --unregister kali-linux</span></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div></div></div><figure><img src="https://picgo.checo.cc/20251211022909.png" alt tabindex="0" loading="lazy"><figcaption></figcaption></figure>
<ol start="4">
<li>使用第二部打的包在E盘中启动新的Kali系统</li>
</ol>
<div class="language- line-numbers-mode" data-highlighter="shiki" data-ext style="--shiki-light:#383A42;--shiki-dark:#abb2bf;--shiki-light-bg:#FAFAFA;--shiki-dark-bg:#282c34"><pre class="shiki shiki-themes one-light one-dark-pro vp-code"><code class="language-"><span class="line"><span>wsl --import kali-linux E:\WSL\Kali D:\kali-backup.tar</span></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div></div></div><figure><img src="https://picgo.checo.cc/20251211022548.png" alt tabindex="0" loading="lazy"><figcaption></figcaption></figure>
<ol start="5">
<li>登录Kali系统</li>
</ol>
<div class="language- line-numbers-mode" data-highlighter="shiki" data-ext style="--shiki-light:#383A42;--shiki-dark:#abb2bf;--shiki-light-bg:#FAFAFA;--shiki-dark-bg:#282c34"><pre class="shiki shiki-themes one-light one-dark-pro vp-code"><code class="language-"><span class="line"><span>wsl -d kali-linux</span></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div></div></div><p>会默认以root身份登录<br>
<img src="https://picgo.checo.cc/20251215005129.png" alt loading="lazy"></p>
<ol start="6">
<li>创建文件告诉WSL默认用checo用户登录</li>
</ol>
<div class="language- line-numbers-mode" data-highlighter="shiki" data-ext style="--shiki-light:#383A42;--shiki-dark:#abb2bf;--shiki-light-bg:#FAFAFA;--shiki-dark-bg:#282c34"><pre class="shiki shiki-themes one-light one-dark-pro vp-code"><code class="language-"><span class="line"><span>echo -e "[user]\ndefault=checo" > /etc/wsl.conf</span></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div></div></div><figure><img src="https://picgo.checo.cc/20251215005258.png" alt tabindex="0" loading="lazy"><figcaption></figcaption></figure>
<ol start="7">
<li>退出并重启WSL</li>
</ol>
<div class="language- line-numbers-mode" data-highlighter="shiki" data-ext style="--shiki-light:#383A42;--shiki-dark:#abb2bf;--shiki-light-bg:#FAFAFA;--shiki-dark-bg:#282c34"><pre class="shiki shiki-themes one-light one-dark-pro vp-code"><code class="language-"><span class="line"><span>wsl --terminate kali-linux</span></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div></div></div><div class="language- line-numbers-mode" data-highlighter="shiki" data-ext style="--shiki-light:#383A42;--shiki-dark:#abb2bf;--shiki-light-bg:#FAFAFA;--shiki-dark-bg:#282c34"><pre class="shiki shiki-themes one-light one-dark-pro vp-code"><code class="language-"><span class="line"><span>wsl -d kali-linux</span></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div></div></div><p><img src="https://picgo.checo.cc/20251215005514.png" alt loading="lazy"><br>
进来后的提示符变成了 $，且用户名是 checo</p>
<h2>总结</h2>
<p>之后可以出一期教程，研究如何使用Kali</p>
]]></content>
    <category term="Windows"/>
    <category term="Linux"/>
    <published>2025-12-11T00:00:00.000Z</published>
  </entry>
  <entry>
    <title type="text">AWS 启动Windows11 EC2</title>
    <id>https://blog.checo.cc/posts/AWS/2.html</id>
    <link href="https://blog.checo.cc/posts/AWS/2.html"/>
    <updated>2026-06-06T15:23:57.000Z</updated>
    <summary type="html"><![CDATA[
<p>众所周知，AWS中国区并没有提供Windows11的AMI，VMimport也比较麻烦<br>
可以直接使用一个开源的reinstall脚本从Linux安装Windows<br>
项目地址：<a href="https://github.com/bin456789/reinstall" target="_blank" rel="noopener noreferrer">https://github.com/bin456789/reinstall</a><br>
参考文档：<a href="https://lpwmm.blog.csdn.net/article/details/155258680?spm=1001.2014.3001.5502" target="_blank" rel="noopener noreferrer">https://lpwmm.blog.csdn.net/article/details/155258680?spm=1001.2014.3001.5502</a></p>]]></summary>
    <content type="html"><![CDATA[
<p>众所周知，AWS中国区并没有提供Windows11的AMI，VMimport也比较麻烦<br>
可以直接使用一个开源的reinstall脚本从Linux安装Windows<br>
项目地址：<a href="https://github.com/bin456789/reinstall" target="_blank" rel="noopener noreferrer">https://github.com/bin456789/reinstall</a><br>
参考文档：<a href="https://lpwmm.blog.csdn.net/article/details/155258680?spm=1001.2014.3001.5502" target="_blank" rel="noopener noreferrer">https://lpwmm.blog.csdn.net/article/details/155258680?spm=1001.2014.3001.5502</a></p>
<h2>操作步骤</h2>
]]></content>
    <category term="AWS"/>
    <published>2025-12-03T00:00:00.000Z</published>
  </entry>
  <entry>
    <title type="text">Windows Server 2008 CloudWatch Agent 证书验证失败</title>
    <id>https://blog.checo.cc/posts/AWS/1.html</id>
    <link href="https://blog.checo.cc/posts/AWS/1.html"/>
    <updated>2026-06-06T16:08:40.000Z</updated>
    <summary type="html"><![CDATA[
<figure><img src="/assets/images/posts/aws-cloudwatch-cert-architecture.svg" alt="CloudWatch Agent 证书链修复架构图" tabindex="0" loading="lazy"><figcaption>CloudWatch Agent 证书链修复架构图</figcaption></figure>
<p>在一台 Windows Server 2008 EC2 实例上，CloudWatch Agent 服务状态正常，但监控指标一直无法上报到 CloudWatch。日志里反复出现 <code>x509: certificate signed by unknown authority</code>，最后定位到旧系统根证书和 TLS 支持不足。</p>
]]></summary>
    <content type="html"><![CDATA[
<figure><img src="/assets/images/posts/aws-cloudwatch-cert-architecture.svg" alt="CloudWatch Agent 证书链修复架构图" tabindex="0" loading="lazy"><figcaption>CloudWatch Agent 证书链修复架构图</figcaption></figure>
<p>在一台 Windows Server 2008 EC2 实例上，CloudWatch Agent 服务状态正常，但监控指标一直无法上报到 CloudWatch。日志里反复出现 <code>x509: certificate signed by unknown authority</code>，最后定位到旧系统根证书和 TLS 支持不足。</p>
<!-- more -->
<h2>现象</h2>
<p>CloudWatch Agent 日志中持续出现类似错误：</p>
<div class="language-text line-numbers-mode" data-highlighter="shiki" data-ext="text" style="--shiki-light:#383A42;--shiki-dark:#abb2bf;--shiki-light-bg:#FAFAFA;--shiki-dark-bg:#282c34"><pre class="shiki shiki-themes one-light one-dark-pro vp-code"><code class="language-text"><span class="line"><span>WriteToCloudWatch failure, err: RequestError: send request failed</span></span>
<span class="line"><span>caused by: Post https://monitoring.&#x3C;region>.amazonaws.com.cn/:</span></span>
<span class="line"><span>x509: certificate signed by unknown authority</span></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p>同时需要注意两个容易误判的点：</p>
<ul>
<li><code>ping monitoring.&lt;region&gt;.amazonaws.com.cn</code> 不通不一定代表服务不可达，Interface Endpoint 通常不响应 ICMP。</li>
<li>浏览器打开 CloudWatch API endpoint 返回 <code>404 Not Found</code> 也是正常现象，它不是普通网页服务。</li>
</ul>
<h2>根因</h2>
<p>Windows Server 2008 的根证书库太旧，可能缺少验证 AWS 服务端证书所需的根证书，例如 Amazon Root CA 1。纯内网实例如果无法访问公网，也不能自动拉取新的受信任根证书。</p>
<p>此外，旧版 Windows Server 2008 还可能缺少支持现代 TLS 链路的补丁。最终表现就是 CloudWatch Agent 建立 HTTPS 连接时无法完成证书链验证。</p>
<h2>处理步骤</h2>
<h3>1. 安装 SHA-2 / TLS 相关补丁</h3>
<p>先安装 Windows Server 2008 所需的安全补丁，例如 KB4474419。补丁安装后必须重启系统。</p>
<div class="language-powershell line-numbers-mode" data-highlighter="shiki" data-ext="powershell" style="--shiki-light:#383A42;--shiki-dark:#abb2bf;--shiki-light-bg:#FAFAFA;--shiki-dark-bg:#282c34"><pre class="shiki shiki-themes one-light one-dark-pro vp-code"><code class="language-powershell"><span class="line"><span style="--shiki-light:#0184BC;--shiki-dark:#56B6C2">wusa.exe</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF"> C:\Patches\windows6.</span><span style="--shiki-light:#986801;--shiki-dark:#D19A66">1</span><span style="--shiki-light:#383A42;--shiki-dark:#56B6C2">-</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF">kb4474419</span><span style="--shiki-light:#383A42;--shiki-dark:#56B6C2">-</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF">v3</span><span style="--shiki-light:#383A42;--shiki-dark:#56B6C2">-</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF">x64.msu </span><span style="--shiki-light:#383A42;--shiki-dark:#56B6C2">/</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF">quiet </span><span style="--shiki-light:#383A42;--shiki-dark:#56B6C2">/</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF">norestart</span></span>
<span class="line"><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF">shutdown </span><span style="--shiki-light:#383A42;--shiki-dark:#56B6C2">/</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF">r </span><span style="--shiki-light:#383A42;--shiki-dark:#56B6C2">/</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF">t </span><span style="--shiki-light:#986801;--shiki-dark:#D19A66">0</span></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div><div class="line-number"></div></div></div><h3>2. 导入 Amazon Root CA 1</h3>
<p>下载 Amazon Root CA 1 证书：</p>
<div class="language-text line-numbers-mode" data-highlighter="shiki" data-ext="text" style="--shiki-light:#383A42;--shiki-dark:#abb2bf;--shiki-light-bg:#FAFAFA;--shiki-dark-bg:#282c34"><pre class="shiki shiki-themes one-light one-dark-pro vp-code"><code class="language-text"><span class="line"><span>https://www.amazontrust.com/repository/AmazonRootCA1.cer</span></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div></div></div><p>在内网环境中，可以先从可访问公网的机器下载，再通过安全方式拷贝到实例。</p>
<p>导入到受信任根证书存储：</p>
<div class="language-powershell line-numbers-mode" data-highlighter="shiki" data-ext="powershell" style="--shiki-light:#383A42;--shiki-dark:#abb2bf;--shiki-light-bg:#FAFAFA;--shiki-dark-bg:#282c34"><pre class="shiki shiki-themes one-light one-dark-pro vp-code"><code class="language-powershell"><span class="line"><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF">certutil </span><span style="--shiki-light:#383A42;--shiki-dark:#56B6C2">-</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF">addstore </span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF">-f</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF"> Root C:\Patches\AmazonRootCA1.cer</span></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div></div></div><p>也可以通过 <code>certmgr.msc</code> 图形界面导入到“受信任的根证书颁发机构”。</p>
<h3>3. 重启 CloudWatch Agent</h3>
<div class="language-powershell line-numbers-mode" data-highlighter="shiki" data-ext="powershell" style="--shiki-light:#383A42;--shiki-dark:#abb2bf;--shiki-light-bg:#FAFAFA;--shiki-dark-bg:#282c34"><pre class="shiki shiki-themes one-light one-dark-pro vp-code"><code class="language-powershell"><span class="line"><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF">net stop </span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379">"Amazon CloudWatch Agent"</span></span>
<span class="line"><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF">net start </span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379">"Amazon CloudWatch Agent"</span></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div><div class="line-number"></div></div></div><h2>验证</h2>
<p>检查 Agent 日志，确认不再出现 <code>x509: certificate signed by unknown authority</code>。</p>
<p>也可以测试 TCP 443 连通性：</p>
<div class="language-powershell line-numbers-mode" data-highlighter="shiki" data-ext="powershell" style="--shiki-light:#383A42;--shiki-dark:#abb2bf;--shiki-light-bg:#FAFAFA;--shiki-dark-bg:#282c34"><pre class="shiki shiki-themes one-light one-dark-pro vp-code"><code class="language-powershell"><span class="line"><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF">(</span><span style="--shiki-light:#0184BC;--shiki-dark:#56B6C2">New-Object</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF"> System.Net.Sockets.TcpClient).Connect(</span><span style="--shiki-light:#50A14F;--shiki-dark:#98C379">"monitoring.&#x3C;region>.amazonaws.com.cn"</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF">, </span><span style="--shiki-light:#986801;--shiki-dark:#D19A66">443</span><span style="--shiki-light:#383A42;--shiki-dark:#ABB2BF">)</span></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div></div></div><p>如果命令无报错，说明 TCP 层连通。最终以 CloudWatch 控制台中指标正常上报为准。</p>
<h2>总结</h2>
<p>旧版 Windows Server 2008 在纯内网环境里运行 CloudWatch Agent 时，常见问题不是 VPC Endpoint，而是系统根证书和 TLS 能力太旧。处理顺序建议是：</p>
<ol>
<li>确认 CloudWatch endpoint TCP 443 可达。</li>
<li>安装必要系统补丁。</li>
<li>手动导入 Amazon Root CA 1。</li>
<li>重启 CloudWatch Agent 并观察日志。</li>
</ol>
<p>这类旧系统应尽量纳入迁移计划，长期运行会不断遇到证书、TLS、补丁和软件兼容问题。</p>
]]></content>
    <category term="AWS"/>
    <category term="Windows"/>
    <published>2026-05-01T00:00:00.000Z</published>
  </entry>
  <entry>
    <title type="text">足球</title>
    <id>https://blog.checo.cc/photos/3.html</id>
    <link href="https://blog.checo.cc/photos/3.html"/>
    <updated>2025-12-02T17:09:45.000Z</updated>
    <summary type="html"><![CDATA[
<h2>2025.4.19 北京国安vs山东泰山</h2>
<figure><img src="https://picgo.checo.cc/DSC_4615.JPG" alt tabindex="0" loading="lazy"><figcaption></figcaption></figure>
]]></summary>
    <content type="html"><![CDATA[
<h2>2025.4.19 北京国安vs山东泰山</h2>
<figure><img src="https://picgo.checo.cc/DSC_4615.JPG" alt tabindex="0" loading="lazy"><figcaption></figcaption></figure>
<!-- more -->
<p><img src="https://picgo.checo.cc/DSC_4616.JPG" alt loading="lazy"><br>
<img src="https://picgo.checo.cc/DSC_4626.JPG" alt loading="lazy"><br>
<img src="https://picgo.checo.cc/DSC_4628.JPG" alt loading="lazy"><br>
<img src="https://picgo.checo.cc/DSC_4637.JPG" alt loading="lazy"><br>
<img src="https://picgo.checo.cc/DSC_4640.JPG" alt loading="lazy"><br>
<img src="https://picgo.checo.cc/DSC_4692.JPG" alt loading="lazy"><br>
<img src="https://picgo.checo.cc/DSC_4696.JPG" alt loading="lazy"><br>
<img src="https://picgo.checo.cc/DSC_4698.JPG" alt loading="lazy"><br>
<img src="https://picgo.checo.cc/DSC_4701.JPG" alt loading="lazy"><br>
<img src="https://picgo.checo.cc/DSC_4702.JPG" alt loading="lazy"><br>
<img src="https://picgo.checo.cc/DSC_4704.JPG" alt loading="lazy"><br>
<img src="https://picgo.checo.cc/DSC_4713.JPG" alt loading="lazy"><br>
<img src="https://picgo.checo.cc/DSC_4747.JPG" alt loading="lazy"></p>
]]></content>
    <category term="摄影"/>
    <published>2025-02-10T00:00:00.000Z</published>
  </entry>
  <entry>
    <title type="text">鸟</title>
    <id>https://blog.checo.cc/photos/2.html</id>
    <link href="https://blog.checo.cc/photos/2.html"/>
    <updated>2025-12-02T17:09:45.000Z</updated>
    <summary type="html"><![CDATA[
<figure><img src="https://picgo.checo.cc/DSC_6427-已增强-降噪.jpg" alt tabindex="0" loading="lazy"><figcaption></figcaption></figure>
]]></summary>
    <content type="html"><![CDATA[
<figure><img src="https://picgo.checo.cc/DSC_6427-已增强-降噪.jpg" alt tabindex="0" loading="lazy"><figcaption></figcaption></figure>
<!-- more -->
<p><img src="https://picgo.checo.cc/DSC_5916-已增强-降噪.jpg" alt loading="lazy"><br>
<img src="https://picgo.checo.cc/DSC_6308.jpg" alt loading="lazy"><br>
<img src="https://picgo.checo.cc/DSC_6359.jpg" alt loading="lazy"><br>
<img src="https://picgo.checo.cc/DSC_6368-已增强-降噪.jpg" alt loading="lazy"><br>
<img src="https://picgo.checo.cc/DSC_6364-已增强-降噪.jpg" alt loading="lazy"><br>
<img src="https://picgo.checo.cc/DSC_6385-已增强-降噪.jpg" alt loading="lazy"><br>
<img src="https://picgo.checo.cc/DSC_9305-2.jpg" alt loading="lazy"><br>
<img src="https://picgo.checo.cc/DSC_9122.jpg" alt loading="lazy"><br>
<img src="https://picgo.checo.cc/DSC_8961-已增强-降噪.jpg" alt loading="lazy"><br>
<img src="https://picgo.checo.cc/DSC_8729.jpg" alt loading="lazy"><br>
<img src="https://picgo.checo.cc/DSC_8666-已增强-降噪.jpg" alt loading="lazy"><br>
<img src="https://picgo.checo.cc/DSC_8668-已增强-降噪.jpg" alt loading="lazy"><br>
<img src="https://picgo.checo.cc/DSC_8727.jpg" alt loading="lazy"><br>
<img src="https://picgo.checo.cc/DSC_4839-已增强-降噪.jpg" alt loading="lazy"><br>
<img src="https://picgo.checo.cc/DSC_4880-已增强-降噪.jpg" alt loading="lazy"></p>
]]></content>
    <category term="摄影"/>
    <published>2025-02-10T00:00:00.000Z</published>
  </entry>
  <entry>
    <title type="text">皖南川藏线</title>
    <id>https://blog.checo.cc/photos/1.html</id>
    <link href="https://blog.checo.cc/photos/1.html"/>
    <updated>2025-05-08T05:03:43.000Z</updated>
    <summary type="html"><![CDATA[
<h2>直接上图</h2>
<figure><img src="https://picgo.checo.cc/DSC_0180.jpg" alt tabindex="0" loading="lazy"><figcaption></figcaption></figure>
]]></summary>
    <content type="html"><![CDATA[
<h2>直接上图</h2>
<figure><img src="https://picgo.checo.cc/DSC_0180.jpg" alt tabindex="0" loading="lazy"><figcaption></figcaption></figure>
<!-- more -->
<p><img src="https://picgo.checo.cc/DSC_0307-已增强-降噪.jpg" alt loading="lazy"><br>
<img src="https://picgo.checo.cc/DSC_0076.jpg" alt loading="lazy"><br>
<img src="https://picgo.checo.cc/DSC_0059.jpg" alt loading="lazy"><br>
<img src="https://picgo.checo.cc/DSC_0085.jpg" alt loading="lazy"></p>
]]></content>
    <category term="摄影"/>
    <published>2025-02-10T00:00:00.000Z</published>
  </entry>
  <entry>
    <title type="text">Linux常用脚本合集</title>
    <id>https://blog.checo.cc/posts/VPS/1.html</id>
    <link href="https://blog.checo.cc/posts/VPS/1.html"/>
    <updated>2025-02-11T06:21:55.000Z</updated>
    <summary type="html"><![CDATA[
<h2>网络相关</h2>
<h2>测评相关</h2>
]]></summary>
    <content type="html"><![CDATA[
<h2>网络相关</h2>
<h2>测评相关</h2>
]]></content>
    <category term="VPS"/>
    <category term="Linux"/>
    <published>2024-05-20T00:00:00.000Z</published>
  </entry>
  <entry>
    <title type="text">摄影</title>
    <id>https://blog.checo.cc/photos/</id>
    <link href="https://blog.checo.cc/photos/"/>
    <updated>2025-05-08T04:37:34.000Z</updated>
    <category term="首页"/>
    <published>2025-02-02T09:36:39.000Z</published>
  </entry>
  <entry>
    <title type="text">DeepSeek本地部署</title>
    <id>https://blog.checo.cc/posts/AI/1.html</id>
    <link href="https://blog.checo.cc/posts/AI/1.html"/>
    <updated>2026-06-06T15:23:57.000Z</updated>
    <summary type="html"><![CDATA[
<h2>为什么使用本地大模型</h2>
<ol>
<li>
<p>近日DeepSeek官网过于火爆，时常不回复<br>
<img src="https://picgo.checo.cc/20250209145239.png" alt loading="lazy"></p>
</li>
<li>
<p>本地部署有更高的安全性</p>
</li>
<li>
<p>本地部署可以绕过一些官方的限制</p>
</li>
</ol>
]]></summary>
    <content type="html"><![CDATA[
<h2>为什么使用本地大模型</h2>
<ol>
<li>
<p>近日DeepSeek官网过于火爆，时常不回复<br>
<img src="https://picgo.checo.cc/20250209145239.png" alt loading="lazy"></p>
</li>
<li>
<p>本地部署有更高的安全性</p>
</li>
<li>
<p>本地部署可以绕过一些官方的限制</p>
</li>
</ol>
<!-- more -->
<h2>测试环境</h2>
<p><strong>OS</strong>: Windows 10 Pro 22H2<br>
<strong>CPU</strong>: AMD Ryzen 5 5600H (6C12T, Base 3.3GHz / Boost 4.2GHz)<br>
<strong>GPU</strong>: NVIDIA GeForce RTX 3050 Ti Laptop GPU (4GB GDDR6 VRAM)<br>
<strong>RAM</strong>: SAMSUNG 16GB DDR4-3200<br>
<strong>IDE</strong>: LM Studio v0.3.9</p>
<h2>部署方法</h2>
<ol start="0">
<li>
<p>推荐使用国外网络环境并开启代理工具的TUN模式</p>
</li>
<li>
<p>下载安装LM Studio客户端<br>
<a href="https://lmstudio.ai" target="_blank" rel="noopener noreferrer">点击跳转</a></p>
</li>
<li>
<p>修改模型下载目录（推荐）<br>
防止模型大量占用C盘空间<br>
<img src="https://picgo.checo.cc/20250209115213.png" alt loading="lazy"></p>
</li>
<li>
<p>根据电脑配置下载对应模型<br>
带<code>Distill</code>字样的是蒸馏模型<br>
这里推荐<code>DeepSeek-R1-Distill-Llama-8B-Abliterated-GGUF</code>，4g显存能流畅运行，该模型还解除了DeepSeek自带的一些限制，让本地应用更加自由<br>
<img src="https://picgo.checo.cc/20250209144621.png" alt loading="lazy"></p>
</li>
<li>
<p>加载模型<br>
下载完成之后点击顶部加载刚刚下载好的模型<br>
建议拉高<code>GPU卸载</code>，打开<code>快速注意力</code>以提高性能<br>
<img src="https://picgo.checo.cc/20250209144950.png" alt loading="lazy"></p>
</li>
<li>
<p>进行使用即可<br>
<img src="https://picgo.checo.cc/20250209145930.png" alt loading="lazy"></p>
</li>
</ol>
<h2>高级用法</h2>
]]></content>
    <category term="AI"/>
    <published>2025-02-02T00:00:00.000Z</published>
  </entry>
  <entry>
    <title type="text">介绍页</title>
    <id>https://blog.checo.cc/intro.html</id>
    <link href="https://blog.checo.cc/intro.html"/>
    <updated>2025-12-02T17:09:45.000Z</updated>
    <summary type="html"><![CDATA[
<p>Checo</p>
<ul>
<li>信息安全专业毕业生</li>
<li>地理爱好者</li>
<li>摄影爱好者</li>
<li>房东的猫粉丝</li>
</ul>
]]></summary>
    <content type="html"><![CDATA[
<p>Checo</p>
<ul>
<li>信息安全专业毕业生</li>
<li>地理爱好者</li>
<li>摄影爱好者</li>
<li>房东的猫粉丝</li>
</ul>
]]></content>
    <published>2025-01-29T01:51:53.000Z</published>
  </entry>
  <entry>
    <title type="text">写在后面</title>
    <id>https://blog.checo.cc/posts/begin.html</id>
    <link href="https://blog.checo.cc/posts/begin.html"/>
    <updated>2026-06-06T15:23:57.000Z</updated>
    <summary type="html"><![CDATA[
<p>这个博客主要用来放两类内容：一类是技术折腾和排障记录，另一类是生活、摄影和一些个人兴趣。很多文章不是标准教程，而是我在真实环境里遇到问题后整理出来的复盘。</p>
]]></summary>
    <content type="html"><![CDATA[
<p>这个博客主要用来放两类内容：一类是技术折腾和排障记录，另一类是生活、摄影和一些个人兴趣。很多文章不是标准教程，而是我在真实环境里遇到问题后整理出来的复盘。</p>
<!-- more -->
<p>写博客对我来说不是为了把每件事包装得很完整，而是把“当时怎么判断、踩了什么坑、最后怎么解决”留下来。以后再次遇到类似问题，能少走一些弯路；别人搜到时，也能快速判断这条路是否适合自己。</p>
<h2>AI</h2>
<p>AI 分类主要记录大模型和相关工具的使用体验。</p>
<p>目前会写这些方向：</p>
<ul>
<li>本地大模型部署，比如 LM Studio、Ollama。</li>
<li>DeepSeek、Cherry Studio、硅基流动这类工具链。</li>
<li>API 调用、模型接入和一些低成本使用方式。</li>
<li>AI 工具在日常工作里的实际用法。</li>
</ul>
<p>这部分文章会偏实践，不会只堆概念。能本地跑起来、能接入客户端、能解决实际问题，才值得记录。</p>
<h2>AWS</h2>
<p>AWS 现在是博客里内容最多的一类。这里主要放云服务排障、EC2 运维、Windows/Linux 系统问题、S3、ALB、IAM、FSx、SSM、CloudWatch 等案例。</p>
<p>这类文章通常会按这个结构写：</p>
<ol>
<li>问题现象</li>
<li>关键日志</li>
<li>排查路径</li>
<li>根因判断</li>
<li>解决方案</li>
<li>后续建议</li>
</ol>
<p>很多 AWS 问题看起来是云平台故障，但最后根因可能在操作系统、证书链、KMS 权限、Windows Update、AD 端口、Kerberos 票据或第三方安全软件。写下来是为了提醒自己：排障要分层，不要一开始就把问题归因到某个组件。</p>
<h2>运维</h2>
<p>运维分类放的是更通用的服务器、容器和服务迁移记录。</p>
<p>比如：</p>
<ul>
<li>1Panel 服务器维护</li>
<li>Docker 网络和 iptables/nftables 问题</li>
<li>new-api 从 SQLite 迁移到 MySQL</li>
<li>生产服务蓝绿切换</li>
<li>反向代理和数据库连接问题</li>
</ul>
<p>这类内容的重点是可复现和可回滚。生产环境里的操作不能只追求“能跑”，还要考虑备份、验证、切流量和失败回退。</p>
<h2>VPS</h2>
<p>VPS 分类会记录服务器、网络、域名和常用脚本。</p>
<p>后面计划补充：</p>
<ul>
<li>Linux 常用脚本</li>
<li>VPS 测评与网络测试</li>
<li>域名、DNS、证书相关配置</li>
<li>哪吒探针、三网 IP、代理和网络连通性</li>
</ul>
<p>这部分会比较杂，但都围绕个人服务器和网络资产管理。</p>
<h2>macOS</h2>
<p>macOS 分类主要记录我自己的 Mac 使用、故障排查和硬件检测。</p>
<p>比如：</p>
<ul>
<li>Mac mini M4 到手后的硬件检测</li>
<li>VS Code 在外置 APFS 卷上自动更新失败</li>
<li>外接硬盘、应用迁移、系统日志排查</li>
</ul>
<p>这类文章偏个人经验，但很多坑具有共性。尤其是 macOS 上跨卷、权限、临时目录、应用自动更新这些问题，平时不明显，一旦出事就很难第一时间定位。</p>
<h2>Windows 与安全</h2>
<p>Windows 分类目前主要放 WSL、Kali 和 Windows 环境相关内容。</p>
<p>以后会继续补：</p>
<ul>
<li>WSL 迁移和折腾</li>
<li>Kali 工具环境</li>
<li>Windows Server 运维经验</li>
<li>安全测试环境搭建</li>
</ul>
<p>这部分和 AWS 里的 Windows 排障不同：AWS 分类更关注云上案例，Windows 分类更偏本地环境和个人使用。</p>
<h2>摄影</h2>
<p>摄影是另一个长期保留的栏目。</p>
<p>这里不会写太多器材参数，更多是照片本身和拍摄场景，比如皖南川藏线、鸟、足球比赛。技术博客容易越写越硬，摄影能让这个站不只是一个问题清单，也保留一点生活感。</p>
<h2>写作原则</h2>
<p>后续文章我会尽量遵循几个原则：</p>
<ul>
<li>不放敏感信息，账号、实例 ID、内网 IP、域名、密钥都要泛化。</li>
<li>少写空泛结论，多写判断依据。</li>
<li>命令能直接复制，但要标清风险。</li>
<li>能解释根因就不只写步骤。</li>
<li>生产操作必须提醒备份和回滚。</li>
<li>未完成的草稿不置顶，不把占位内容当正式文章。</li>
</ul>
<h2>后续计划</h2>
<p>短期先把已有笔记整理干净，尤其是 AWS、运维和 VPS 相关内容。中期会把博客的视觉和导航再整理一下，让分类更清楚，文章列表更适合浏览。</p>
<p>这个博客现在还不算丰富，但已经开始有自己的方向：技术问题不只记录“怎么做”，更记录“为什么这么做”。能长期积累下去，就会越来越有价值。</p>
]]></content>
    <category term="博客"/>
    <published>2024-05-20T00:00:00.000Z</published>
  </entry>
  <entry>
    <title type="text">通过硅基流动使用DeepSeek-R1</title>
    <id>https://blog.checo.cc/posts/AI/2.html</id>
    <link href="https://blog.checo.cc/posts/AI/2.html"/>
    <updated>2025-12-04T03:40:14.000Z</updated>
    <summary type="html"><![CDATA[
<h2>下载安装Cherry Studio</h2>
<p>这里是内容。</p>
<h2>注册硅基流动账号</h2>
<p><a href="https://cloud.siliconflow.cn/i/YCwowtrD" target="_blank" rel="noopener noreferrer">点击注册</a></p>
<h2>获取API key</h2>
]]></summary>
    <content type="html"><![CDATA[
<h2>下载安装Cherry Studio</h2>
<p>这里是内容。</p>
<h2>注册硅基流动账号</h2>
<p><a href="https://cloud.siliconflow.cn/i/YCwowtrD" target="_blank" rel="noopener noreferrer">点击注册</a></p>
<h2>获取API key</h2>
]]></content>
    <category term="AI"/>
    <published>2025-02-09T00:00:00.000Z</published>
  </entry>
  <entry>
    <title type="text">通过FOFA白嫖DeepSeek</title>
    <id>https://blog.checo.cc/posts/AI/3.html</id>
    <link href="https://blog.checo.cc/posts/AI/3.html"/>
    <updated>2025-02-11T06:21:55.000Z</updated>
    <summary type="html"><![CDATA[
]]></summary>
    <content type="html"><![CDATA[
]]></content>
    <category term="AI"/>
    <category term="白嫖"/>
    <published>2025-02-11T00:00:00.000Z</published>
  </entry>
  <entry>
    <title type="text">从零训练一个 TinyStories 风格 GPT 小模型</title>
    <id>https://blog.checo.cc/posts/AI/4.html</id>
    <link href="https://blog.checo.cc/posts/AI/4.html"/>
    <updated>2026-06-06T16:08:40.000Z</updated>
    <summary type="html"><![CDATA[
<figure><img src="/assets/images/posts/llm-from-scratch-hero.png" alt="从零训练 LLM 的简约流程图" tabindex="0" loading="lazy"><figcaption>从零训练 LLM 的简约流程图</figcaption></figure>
<p>这个项目是在 Apple M4 Mac mini 16GB 上，用 MLX 从随机初始化开始训练一个 TinyStories 风格的小型 GPT 模型。它不是调用 API，也不是微调现成模型，而是把数据准备、tokenizer、模型结构、训练循环、checkpoint 和推理生成完整走了一遍。</p>
<p>项目地址：<a href="https://github.com/sergioperezcheco/llm-from-scratch" target="_blank" rel="noopener noreferrer">sergioperezcheco/llm-from-scratch</a></p>
]]></summary>
    <content type="html"><![CDATA[
<figure><img src="/assets/images/posts/llm-from-scratch-hero.png" alt="从零训练 LLM 的简约流程图" tabindex="0" loading="lazy"><figcaption>从零训练 LLM 的简约流程图</figcaption></figure>
<p>这个项目是在 Apple M4 Mac mini 16GB 上，用 MLX 从随机初始化开始训练一个 TinyStories 风格的小型 GPT 模型。它不是调用 API，也不是微调现成模型，而是把数据准备、tokenizer、模型结构、训练循环、checkpoint 和推理生成完整走了一遍。</p>
<p>项目地址：<a href="https://github.com/sergioperezcheco/llm-from-scratch" target="_blank" rel="noopener noreferrer">sergioperezcheco/llm-from-scratch</a></p>
<!-- more -->
<h2>项目结果</h2>
<p>最终训练的是一个 44M 参数量的 GPT 模型：</p>
<p>| 项目 | 结果 |<br>
|</p>
]]></content>
    <category term="AI"/>
    <published>2026-06-06T00:00:00.000Z</published>
  </entry>
  <entry>
    <title type="text">通过FOFA寻找三网IP</title>
    <id>https://blog.checo.cc/posts/VPS/2.html</id>
    <link href="https://blog.checo.cc/posts/VPS/2.html"/>
    <updated>2026-04-02T16:35:01.000Z</updated>
    <summary type="html"><![CDATA[
<p>哪吒探针的三网延迟功能非常好用，我们可以通过FOFA这一网络空间测绘工具寻找我们需要的三网IP</p>
]]></summary>
    <content type="html"><![CDATA[
<p>哪吒探针的三网延迟功能非常好用，我们可以通过FOFA这一网络空间测绘工具寻找我们需要的三网IP</p>
<!-- more -->
]]></content>
    <published>2022-01-06T00:00:00.000Z</published>
  </entry>
</feed>