> For the complete documentation index, see [llms.txt](https://overleaf-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://overleaf-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（僅附加檔案）持久化提供了一種穩健的方式，透過記錄伺服器收到的每一個寫入操作來確保資料持久性。不同於會對資料集做即時快照的 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. 輸入 `exit` 並按下 Return 鍵
9. 輸入以下內容以離開 redis 容器： `exit` 並按下 Return 鍵
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://overleaf-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.
