> 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-cn/pei-zhi/overleaf-toolkit/redis.md).

# Redis

### 启用密码认证

如果您正在使用外部 Redis 服务并且需要提供密码，可以通过设置 `OVERLEAF_REDIS_PASS` 和 `REDIS_PASSWORD` 中的环境变量来实现 **config/variables.env** 文件中的配置并运行 `bin/up -d` 命令来重新创建 **sharelatex** 容器内。

如果您正在运行本地 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. 通过输入以下命令退出 redis-cli `exit` 并按回车键
9. 通过输入以下命令退出 redis 容器 `exit` 并按回车键
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-cn/pei-zhi/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.
