<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Livesync on OHTLY Blog</title>
    <link>https://blog.ohtly.com/tags/livesync/</link>
    <description>Recent content in Livesync on OHTLY Blog</description>
    <generator>Hugo</generator>
    <language>zh-cn</language>
    <lastBuildDate>Wed, 01 Jul 2026 12:29:20 +0800</lastBuildDate>
    <atom:link href="https://blog.ohtly.com/tags/livesync/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>通过配置文件管理 Self-hosted LiveSync</title>
      <link>https://blog.ohtly.com/posts/2026-07-01-self-hosted-livesync-config/</link>
      <pubDate>Wed, 01 Jul 2026 12:29:20 +0800</pubDate>
      <guid>https://blog.ohtly.com/posts/2026-07-01-self-hosted-livesync-config/</guid>
      <description>&lt;h2 id=&#34;背景&#34;&gt;&#xA;  背景&#xA;  &lt;a class=&#34;heading-link&#34; href=&#34;#%e8%83%8c%e6%99%af&#34;&gt;&#xA;    &lt;i class=&#34;fa-solid fa-link&#34; aria-hidden=&#34;true&#34; title=&#34;链接到标题&#34;&gt;&lt;/i&gt;&#xA;    &lt;span class=&#34;sr-only&#34;&gt;链接到标题&lt;/span&gt;&#xA;  &lt;/a&gt;&#xA;&lt;/h2&gt;&#xA;&lt;p&gt;Self-hosted LiveSync 插件的配置分散在多个设置页面，首次配置需要经过数步对话框引导，涉及 CouchDB 连接、同步模式、Doctor 诊断等多项设置。如果跨多台设备部署，每次手动点对话框效率低且难以保持一致。&lt;/p&gt;&#xA;&lt;p&gt;将配置收敛到插件目录下的 &lt;code&gt;data.json&lt;/code&gt; 文件 + 服务器端 CLI 操作，可以实现可重复、可审计、跨设备一致的部署流程。&lt;/p&gt;&#xA;&lt;h2 id=&#34;服务器端couchdb-初始化&#34;&gt;&#xA;  服务器端：CouchDB 初始化&#xA;  &lt;a class=&#34;heading-link&#34; href=&#34;#%e6%9c%8d%e5%8a%a1%e5%99%a8%e7%ab%afcouchdb-%e5%88%9d%e5%a7%8b%e5%8c%96&#34;&gt;&#xA;    &lt;i class=&#34;fa-solid fa-link&#34; aria-hidden=&#34;true&#34; title=&#34;链接到标题&#34;&gt;&lt;/i&gt;&#xA;    &lt;span class=&#34;sr-only&#34;&gt;链接到标题&lt;/span&gt;&#xA;  &lt;/a&gt;&#xA;&lt;/h2&gt;&#xA;&lt;p&gt;Livesync 需要 CouchDB 作为同步后端。以 CouchDB 3.x 为例，通过 API 完成初始化。&lt;/p&gt;&#xA;&lt;h3 id=&#34;创建数据库&#34;&gt;&#xA;  创建数据库&#xA;  &lt;a class=&#34;heading-link&#34; href=&#34;#%e5%88%9b%e5%bb%ba%e6%95%b0%e6%8d%ae%e5%ba%93&#34;&gt;&#xA;    &lt;i class=&#34;fa-solid fa-link&#34; aria-hidden=&#34;true&#34; title=&#34;链接到标题&#34;&gt;&lt;/i&gt;&#xA;    &lt;span class=&#34;sr-only&#34;&gt;链接到标题&lt;/span&gt;&#xA;  &lt;/a&gt;&#xA;&lt;/h3&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;curl -X PUT -u admin:密码 http://couchdb:5984/笔记库名&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id=&#34;创建专用用户&#34;&gt;&#xA;  创建专用用户&#xA;  &lt;a class=&#34;heading-link&#34; href=&#34;#%e5%88%9b%e5%bb%ba%e4%b8%93%e7%94%a8%e7%94%a8%e6%88%b7&#34;&gt;&#xA;    &lt;i class=&#34;fa-solid fa-link&#34; aria-hidden=&#34;true&#34; title=&#34;链接到标题&#34;&gt;&lt;/i&gt;&#xA;    &lt;span class=&#34;sr-only&#34;&gt;链接到标题&lt;/span&gt;&#xA;  &lt;/a&gt;&#xA;&lt;/h3&gt;&#xA;&lt;p&gt;为每个同步的 vault 创建独立用户，限制其权限范围：&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;curl -X PUT -u admin:密码 &lt;span style=&#34;color:#ae81ff&#34;&gt;\&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#ae81ff&#34;&gt;&lt;/span&gt;  http://couchdb:5984/_users/org.couchdb.user:sync_用户名 &lt;span style=&#34;color:#ae81ff&#34;&gt;\&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#ae81ff&#34;&gt;&lt;/span&gt;  -H &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;Content-Type: application/json&amp;#34;&lt;/span&gt; &lt;span style=&#34;color:#ae81ff&#34;&gt;\&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#ae81ff&#34;&gt;&lt;/span&gt;  -d &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;{&amp;#34;_id&amp;#34;:&amp;#34;org.couchdb.user:sync_用户名&amp;#34;,&amp;#34;name&amp;#34;:&amp;#34;sync_用户名&amp;#34;,&amp;#34;type&amp;#34;:&amp;#34;user&amp;#34;,&amp;#34;roles&amp;#34;:[],&amp;#34;password&amp;#34;:&amp;#34;随机密码&amp;#34;}&amp;#39;&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id=&#34;设置数据库权限&#34;&gt;&#xA;  设置数据库权限&#xA;  &lt;a class=&#34;heading-link&#34; href=&#34;#%e8%ae%be%e7%bd%ae%e6%95%b0%e6%8d%ae%e5%ba%93%e6%9d%83%e9%99%90&#34;&gt;&#xA;    &lt;i class=&#34;fa-solid fa-link&#34; aria-hidden=&#34;true&#34; title=&#34;链接到标题&#34;&gt;&lt;/i&gt;&#xA;    &lt;span class=&#34;sr-only&#34;&gt;链接到标题&lt;/span&gt;&#xA;  &lt;/a&gt;&#xA;&lt;/h3&gt;&#xA;&lt;p&gt;仅该用户和 admin 可以访问：&lt;/p&gt;</description>
    </item>
  </channel>
</rss>
