Redis server start / stop / restart / status check
Explains how to start / stop / restart / check the status of the Redis server.
Check Redis status
To check the status of Redis, use "status" of the systemctl command.
sudo systemctl status redis-server
If it is running
If it is running, the following will be displayed.
● redis-server.service --Advanced key-value store Loaded: loaded (/lib/systemd/system/redis-server.service; enabled; vendor preset: enabled) Active: active (running) since Tue 2020-06-16 10:12:56 JST; 3h 57min ago Docs: http://redis.io/documentation, man: redis-server (1) Main PID: 108380 (r.edis-server) Tasks: 4 (limit: 9479) CGroup: /system.slice/redis-server.service mq108380 /usr/bin/redis-server 127.0.0.1:6379
When stopped
If it is stopped, the following will be displayed.
● redis-server.service --Advanced key-value store Loaded: loaded (/lib/systemd/system/redis-server.service; enabled; vendor preset: enabled) Active: inactive (dead) since Tue 2020-06-16 14:11:18 JST; 2s ago Docs: http://redis.io/documentation, man: redis-server (1) Process: 27892 ExecStop = / bin / kill -s TERM $MAINPID (code = exited, status = 0 / SUCCESS) Main PID: 108380 (code = exited, status = 0 / SUCCESS)
Start Redis
To start Redis, use the systemctl command "start". Run with root privileges using the sudo command.
sudo systemctl start redis-server
Even if the boot is successful, the message that it was successful is not returned. Please check the status.
Stop Redis
To stop Redis, use the systemctl command "stop". Run with root privileges using the sudo command.
sudo systemctl stop redis-server
If the outage is successful, no successful message will be returned. Please check the status.
Restart Redis
To restart Redis, use the systemctl command "restart". Run with root privileges using the sudo command.
sudo systemctl restart redis-server
restart simply executes the stop command and executes the start command.
To see the Redis start / stop log
Servers such as Redis are centrally managed by a program called systemd.
The Redis start / stop log is output to the systemd log.
Use the journalctl command to see the systemd logs. Specify the unit "redis-server" with the "-u" option. Please note that you will not be able to see the Redis server logs unless you run it with sudo. If you want to see only the last part of the log, combine the "-r" option.
sudo journalctl -r -u redis-server
This is a sample log.
Jul 22 13:24:34 shinshina-development-app-00000001 systemd [1]: Started Advanced key-value store. Jul 22 13:24:34 shinshina-development-app-00000001 systemd [1]: redis-server.service: Can't open PID file /var/run/redis/redis-server.pid (yet?) after start: No such file or directory Jul 22 13:24:33 shinshina-development-app-00000001 systemd [1]: Starting Advanced key-value store ... --Reboot - Jul 22 13:13:48 shinshina-development-app-00000001 systemd [1]: Stopped Advanced key-value store. Jul 22 13:13:47 shinshina-development-app-00000001 systemd [1]: Stopping Advanced key-value store ...
To see the Redis systemd config file
You can see the Redis systemd configuration file under "systemctl status redis-server".
Let's take a look at the configuration file with the cat command.
cat /lib/systemd/system/redis-server.service
Redis Troubleshooting
The Redis server may not start with the following error.
redis-server.service: Can't open PID file /var/run/redis/redis-server.pid (yet?) after start: No such file or directory
This is an error that occurs when IPv6 is not enabled in the server's network settings and IPv6 is enabled in the Redis server's configuration file.
Edit and modify your Redis config file. Make a backup in case you make a mistake.
sudo cp /etc/redis/redis.conf /etc/redis/redis.conf.bak sudo vi /etc/redis/redis.conf
The following
bind 127.0.0.1::1
Changed to
bind 127.0.0.1
Start and check Redis
Start and check Redis.
sudo systemctl start redis-server sudo systemctl status redis-server