Use RocksMQ as the Milvus Message Queue
RocksMQ 是 Milvus 内置的嵌入式消息队列(WAL),仅适用于 Milvus Standalone。在早期 Milvus 版本中,它是默认的 Standalone 消息队列;在 Milvus 3.x 中,Milvus Standalone 默认使用嵌入式 Woodpecker。
Version compatibility
- 仅 Standalone - RocksMQ 不支持 Milvus Distributed(cluster)。请参阅 message queue 支持矩阵。
- RocksMQ 随 Milvus 一起提供,因此无需安装单独版本。
- RocksMQ 是早期 Milvus 版本中默认的 standalone message queue,在 Milvus 3.x 中已由 embedded Woodpecker 取代。
使用 Docker 基于 RocksMQ 部署 Milvus Standalone
Install
按照 Run Milvus in Docker 操作。在 Milvus 3.x 中,standalone 默认使用 Woodpecker,因此需要显式将消息队列类型切换为 RocksMQ。bootstrap 脚本会在 首次 执行 start 时写入全新的 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 适用于全新实例(尚未创建任何 collection)。如果要为已有数据的实例变更消息队列,请改为按照切换流程操作。
Configure
如需调优 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
Uninstall
bash standalone_embed.sh stop
bash standalone_embed.sh delete
Notes
- 从 2.5.x 升级到 2.6.x: Message Queue 限制:升级到 Milvus v3.0.0 时,必须保持当前的 message queue 选择。升级过程中不支持在不同的 message queue 系统之间切换。未来版本将支持更改 message queue 系统。
由于 2.6.x 将 standalone 的默认值改为 Woodpecker,如果你想继续使用 RocksMQ,请在升级前在
user.yaml中固定mq.type: rocksmq。 - 如需更改正在运行实例的 message queue,请参阅 Switch from RocksMQ to Woodpecker。