> For the complete documentation index, see [llms.txt](https://ayakaleaf-pro.ayaka.space/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://ayakaleaf-pro.ayaka.space/on-premises/zh-tw/she-ding/overleaf-toolkit/redis.md).

# Redis

### 啟用密碼驗證

如果您使用外部 Redis 服務並需要提供密碼，您可以透過設定以下 `OVERLEAF_REDIS_PASS` 以及 `REDIS_PASSWORD` 環境變數於 **config/variables.env** 檔案中，並執行 `bin/up -d` 指令來重新建立 **sharelatex** 容器內的 .log。

如果您正在執行本機 Redis 執行個體，您需要設定 **redis** 服務以密碼驗證方式啟動。設定上述環境變數後，您還需要完成以下額外步驟：

建立一個 **docker-compose.override.yml** 檔案於 **config/** 目錄中，內容如下：

{% code title="config/docker-compose.override.yml" %}

```yaml
services:
    redis:
        指令："redis-server --requirepass <YOUR-PASSWORD>"
```

{% endcode %}

{% hint style="warning" %}
如果您已啟用 AOF 持久化，您需要新增 `--appendonly yes` 設為 `指令`.
{% endhint %}

執行 `bin/up -d` 以重新建立容器。

### 啟用追加寫入檔案持久化

（原文：<https://docs.overleaf.com/on-premises/configuration/overleaf-toolkit/redis#enabling-append-only-file-persistence）>

Redis AOF（Append-Only File，追加寫入檔案）持久化透過記錄伺服器接收到的每個寫入操作，提供一種穩健的方式來確保資料持久性。不同於會對資料集進行某一時間點快照的 RDB 快照，AOF 會保留資料所有變更的完整記錄。

{% hint style="info" %}
停用 RDB 是可選的。一般建議同時使用兩種持久化方式。在生產環境中做任何變更之前，請先評估同時執行 AOF 與 RDB 的優缺點。
{% endhint %}

您可以在此進一步了解如何在 Redis 中啟用 AOF 持久化： <https://redis.io/docs/latest/operate/oss_and_stack/management/persistence/#how-i-can-switch-to-aof-if-im-currently-using-dumprdb-snapshotsarrow-up-right>

1. 為升級安排維護時段。
2. 使用以下方式停止執行個體 `bin/stop` 並備份 **config/** 以及 **data/** 資料夾。
3. 執行 `bin/up` 以啟動執行個體
4. 執行指令 `docker exec -it redis sh`
5. 執行指令 `redis-cli` 以開啟 Redis 命令列介面
6. 在 redis-cli 中執行指令 `config set appendonly yes`
7. 現在您需要等待 AOF 重寫完成資料持久化。您可以輸入 `INFO persistence` 到 redis-cli 中，並等待 `aof_rewrite_in_progress` 以及 `aof_rewrite_scheduled` 為 `0`，並確認 `aof_last_bgrewrite_status` 為 `ok`.
8. 輸入以下內容以退出 redis-cli： `exit` 並按下 Enter 鍵
9. 輸入以下內容以退出 redis 容器： `exit` 並按下 Enter 鍵
10. 執行指令 `ls ./data/redis` 並確認您可以看到 **appendonly.aof** 檔案
11. 編輯 **config/overleaf.rc** 檔案，並將 `REDIS_AOF_PERSISTENCE` 環境變數從 `false` 到 `true`
12. 執行 `bin/up -d` 並確保應用程式可正常運作（專案編輯器與歷史記錄窗格可正常使用）。


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://ayakaleaf-pro.ayaka.space/on-premises/zh-tw/she-ding/overleaf-toolkit/redis.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
