阿里云CentOS 7.9 64位 Liunx 安装redis

具体的步骤如下:

  1. 添加 EPEL 仓库,因为 Redis 在标准的 CentOS 仓库中不可用:
bash 复制代码
sudo yum install epel-release
  1. 安装 Redis:
bash 复制代码
sudo yum install redis
  1. 启动 Redis 服务:
bash 复制代码
sudo systemctl start redis
  1. 如果你想让 Redis 在启动时自动运行,你可以启用它:
bash 复制代码
sudo systemctl enable redis
  1. 检查 Redis 是否正在运行:
bash 复制代码
sudo systemctl status redis
  1. 修改端口
    打开 Redis 配置文件。根据你的系统和安装方式,它通常在 /etc/redis/redis.conf 或 /etc/redis.conf。你可以使用你喜欢的文本编辑器打开它。
bash 复制代码
sudo vim /etc/redis.conf

#将这个改成你想要的端口
port 26379
  1. 修改密码
    查找 requirepass 参数。如果找不到,你可以直接添加它。将它设置为你想要的密码,请将 yournewpassword 替换为你想要的密码。
bash 复制代码
requirepass yournewpassword:
  1. 修改允许外网访问

查找 bind 参数,它定义了允许连接到 Redis 的主机。默认情况下,它可能设置为 127.0.0.1,这意味着只允许本地连接。你可以将其更改为 0.0.0.0 来允许所有主机的连接:

bash 复制代码
bind 0.0.0.0
  1. 重新redis
bash 复制代码
sudo systemctl restart redis

注意:

如果远程连接不成功,解决方法:

  1. 允许端口访问
bash 复制代码
sudo systemctl start firewalld
sudo firewall-cmd --zone=public --add-port=26379/tcp --permanent
sudo firewall-cmd --reload
  1. 在阿里云服务器上开放端口 26379

  2. windows 使用 redis Desktop Manager 进行连接

相关推荐
加勒比海涛23 分钟前
Spring Cloud Gateway 实战:从网关搭建到过滤器与跨域解决方案
数据库·redis·缓存
大只鹅2 小时前
分布式部署下如何做接口防抖---使用分布式锁
redis·分布式
draymond71073 小时前
阿里云-spring boot 接入SLS日志
阿里云
MonkeyKing_sunyuhua6 小时前
Ehcache、Caffeine、Spring Cache、Redis、J2Cache、Memcached 和 Guava Cache 的主要区别
redis·spring·memcached
就叫飞六吧9 天前
基于keepalived、vip实现高可用nginx (centos)
python·nginx·centos
敏叔V5879 天前
大模型Text2SQL之在CentOS上使用yum安装与使用MySQL
linux·mysql·centos
笨手笨脚の10 天前
Redis 源码分析-Redis 中的事件驱动
数据库·redis·缓存·select·nio·epoll·io模型
(:满天星:)10 天前
Redis哨兵模式深度解析与实战部署
linux·服务器·网络·数据库·redis·缓存·centos
weixin_4383354010 天前
Spring Boot:运用Redis统计用户在线数量
java·spring boot·redis
十六点五10 天前
Redis(2)——AOF持久化
java·redis·后端