Original article link: https://www.jianshu.com/p/93085829535c

The environment

Ubuntu 18.04

Port 6379

Redis version 5:4.0.9-1

1 – the installation

apt install redis
Copy the code

2- Installation complete – Startup failure message is displayed

Errors were encountered while processing:
 redis-server
 redis
E: Sub-process /usr/bin/dpkg returned an error code (1)
W: Operation was interrupted before it could finish
root@iZ2zeiudkwjc07o9jfa4fgZ:/var/log/nginx# systemctl status redis-server.serviceLow redis - server. The service - the Advanced key value store - the Loaded: the Loaded (/ lib/systemd/system/redis - server. The service; disabled; vendor preset: enabled) Active: activating (start) since Fri 2019-01-25 15:15:44 CST; 20s ago Docs: http://redis.io/documentation, man:redis-server(1) Process: 28248 ExecStart=/usr/bin/redis-server /etc/redis/redis.conf (code=exited, status=0/SUCCESS) Tasks: 0 (limit: 2325)
   CGroup: /system.slice/redis-server.service

Jan 25 15:15:44 iZ2zeiudkwjc07o9jfa4fgZ systemd[1]: Starting Advanced key-value store...
Jan 25 15:15:44 iZ2zeiudkwjc07o9jfa4fgZ systemd[1]: redis-server.service: Can't open PID file /var/run/redis/redis-server.pid (yet?) after start: No such file or directory
Copy the code

3- View log information

cat /var/log/redis/redis-server.log
# prompt
 Creating Server TCP listening socket ::1:6379: bind: Cannot assign requested address
 oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
Copy the code

4- Preliminary analysis

IPv6 is disabled on the host, and Ubuntu’s Redis-Server package (version 5:4.0.9 -1) comes with: bind 127.0.0.1 :: 1

5- Solutions

Modify the bind address in the Redis configuration file. Comment the bind address or change the bind address to 0.0.0.0

Vim /etc/redis/redis.conf //bindaddress# bind 127.0.0.1: : 1/ / or modifiedbindAddress - and allow it open accessbind 0.0.0.0
Copy the code

6- Start redis service

service redis-server start
Copy the code

7- Check services and ports

Systemctl status redis-server // An information is displayed#redis-server.service - Advanced key-value store
#Active: active (running) since Fri 2019-01-25 15:24:47 CST; 41min agoNetstat NTPL | grep 6379 / / message# TCP 0 0 0.0.0.0:6379 0.0.0.0Copy the code