> 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/vi/cau-hinh/overleaf-toolkit/redis.md).

# Redis

### Bật xác thực bằng mật khẩu

Nếu bạn đang sử dụng dịch vụ Redis bên ngoài và cần cung cấp mật khẩu, bạn có thể làm điều này bằng cách đặt `OVERLEAF_REDIS_PASS` và `REDIS_PASSWORD` các biến môi trường trong **config/variables.env** tệp và chạy `bin/up -d` lệnh để tạo lại **sharelatex** container.

Nếu bạn đang chạy một phiên bản Redis cục bộ, bạn cần cấu hình **redis** dịch vụ để khởi động với xác thực bằng mật khẩu. Sau khi đặt các biến môi trường ở trên, bạn cũng cần hoàn thành các bước bổ sung sau:

Tạo một **docker-compose.override.yml** tệp trong **thư mục config/,** thư mục với nội dung sau:

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

```yaml
services:
    redis:
        lệnh: "redis-server --requirepass <YOUR-PASSWORD>"
```

{% endcode %}

{% hint style="warning" %}
Nếu bạn đã bật lưu trữ AOF, bạn cần thêm `--appendonly yes` thành `lệnh`.
{% endhint %}

Chạy `bin/up -d` để tạo lại các container.

### Bật cơ chế lưu trữ Append-Only File

(Bản gốc: <https://docs.overleaf.com/on-premises/configuration/overleaf-toolkit/redis#enabling-append-only-file-persistence>)

Cơ chế lưu trữ AOF (Append-Only File) của Redis cung cấp một cách mạnh mẽ để đảm bảo độ bền dữ liệu bằng cách ghi lại mọi thao tác ghi mà máy chủ nhận được. Không giống như các ảnh chụp nhanh RDB, vốn tạo bản sao dữ liệu tại một thời điểm, AOF giữ một bản ghi đầy đủ về mọi thay đổi được thực hiện đối với dữ liệu của bạn.

{% hint style="info" %}
Tắt RDB là tùy chọn. Thông thường, nên sử dụng cả hai phương thức lưu trữ cùng nhau. Trước khi thực hiện bất kỳ thay đổi nào trong môi trường sản xuất, hãy xem xét ưu và nhược điểm của việc chạy AOF và RDB cùng nhau.
{% endhint %}

Bạn có thể đọc thêm về cách bật cơ chế lưu trữ AOF trong Redis tại đây: <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. Lên lịch một khoảng thời gian bảo trì cho việc nâng cấp.
2. Dừng phiên bản bằng cách sử dụng `bin/stop` và sao lưu **thư mục config/,** và **data/** các thư mục.
3. Chạy `bin/up` để khởi động phiên bản
4. Chạy lệnh `docker exec -it redis sh`
5. Chạy lệnh `redis-cli` để mở giao diện dòng lệnh Redis
6. Trong redis-cli, chạy lệnh `config set appendonly yes`
7. Bây giờ bạn cần chờ quá trình ghi lại AOF hoàn tất việc lưu dữ liệu. Bạn có thể làm điều đó bằng cách nhập `INFO persistence` vào redis-cli và chờ cho `aof_rewrite_in_progress` và `aof_rewrite_scheduled` được `0`, và xác minh rằng `aof_last_bgrewrite_status` là `ok`.
8. Thoát khỏi redis-cli bằng cách nhập `exit` và nhấn phím Enter
9. Thoát khỏi container Redis bằng cách nhập `exit` và nhấn phím Enter
10. Chạy lệnh `ls ./data/redis` và xác nhận bạn có thể thấy **appendonly.aof** tệp
11. Chỉnh sửa **config/overleaf.rc** tệp và thay đổi `REDIS_AOF_PERSISTENCE` biến môi trường từ `false` đến `true`
12. Chạy `bin/up -d` và đảm bảo ứng dụng hoạt động (trình soạn thảo dự án và khung lịch sử hoạt động bình thường).


---

# 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/vi/cau-hinh/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.
