Table of contents
Introduction
Redis is a fast, open-source key-value storage database that is often used in scenarios such as caching, message queues, and data persistence.
1. Install Redis
1. Update the package manager
sudo apt update
2. Install Redis
sudo apt install redis-server
Two, configure Redis
1. Open the Redis configuration file
vi /etc/redis/redis.conf
2. Configure binding IP and port
By default, Redis binds on the local loopback address 127.0.0.1 and default port 6379. To access Redis from other devices, you need to modify bind
and port
configuration items.
3. Save and close the file
Press Ctrl + X
, enter to Y
confirm saving, and press Enter
to close the file.
3. Start Redis
1. Start the Redis service
sudo systemctl start redis-server
2. Verify that Redis has started successfully
sudo systemctl status redis-server
If the output shows that Redis is running, Redis started successfully
4. Test Redis
1. Connect to the Redis server
redis-cli
2. Execute the Redis command
SET key value
GET key
SET key value
A key-value pair is set, GET key
and the value corresponding to the key is obtained.
5. Start Redis automatically after booting
1. Enable self-starting of Redis service
sudo systemctl enable redis-server
2. Verify that the Redis service is set to start automatically at boot
sudo systemctl is-enabled redis-server
If the output is enabled
, it means that the Redis service has been successfully set to start automatically at boot.