Skip to content

Instantly share code, notes, and snippets.

@nolanlawson
Last active July 27, 2025 19:02
Show Gist options
  • Save nolanlawson/b749e1646fa38cb7d3b172837bb7e5a1 to your computer and use it in GitHub Desktop.
Save nolanlawson/b749e1646fa38cb7d3b172837bb7e5a1 to your computer and use it in GitHub Desktop.
Updating Redis from v6.0 to v8.0.3 on Ubuntu 22.04

Updating Redis from v6.0 to v8.0.3 on Ubuntu 22.04

For the Mastodon v4.4 release, you need at least Redis v6.2+. Unfortunately if you're running Ubuntu 22.04, the latest distro release of Redis is v6.0 which is too old. So you need the official Redis PPA instead. (Assuming you want to avoid the full Ubuntu update, which I happen to.)

Simply adding the PPA is not enough, because Ubuntu tries to block it in favor of its own ESM (Extended Security Maintenance) version. So it ends up being kind of a pain.

This is a simple bash script you can run (I encourage running every command line-by-line just in case) which successfully updated Redis from v6.0 to v8.0.3 for me.

Thanks to multiple folks in the Mastodon Discord for help putting this together ([email protected],deadinsi.de, [email protected], [email protected]).

#!/usr/bin/env bash
# stop mastodon
sudo systemctl stop mastodon-streaming mastodon-web mastodon-sidekiq
# stop redis
sudo systemctl stop redis-server
# backup /var/lib/redis file just in case
sudo cp /var/lib/redis/dump.rdb /tmp/dump-backup.rdb
# remove ubuntu redis
sudo apt remove -y redis-server redis-tools
# setup redis ppa - via https://redis.io/docs/latest/operate/oss_and_stack/install/archive/install-redis/install-redis-on-linux/
sudo apt install -y lsb-release curl gpg
curl -fsSL https://packages.redis.io/gpg | sudo gpg --dearmor -o /usr/share/keyrings/redis-archive-keyring.gpg
sudo chmod 644 /usr/share/keyrings/redis-archive-keyring.gpg
echo "deb [signed-by=/usr/share/keyrings/redis-archive-keyring.gpg] https://packages.redis.io/deb $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/redis.list
# prefer redis ppa - ubuntu esm (extended security maintenance) repositories are pinned at 510
echo -e 'Package: *\nPin: origin "packages.redis.io"\nPin-Priority: 520' | sudo tee /etc/apt/preferences.d/redis-ppa
# install
sudo apt update
sudo apt install -y redis-server redis-tools
# check the version - should say 6:8.0.3-1rl1~jammy1 (note redis version 8.0.3)
sudo aptitude versions redis-tools
sudo aptitude versions redis-server
# restart redis
sudo systemctl start redis-server
# wait for it to be ready, see logs for when it's done
sudo journalctl -f -u redis-server
# restart mastodon
sudo systemctl start mastodon-streaming mastodon-web mastodon-sidekiq
@ThisIsMissEm
Copy link

I don't think you actually want

echo -e 'Package: *\nPin: origin "packages.redis.io"\nPin-Priority: 520' | sudo tee /etc/apt/preferences.d/redis-ppa

but instead

echo -e 'Package: redis-*\nPin: origin "packages.redis.io"\nPin-Priority: 520' | sudo tee /etc/apt/preferences.d/redis-ppa

Though I'm not 100% sure.

@ThisIsMissEm
Copy link

That is, you only want to pin the redis packages to the redis origin, not other system packages.

@ThisIsMissEm
Copy link

Screenshot 2025-07-27 at 18 34 39

From what I can tell their apt repo has the above packages in it.

@nolanlawson
Copy link
Author

redis-* is not quite right - shouldn't it be redis*? Otherwise it won't get the redis package itself.

Although it looks like * is harmless if the only non-redis package they host is memtier-benchmark (whatever that is)?

@ThisIsMissEm
Copy link

Ah, yeah, I hadn't actually listed the packages when I did the first comment, but yeah, redis* is what you want — essentially you'd want whatever the most minimal range is, as to prevent say, Redis Labs going rogue and adding a package that's suspicious, e.g., ruby that's actually not just ruby but something else. So trusting the least number of packages from them.

@nolanlawson
Copy link
Author

I'm going to keep it as * for now since I'm worried that redis* doesn't match redis (and I'm too lazy to research it 🙃), but yes you're right it is the more future-proof approach!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment