Redis教程

Redis服务器开启远程访问

本文主要是介绍Redis服务器开启远程访问,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

来源:微信公众号「编程学习基地」

文章目录

      • 提权限
      • 编辑redis配置文件
      • 重启Redis服务器

提权限

首先把权限升到root

su root

编辑redis配置文件

sudo vi /etc/redis/redis.conf

在这里插入图片描述

重启Redis服务器

sudo /etc/init.d/redis-server restart
root@VM-16-5-ubuntu:/home/ubuntu/redis# vi /etc/redis/redis.conf
root@VM-16-5-ubuntu:/home/ubuntu/redis# /etc/init.d/redis-server restart
[ ok ] Restarting redis-server (via systemctl): redis-server.service.
root@VM-16-5-ubuntu:/home/ubuntu/redis# sudo /etc/init.d/redis-server status
● redis-server.service - Advanced key-value store
   Loaded: loaded (/lib/systemd/system/redis-server.service; enabled; vendor preset: enabled)
   Active: active (running) since Tue 2021-05-11 18:37:44 CST; 7s ago
     Docs: http://redis.io/documentation,
           man:redis-server(1)
  Process: 27417 ExecStop=/bin/kill -s TERM $MAINPID (code=exited, status=0/SUCCESS)
  Process: 27423 ExecStart=/usr/bin/redis-server /etc/redis/redis.conf (code=exited, status=0/SUCCESS)
 Main PID: 27436 (redis-server)
    Tasks: 4 (limit: 2122)
   CGroup: /system.slice/redis-server.service
           └─27436 /usr/bin/redis-server *:6379

May 11 18:37:44 VM-16-5-ubuntu systemd[1]: Stopped Advanced key-value store.
May 11 18:37:44 VM-16-5-ubuntu systemd[1]: Starting Advanced key-value store...
May 11 18:37:44 VM-16-5-ubuntu systemd[1]: redis-server.service: Can't open PID file /var/run/redis/redis-server.pid (yet?) after start: No such fil…r directory
May 11 18:37:44 VM-16-5-ubuntu systemd[1]: Started Advanced key-value store.
Hint: Some lines were ellipsized, use -l to show in full.
root@VM-16-5-ubuntu:/home/ubuntu/redis# redis-cli 
这篇关于Redis服务器开启远程访问的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!