将 RocksMQ 用作 Milvus 消息队列
RocksMQ 是随 Milvus 捆绑提供的嵌入式消息队列(WAL),仅适用于Milvus Standalone。在早期版本的 Milvus 中,它是默认的独立模式消息队列;而在 Milvus 3.x 中,Milvus Standalone 默认使用嵌入式Woodpecker。
版本兼容性
- 仅限独立版— Milvus Distributed(集群)不支持 RocksMQ。请参阅消息队列支持矩阵。
- RocksMQ 随 Milvus 一起提供,因此无需单独安装。
- 它是早期 Milvus 版本中的默认独立模式消息队列,但在 Milvus 3.x 中已被内置的 Woodpecker 取代。
使用 Docker 部署带 RocksMQ 的 Milvus Standalone
安装
请按照《在 Docker 中运行 Milvus Standalone》中的步骤操作。在 Milvus 3.x 中,独立部署的默认消息队列为 Woodpecker,因此需显式将消息队列类型切换为 RocksMQ。引导脚本会在首次运行时将user.yaml 写入start ,因此请在首次启动后设置类型,然后执行restart 以应用更改(执行restart 可保留user.yaml ):
mkdir milvus-rocksmq && cd milvus-rocksmq
curl -sfL https://raw.githubusercontent.com/milvus-io/milvus/master/scripts/standalone_embed.sh -o standalone_embed.sh
# 1. First start — boots the container and writes a default user.yaml
bash standalone_embed.sh start
# 2. Set the message queue to RocksMQ
cat > user.yaml <<'EOF'
mq:
type: rocksmq
EOF
# 3. Restart to apply the change
bash standalone_embed.sh restart
通过这种方式切换
mq.type 仅适用于全新实例(尚未包含任何 Collections)。若要更改已包含数据的实例的消息队列,请改用切换流程。
配置
要调整 RocksMQ 的配置,请在user.yaml 文件中添加rocksmq 部分,然后重启服务:
mq:
type: rocksmq
rocksmq:
path: /var/lib/milvus/rdb_data # where messages are stored
lrucacheratio: 0.06 # rocksdb cache memory ratio
rocksmqPageSize: 67108864 # 64 MB, size of each message page
retentionTimeInMinutes: 4320 # 3 days
retentionSizeInMB: 8192 # 8 GB
compactionInterval: 86400 # 1 day, trigger rocksdb compaction
compressionTypes: [0, 0, 7, 7, 7]
bash standalone_embed.sh restart
卸载
bash standalone_embed.sh stop
bash standalone_embed.sh delete
注意事项
- 从 2.5.x 升级至 2.6.x: 消息队列限制:升级至 Milvus v3.0.0 时,必须保留当前的消息队列选择。升级过程中不支持在不同的消息队列系统之间切换。未来版本将支持更改消息队列系统。
由于 2.6.x 将独立部署模式的默认消息队列更改为 Woodpecker,若您希望保留 RocksMQ,请在升级前将
mq.type: rocksmq固定在您的user.yaml中。 - 若要更改正在运行的实例的消息队列,请参阅《从 RocksMQ 切换到 Woodpecker》。