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
相关推荐
vivo互联网技术17 小时前
Redis key 消失之谜
数据库·redis·内存淘汰策略·redis抓包分析·机制分析
JosieBook18 小时前
【SpringBoot】29 核心功能 - 数据访问 - Spring Boot 2 操作 Redis 实践指南:本地安装与阿里云 Redis 对比应用
spring boot·redis·阿里云
青鱼入云1 天前
redisson介绍
redis·1024程序员节
哲Zheᗜe༘1 天前
了解学习Redis主从复制
数据库·redis·学习
一条懒鱼6661 天前
Redis Sentinel哨兵集群
数据库·redis·sentinel
Zhu_S W1 天前
Redis跳表:高效有序数据结构的深度剖析
数据结构·数据库·redis
初学者_xuan1 天前
零基础新手小白快速了解掌握服务集群与自动化运维(十五)Redis模块-哨兵集群
运维·redis·自动化
weixin_445476681 天前
Vue+redis全局添加水印解决方案
前端·vue.js·redis
Deamon Tree1 天前
Redis的过期策略以及内存淘汰机制
java·数据库·redis·缓存
fouryears_234171 天前
Redis缓存更新策略
java·spring boot·redis·spring