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
相关推荐
甜可儿11 分钟前
redis序列化设置
数据库·redis
千层冷面1 小时前
Redis除了做缓存还能做什么?
数据库·redis·缓存
码有余悸3 小时前
Redis:高性能的键值存储系统
数据库·redis·缓存
老朋友此林10 小时前
浅析 Redis 分片集群 Cluster 原理、手动搭建、动态伸缩集群、故障转移
java·数据库·redis
因兹菜11 小时前
[LeetCode]day29 232.用栈实现队列
redis·算法·leetcode
guihong00414 小时前
深入理解 Redis 设计与集群管理
数据库·redis·缓存
IT_狂奔者14 小时前
Redis Lua Script 溢出漏洞(CVE-2024-31449)
数据库·redis·lua
吴晓斌kobe15 小时前
Java中的缓存技术:Guava Cache vs Caffeine vs Redis
java·redis·缓存·guava·caffeine
Kerwin要坚持日更17 小时前
一文讲解Redis的内存淘汰和过期策略
数据库·redis·缓存
EterNity_TiMe_17 小时前
【Linux高级IO】掌握Linux高效编程:深入探索多路转接select机制
linux·运维·数据库·redis·高级io·selete