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
相关推荐
独泪了无痕9 小时前
Spring Data Redis 快速上手
spring boot·redis·后端
用户529589316685014 小时前
三马代驾实战:抢单池的 Redis 锁 + RabbitMQ 异步消费怎么做
redis
代码丰15 小时前
跨系统传输大 JSON:直接压缩,还是把数据放进 Redis?
redis·后端·json
devilnumber17 小时前
Redis 数据类型 + 项目落地场景(面试版,全面、实用,后端常用)
数据库·redis·面试
靳某某。18 小时前
Ubuntu安装php8.4 及redis ngin
linux·redis·ubuntu
Zhang~Ling19 小时前
Redis 基础教程:从常用命令到实际业务场景
数据库·redis·缓存
用户0942485680321 小时前
第8章:Redis Bitmap 与 BitField 实战:签到、活跃用户与状态压缩
redis·架构·源码
Flynt1 天前
我把微信运动的排行榜和定点推送复刻了一遍:100万次步数更新只要4秒,坑在别处
redis·后端·性能优化
Song_RsHt2 天前
Redis 与微服务,什么场景下无可替代
java·redis·后端·学习·微服务
GottdesKrieges2 天前
Redis哨兵模式新建用户和修改口令
数据库·redis