<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/">
    <channel>
        <title>小明</title>
        <link>https://b.696988.xyz/</link>
        <description>哦哦啊啊诶诶</description>
        <lastBuildDate>Sat, 16 May 2026 07:47:34 GMT</lastBuildDate>
        <docs>https://validator.w3.org/feed/docs/rss2.html</docs>
        <generator>https://github.com/jpmonette/feed</generator>
        <language>zh-CN</language>
        <copyright>All rights reserved 2026, 小明momo</copyright>
        <item>
            <title><![CDATA[nezha v0探针排查指南]]></title>
            <link>https://b.696988.xyz/article/nezha-v0-probe-troubleshooting-guide</link>
            <guid>https://b.696988.xyz/article/nezha-v0-probe-troubleshooting-guide</guid>
            <pubDate>Sat, 21 Mar 2026 00:00:00 GMT</pubDate>
            <content:encoded><![CDATA[<div id="notion-article" class="mx-auto overflow-hidden "><main class="notion light-mode notion-page notion-block-32ab72e8655880a589f3f8f8da400890"><div class="notion-viewport"></div><div class="notion-collection-page-properties"></div><div class="notion-blank notion-block-32ab72e8655880bfac8eedd68a28d6bd"> </div><h4 class="notion-h notion-h3 notion-h-indent-0 notion-block-32ab72e8655880b0b55be73c7b76f392" data-id="32ab72e8655880b0b55be73c7b76f392"><span><div id="32ab72e8655880b0b55be73c7b76f392" class="notion-header-anchor"></div><a class="notion-hash-link" href="#32ab72e8655880b0b55be73c7b76f392" title="哪吒 Agent 排障速查清单"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">哪吒 Agent 排障速查清单</span></span></h4><h4 class="notion-h notion-h3 notion-h-indent-0 notion-block-32ab72e8655880c4b92ee9ab23b4fd81" data-id="32ab72e8655880c4b92ee9ab23b4fd81"><span><div id="32ab72e8655880c4b92ee9ab23b4fd81" class="notion-header-anchor"></div><a class="notion-hash-link" href="#32ab72e8655880c4b92ee9ab23b4fd81" title="1. 看服务状态"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">1. 看服务状态</span></span></h4><div class="notion-text notion-block-32ab72e8655880098cb4ea9bd62d8c67">重点看：</div><ul class="notion-list notion-list-disc notion-block-32ab72e865588058aa49d4c53e68a6e3"><li><code class="notion-inline-code">Active: active (running)</code> = 正常运行</li></ul><ul class="notion-list notion-list-disc notion-block-32ab72e865588021802fd48838219a8b"><li><code class="notion-inline-code">Active: failed</code> = 启动失败</li></ul><ul class="notion-list notion-list-disc notion-block-32ab72e86558805898d1e1bcca487c0d"><li><code class="notion-inline-code">Unit ... could not be found</code> = 服务文件没了</li></ul><hr class="notion-hr notion-block-32ab72e86558805b974dd4afa96e747b"/><h4 class="notion-h notion-h3 notion-h-indent-0 notion-block-32ab72e865588097a13bf67bb2337b32" data-id="32ab72e865588097a13bf67bb2337b32"><span><div id="32ab72e865588097a13bf67bb2337b32" class="notion-header-anchor"></div><a class="notion-hash-link" href="#32ab72e865588097a13bf67bb2337b32" title="2. 看日志"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">2. 看日志</span></span></h4><div class="notion-text notion-block-32ab72e8655880fa9ef4fd37c22c85b2">实时看：</div><hr class="notion-hr notion-block-32ab72e865588018af96f62eb809e5fd"/><h4 class="notion-h notion-h3 notion-h-indent-0 notion-block-32ab72e8655880d7bc95ef3336fcbaa7" data-id="32ab72e8655880d7bc95ef3336fcbaa7"><span><div id="32ab72e8655880d7bc95ef3336fcbaa7" class="notion-header-anchor"></div><a class="notion-hash-link" href="#32ab72e8655880d7bc95ef3336fcbaa7" title="3. 看 service 文件内容"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">3. 看 service 文件内容</span></span></h4><div class="notion-text notion-block-32ab72e8655880e1959dcce067bd91a6">如果提示：</div><div class="notion-text notion-block-32ab72e8655880a68eb1f543de739a28">说明 service 文件丢了。</div><hr class="notion-hr notion-block-32ab72e8655880349f18d0cd24e88ee5"/><h4 class="notion-h notion-h3 notion-h-indent-0 notion-block-32ab72e865588051a99aec4bf3891694" data-id="32ab72e865588051a99aec4bf3891694"><span><div id="32ab72e865588051a99aec4bf3891694" class="notion-header-anchor"></div><a class="notion-hash-link" href="#32ab72e865588051a99aec4bf3891694" title="4. 找 agent 二进制"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">4. 找 agent 二进制</span></span></h4><div class="notion-text notion-block-32ab72e865588099b3c8e93d62873bf2">常见路径：</div><hr class="notion-hr notion-block-32ab72e865588067932bcf525d475d13"/><h4 class="notion-h notion-h3 notion-h-indent-0 notion-block-32ab72e8655880a6994ae31d4fe883fb" data-id="32ab72e8655880a6994ae31d4fe883fb"><span><div id="32ab72e8655880a6994ae31d4fe883fb" class="notion-header-anchor"></div><a class="notion-hash-link" href="#32ab72e8655880a6994ae31d4fe883fb" title="5. 看 agent 版本"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">5. 看 agent 版本</span></span></h4><hr class="notion-hr notion-block-32ab72e865588002a8b2fbb7de674dce"/><h4 class="notion-h notion-h3 notion-h-indent-0 notion-block-32ab72e865588009bbe4e32dbbd24d92" data-id="32ab72e865588009bbe4e32dbbd24d92"><span><div id="32ab72e865588009bbe4e32dbbd24d92" class="notion-header-anchor"></div><a class="notion-hash-link" href="#32ab72e865588009bbe4e32dbbd24d92" title="6. 看支持的参数"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">6. 看支持的参数</span></span></h4><div class="notion-text notion-block-32ab72e8655880d79713fb594a6d1e3b">如果不支持 <code class="notion-inline-code">-c</code>，就别用 <code class="notion-inline-code">config.yml</code> 启动。</div><hr class="notion-hr notion-block-32ab72e865588006a970db7da9f6b5e8"/><h4 class="notion-h notion-h3 notion-h-indent-0 notion-block-32ab72e86558800d87c3cb33813e7aeb" data-id="32ab72e86558800d87c3cb33813e7aeb"><span><div id="32ab72e86558800d87c3cb33813e7aeb" class="notion-header-anchor"></div><a class="notion-hash-link" href="#32ab72e86558800d87c3cb33813e7aeb" title="7. 找旧安装参数"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">7. 找旧安装参数</span></span></h4><div class="notion-text notion-block-32ab72e86558803dbd5dd09662df3592">常能找到：</div><hr class="notion-hr notion-block-32ab72e865588073a971f5752ce941ee"/><h4 class="notion-h notion-h3 notion-h-indent-0 notion-block-32ab72e86558802f9a84f1d96a8d7af9" data-id="32ab72e86558802f9a84f1d96a8d7af9"><span><div id="32ab72e86558802f9a84f1d96a8d7af9" class="notion-header-anchor"></div><a class="notion-hash-link" href="#32ab72e86558802f9a84f1d96a8d7af9" title="8. 重建 service"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">8. 重建 service</span></span></h4><div class="notion-text notion-block-32ab72e8655880d0b77ce5f4d44695de">然后：</div><hr class="notion-hr notion-block-32ab72e8655880608b27c6de33c871b7"/><h4 class="notion-h notion-h3 notion-h-indent-0 notion-block-32ab72e86558806e80b9fc837fe3e061" data-id="32ab72e86558806e80b9fc837fe3e061"><span><div id="32ab72e86558806e80b9fc837fe3e061" class="notion-header-anchor"></div><a class="notion-hash-link" href="#32ab72e86558806e80b9fc837fe3e061" title="9. 常见问题判断"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">9. 常见问题判断</span></span></h4><div class="notion-text notion-block-32ab72e86558804cbe85cf288accc1df"><b>A. service not found</b></div><ul class="notion-list notion-list-disc notion-block-32ab72e865588021adc5f59253e62497"><li>服务文件没了</li></ul><ul class="notion-list notion-list-disc notion-block-32ab72e8655880aeb0affe6e62c4e484"><li>重建 service 即可</li></ul><div class="notion-text notion-block-32ab72e865588012ad5ef0702cfdc2d4"><b>B. authentication failed / 连不上</b></div><ul class="notion-list notion-list-disc notion-block-32ab72e8655880f5b82fc485ee248c7a"><li><code class="notion-inline-code">s</code> 或 <code class="notion-inline-code">p</code> 填错</li></ul><ul class="notion-list notion-list-disc notion-block-32ab72e865588020b852c3d0d7200792"><li>去面板重新确认地址和密钥</li></ul><div class="notion-text notion-block-32ab72e8655880419f94c5e459e45373"><b>C. panic / nil pointer / GetHost()</b></div><ul class="notion-list notion-list-disc notion-block-32ab72e8655880849610d5092f854712"><li>旧版本 agent 崩溃</li></ul><ul class="notion-list notion-list-disc notion-block-32ab72e86558800385b9ed1cc3d93b23"><li>优先怀疑版本兼容问题</li></ul><div class="notion-text notion-block-32ab72e865588058900efe5593de38fc"><b>D. journalctl 有日志，但 systemctl 找不到</b></div><ul class="notion-list notion-list-disc notion-block-32ab72e8655880edb58dfa27a4a7cb5b"><li>正常</li></ul><ul class="notion-list notion-list-disc notion-block-32ab72e8655880fb9191e503e24349fd"><li>说明 service 以前存在过，现在被删了</li></ul><hr class="notion-hr notion-block-32ab72e86558808cb91ff310e511c477"/><h4 class="notion-h notion-h3 notion-h-indent-0 notion-block-32ab72e8655880069a02de7a88656cfa" data-id="32ab72e8655880069a02de7a88656cfa"><span><div id="32ab72e8655880069a02de7a88656cfa" class="notion-header-anchor"></div><a class="notion-hash-link" href="#32ab72e8655880069a02de7a88656cfa" title="10. 最后确认"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">10. 最后确认</span></span></h4><div class="notion-text notion-block-32ab72e86558807cb52aecc05632fcf8">应该看到：</div><hr class="notion-hr notion-block-32ab72e86558805b8113f99aa908e477"/><div class="notion-text notion-block-32ab72e86558804d8acec94b5c600f3d">还有一点：</div><div class="notion-text notion-block-32ab72e8655880b7ad4dd13f320cf1e7">你之前贴出来过 secret，<b>建议去面板重置密钥</b>。</div><div class="notion-text notion-block-32ab72e865588007b765e14c7c943df4">如果以后你还有哪台机器出问题，直接把这几项贴出来就够了：</div><div class="notion-text notion-block-32ab72e8655880f59aa3f8f71d195c48">我就能很快帮你判断。</div></main></div>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[每次发现一个网站【1】：mastra.ai]]></title>
            <link>https://b.696988.xyz/article/314b72e8-6558-8086-8bb6-f503bd1e384a</link>
            <guid>https://b.696988.xyz/article/314b72e8-6558-8086-8bb6-f503bd1e384a</guid>
            <pubDate>Fri, 27 Feb 2026 00:00:00 GMT</pubDate>
            <content:encoded><![CDATA[<div id="notion-article" class="mx-auto overflow-hidden "><main class="notion light-mode notion-page notion-block-314b72e8655880868bb6f503bd1e384a"><div class="notion-viewport"></div><div class="notion-collection-page-properties"></div><div class="notion-text notion-block-314b72e865588066b21cf9c9f6f6aa46">这个网站 <b><a class="notion-link" href="https://mastra.ai/" target="_blank" rel="noopener noreferrer">https://mastra.ai/</a></b> 是 <b>Mastra 框架的官网</b>，主要是给开发者用来<b>快速构建 AI 应用和智能 Agent 的 TypeScript 框架</b>。</div><div class="notion-text notion-block-314b72e8655880d89622fd600fb24877">可以简单理解成：</div><blockquote class="notion-quote notion-block-314b72e8655880beafbec58f78d9a299"><div>如果你会 JavaScript/TypeScript，Mastra 提供一整套“积木”和基础设施，让你很快做出聊天机器人、智能助手、工作流自动化、RAG 知识库问答等 AI 应用。</div></blockquote><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-314b72e8655880a89d64c39781a0d8b2" data-id="314b72e8655880a89d64c39781a0d8b2"><span><div id="314b72e8655880a89d64c39781a0d8b2" class="notion-header-anchor"></div><a class="notion-hash-link" href="#314b72e8655880a89d64c39781a0d8b2" title="它具体是干嘛的？"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">它具体是干嘛的？</span></span></h3><h4 class="notion-h notion-h3 notion-h-indent-1 notion-block-314b72e8655880c581ccf7b39921c1c1" data-id="314b72e8655880c581ccf7b39921c1c1"><span><div id="314b72e8655880c581ccf7b39921c1c1" class="notion-header-anchor"></div><a class="notion-hash-link" href="#314b72e8655880c581ccf7b39921c1c1" title="1. 提供一个「AI 应用开发框架」"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">1. 提供一个「AI 应用开发框架」</span></span></h4><div class="notion-text notion-block-314b72e86558805a87b0eaa91f3a7da0">Mastra 是一个 <b>开源的 TypeScript AI 框架</b>，用途是：</div><ul class="notion-list notion-list-disc notion-block-314b72e8655880cf8e38c08c862363b0"><li>构建 <b>AI 驱动的 Web / 后端应用</b></li></ul><ul class="notion-list notion-list-disc notion-block-314b72e86558805aaa62cda71f399d60"><li>构建 <b>智能代理（Agent）</b>，例如自动帮你：</li><ul class="notion-list notion-list-disc notion-block-314b72e86558805aaa62cda71f399d60"><li>调用工具 / API</li><li>走多步流程</li><li>记住历史对话和知识</li></ul></ul><ul class="notion-list notion-list-disc notion-block-314b72e8655880f0b8e6fd1e4b2242e7"><li>帮你把这些能力 <b>接到现有项目里</b>（如 Next.js、Express 等）</li></ul><div class="notion-text notion-block-314b72e8655880358a44c13888138368">官网给出的定位：</div><blockquote class="notion-quote notion-block-314b72e8655880cea4fbd89dcb56785a"><div>“The TypeScript AI Framework / The TypeScript agent framework with workflows, memory, streaming, an interactive playground, evals, and tracing.”[1]</div></blockquote><h4 class="notion-h notion-h3 notion-h-indent-1 notion-block-314b72e8655880ce88e1fbe8d54683e0" data-id="314b72e8655880ce88e1fbe8d54683e0"><span><div id="314b72e8655880ce88e1fbe8d54683e0" class="notion-header-anchor"></div><a class="notion-hash-link" href="#314b72e8655880ce88e1fbe8d54683e0" title="2. Mastra 提供哪些核心能力？"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">2. Mastra 提供哪些核心能力？</span></span></h4><div class="notion-text notion-block-314b72e8655880bc8636e98c899736fd">从官网首页和文档整理出来，Mastra 主要包含这些模块：[1][2]</div><ul class="notion-list notion-list-disc notion-block-314b72e865588090ba2aded43536ad0f"><li><b>Agents（代理）</b></li><ul class="notion-list notion-list-disc notion-block-314b72e865588090ba2aded43536ad0f"><li>基于大模型的“智能体”，可以：</li><ul class="notion-list notion-list-disc notion-block-314b72e86558804794aeddb1cb96be8d"><li>结合工具和 API 完成复杂任务</li><li>自己决定调用哪个工具、调用几次</li><li>多轮推理后再给最终答案</li></ul></ul></ul><ul class="notion-list notion-list-disc notion-block-314b72e86558809a8d27e5bda8652fe0"><li><b>Workflows（工作流）</b></li><ul class="notion-list notion-list-disc notion-block-314b72e86558809a8d27e5bda8652fe0"><li>用图式 / 链式方式编排多步流程</li><li>支持分支、并行、重试、错误处理、嵌套工作流等</li><li>可以通过代码或可视化编辑器来搭建</li></ul></ul><ul class="notion-list notion-list-disc notion-block-314b72e86558801db2f8dd4abe426cc4"><li><b>Memory（记忆）</b></li><ul class="notion-list notion-list-disc notion-block-314b72e86558801db2f8dd4abe426cc4"><li>管理对话上下文和长期记忆</li><li>支持“消息历史”“工作记忆”和“语义记忆”（向量检索）</li></ul></ul><ul class="notion-list notion-list-disc notion-block-314b72e86558802d89ade213dc5f0b93"><li><b>RAG（检索增强生成）</b></li><ul class="notion-list notion-list-disc notion-block-314b72e86558802d89ade213dc5f0b93"><li>将文档、知识库与大模型结合，让回答基于你自己的数据而不是纯模型“瞎猜”</li></ul></ul><ul class="notion-list notion-list-disc notion-block-314b72e86558801ba687fbd9f27d069f"><li><b>模型路由（Model routing）</b></li><ul class="notion-list notion-list-disc notion-block-314b72e86558801ba687fbd9f27d069f"><li>一套统一接口对接多个模型提供商</li><li>支持 OpenAI、Anthropic、Google Gemini 等 40+ 提供商[2]</li></ul></ul><ul class="notion-list notion-list-disc notion-block-314b72e86558804c8977edcc312ffdcf"><li><b>集成（Integrations）</b></li><ul class="notion-list notion-list-disc notion-block-314b72e86558804c8977edcc312ffdcf"><li>能嵌入到：</li><ul class="notion-list notion-list-disc notion-block-314b72e86558801ebfdbe76c67e1c022"><li>Next.js / React 前端</li><li>Node.js / Express / Hono / Fastify / Koa 等后端</li></ul><li>也可以单独作为服务部署，对外暴露 HTTP API[2][3]</li></ul></ul><ul class="notion-list notion-list-disc notion-block-314b72e8655880209987cfb874e717af"><li><b>观测与评估（Observability &amp; Evals）</b></li><ul class="notion-list notion-list-disc notion-block-314b72e8655880209987cfb874e717af"><li>自带 tracing、日志和评估系统</li><li>帮你监控每次调用、耗时、错误、模型表现等[1][2][3]</li></ul></ul><h4 class="notion-h notion-h3 notion-h-indent-1 notion-block-314b72e86558803a898de12424a30960" data-id="314b72e86558803a898de12424a30960"><span><div id="314b72e86558803a898de12424a30960" class="notion-header-anchor"></div><a class="notion-hash-link" href="#314b72e86558803a898de12424a30960" title="3. 它能用来做什么样的东西？"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">3. 它能用来做什么样的东西？</span></span></h4><div class="notion-text notion-block-314b72e8655880a0b117e14011ae7589">官网和文档列出了一些典型场景示例：[1][2]</div><ul class="notion-list notion-list-disc notion-block-314b72e8655880bc90ffed3402602305"><li><b>浏览器 Agent</b>：自动化浏览器操作，帮你点页面、抓数据</li></ul><ul class="notion-list notion-list-disc notion-block-314b72e865588096bee6ec807a080b5c"><li><b>Google Sheets / 数据分析助手</b>：对表格做分析并给结论</li></ul><ul class="notion-list notion-list-disc notion-block-314b72e865588007adf3cef2f0aa9007"><li><b>代码 Agent</b>：带沙箱环境的 AI 编码助手</li></ul><ul class="notion-list notion-list-disc notion-block-314b72e8655880ef8426e278477549b2"><li><b>深度研究助手</b>：自动搜索 Web、阅读内容并输出总结</li></ul><ul class="notion-list notion-list-disc notion-block-314b72e8655880eb9ac6c144744f8b63"><li><b>PDF → 音频</b>：把 PDF 转成音频朗读</li></ul><ul class="notion-list notion-list-disc notion-block-314b72e8655880bdbf2bfc29fd598491"><li><b>Text-to-SQL</b>：自然语言自动转为 SQL 查询</li></ul><div class="notion-text notion-block-314b72e865588020a006d83e966aab19">更抽象一点，它适合做：</div><ul class="notion-list notion-list-disc notion-block-314b72e8655880acb7d0e85fa60d0f8e"><li>客服机器人、内部知识问答、企业搜索</li></ul><ul class="notion-list notion-list-disc notion-block-314b72e865588021ba11f5002abcebb7"><li>针对某专业领域（法律、金融、研发等）的智能助手</li></ul><ul class="notion-list notion-list-disc notion-block-314b72e8655880c18ad5f072840b5d9c"><li>Workflow 自动化（多步审批、任务处理等）</li></ul><ul class="notion-list notion-list-disc notion-block-314b72e86558805f88cecfc0ecbc54d0"><li>SaaS 产品中的“内置 AI 助手”或智能侧边栏</li></ul><h4 class="notion-h notion-h3 notion-h-indent-1 notion-block-314b72e8655880e39433d92b7da745c4" data-id="314b72e8655880e39433d92b7da745c4"><span><div id="314b72e8655880e39433d92b7da745c4" class="notion-header-anchor"></div><a class="notion-hash-link" href="#314b72e8655880e39433d92b7da745c4" title="4. 面向的人群"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">4. 面向的人群</span></span></h4><ul class="notion-list notion-list-disc notion-block-314b72e86558805e86fddef59e599094"><li>有 JS / TS 基础的 <b>前端 / 全栈 / Node 开发者</b></li></ul><ul class="notion-list notion-list-disc notion-block-314b72e865588055bdb7c30f55c8a1cf"><li>想做 AI Agent / 工作流 / RAG 系统，但不想从零造轮子的团队</li></ul><ul class="notion-list notion-list-disc notion-block-314b72e865588028b8c1ef94733cae44"><li>有现成 Web / 后端服务，希望 <b>加一层 AI 能力</b> 的公司或个人</li></ul><h4 class="notion-h notion-h3 notion-h-indent-1 notion-block-314b72e8655880f1ad90de24890622b5" data-id="314b72e8655880f1ad90de24890622b5"><span><div id="314b72e8655880f1ad90de24890622b5" class="notion-header-anchor"></div><a class="notion-hash-link" href="#314b72e8655880f1ad90de24890622b5" title="5. 一句话总结"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">5. 一句话总结</span></span></h4><div class="notion-text notion-block-314b72e86558804db705f36d0a17adf5"><b>Mastra.ai 这个网站是 Mastra AI 框架的官方站点</b>，</div><div class="notion-text notion-block-314b72e865588048af68d94a51dc2738">它提供的 Mastra 是一个基于 TypeScript 的开源框架，</div><div class="notion-text notion-block-314b72e86558806eb53cd2ccac4f2a36">专门用来 <b>快速开发、调试和部署各类 AI 应用与智能代理</b>，</div><div class="notion-text notion-block-314b72e8655880ac89b9c71aa8245100">并支持对接主流大模型、构建工作流、记忆、RAG、监控和评估等「生产级」能力。</div><hr class="notion-hr notion-block-314b72e86558800e9eb5dfa2ad9be607"/><div class="notion-text notion-block-314b72e865588079b24dfa2f51de09ef"><b>References</b></div><div class="notion-text notion-block-314b72e8655880438417ef170efdf616">[1] Mastra: The TypeScript AI Framework. <a class="notion-link" href="https://mastra.ai/" target="_blank" rel="noopener noreferrer">https://mastra.ai/</a>.</div><div class="notion-text notion-block-314b72e865588096acf8e373bba1df0a">[2] About Mastra | Mastra Docs. <a class="notion-link" href="https://mastra.ai/docs" target="_blank" rel="noopener noreferrer">https://mastra.ai/docs</a>.</div><div class="notion-text notion-block-314b72e86558805d8642cd852b94ab4f">[3] Announcing Mastra 1.0!. <a class="notion-link" href="https://mastra.ai/blog/announcing-mastra-1" target="_blank" rel="noopener noreferrer">https://mastra.ai/blog/announcing-mastra-1</a>.</div><div class="notion-blank notion-block-314b72e8655880a8ac39c9edebeae9cd"> </div></main></div>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[解决avien数据库空间占用大而导致的只读模式]]></title>
            <link>https://b.696988.xyz/article/how-to-fix-avien-database-space-full-read-only</link>
            <guid>https://b.696988.xyz/article/how-to-fix-avien-database-space-full-read-only</guid>
            <pubDate>Fri, 12 Sep 2025 00:00:00 GMT</pubDate>
            <content:encoded><![CDATA[<div id="notion-article" class="mx-auto overflow-hidden "><main class="notion light-mode notion-page notion-block-26cb72e865588040acd3c6e84f651fee"><div class="notion-viewport"></div><div class="notion-collection-page-properties"></div><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-26cb72e865588085ad1cfc9b4747d6bd" data-id="26cb72e865588085ad1cfc9b4747d6bd"><span><div id="26cb72e865588085ad1cfc9b4747d6bd" class="notion-header-anchor"></div><a class="notion-hash-link" href="#26cb72e865588085ad1cfc9b4747d6bd" title="MySQL日志清理步骤总结"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">MySQL日志清理步骤总结</span></span></h3><div class="notion-text notion-block-26cb72e8655880a39914d38593c2f9c2">当您的Aiven MySQL数据库因日志过多导致空间不足并进入只读模式时，可以按照以下步骤进行清理：</div><div class="notion-text notion-block-26cb72e865588048982befe89b52ee53">原来pg数据库只需要重启一遍就可以快速回到之前的空闲状态</div><h4 class="notion-h notion-h3 notion-h-indent-1 notion-block-26cb72e865588003bcc6ee20bbdd313e" data-id="26cb72e865588003bcc6ee20bbdd313e"><span><div id="26cb72e865588003bcc6ee20bbdd313e" class="notion-header-anchor"></div><a class="notion-hash-link" href="#26cb72e865588003bcc6ee20bbdd313e" title="1. 确认数据库状态和问题表"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">1. 确认数据库状态和问题表</span></span></h4><div class="notion-text notion-block-26cb72e8655880a8a605cabf3bebb306">首先，确认数据库是否处于只读模式，并识别可能占用大量空间的日志表。您可以使用以下命令连接到数据库并查看表：</div><h4 class="notion-h notion-h3 notion-h-indent-1 notion-block-26cb72e86558802d980bd8217d05abb7" data-id="26cb72e86558802d980bd8217d05abb7"><span><div id="26cb72e86558802d980bd8217d05abb7" class="notion-header-anchor"></div><a class="notion-hash-link" href="#26cb72e86558802d980bd8217d05abb7" title="2. 暂时启用数据库写入权限"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">2. 暂时启用数据库写入权限</span></span></h4><div class="notion-text notion-block-26cb72e865588089b407dffb873007d8">由于数据库处于只读模式，您需要通过Aiven API暂时启用写入权限。这需要一个有效的Aiven API令牌。请将 <code class="notion-inline-code">&lt;YOUR_AIVEN_API_TOKEN&gt;</code>、<code class="notion-inline-code">&lt;PROJECT&gt;</code> 和 <code class="notion-inline-code">&lt;SERVICE_NAME&gt;</code> 替换为您的实际信息：</div><div class="notion-text notion-block-26cb72e8655880a08033f5eaf0d53288">此操作会暂时启用写入权限15分钟。请确保在权限失效前完成后续操作。</div><h4 class="notion-h notion-h3 notion-h-indent-1 notion-block-26cb72e865588095bc36c2f92e3a70f8" data-id="26cb72e865588095bc36c2f92e3a70f8"><span><div id="26cb72e865588095bc36c2f92e3a70f8" class="notion-header-anchor"></div><a class="notion-hash-link" href="#26cb72e865588095bc36c2f92e3a70f8" title="3. 清空日志表数据"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">3. 清空日志表数据</span></span></h4><div class="notion-text notion-block-26cb72e865588048b684e2025a4a1b2d">一旦写入权限被启用，您可以清空识别出的日志表。例如，清空 <code class="notion-inline-code">t_error_logs</code> 和 <code class="notion-inline-code">t_request_log</code> 表：</div><div class="notion-text notion-block-26cb72e8655880bda571c125f52436e5"><code class="notion-inline-code">TRUNCATE TABLE</code> 命令会快速删除表中的所有数据，并且通常比 <code class="notion-inline-code">DELETE FROM</code> 更有效地回收空间。</div><h4 class="notion-h notion-h3 notion-h-indent-1 notion-block-26cb72e8655880fd8ee4e91dc1392b38" data-id="26cb72e8655880fd8ee4e91dc1392b38"><span><div id="26cb72e8655880fd8ee4e91dc1392b38" class="notion-header-anchor"></div><a class="notion-hash-link" href="#26cb72e8655880fd8ee4e91dc1392b38" title="4. 优化表以回收磁盘空间"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">4. 优化表以回收磁盘空间</span></span></h4><div class="notion-text notion-block-26cb72e8655880c39b74d82cef8faed0">清空数据后，为了让InnoDB回收未使用的磁盘空间，您需要对表进行优化。这有助于将空间释放回操作系统，尽管InnoDB的特性可能不会立即完全缩小文件大小。</div><h4 class="notion-h notion-h3 notion-h-indent-1 notion-block-26cb72e8655880dfa486d0021b7ca4c3" data-id="26cb72e8655880dfa486d0021b7ca4c3"><span><div id="26cb72e8655880dfa486d0021b7ca4c3" class="notion-header-anchor"></div><a class="notion-hash-link" href="#26cb72e8655880dfa486d0021b7ca4c3" title="5. 验证清理结果"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">5. 验证清理结果</span></span></h4><div class="notion-text notion-block-26cb72e8655880059d10cb865759a17d">您可以查询表中的数据量来验证是否已清空：</div><div class="notion-text notion-block-26cb72e8655880119301e56e82faf75b">您还可以查询数据库中各个表的大小，以查看空间回收情况：</div><div class="notion-text notion-block-26cb72e8655880a7a829ed1ad0783667"><b>重要提示：</b></div><ul class="notion-list notion-list-disc notion-block-26cb72e86558804082a5f243415c2d47"><li>请务必替换命令中的占位符（如 <code class="notion-inline-code">&lt;YOUR_MYSQL_HOST&gt;</code>、<code class="notion-inline-code">&lt;YOUR_MYSQL_PASSWORD&gt;</code> 等）。</li></ul><ul class="notion-list notion-list-disc notion-block-26cb72e8655880ca98fdf1ec2b881aa4"><li>Aiven API令牌是敏感信息，请妥善保管，不要泄露。</li></ul><ul class="notion-list notion-list-disc notion-block-26cb72e86558805189bcd6c19849cdc7"><li>如果磁盘空间问题持续存在，可能需要考虑升级您的Aiven服务套餐以获取更大的磁盘容量。</li></ul><div class="notion-blank notion-block-26cb72e8655880a09a16db7262ae6c00"> </div></main></div>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[在vps上使用codex]]></title>
            <link>https://b.696988.xyz/article/how-to-run-codex-on-vps</link>
            <guid>https://b.696988.xyz/article/how-to-run-codex-on-vps</guid>
            <pubDate>Tue, 14 Oct 2025 00:00:00 GMT</pubDate>
            <content:encoded><![CDATA[<div id="notion-article" class="mx-auto overflow-hidden "><main class="notion light-mode notion-page notion-block-28cb72e86558802a9c17e1f84a9d4145"><div class="notion-viewport"></div><div class="notion-collection-page-properties"></div><div class="notion-text notion-block-28cb72e8655880fa9803d88e0962a0c4">登陆通常会有回调链接 <code class="notion-inline-code">http://localhost:1455/auth/callback?...</code> </div><div class="notion-text notion-block-28cb72e865588071b1b1fd0f3a14a614">并不是报错，它只是说明 Codex/插件在<b>本机回环地址 1455 端口</b>上等着接收授权结果。但现在是在 <b>VPS + code-server（远程 VS Code）</b> 里用 Codex，真正“监听 1455 端口”的进程在<b>远程 VPS</b>上，而浏览器是在你本地电脑上，所以浏览器跳回 <code class="notion-inline-code">localhost:1455</code> 时连不到远程那头，授权就卡住了。解决思路是把本地的 <code class="notion-inline-code">localhost:1455</code> 转发到远端机器的 <code class="notion-inline-code">localhost:1455</code>。官方和社区都推荐这样做。(<a class="notion-link" href="https://github.com/openai/codex/blob/main/docs/authentication.md?utm_source=chatgpt.com" target="_blank" rel="noopener noreferrer">GitHub</a>)</div><div class="notion-text notion-block-28cb72e86558806092edcf562d2163a4">三种可行方案，按推荐顺序来：</div><h2 class="notion-h notion-h1 notion-h-indent-0 notion-block-28cb72e86558802080a9e216124e57f7" data-id="28cb72e86558802080a9e216124e57f7"><span><div id="28cb72e86558802080a9e216124e57f7" class="notion-header-anchor"></div><a class="notion-hash-link" href="#28cb72e86558802080a9e216124e57f7" title="方案 A（推荐）：SSH 端口转发打通回调"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">方案 A（推荐）：SSH 端口转发打通回调</span></span></h2><ol start="1" class="notion-list notion-list-numbered notion-block-28cb72e865588007aedccca460150abe" style="list-style-type:decimal"><li>在你<b>本地电脑</b>开一个 SSH 隧道，把本地 1455 转发到 VPS 的 1455：</li></ol><div class="notion-text notion-block-28cb72e865588051a4c7cb06658df5e5">保持这个 SSH 窗口<b>不要关</b>。(<a class="notion-link" href="https://github.com/openai/codex/issues/2869?utm_source=chatgpt.com" target="_blank" rel="noopener noreferrer">GitHub</a>)</div><ol start="1" class="notion-list notion-list-numbered notion-block-28cb72e86558804d9c78cf68a05c5fd9" style="list-style-type:decimal"><li>回到 <b>code-server 的终端</b>（或在 VS Code Web 里的 Codex 扩展里）重新触发登录（如 <code class="notion-inline-code">codex login</code> 或“Sign in with ChatGPT”）。</li></ol><ol start="2" class="notion-list notion-list-numbered notion-block-28cb72e865588030957cf14e36bf29f9" style="list-style-type:decimal"><li>当浏览器再次跳回 <code class="notion-inline-code">http://localhost:1455/auth/callback?...</code> 时，这个请求会通过隧道被送到 VPS 上的回调服务，登录就能<b>自动完成</b>。如果你已经拿到了那条 <code class="notion-inline-code">localhost:1455/...</code> 链接，也可以在隧道建立后<b>直接再打开一次</b>那条链接。(<a class="notion-link" href="https://github.com/openai/codex/blob/main/docs/authentication.md?utm_source=chatgpt.com" target="_blank" rel="noopener noreferrer">GitHub</a>)</li></ol><blockquote class="notion-quote notion-block-28cb72e8655880ae8750fdca0c00a3f6"><div>小检查：启动登录后，在 VPS 上运行</div><div class="notion-text notion-block-28cb72e8655880db9971ca6fa716a03c"><code class="notion-inline-code">ss -ltnp | grep 1455</code></div><div class="notion-text notion-block-28cb72e8655880e6a073e6f8f4f5a8ba">应该能看到 <code class="notion-inline-code">127.0.0.1:1455</code> 处于 LISTEN 状态；否则先重跑一次 <code class="notion-inline-code">codex login</code>。(<a class="notion-link" href="https://github.com/openai/codex/issues/2798?utm_source=chatgpt.com" target="_blank" rel="noopener noreferrer">GitHub</a>)</div></blockquote><h2 class="notion-h notion-h1 notion-h-indent-0 notion-block-28cb72e8655880d6a2e7fa16aebb2b6e" data-id="28cb72e8655880d6a2e7fa16aebb2b6e"><span><div id="28cb72e8655880d6a2e7fa16aebb2b6e" class="notion-header-anchor"></div><a class="notion-hash-link" href="#28cb72e8655880d6a2e7fa16aebb2b6e" title="方案 B：先在一台可本地登录的机器完成授权，然后把凭据拷到 VPS"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">方案 B：先在一台可本地登录的机器完成授权，然后把凭据拷到 VPS</span></span></h2><ol start="1" class="notion-list notion-list-numbered notion-block-28cb72e8655880b397fddf79c985be49" style="list-style-type:decimal"><li>在你<b>本地</b>或任何有桌面浏览器的机器上安装并运行 <code class="notion-inline-code">codex login</code> 完成登录。</li></ol><ol start="2" class="notion-list notion-list-numbered notion-block-28cb72e8655880adae77f6cf32888768" style="list-style-type:decimal"><li>复制生成的 <code class="notion-inline-code">~/.codex/auth.json</code>（Windows 在 <code class="notion-inline-code">C:\Users\你的用户名\.codex\auth.json</code>），把它放到 VPS 上对应用户的同一路径。</li></ol><ol start="3" class="notion-list notion-list-numbered notion-block-28cb72e8655880cfb5a8fec8bc3d6df3" style="list-style-type:decimal"><li>重启 code-server / 重新加载扩展即可生效。(<a class="notion-link" href="https://github.com/openai/codex/discussions/4650?utm_source=chatgpt.com" target="_blank" rel="noopener noreferrer">GitHub</a>)</li></ol><h2 class="notion-h notion-h1 notion-h-indent-0 notion-block-28cb72e8655880448ba2eb4c3260dc5a" data-id="28cb72e8655880448ba2eb4c3260dc5a"><span><div id="28cb72e8655880448ba2eb4c3260dc5a" class="notion-header-anchor"></div><a class="notion-hash-link" href="#28cb72e8655880448ba2eb4c3260dc5a" title="方案 C（备选）：用 API Key（取决于版本/配置是否开放）"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">方案 C（备选）：用 API Key（取决于版本/配置是否开放）</span></span></h2><div class="notion-text notion-block-28cb72e865588025997ac8bb52561302">某些版本/发行渠道允许在 <code class="notion-inline-code">~/.codex/auth.json</code> 里直接放 API Key 或在 <code class="notion-inline-code">~/.codex/config.toml</code> 中配置，从而绕过 ChatGPT 登录流；但这并非所有版本都支持，优先用上面 A/B。参考 Codex CLI 说明。(<a class="notion-link" href="https://developers.openai.com/codex/cli?utm_source=chatgpt.com" target="_blank" rel="noopener noreferrer">OpenAI Developers</a>)</div><hr class="notion-hr notion-block-28cb72e8655880829edeedb1c2b757e1"/><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-28cb72e86558803ebf92c0ae585be6b7" data-id="28cb72e86558803ebf92c0ae585be6b7"><span><div id="28cb72e86558803ebf92c0ae585be6b7" class="notion-header-anchor"></div><a class="notion-hash-link" href="#28cb72e86558803ebf92c0ae585be6b7" title="常见坑位与排查"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">常见坑位与排查</span></span></h3><ul class="notion-list notion-list-disc notion-block-28cb72e86558800b9768e5f9ad3ae3cf"><li><b>1455 端口被占用</b>（VPS 上）：先查占用并结束进程，然后重试登录。</li><ul class="notion-list notion-list-disc notion-block-28cb72e86558800b9768e5f9ad3ae3cf"><div class="notion-text notion-block-28cb72e865588077affefc7713620d9b">社区报告了“Port 127.0.0.1:1455 is already in use”这类问题，本质就是端口冲突。(<a class="notion-link" href="https://github.com/openai/codex/issues/3927?utm_source=chatgpt.com" target="_blank" rel="noopener noreferrer">GitHub</a>)</div></ul></ul><ul class="notion-list notion-list-disc notion-block-28cb72e865588027ac39d7a9d8907efb"><li><b>Docker 环境</b>：如果 code-server 在容器里跑，确保回调服务监听在容器的 127.0.0.1:1455，并把 <b>SSH 隧道连到容器所在宿主</b>；必要时把容器的 1455 暂时映射到宿主（<code class="notion-inline-code">p 127.0.0.1:1455:1455</code>）再做转发。</li></ul><ul class="notion-list notion-list-disc notion-block-28cb72e8655880509a79d901d5cbfbe2"><li><b>必须边登录边监听</b>：回调服务只在 <code class="notion-inline-code">codex login</code> 期间监听；如果浏览器报错“连接被拒绝”，在 VPS 上<b>重新执行</b>登录命令，让 1455 再次处于监听状态，然后刷新回调链接。(<a class="notion-link" href="https://github.com/openai/codex/issues/2798?utm_source=chatgpt.com" target="_blank" rel="noopener noreferrer">GitHub</a>)</li></ul><div class="notion-blank notion-block-28cb72e865588076a539e644a9bc7038"> </div></main></div>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[win11一键安装openclaw]]></title>
            <link>https://b.696988.xyz/article/one-click-install-openclaw-on-windows-11</link>
            <guid>https://b.696988.xyz/article/one-click-install-openclaw-on-windows-11</guid>
            <pubDate>Sat, 07 Feb 2026 00:00:00 GMT</pubDate>
            <content:encoded><![CDATA[<div id="notion-article" class="mx-auto overflow-hidden "><main class="notion light-mode notion-page notion-block-300b72e8655880309d90eedce2574be5"><div class="notion-viewport"></div><div class="notion-collection-page-properties"></div><div class="notion-blank notion-block-300b72e865588005b88fe080d1c7c910"> </div></main></div>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[systemctl 入门与进阶使用文档（适合初学者）]]></title>
            <link>https://b.696988.xyz/article/systemctl-beginner-advanced-guide</link>
            <guid>https://b.696988.xyz/article/systemctl-beginner-advanced-guide</guid>
            <pubDate>Wed, 21 Jan 2026 00:00:00 GMT</pubDate>
            <content:encoded><![CDATA[<div id="notion-article" class="mx-auto overflow-hidden "><main class="notion light-mode notion-page notion-block-2efb72e8655880738625d27be63f7bd4"><div class="notion-viewport"></div><div class="notion-collection-page-properties"></div><div class="notion-blank notion-block-2efb72e86558803eb7eacdb90b19fa06"> </div><hr class="notion-hr notion-block-2efb72e8655880e88decf72f464289ed"/><h2 class="notion-h notion-h1 notion-h-indent-0 notion-block-2efb72e865588031b3f6cf39c8a1cb29" data-id="2efb72e865588031b3f6cf39c8a1cb29"><span><div id="2efb72e865588031b3f6cf39c8a1cb29" class="notion-header-anchor"></div><a class="notion-hash-link" href="#2efb72e865588031b3f6cf39c8a1cb29" title="systemctl 入门与进阶使用文档（适合初学者）"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">systemctl 入门与进阶使用文档（适合初学者）</span></span></h2><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-2efb72e86558800d8682e3ad9aa4f9a7" data-id="2efb72e86558800d8682e3ad9aa4f9a7"><span><div id="2efb72e86558800d8682e3ad9aa4f9a7" class="notion-header-anchor"></div><a class="notion-hash-link" href="#2efb72e86558800d8682e3ad9aa4f9a7" title="一、systemctl 是什么？"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">一、systemctl 是什么？</span></span></h3><ul class="notion-list notion-list-disc notion-block-2efb72e8655880df8d0ccfc35cf1f590"><li><b>systemd</b>：现代 Linux 系统（如 Ubuntu、Debian、CentOS、RHEL、Fedora 等）默认使用的“系统和服务管理器”（init 系统）。</li></ul><ul class="notion-list notion-list-disc notion-block-2efb72e8655880709555d34120e981c3"><li><b>systemctl</b>：是用来和 systemd 交互的命令行工具，用它来：</li><ul class="notion-list notion-list-disc notion-block-2efb72e8655880709555d34120e981c3"><li>启动 / 停止 / 重启服务</li><li>设置服务开机自启动</li><li>查看服务状态和日志</li><li>管理各种 “单元（Unit）”，如服务、定时器、挂载点等</li></ul></ul><div class="notion-text notion-block-2efb72e86558808fa23ae4caf0c74484">可以简单理解：</div><blockquote class="notion-quote notion-block-2efb72e8655880c08a01c5adbddafb47"><div>systemctl = 管服务和系统状态的万能遥控器</div></blockquote><hr class="notion-hr notion-block-2efb72e865588000a10cd612eb81ea2b"/><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-2efb72e86558806c8c10d9cfc636b007" data-id="2efb72e86558806c8c10d9cfc636b007"><span><div id="2efb72e86558806c8c10d9cfc636b007" class="notion-header-anchor"></div><a class="notion-hash-link" href="#2efb72e86558806c8c10d9cfc636b007" title="二、几个必须先知道的概念"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">二、几个必须先知道的概念</span></span></h3><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-2efb72e8655880f6917eed4c0a6afa1f" data-id="2efb72e8655880f6917eed4c0a6afa1f"><span><div id="2efb72e8655880f6917eed4c0a6afa1f" class="notion-header-anchor"></div><a class="notion-hash-link" href="#2efb72e8655880f6917eed4c0a6afa1f" title="1. Unit（单元）"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">1. Unit（单元）</span></span></h4><div class="notion-text notion-block-2efb72e865588092ace8f77bd169b6b7">systemd 把要管理的东西都抽象成 <b>Unit 文件</b>（通常在 <code class="notion-inline-code">/lib/systemd/system</code> 和 <code class="notion-inline-code">/etc/systemd/system</code> 下）。</div><div class="notion-text notion-block-2efb72e8655880d29ebfca3c13cf516b">常见类型：</div><table class="notion-simple-table notion-block-2efb72e8655880199f0fc5a08654a1ec"><tbody><tr class="notion-simple-table-row notion-simple-table-header-row notion-block-2efb72e865588046b97af93ffa9a425f"><td class="" style="width:120px"><div class="notion-simple-table-cell">类型后缀</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">含义</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">示例</div></td></tr><tr class="notion-simple-table-row notion-block-2efb72e865588038b6f5c11bf02c8c4e"><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">.service</code></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">服务/守护进程</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">sshd.service</code>, <code class="notion-inline-code">nginx.service</code></div></td></tr><tr class="notion-simple-table-row notion-block-2efb72e86558801697cfcd61b9f6a6d5"><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">.socket</code></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">套接字（端口监听）</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">ssh.socket</code></div></td></tr><tr class="notion-simple-table-row notion-block-2efb72e8655880d0a425ede55be7a415"><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">.timer</code></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">定时器（类似 cron）</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">logrotate.timer</code></div></td></tr><tr class="notion-simple-table-row notion-block-2efb72e8655880d5b433f35b58edf0b0"><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">.target</code></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">运行级别集合</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">multi-user.target</code>, <code class="notion-inline-code">graphical.target</code></div></td></tr><tr class="notion-simple-table-row notion-block-2efb72e86558806787f6dfcd4348e8a2"><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">.mount</code></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">挂载点</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">home.mount</code></div></td></tr><tr class="notion-simple-table-row notion-block-2efb72e86558804aa59cfa0ab40bcd85"><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">.swap</code></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">交换分区</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">swap.swap</code></div></td></tr></tbody></table><div class="notion-text notion-block-2efb72e865588020bf7bd38d814ba933"><b>注意</b>：很多时候 <code class="notion-inline-code">.service</code> 后缀可以省略，如 <code class="notion-inline-code">nginx.service</code> 直接写成 <code class="notion-inline-code">nginx</code>。</div><hr class="notion-hr notion-block-2efb72e865588072af0ee386e6bcab58"/><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-2efb72e86558800bb84afc37b220cfa6" data-id="2efb72e86558800bb84afc37b220cfa6"><span><div id="2efb72e86558800bb84afc37b220cfa6" class="notion-header-anchor"></div><a class="notion-hash-link" href="#2efb72e86558800bb84afc37b220cfa6" title="2. “当前状态” vs “开机自启”"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">2. “当前状态” vs “开机自启”</span></span></h4><ul class="notion-list notion-list-disc notion-block-2efb72e865588011a0e2c597e642f73d"><li><code class="notion-inline-code">start/stop/restart</code>：<b>只影响当前这次开机的状态</b></li></ul><ul class="notion-list notion-list-disc notion-block-2efb72e86558800e9503d28681302be4"><li><code class="notion-inline-code">enable/disable</code>：<b>影响以后每次开机时是否自动启动</b></li></ul><div class="notion-text notion-block-2efb72e865588009b5bfff1fc3e6200e">你可以记住一对：</div><ul class="notion-list notion-list-disc notion-block-2efb72e86558809090fee646d3d13988"><li><code class="notion-inline-code">start</code> = 现在就启动</li></ul><ul class="notion-list notion-list-disc notion-block-2efb72e8655880c5ae6bdcc56d083faf"><li><code class="notion-inline-code">enable</code> = 以后每次开机都自动启动</li></ul><hr class="notion-hr notion-block-2efb72e86558804fa6b5c7a5462b9ac4"/><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-2efb72e86558808e9736f0a98ace4209" data-id="2efb72e86558808e9736f0a98ace4209"><span><div id="2efb72e86558808e9736f0a98ace4209" class="notion-header-anchor"></div><a class="notion-hash-link" href="#2efb72e86558808e9736f0a98ace4209" title="三、最常用的 systemctl 命令（一定要先会）"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">三、最常用的 systemctl 命令（一定要先会）</span></span></h3><div class="notion-text notion-block-2efb72e865588099bfdae8aa446588bd">下面所有命令都假设以 <code class="notion-inline-code">nginx</code> 为例，你可以换成任何你系统中安装的服务名。</div><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-2efb72e8655880a29372f8abcc9bc3fc" data-id="2efb72e8655880a29372f8abcc9bc3fc"><span><div id="2efb72e8655880a29372f8abcc9bc3fc" class="notion-header-anchor"></div><a class="notion-hash-link" href="#2efb72e8655880a29372f8abcc9bc3fc" title="1. 启动 / 停止 / 重启服务"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">1. 启动 / 停止 / 重启服务</span></span></h4><div class="notion-text notion-block-2efb72e86558800dad88d658bcfac102">bash复制</div><div class="notion-text notion-block-2efb72e86558805ebc6de2bd32ad6534"><code class="notion-inline-code"># 启动服务
sudo systemctl start nginx

# 停止服务
sudo systemctl stop nginx

# 重启服务（先停再启）
sudo systemctl restart nginx

# 只重载配置，不中断进程（程序要支持）
sudo systemctl reload nginx

# 智能：能 reload 就 reload，否则就 restart
sudo systemctl reload-or-restart nginx</code></div><blockquote class="notion-quote notion-block-2efb72e86558805f97fac98d86d0c194"><div>一般你会最常用：start / stop / restart / reload</div></blockquote><hr class="notion-hr notion-block-2efb72e865588091871df03f13576371"/><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-2efb72e86558802ab59ac4baafbf7917" data-id="2efb72e86558802ab59ac4baafbf7917"><span><div id="2efb72e86558802ab59ac4baafbf7917" class="notion-header-anchor"></div><a class="notion-hash-link" href="#2efb72e86558802ab59ac4baafbf7917" title="2. 查看服务状态"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">2. 查看服务状态</span></span></h4><div class="notion-text notion-block-2efb72e8655880dd979ef1b8fbe774ed">bash复制</div><div class="notion-text notion-block-2efb72e865588087a28cfb20ba544d3b"><code class="notion-inline-code"># 查看服务状态
systemctl status nginx</code></div><div class="notion-text notion-block-2efb72e865588098a3c3ffde13fe8854">输出中主要看几行：</div><ul class="notion-list notion-list-disc notion-block-2efb72e8655880d58755d1c6cf18ebb6"><li><code class="notion-inline-code">Loaded:</code> 表示 Unit 文件路径、是否 enable</li></ul><ul class="notion-list notion-list-disc notion-block-2efb72e8655880d7b9ecd9406cc71fab"><li><code class="notion-inline-code">Active:</code> 状态，如</li><ul class="notion-list notion-list-disc notion-block-2efb72e8655880d7b9ecd9406cc71fab"><li><code class="notion-inline-code">active (running)</code>：正在运行</li><li><code class="notion-inline-code">inactive (dead)</code>：已停止</li><li><code class="notion-inline-code">failed</code>：启动失败</li></ul></ul><ul class="notion-list notion-list-disc notion-block-2efb72e8655880998841e92872a18f16"><li><code class="notion-inline-code">Main PID:</code> 主进程号</li></ul><ul class="notion-list notion-list-disc notion-block-2efb72e86558801789b2e783bb171769"><li>最下面有最近几条日志</li></ul><hr class="notion-hr notion-block-2efb72e8655880f09be0e75ce9658e09"/><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-2efb72e8655880d9a3aedf874bde87b1" data-id="2efb72e8655880d9a3aedf874bde87b1"><span><div id="2efb72e8655880d9a3aedf874bde87b1" class="notion-header-anchor"></div><a class="notion-hash-link" href="#2efb72e8655880d9a3aedf874bde87b1" title="3. 设置开机自启与取消"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">3. 设置开机自启与取消</span></span></h4><div class="notion-text notion-block-2efb72e865588029904bc7e1c4c5e191">bash复制</div><div class="notion-text notion-block-2efb72e8655880a18018eff1374d2739"><code class="notion-inline-code"># 设置服务开机自启
sudo systemctl enable nginx

# 取消开机自启
sudo systemctl disable nginx

# 查看当前是否开机自启
systemctl is-enabled nginx    # 返回 enabled / disabled / static / masked</code></div><ul class="notion-list notion-list-disc notion-block-2efb72e8655880c3a49bdc3c892d4da0"><li><b>enabled</b>：开机自启</li></ul><ul class="notion-list notion-list-disc notion-block-2efb72e86558808aab73fddab6d8c246"><li><b>disabled</b>：不开机自启</li></ul><ul class="notion-list notion-list-disc notion-block-2efb72e8655880168e46c7b23264a3b3"><li><b>static</b>：自身不能直接 enable，一般被别的 unit 依赖</li></ul><ul class="notion-list notion-list-disc notion-block-2efb72e865588003ac77ea71c30c7888"><li><b>masked</b>：被“屏蔽”，完全禁止启动（见后面）</li></ul><hr class="notion-hr notion-block-2efb72e8655880bb8013fc68c8a9665a"/><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-2efb72e86558808f9913cf19dfd43446" data-id="2efb72e86558808f9913cf19dfd43446"><span><div id="2efb72e86558808f9913cf19dfd43446" class="notion-header-anchor"></div><a class="notion-hash-link" href="#2efb72e86558808f9913cf19dfd43446" title="4. 查看系统中有哪些服务"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">4. 查看系统中有哪些服务</span></span></h4><div class="notion-text notion-block-2efb72e865588078b257e53fa59d21d3">bash复制</div><div class="notion-text notion-block-2efb72e8655880b7908dd3424be94883"><code class="notion-inline-code"># 列出当前“已加载”并可能在运行的服务
systemctl list-units --type=service

# 列出所有服务单元文件（包括没加载的）
systemctl list-unit-files --type=service</code></div><div class="notion-text notion-block-2efb72e86558804eb95cd07559512a0b">常配合 <code class="notion-inline-code">grep</code> 使用：</div><div class="notion-text notion-block-2efb72e86558802b9f2ef8621a84487b">bash复制</div><div class="notion-text notion-block-2efb72e86558807f97e3ecfda4e4a8c7"><code class="notion-inline-code">systemctl list-units --type=service | grep ssh
systemctl list-unit-files --type=service | grep nginx</code></div><hr class="notion-hr notion-block-2efb72e8655880fab81dd29874cce46e"/><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-2efb72e86558807ba1daf52016304871" data-id="2efb72e86558807ba1daf52016304871"><span><div id="2efb72e86558807ba1daf52016304871" class="notion-header-anchor"></div><a class="notion-hash-link" href="#2efb72e86558807ba1daf52016304871" title="四、Unit 文件放在哪里？优先级如何？"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">四、Unit 文件放在哪里？优先级如何？</span></span></h3><div class="notion-text notion-block-2efb72e8655880cc9b89d084fa2d8a5c">常见路径：</div><ul class="notion-list notion-list-disc notion-block-2efb72e86558806e93bff6ba18f674b9"><li><code class="notion-inline-code">/lib/systemd/system/</code> 或 <code class="notion-inline-code">/usr/lib/systemd/system/</code>
系统或软件包自带的 unit 文件</li></ul><ul class="notion-list notion-list-disc notion-block-2efb72e8655880f79279fab8ae6ac4c1"><li><code class="notion-inline-code">/etc/systemd/system/</code>
管理员本地自定义或覆盖的 unit，<b>优先级更高</b></li></ul><div class="notion-text notion-block-2efb72e8655880108903f383e92c8e0d">一般不直接改 <code class="notion-inline-code">/lib/systemd/system</code> 里的文件，而是用：</div><div class="notion-text notion-block-2efb72e8655880db83ebe4a5876d063d">bash复制</div><div class="notion-text notion-block-2efb72e8655880729f3ac7abccdcc5cb"><code class="notion-inline-code">sudo systemctl edit nginx</code></div><div class="notion-text notion-block-2efb72e86558801586fee925077d5a99">这会在 <code class="notion-inline-code">/etc/systemd/system/nginx.service.d/override.conf</code> 里生成覆盖文件，更安全、可维护。</div><hr class="notion-hr notion-block-2efb72e865588071b148ee350e2768f2"/><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-2efb72e86558805d968ed5b167d6a457" data-id="2efb72e86558805d968ed5b167d6a457"><span><div id="2efb72e86558805d968ed5b167d6a457" class="notion-header-anchor"></div><a class="notion-hash-link" href="#2efb72e86558805d968ed5b167d6a457" title="五、服务日志查看（配合 journalctl）"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">五、服务日志查看（配合 journalctl）</span></span></h3><div class="notion-text notion-block-2efb72e8655880e581c0f6af6927372c">systemd 的日志由 <code class="notion-inline-code">journald</code> 管理，命令是 <code class="notion-inline-code">journalctl</code>。</div><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-2efb72e8655880268b9dc0189e5f021b" data-id="2efb72e8655880268b9dc0189e5f021b"><span><div id="2efb72e8655880268b9dc0189e5f021b" class="notion-header-anchor"></div><a class="notion-hash-link" href="#2efb72e8655880268b9dc0189e5f021b" title="1. 查看某个服务日志"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">1. 查看某个服务日志</span></span></h4><div class="notion-text notion-block-2efb72e8655880bf91aecbb41b1fce79">bash复制</div><div class="notion-text notion-block-2efb72e86558803aa19aefd453eba996"><code class="notion-inline-code"># 查看某服务的所有日志
journalctl -u nginx

# 实时查看日志（类似 tail -f）
journalctl -u nginx -f

# 指定时间段
journalctl -u nginx --since &quot;2026-01-01 00:00:00&quot; --until &quot;2026-01-21 23:59:59&quot;

# 查看上一次开机的日志
journalctl -b -1 -u nginx</code></div><div class="notion-text notion-block-2efb72e8655880a88a69ea63f134f857">启动失败时：</div><div class="notion-text notion-block-2efb72e8655880fb832ceaeb7a66c6af">bash复制</div><div class="notion-text notion-block-2efb72e865588074b6e3f2c9ffa3a2c8"><code class="notion-inline-code">systemctl status nginx         # 先看状态
journalctl -u nginx -xe        # 再看详细错误日志</code></div><ul class="notion-list notion-list-disc notion-block-2efb72e86558800aa8dfdaa2122a26a4"><li><code class="notion-inline-code">x</code> 会附加解释，<code class="notion-inline-code">e</code> 跳到日志结尾。</li></ul><hr class="notion-hr notion-block-2efb72e8655880f4bfd1fa56dd8d8537"/><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-2efb72e865588006a0b0fd4a9b75eab5" data-id="2efb72e865588006a0b0fd4a9b75eab5"><span><div id="2efb72e865588006a0b0fd4a9b75eab5" class="notion-header-anchor"></div><a class="notion-hash-link" href="#2efb72e865588006a0b0fd4a9b75eab5" title="六、常见操作场景示例"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">六、常见操作场景示例</span></span></h3><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-2efb72e86558802580d1ec2fdb62d72a" data-id="2efb72e86558802580d1ec2fdb62d72a"><span><div id="2efb72e86558802580d1ec2fdb62d72a" class="notion-header-anchor"></div><a class="notion-hash-link" href="#2efb72e86558802580d1ec2fdb62d72a" title="场景 1：安装了 nginx，想让它一直随系统运行"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">场景 1：安装了 nginx，想让它一直随系统运行</span></span></h4><ol start="1" class="notion-list notion-list-numbered notion-block-2efb72e86558807f9effc50104a0a2cf" style="list-style-type:decimal"><li><b>立即启动</b>：</li><ol class="notion-list notion-list-numbered notion-block-2efb72e86558807f9effc50104a0a2cf" style="list-style-type:lower-alpha"><div class="notion-text notion-block-2efb72e865588077b903dbd90a2f6429">bash复制</div><div class="notion-text notion-block-2efb72e8655880dda3b1f33c69debce7"><code class="notion-inline-code">sudo systemctl start nginx</code></div></ol></ol><ol start="2" class="notion-list notion-list-numbered notion-block-2efb72e865588050a6e7d235ee0e25c8" style="list-style-type:decimal"><li><b>确认运行状态</b>：</li><ol class="notion-list notion-list-numbered notion-block-2efb72e865588050a6e7d235ee0e25c8" style="list-style-type:lower-alpha"><div class="notion-text notion-block-2efb72e86558803db20efbc076cdb1ed">bash复制</div><div class="notion-text notion-block-2efb72e86558804488afd6a112435ec9"><code class="notion-inline-code">systemctl status nginx</code></div></ol></ol><ol start="3" class="notion-list notion-list-numbered notion-block-2efb72e86558802ca70ff34052e69904" style="list-style-type:decimal"><li><b>设置开机自启</b>：</li><ol class="notion-list notion-list-numbered notion-block-2efb72e86558802ca70ff34052e69904" style="list-style-type:lower-alpha"><div class="notion-text notion-block-2efb72e86558808b884df33a3e48151f">bash复制</div><div class="notion-text notion-block-2efb72e86558802fabc6d48582f0282b"><code class="notion-inline-code">sudo systemctl enable nginx</code></div></ol></ol><hr class="notion-hr notion-block-2efb72e86558808087d3f020107339c8"/><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-2efb72e865588049997ef48923072851" data-id="2efb72e865588049997ef48923072851"><span><div id="2efb72e865588049997ef48923072851" class="notion-header-anchor"></div><a class="notion-hash-link" href="#2efb72e865588049997ef48923072851" title="场景 2：一个服务老是出问题，想暂时禁用它"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">场景 2：一个服务老是出问题，想暂时禁用它</span></span></h4><ol start="1" class="notion-list notion-list-numbered notion-block-2efb72e8655880b38120deeb6d9faa8a" style="list-style-type:decimal"><li><b>先停掉</b>：</li><ol class="notion-list notion-list-numbered notion-block-2efb72e8655880b38120deeb6d9faa8a" style="list-style-type:lower-alpha"><div class="notion-text notion-block-2efb72e86558801a9223d87069d79c91">bash复制</div><div class="notion-text notion-block-2efb72e865588061a526da6c34ab1e6c"><code class="notion-inline-code">sudo systemctl stop foo</code></div></ol></ol><ol start="2" class="notion-list notion-list-numbered notion-block-2efb72e8655880a09dcfe1f8b2883afd" style="list-style-type:decimal"><li><b>禁止开机自启</b>：</li><ol class="notion-list notion-list-numbered notion-block-2efb72e8655880a09dcfe1f8b2883afd" style="list-style-type:lower-alpha"><div class="notion-text notion-block-2efb72e8655880b1a434c2b5dcc8851f">bash复制</div><div class="notion-text notion-block-2efb72e8655880c7822de8d534668780"><code class="notion-inline-code">sudo systemctl disable foo</code></div></ol></ol><ol start="3" class="notion-list notion-list-numbered notion-block-2efb72e865588039b0c5e7d61b276e70" style="list-style-type:decimal"><li><b>如果想完全禁止任何人（包括依赖）启动它</b>：</li><ol class="notion-list notion-list-numbered notion-block-2efb72e865588039b0c5e7d61b276e70" style="list-style-type:lower-alpha"><div class="notion-text notion-block-2efb72e86558802c9258f45744f29ceb">bash复制</div><div class="notion-text notion-block-2efb72e865588003a5dbebd12c98fe60"><code class="notion-inline-code">sudo systemctl mask foo
# 取消屏蔽
sudo systemctl unmask foo</code></div></ol></ol><div class="notion-text notion-block-2efb72e86558803a8be1ca55a5357a2b"><code class="notion-inline-code">mask</code> 会把这个服务的 unit 链接到 <code class="notion-inline-code">/dev/null</code>，就算有人 <code class="notion-inline-code">start foo</code> 也会失败。</div><hr class="notion-hr notion-block-2efb72e8655880b1876ecc98dce09df8"/><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-2efb72e865588072a44ad7167a85fe31" data-id="2efb72e865588072a44ad7167a85fe31"><span><div id="2efb72e865588072a44ad7167a85fe31" class="notion-header-anchor"></div><a class="notion-hash-link" href="#2efb72e865588072a44ad7167a85fe31" title="场景 3：自己写一个简单的 systemd 服务"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">场景 3：自己写一个简单的 systemd 服务</span></span></h4><div class="notion-text notion-block-2efb72e865588012a04bf4be112874f0">假设你有一个脚本 <code class="notion-inline-code">/usr/local/bin/myapp.sh</code>：</div><div class="notion-text notion-block-2efb72e86558806da85dc1726dca1577">bash复制</div><div class="notion-text notion-block-2efb72e8655880158f8fc3a0bab9ae5b"><code class="notion-inline-code">sudo nano /etc/systemd/system/myapp.service</code></div><div class="notion-text notion-block-2efb72e8655880c29ea7e0ba3733519d">内容示例：</div><div class="notion-text notion-block-2efb72e865588067a117d2a40da2f0e1">ini复制</div><div class="notion-text notion-block-2efb72e865588057a77ed80b33850843"><code class="notion-inline-code">[Unit]
Description=My Test App
After=network.target

[Service]
Type=simple
ExecStart=/usr/local/bin/myapp.sh
Restart=on-failure

[Install]
WantedBy=multi-user.target</code></div><div class="notion-text notion-block-2efb72e8655880969b3afc6104632e99">然后：</div><div class="notion-text notion-block-2efb72e8655880ff8d56c2d3f9d36c6a">bash复制</div><div class="notion-text notion-block-2efb72e86558802bb181f6a7026ed466"><code class="notion-inline-code"># 重新加载 unit 文件
sudo systemctl daemon-reload

# 启动服务试试
sudo systemctl start myapp

# 查看状态
systemctl status myapp

# 设置开机自启
sudo systemctl enable myapp</code></div><hr class="notion-hr notion-block-2efb72e8655880f4af58d0ac6a275240"/><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-2efb72e8655880539b84d7bb11163662" data-id="2efb72e8655880539b84d7bb11163662"><span><div id="2efb72e8655880539b84d7bb11163662" class="notion-header-anchor"></div><a class="notion-hash-link" href="#2efb72e8655880539b84d7bb11163662" title="七、定时任务：用 .timer 替代 cron（入门示例）"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">七、定时任务：用 .timer 替代 cron（入门示例）</span></span></h3><div class="notion-text notion-block-2efb72e865588006aa65c46f85e6f5bc">假设你有一个备份脚本 <code class="notion-inline-code">/usr/local/bin/backup.sh</code>，想每 30 分钟跑一次。</div><ol start="1" class="notion-list notion-list-numbered notion-block-2efb72e865588050bc90f2fbf49c23ad" style="list-style-type:decimal"><li><b>写 Service 文件</b>（真正执行脚本的单元）：</li><ol class="notion-list notion-list-numbered notion-block-2efb72e865588050bc90f2fbf49c23ad" style="list-style-type:lower-alpha"><div class="notion-text notion-block-2efb72e86558801780c3dc7c33f9ff8e">bash复制</div><div class="notion-text notion-block-2efb72e86558808995def99f9e743ac7"><code class="notion-inline-code">sudo nano /etc/systemd/system/backup.service</code></div><div class="notion-text notion-block-2efb72e8655880efa577d25f5881d6bd">ini复制</div><div class="notion-text notion-block-2efb72e8655880e28d23fcc919e6f803"><code class="notion-inline-code">[Unit]
Description=Run backup script

[Service]
Type=oneshot
ExecStart=/usr/local/bin/backup.sh</code></div></ol></ol><ol start="2" class="notion-list notion-list-numbered notion-block-2efb72e8655880d8add0e66a98660b18" style="list-style-type:decimal"><li><b>写 Timer 文件</b>（定义执行频率）：</li><ol class="notion-list notion-list-numbered notion-block-2efb72e8655880d8add0e66a98660b18" style="list-style-type:lower-alpha"><div class="notion-text notion-block-2efb72e86558806fad40cac195c7f297">bash复制</div><div class="notion-text notion-block-2efb72e86558806fb965cccdc4bfba71"><code class="notion-inline-code">sudo nano /etc/systemd/system/backup.timer</code></div><div class="notion-text notion-block-2efb72e86558803580a5f20db7776611">ini复制</div><div class="notion-text notion-block-2efb72e8655880fb9cbfc010f5e85175"><code class="notion-inline-code">[Unit]
Description=Run backup every 30 minutes

[Timer]
OnBootSec=10min         # 开机后 10 分钟执行第一次
OnUnitActiveSec=30min   # 每隔 30 分钟执行一次
Persistent=true         # 开机后会补跑关机期间错过的任务（如果可能）

[Install]
WantedBy=timers.target</code></div></ol></ol><ol start="3" class="notion-list notion-list-numbered notion-block-2efb72e865588026aaead9d109d34939" style="list-style-type:decimal"><li><b>启用并启动定时器</b>：</li><ol class="notion-list notion-list-numbered notion-block-2efb72e865588026aaead9d109d34939" style="list-style-type:lower-alpha"><div class="notion-text notion-block-2efb72e86558802e964dd5237db934fd">bash复制</div><div class="notion-text notion-block-2efb72e865588044ae79d547197f5009"><code class="notion-inline-code">sudo systemctl daemon-reload
sudo systemctl enable --now backup.timer</code></div></ol></ol><ol start="4" class="notion-list notion-list-numbered notion-block-2efb72e865588074a9e2c8d0f6f77542" style="list-style-type:decimal"><li><b>查看定时器情况</b>：</li><ol class="notion-list notion-list-numbered notion-block-2efb72e865588074a9e2c8d0f6f77542" style="list-style-type:lower-alpha"><div class="notion-text notion-block-2efb72e8655880bf81a2dbbc552f1ae7">bash复制</div><div class="notion-text notion-block-2efb72e865588025aac1f80cc274c70d"><code class="notion-inline-code">systemctl list-timers --all</code></div></ol></ol><div class="notion-text notion-block-2efb72e86558804fa399c6ccd3c99e8e">你会看到下一次执行时间、上一次执行时间等信息。</div><hr class="notion-hr notion-block-2efb72e86558805b953ddea673a958cb"/><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-2efb72e8655880a59e93c307f3c765ff" data-id="2efb72e8655880a59e93c307f3c765ff"><span><div id="2efb72e8655880a59e93c307f3c765ff" class="notion-header-anchor"></div><a class="notion-hash-link" href="#2efb72e8655880a59e93c307f3c765ff" title="八、Target（目标）：理解“运行级别”"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">八、Target（目标）：理解“运行级别”</span></span></h3><div class="notion-text notion-block-2efb72e8655880e28b05cb84aa0aa9c8">target 是一组 unit 的集合，用来表示系统所处的“模式”。</div><div class="notion-text notion-block-2efb72e86558807c9090f3c1a309fe10">常见 target：</div><ul class="notion-list notion-list-disc notion-block-2efb72e8655880da87d8dffb08fb0ea2"><li><code class="notion-inline-code">graphical.target</code>：图形界面模式（桌面）</li></ul><ul class="notion-list notion-list-disc notion-block-2efb72e8655880a695f6d3db5815f55a"><li><code class="notion-inline-code">multi-user.target</code>：多用户命令行模式（无桌面）</li></ul><ul class="notion-list notion-list-disc notion-block-2efb72e8655880e6b2f8ed3548544cb5"><li><code class="notion-inline-code">rescue.target</code>：单用户救援模式</li></ul><ul class="notion-list notion-list-disc notion-block-2efb72e86558801a8c86ee878fd8e496"><li><code class="notion-inline-code">emergency.target</code>：更低级的紧急模式（很少用）</li></ul><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-2efb72e8655880b6948af0b50457e06f" data-id="2efb72e8655880b6948af0b50457e06f"><span><div id="2efb72e8655880b6948af0b50457e06f" class="notion-header-anchor"></div><a class="notion-hash-link" href="#2efb72e8655880b6948af0b50457e06f" title="常用命令"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">常用命令</span></span></h4><div class="notion-text notion-block-2efb72e86558805583f9c19b8604d136">bash复制</div><div class="notion-text notion-block-2efb72e8655880afb668ea9078d8f542"><code class="notion-inline-code"># 查看当前默认 target（类似默认运行级别）
systemctl get-default

# 设置默认 target（开机会进到这个模式）
sudo systemctl set-default multi-user.target

# 立即切换到某个 target（相当于切换运行级别）
sudo systemctl isolate graphical.target</code></div><hr class="notion-hr notion-block-2efb72e86558802ea4f9c97bbb6f1b02"/><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-2efb72e8655880028902e436412ff4c1" data-id="2efb72e8655880028902e436412ff4c1"><span><div id="2efb72e8655880028902e436412ff4c1" class="notion-header-anchor"></div><a class="notion-hash-link" href="#2efb72e8655880028902e436412ff4c1" title="九、一些实用小技巧（建议掌握）"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">九、一些实用小技巧（建议掌握）</span></span></h3><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-2efb72e8655880f6b89cf50f19a67f02" data-id="2efb72e8655880f6b89cf50f19a67f02"><span><div id="2efb72e8655880f6b89cf50f19a67f02" class="notion-header-anchor"></div><a class="notion-hash-link" href="#2efb72e8655880f6b89cf50f19a67f02" title="1. 列出失败的单元"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">1. 列出失败的单元</span></span></h4><div class="notion-text notion-block-2efb72e8655880ca966ff184ca8d1960">bash复制</div><div class="notion-text notion-block-2efb72e865588018b133f3635911d490"><code class="notion-inline-code">systemctl list-units --failed</code></div><div class="notion-text notion-block-2efb72e86558806f9a0cc816010dbc47">如果某些服务启动失败了，这里一目了然。</div><hr class="notion-hr notion-block-2efb72e865588025b728f50ec5aa63f0"/><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-2efb72e8655880b49c75ca01cf56ffb6" data-id="2efb72e8655880b49c75ca01cf56ffb6"><span><div id="2efb72e8655880b49c75ca01cf56ffb6" class="notion-header-anchor"></div><a class="notion-hash-link" href="#2efb72e8655880b49c75ca01cf56ffb6" title="2. 重置失败状态"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">2. 重置失败状态</span></span></h4><div class="notion-text notion-block-2efb72e8655880728d18fe4891742914">bash复制</div><div class="notion-text notion-block-2efb72e8655880afa1d1e2e079f8849c"><code class="notion-inline-code">sudo systemctl reset-failed
# 或仅重置某个服务：
sudo systemctl reset-failed nginx</code></div><div class="notion-text notion-block-2efb72e8655880c49743e73601d1aca3">配合自动化运维时会用到。</div><hr class="notion-hr notion-block-2efb72e86558808a940cf264d60c5285"/><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-2efb72e86558806d851bee45a1da9207" data-id="2efb72e86558806d851bee45a1da9207"><span><div id="2efb72e86558806d851bee45a1da9207" class="notion-header-anchor"></div><a class="notion-hash-link" href="#2efb72e86558806d851bee45a1da9207" title="3. 临时运行服务，不改变永久设置"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">3. 临时运行服务，不改变永久设置</span></span></h4><div class="notion-text notion-block-2efb72e865588021bd50c7cc3bdd1c75">bash复制</div><div class="notion-text notion-block-2efb72e865588061aae9eaf4a4f90ace"><code class="notion-inline-code"># 只在当前运行期启用（reboot 后不再启用）
sudo systemctl start --runtime nginx</code></div><div class="notion-text notion-block-2efb72e8655880eda7e7e89302848521">适合临时测试某个服务，不想影响正式配置。</div><hr class="notion-hr notion-block-2efb72e8655880e78f83fa9a6966b38b"/><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-2efb72e86558807e9be0e0cee0e42269" data-id="2efb72e86558807e9be0e0cee0e42269"><span><div id="2efb72e86558807e9be0e0cee0e42269" class="notion-header-anchor"></div><a class="notion-hash-link" href="#2efb72e86558807e9be0e0cee0e42269" title="4. 查看服务依赖关系"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">4. 查看服务依赖关系</span></span></h4><div class="notion-text notion-block-2efb72e8655880f09c67f420aa18b838">bash复制</div><div class="notion-text notion-block-2efb72e8655880708f31f2ddcbabab74"><code class="notion-inline-code">systemctl list-dependencies nginx</code></div><div class="notion-text notion-block-2efb72e86558809ea2afdb171b26e831">可以看到它依赖哪些单元，哪些又依赖它。</div><hr class="notion-hr notion-block-2efb72e865588001b838defdb96634e7"/><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-2efb72e8655880b3bc91c05de98044b6" data-id="2efb72e8655880b3bc91c05de98044b6"><span><div id="2efb72e8655880b3bc91c05de98044b6" class="notion-header-anchor"></div><a class="notion-hash-link" href="#2efb72e8655880b3bc91c05de98044b6" title="5. 修改服务配置的推荐方式：systemctl edit"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">5. 修改服务配置的推荐方式：<code class="notion-inline-code">systemctl edit</code></span></span></h4><div class="notion-text notion-block-2efb72e86558800da639fda185247ce8">不要直接改 <code class="notion-inline-code">/lib/systemd/system/*.service</code>，官方推荐方式：</div><div class="notion-text notion-block-2efb72e865588061a5a2f3dab2d3c921">bash复制</div><div class="notion-text notion-block-2efb72e8655880e88a38fdd944d387f8"><code class="notion-inline-code">sudo systemctl edit nginx</code></div><div class="notion-text notion-block-2efb72e8655880cb8663f6fba4c5e8d6">会打开一个编辑器，你只需写<b>想覆盖或追加的那几行</b>：</div><div class="notion-text notion-block-2efb72e8655880b7a748e1b293aec8b6">ini复制</div><div class="notion-text notion-block-2efb72e86558808d9cd8e7abedd25c5c"><code class="notion-inline-code">[Service]
Environment=&quot;ENV=prod&quot;</code></div><div class="notion-text notion-block-2efb72e8655880b1a978db56d2bf6eb1">保存后：</div><div class="notion-text notion-block-2efb72e86558801a9075d8b5aaf845a5">bash复制</div><div class="notion-text notion-block-2efb72e8655880babd04f34e2ed6f170"><code class="notion-inline-code">sudo systemctl daemon-reload
sudo systemctl restart nginx</code></div><div class="notion-text notion-block-2efb72e8655880479909ef969d37b5bb">override 文件会保存在：</div><div class="notion-text notion-block-2efb72e8655880e0b347c69664a94933">text复制</div><div class="notion-text notion-block-2efb72e86558804a8548f4bca62eba4a"><code class="notion-inline-code">/etc/systemd/system/nginx.service.d/override.conf</code></div><div class="notion-text notion-block-2efb72e865588026a585e5561ab2c12e">以后系统升级不会被覆盖。</div><hr class="notion-hr notion-block-2efb72e8655880af83caf7adecd8f306"/><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-2efb72e865588019858fed9d92a1c04e" data-id="2efb72e865588019858fed9d92a1c04e"><span><div id="2efb72e865588019858fed9d92a1c04e" class="notion-header-anchor"></div><a class="notion-hash-link" href="#2efb72e865588019858fed9d92a1c04e" title="十、学习与排错建议"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">十、学习与排错建议</span></span></h3><ol start="1" class="notion-list notion-list-numbered notion-block-2efb72e86558802ab673c0cc5fdad04f" style="list-style-type:decimal"><li><b>遇到问题的基本排查套路</b>：</li><ol class="notion-list notion-list-numbered notion-block-2efb72e86558802ab673c0cc5fdad04f" style="list-style-type:lower-alpha"><li><code class="notion-inline-code">systemctl status your-service</code></li><li><code class="notion-inline-code">journalctl -u your-service -xe</code></li><li>查看 unit 文件路径，看配置是否正确；如有修改记得：</li><ol class="notion-list notion-list-numbered notion-block-2efb72e86558807a955be80703716d88" style="list-style-type:lower-roman"><div class="notion-text notion-block-2efb72e8655880a7a5aee0ae2f6b33fe">bash复制</div><div class="notion-text notion-block-2efb72e8655880f082f7f4c26a6749bb"><code class="notion-inline-code">sudo systemctl daemon-reload
sudo systemctl restart your-service</code></div></ol></ol></ol><ol start="2" class="notion-list notion-list-numbered notion-block-2efb72e86558808ea5e3c368c8e67576" style="list-style-type:decimal"><li><b>多用 </b><code class="notion-inline-code"><b>-help</b></code><b> 和 </b><code class="notion-inline-code"><b>man</b></code>：</li><ol class="notion-list notion-list-numbered notion-block-2efb72e86558808ea5e3c368c8e67576" style="list-style-type:lower-alpha"><div class="notion-text notion-block-2efb72e86558806a9d00d57781495e91">bash复制</div><div class="notion-text notion-block-2efb72e865588004ac52d2fc60b4e5ba"><code class="notion-inline-code">systemctl --help
man systemctl
man systemd.service
man systemd.timer</code></div></ol></ol><ol start="3" class="notion-list notion-list-numbered notion-block-2efb72e865588004bdc3e071ad3ff20e" style="list-style-type:decimal"><li><b>在测试环境大胆尝试</b>：</li><ol class="notion-list notion-list-numbered notion-block-2efb72e865588004bdc3e071ad3ff20e" style="list-style-type:lower-alpha"><div class="notion-text notion-block-2efb72e8655880e79fefe93c81f18ad1">可以在虚拟机或容器里自由练习 <code class="notion-inline-code">enable/disable/start/stop/status</code> 等命令，而不怕影响生产环境。</div></ol></ol><hr class="notion-hr notion-block-2efb72e8655880f69583c756b594cdb5"/><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-2efb72e8655880eebbc1cfb82f602884" data-id="2efb72e8655880eebbc1cfb82f602884"><span><div id="2efb72e8655880eebbc1cfb82f602884" class="notion-header-anchor"></div><a class="notion-hash-link" href="#2efb72e8655880eebbc1cfb82f602884" title="十一、常用命令速查表（可收藏）"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">十一、常用命令速查表（可收藏）</span></span></h3><table class="notion-simple-table notion-block-2efb72e8655880e2859ecba866e767bc"><tbody><tr class="notion-simple-table-row notion-simple-table-header-row notion-block-2efb72e8655880909768cdc07a039ac3"><td class="" style="width:120px"><div class="notion-simple-table-cell">操作</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">命令示例</div></td></tr><tr class="notion-simple-table-row notion-block-2efb72e86558808c8294f0b1f8683005"><td class="" style="width:120px"><div class="notion-simple-table-cell">启动服务</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">sudo systemctl start nginx</code></div></td></tr><tr class="notion-simple-table-row notion-block-2efb72e86558808fa5c9d371d3504587"><td class="" style="width:120px"><div class="notion-simple-table-cell">停止服务</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">sudo systemctl stop nginx</code></div></td></tr><tr class="notion-simple-table-row notion-block-2efb72e8655880638efae5bd8c4b156d"><td class="" style="width:120px"><div class="notion-simple-table-cell">重启服务</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">sudo systemctl restart nginx</code></div></td></tr><tr class="notion-simple-table-row notion-block-2efb72e8655880e2aacac11f263b7f91"><td class="" style="width:120px"><div class="notion-simple-table-cell">重载配置</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">sudo systemctl reload nginx</code></div></td></tr><tr class="notion-simple-table-row notion-block-2efb72e86558802c80edf250c50b48a8"><td class="" style="width:120px"><div class="notion-simple-table-cell">状态查看</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">systemctl status nginx</code></div></td></tr><tr class="notion-simple-table-row notion-block-2efb72e8655880c98287dbbfaec16feb"><td class="" style="width:120px"><div class="notion-simple-table-cell">设置开机自启</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">sudo systemctl enable nginx</code></div></td></tr><tr class="notion-simple-table-row notion-block-2efb72e8655880139353f7ac39578819"><td class="" style="width:120px"><div class="notion-simple-table-cell">取消开机自启</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">sudo systemctl disable nginx</code></div></td></tr><tr class="notion-simple-table-row notion-block-2efb72e86558802a9781c4a057b8c663"><td class="" style="width:120px"><div class="notion-simple-table-cell">屏蔽服务</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">sudo systemctl mask nginx</code></div></td></tr><tr class="notion-simple-table-row notion-block-2efb72e865588088afccc9779eaa7e9e"><td class="" style="width:120px"><div class="notion-simple-table-cell">取消屏蔽</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">sudo systemctl unmask nginx</code></div></td></tr><tr class="notion-simple-table-row notion-block-2efb72e8655880298326d56b97e626ff"><td class="" style="width:120px"><div class="notion-simple-table-cell">查看运行中服务</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">systemctl list-units --type=service</code></div></td></tr><tr class="notion-simple-table-row notion-block-2efb72e8655880bf8c79fd37e69d3e6c"><td class="" style="width:120px"><div class="notion-simple-table-cell">查看所有服务文件</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">systemctl list-unit-files --type=service</code></div></td></tr><tr class="notion-simple-table-row notion-block-2efb72e86558801f9ecac14f05883cbb"><td class="" style="width:120px"><div class="notion-simple-table-cell">查看失败的单元</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">systemctl list-units --failed</code></div></td></tr><tr class="notion-simple-table-row notion-block-2efb72e8655880ca9382fbb7a6e7de34"><td class="" style="width:120px"><div class="notion-simple-table-cell">查看服务日志</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">journalctl -u nginx -f</code></div></td></tr><tr class="notion-simple-table-row notion-block-2efb72e865588082b3bed6212b3ff2b8"><td class="" style="width:120px"><div class="notion-simple-table-cell">重新加载所有 unit</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">sudo systemctl daemon-reload</code></div></td></tr></tbody></table><hr class="notion-hr notion-block-2efb72e865588067860cf58f6aa29f8b"/><div class="notion-blank notion-block-2efb72e8655880d0916cededf3935337"> </div></main></div>]]></content:encoded>
        </item>
    </channel>
</rss>