Ubuntu18.04 set up Redis server

1, the installation Redis

apt-get install redis-server

2, configure Redis

After installation is complete, Redis will automatically start, but when I install, startup has been given:

Job for redis-server.service failed because a timeout was exceeded.
See "systemctl status redis-server.service" and "journalctl -xe" for details.
invoke-rc.d: initscript redis-server, action "start" failed.
● redis-server.service - Advanced key-value store
   Loaded: loaded (/lib/systemd/system/redis-server.service; disabled; vendor preset: enabled)
   Active: activating (auto-restart) (Result: timeout) since Sat 2020-01-18 17:27:38 CST; 10ms ago
     Docs: http://redis.io/documentation,
           man:redis-server(1)
  Process: 23867 ExecStart=/usr/bin/redis-server /etc/redis/redis.conf (code=exited, status=0/SUCCESS)

Jan 18 17:27:38 jz systemd[1]: Failed to start Advanced key-value store.
dpkg: error processing package redis-server (--configure):
 installed redis-server package post-installation script subprocess returned error exit status 1
Processing triggers for libc-bin (2.27-3ubuntu1) ...
Processing triggers for systemd (237-3ubuntu10.31) ...
Processing triggers for man-db (2.8.3-2ubuntu0.1) ...
Processing triggers for ureadahead (0.100.0-21) ...
Errors were encountered while processing:
 redis-server
E: Sub-process /usr/bin/dpkg returned an error code (1)

Modify the configuration file /etc/redis/redis.conf:

Will bind 127.0.0.1 ::1be changedbind 127.0.0.1
Here Insert Picture Description

3, start the Redis service

/etc/init.d/redis-server stop     # 停止

/etc/init.d/redis-server start    # 启动

/etc/init.d/redis-server restart  # 重启

redis-cli                         #连接客户端

4, see the Redis server system processes

ps -aux | grep redis

Here Insert Picture Description
If Redis does not start, no first process.

5, see the Redis server status

netstat -nlt | grep 6379

6379 is the default port Redis

6, set up remote access

To set up remote access, the second step will be to modify the 127.0.0.1change 0.0.0.0, and then restart Redis can be.
Here Insert Picture Description

7, set a password

In /etc/redis/redis.confthe Find # requirepass foobaredthis line, uncommented, will foobaredreplace the password to be set.
Here Insert Picture Description
After the setup is complete, although can still redis-clicommand the client to enter but no rights:
Here Insert Picture Description

You need to use the -a parameter password:

redis-cli -h 127.0.0.1 -p 6379 -a 123456

Here Insert Picture Description

8, uninstall redis

Use apt-getuninstall mode installation:

apt-get purge --auto-remove redis-server
Published 257 original articles · won praise 186 · views 220 000 +

Guess you like

Origin blog.csdn.net/k_young1997/article/details/104031368