Installation Redis on Redhat/Rocky/Ubuntu Linux
Installation Redis on Linux
Install Redis on Ubuntu
Add the repository to the APT index, update it, and install Redis:
sudo apt-get install 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
sudo apt-get update
sudo apt-get install redisRedis will start automatically, and it should restart at boot time. If Redis doesn't start across reboots, you may need to manually enable it:
sudo systemctl enable redis-server
sudo systemctl start redis-serverInstall Redis on Red Hat/Rocky 8*/9*
sudo yum install redis
sudo systemctl enable redis
sudo systemctl start redisRedis will restart at boot time.
Install on Ubuntu using Snap
To install via Snap, run:
sudo apt update
sudo apt install redis-tools # for redis-cli
sudo snap install redisRedis will start automatically, but it won't restart at boot time. To do this, run:
setYou can use these additional snap-related commands to start, stop, restart, and check the status of Redis:
sudo snap start redissudo snap stop redissudo snap restart redissudo snap services redis
Starting and stopping Redis in the background
You can start the Redis server as a background process using the systemctl command. This only applies to Ubuntu/Debian when installed using apt, and Red Hat/Rocky when installed using yum.
sudo systemctl start <redis-service-name> # redis or redis-server depending on platformTo stop the server, use:
sudo systemctl stop <redis-service-name> # redis or redis-server depending on platformConnect to Redis
Once Redis is running, you can test it by running redis-cli:
redis-cliTest the connection with the ping command:
127.0.0.1:6379> ping
PONG
Comments
Post a Comment