Redis is an in-memory key-value data structure store. It often used as a database, cache, and message broker. Redis is an open-source project which released under a 3-clause BSD license.
This tutorial demonstrates how to install Redis on Ubuntu 22.04.
Add the official Redis repository:
sudo add-apt-repository -y ppa:redislabs/redis
sudo apt install -y redis
Once installation is completed, we can check Redis version:
Execute the following command to enable Redis to start on boot:
sudo systemctl enable redis-server
You can check whether Redis service is running with command:
sudo service redis-server status
We can also stop, start and restart the Redis service:
sudo service redis-server stop
sudo service redis-server start
sudo service redis-server restart
Connect to the Redis server with client:
For connectivity testing, use
PING command. Server returns
GET commands can be used to store and retrieve value by key.
127.0.0.1:6379> SET message "Hello"
127.0.0.1:6379> GET message
QUIT command to exit the Redis prompt.
If you decided to completely remove Redis, run the following command:
sudo apt purge --autoremove -y redis
Disable Redis service:
sudo systemctl disable redis-server
sudo systemctl daemon-reload
sudo systemctl reset-failed
Remove GPG key and repository:
sudo rm -rf /etc/apt/trusted.gpg.d/redislabs-ubuntu-redis.gpg*
sudo rm -rf /etc/apt/sources.list.d/redislabs-ubuntu-redis-jammy.list
You can also remove a history of commands executed with Redis client:
rm -rf ~/.rediscli_history