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
相关推荐
星辰_mya10 小时前
redis集群
数据库·redis·缓存
我爱学习好爱好爱14 小时前
Docker Compose部署SpringBoot2+Vue3+redis项目(Rockylinux9.6)
redis·docker·容器
典孝赢麻崩乐急15 小时前
Redis复习-------Redis数据类型
redis
Hello World呀18 小时前
登录时,redis出现错误
数据库·redis·缓存
企鹅侠客18 小时前
第02章—先导基础篇:初识Redis
数据库·redis·缓存
DemonAvenger19 小时前
Redis哨兵模式详解:自动故障转移与高可用保障
数据库·redis·性能优化
典孝赢麻崩乐急20 小时前
Redis复习----------Redis超高性能的原因
数据库·redis·学习·缓存
汪不止20 小时前
【 分布式唯一业务单号生成方案:Redis + 数据库双保险架构】
数据库·redis·分布式
典孝赢麻崩乐急20 小时前
Redis复习-------Redis事务
数据库·redis·缓存
橘子真甜~20 小时前
Reids命令原理与应用3 - Redis 主线程,辅助线程与存储原理
网络·数据库·redis·缓存·线程·数据类型·存储结构