本篇文章将通过两种方式安装 Redis。

更新系统中所有的软件包

# 更新软件包

sudo dnf upgrade --refresh -y

dnf 安装 Redis
1)安装 redis

sudo dnf -y install redis

2)启用 redis

sudo systemctl enable redis --now

通过 EPEP & Remi 源安装

#安装 remi 源
sudo dnf -y install https://rpms.remirepo.net/enterprise/remi-release-9.rpm

安装 Redis
1)安装 Redis

sudo dnf module list redis

2)启用 redis 7

sudo dnf -y module enable redis:remi-7.0

扩展:启用其他版本
sudo dnf -y module enable redis:remi-6.2
sudo dnf -y module enable redis:remi-5.0

说明:启用哪一个版本的 redis,后续安装的就是哪个版本的 redis

3)安装 redis

sudo dnf -y install redis

4)查看 redis 版本

redis-server -v    
Redis server v=7.0.9 sha=00000000:0 malloc=jemalloc-5.2.1 bits=64 build=6017938c3cd0c82b

5)启用 redis

sudo systemctl enable redis --now

6)查看 redis 状态

systemctl status redis

7)查看 redis 进程

ps aux | grep redis

8)redis-cli 连接

redis-cli

配置 redis.conf
配置文件位于:/etc/redis.conf, 配置时修改该文件即可。

重启 redis

sudo systemctl restart redis-server

配置防火墙

#配置防火墙
# 允许 redis 通过防火墙
firewall-cmd --permanent --zone=public --add-service=redis
配置允许通过的 IP
firewall-cmd --permanent --zone=public --add-rich-rule='rule family="ipv4" source address="192.168.1.100" port protocol="tcp" port="6379" accept'

配置允许通过的端口
firewall-cmd --permanent --zone=public --add-port=6379/tcp

标签: none

添加新评论