I’ve been running Dragonflydb on a single node using Docker compose for about 8 months now. I am using the following docker compose yaml to attempt to take snapshots every 5 minutes:
# This version persists data.
services:
dragonfly:
image: 'docker.dragonflydb.io/dragonflydb/dragonfly'
command: ["dragonfly", "--logtostderr", "--dir", "/data", "--snapshot_cron", "*/5 * * * *"] # Example cron schedule for every 5 minutes
# Then you will also have to have a cron job to delete old snapshots
ulimits:
memlock: -1
restart: unless-stopped
#ports:
# - "6379:6379"
# For better performance, consider `host` mode instead `port` to avoid dock>
# `host` mode is NOT currently supported in Swarm Mode.
# https://docs.docker.com/compose/compose-file/compose-file-v3/#network_mode
network_mode: "host"
volumes:
- dragonflydata:/data
volumes:
dragonflydata:
This code runs the db fine, but when I look at
/var/lib/docker/volumes/redis_dragonflydata/_data
Timestamps are created when I first start the container but never updated afterwards. If the snapshot files are getting updated then I would expect the filesystem timestamps to change.
Either something’s not working or I have some incorrect assumptions.
Thanks for any help.
Hi @windmeup, good question!
I think the gist is that you don’t pass dragonfly
as the first argument. I tested it myself, and all the following 3 ways could work.
Command as a Whole String
services:
dragonfly:
image: "docker.dragonflydb.io/dragonflydb/dragonfly"
command: "--proactor_threads 2 --snapshot_cron '*/5 * * * *'"
ulimits:
memlock: -1
ports:
- "6379:6379"
restart: unless-stopped
volumes:
- dragonflydata:/data
volumes:
dragonflydata:
Command as a YAML List
services:
dragonfly:
image: "docker.dragonflydb.io/dragonflydb/dragonfly"
command:
- "--proactor_threads"
- "2"
- "--snapshot_cron"
- "*/5 * * * *"
ulimits:
memlock: -1
ports:
- "6379:6379"
restart: unless-stopped
volumes:
- dragonflydata:/data
volumes:
dragonflydata:
Command as a Compact List
This is probably the way you prefer:
services:
dragonfly:
image: "docker.dragonflydb.io/dragonflydb/dragonfly"
command: ["--proactor_threads", "2", "--snapshot_cron", "*/5 * * * *"]
ulimits:
memlock: -1
ports:
- "6379:6379"
restart: unless-stopped
volumes:
- dragonflydata:/data
volumes:
dragonflydata:
After Dragonfly is booted, you can connect and verify the snapshot_cron
configuration like below:
$> redis-cli # Note that I have the port accessible locally.
dragonfly$> CONFIG GET snapshot_cron
1) "snapshot_cron"
2) "*/5 * * * *"
I also monitored, seeing that snapshots are created based on the cron schedule:
Thanks for the question. I will update the documentation with examples like this shortly.
Question; does that mean that I no longer need these?"
“–logtostderr”, “–dir”, “/data”,
You can still pass additional server flags as needed!
I was using "--proactor_threads", "2", "--snapshot_cron", "*/5 * * * *"
earlier just as an example, as I was running it locally too and wanted to have a smaller memory requirement and test the flags.
I did pass some more and it’s working great. I also wrote a script to be run on cron every 15 minutes to leave just the last 4 days of logs.
1 Like