Now that Redis is configured and ready for use, you can initiate and test your Redis installation. To start Redis, execute the following command:
sudo systemctl start redis
To verify if Redis starts up without errors, execute the following command:
sudo systemctl status redis
You should observe output similar to the following:
Output
â redis.service - Redis Server
Loaded: loaded (/etc/systemd/system/redis.service; enabled; vendor preset: enabled)
Active: active (running) since Wed 2016-11-01 20:12:07 EDT; 1min 2s ago
Process: 2165 ExecStop=/usr/local/bin/redis-cli shutdown (code=exited, status=0/SUCCESS)
Main PID: 2166 (redis-server)
Tasks: 3 (limit: 512)
Memory: 752.0K
CPU: 125ms
CGroup: /system.slice/redis.service
ââ2166 /usr/local/bin/redis-server 127.0.0.1:6379
. . .
To test Redis functionality, you can launch the Redis command line client by typing and running:
redis-cli
In the prompt, execute:
127.0.0.1:6379> ping
You should observe:
output
PONG
Now, verify if you can set a key by executing
127.0.0.1:6379> set test "Hello!"
The output should display:
output
OK
To retrieve the value that was just stored, execute:
127.0.0.1:6379> get test
The output should show:
output
"Hello!"
Exit the Redis CLI, and proceed to restart the Redis instance:
127.0.0.1:6379> exit
sudo systemctl restart redis
Now, reconnect to the Redis client and confirm whether the test values are still present:
redis-cli
To retrieve the ‘test value’, execute:
127.0.0.1:6379> get test
The output should remain:
output
"Hello!"