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
相关推荐
鼠鼠我捏,要死了捏7 小时前
生产环境Redis缓存穿透与雪崩防护性能优化实战指南
redis·cache
曾经的三心草10 小时前
微服务的编程测评系统11-jmeter-redis-竞赛列表
redis·jmeter·微服务
努力努力再努力wz12 小时前
【c++深入系列】:万字详解模版(下)
java·c++·redis
2301_7930868712 小时前
Redis 04 Reactor
数据库·redis·缓存
AAA修煤气灶刘哥17 小时前
搞定 Redis 不难:从安装到实战的保姆级教程
java·redis·后端
青鱼入云17 小时前
redis怎么做rehash的
redis·缓存
考虑考虑18 小时前
Redis事务
redis·后端
陈天cjq1 天前
Redis 实用型限流与延时队列:从 Lua 固定/滑动窗口到 Streams 消费组(含脚本与压测)
redis·junit·lua
Warren981 天前
Lua 脚本在 Redis 中的应用
java·前端·网络·vue.js·redis·junit·lua
xiao-xiang1 天前
redis-保姆级配置详解
数据库·redis