Ubuntu 安装 redis

一、使⽤apt安装

cpp 复制代码
apt install redis -y

二、⽀持远程连接

修改 /etc/redis/redis.conf

  • 修改 bind 127.0.0.1 为 bind 0.0.0.0
  • 修改 protected-mode yes 为 protected-mode no
bash 复制代码
 # By default, if no "bind" configuration directive is specified, Redis listens
 # for connections from all the network interfaces available on the server.
 # It is possible to listen to just one or multiple selected interfaces using
 # the "bind" configuration directive, followed by one or more IP addresses.
 #
 # Examples:
 #
 # bind 192.168.1.100 10.0.0.1
 # bind 127.0.0.1 ::1
 #
 # ~~~ WARNING ~~~ If the computer running Redis is directly exposed to the
 # internet, binding to all the interfaces is dangerous and will expose the
 # instance to everybody on the internet. So by default we uncomment the
 # following bind directive, that will force Redis to listen only into
 # the IPv4 loopback interface address (this means Redis will be able to
 # accept connections only from clients running into the same computer it
 # is running).
 #
 # IF YOU ARE SURE YOU WANT YOUR INSTANCE TO LISTEN TO ALL THE INTERFACES
 # JUST COMMENT THE FOLLOWING LINE.
 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 # bind 127.0.0.1   # 注释掉这⾏
bind 0.0.0.0        # 添加这⾏
protected-mode no   # 把 yes 改成 no

三、控制Redis启动

3.1、启动Redis服务

bash 复制代码
service redis-server start

3.2、停⽌Redis服务

bash 复制代码
service redis-server stop

3.3、重启Redis服务

bash 复制代码
service redis-server restart
相关推荐
KK溜了溜了8 小时前
JAVA-springboot 整合Redis
java·spring boot·redis
爱上语文12 小时前
Redis基础(6):SpringDataRedis
数据库·redis·后端
Java初学者小白13 小时前
秋招Day14 - Redis - 应用
java·数据库·redis·缓存
奈斯ing13 小时前
【Redis篇】数据库架构演进中Redis缓存的技术必然性—高并发场景下穿透、击穿、雪崩的体系化解决方案
运维·redis·缓存·数据库架构
一眼万年0414 小时前
Redis Cluster模式
redis·微服务
deriva15 小时前
.netcore+ef+redis+rabbitmq+dotcap先同步后异步再同步的方法,亲测有效
redis·rabbitmq·.netcore
爱上语文16 小时前
Redis基础(5):Redis的Java客户端
java·开发语言·数据库·redis·后端
Java初学者小白19 小时前
秋招Day15 - Redis - 缓存设计
java·数据库·redis·缓存
都叫我大帅哥1 天前
Redis GEO全解:从入门到精通,让你的应用“空间觉醒”
redis
都叫我大帅哥1 天前
Redis 的 HyperLogLog:用 12KB 数清银河系星星的魔法计数器
redis