实现 Chaos Dashboard 数据持久化
非官方测试版翻译
本页面由 PageTurner AI 翻译(测试版)。未经项目官方认可。 发现错误? 报告问题 →
本文档介绍如何实现 Chaos Dashboard 的数据持久化。
Chaos Dashboard 支持使用 SQLite、MySQL 和 PostgreSQL 作为持久化存储的数据库后端。
SQLite(默认)
Chaos Dashboard 默认使用 SQLite 作为数据库引擎,建议启用 PV(持久卷)。要启用 PV,请将 dashboard.persistentVolume.enabled 设置为 true。你可以在 value.yaml 中找到相关配置,如下所示:
dashboard:
...
persistentVolume:
# If you are using SQLite as your DB for Chaos Dashboard, it is recommended to enable persistence.
# If enable, the chart will create a PersistenceVolumeClaim to store its state in. If you are
# using a DB other than SQLite, set this to false to avoid allocating unused storage.
# If set to false, Chaos Mesh will use an emptyDir instead, which is ephemeral.
enabled: true
# If you'd like to bring your own PVC for persisting chaos event, pass the name of the
# created + ready PVC here. If set, this Chart will not create the default PVC.
# Requires server.persistentVolume.enabled: true
existingClaim: ""
# Chaos Dashboard data Persistent Volume size.
size: 8Gi
# Chaos Dashboard data Persistent Volume Storage Class.
# If defined, storageClassName: <storageClass>
storageClassName: standard
# Chaos Dashboard data Persistent Volume mount root path
mountPath: /data
# Subdirectory of Chaos Dashboard data Persistent Volume to mount
# Useful if the volume's root directory is not empty
subPath: ""
警告
如果 Chaos Dashboard 组件在没有 PV 的情况下重启,其数据将会丢失且无法恢复。
MySQL
Chaos Dashboard 支持 MySQL 5.6 及更高版本作为数据库引擎。以下示例演示了 MySQL 数据库的配置。有关连接字符串配置的详细信息,请参考 Go 的 MySQL 驱动。
PostgreSQL
Chaos Dashboard 支持 PostgreSQL 9.6 及更高版本作为数据库引擎。以下示例演示了 PostgreSQL 数据库的配置。有关连接字符串配置的详细信息,请参考 libpq 连接。
设置 Chaos Dashboard 数据的 TTL(生存时间)
Chaos Dashboard 支持设置数据的过期时间。默认情况下,Event 相关数据的过期时间为 168h,Experiment 相关数据的过期时间默认为 336h。如需修改,可以设置 dashboard.env.TTL_EVENT 和 dashboard.env.TTL_EXPERIMENT 参数,例如: