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
相关推荐
A.说学逗唱的Coke2 小时前
【人工智能专题】Redis 杀进 AI 数据层:向量搜索、语义缓存与 Agent 记忆工程从入门到踩坑
人工智能·redis·缓存
XiYang-DING3 小时前
地图城市缓存优化:ApplicationReadyEvent + Caffeine + Redis + Redisson 分布式锁
redis·分布式·缓存
爱和冰阔落5 小时前
【Linux】多线程打印为什么会乱?pthread 创建、等待、退出、取消与分离全实战
linux·运维·c++·redis
一只小bit7 小时前
Redis哨兵机制、主从复制与集群搭建与维护
数据库·redis·bootstrap
智购科技无人售货机厂家14 小时前
2026自动售货机制冷系统维护指南:从散热器清洁到压缩机换油的工程实践~YH
运维·redis·物联网·缓存·架构
2601_9621741718 小时前
Redis 简介
数据库·redis·wpf
garmin Chen1 天前
redis面试题
java·数据库·redis·缓存
2601_962181961 天前
Redis Redis介绍、安装 - Redis客户端
数据库·redis·postman
程序员夏洛1 天前
Redis 中如何实现分布式锁?
数据库·redis·分布式
程序员夏洛1 天前
Redis 的 Red Lock 是什么?你了解吗?
数据库·redis·缓存