温馨提示×

centos redis配置如何查看

小樊
46
2026-09-05 23:58:24
栏目: 云计算

在 CentOS 上查看 Redis 配置 通常有几种常见方式,下面按使用场景给你说明:


一、查看 Redis 当前运行配置(推荐)

1️⃣ 通过 redis-cli 查看

redis-cli

进入后执行:

CONFIG GET *

查看某一项,例如:

CONFIG GET maxmemory
CONFIG GET requirepass
CONFIG GET bind

✅ 这种方式看到的是 Redis 实际生效的配置


二、查看 Redis 配置文件(最常用)

1️⃣ 找到配置文件路径

redis-cli CONFIG GET dir

ps -ef | grep redis

常见路径:

/etc/redis.conf
/etc/redis/redis.conf

2️⃣ 查看配置文件内容

cat /etc/redis.conf

vim /etc/redis.conf

常见配置项:

bind 127.0.0.1
port 6379
requirepass yourpassword
maxmemory 2gb
appendonly yes

三、查看 Redis 是否开机启动 & 服务状态

1️⃣ CentOS 7+(systemd)

systemctl status redis

systemctl status redis.service

查看配置文件位置:

systemctl cat redis

四、查看 Redis 版本

redis-server --version

redis-cli INFO server

五、查看 Redis 运行信息(INFO)

redis-cli INFO

分类查看:

redis-cli INFO memory
redis-cli INFO persistence
redis-cli INFO replication

六、常见问题排查

Redis 连不上?

CONFIG GET bind
CONFIG GET protected-mode

检查:

  • bind
  • requirepass
  • 防火墙
firewall-cmd --list-all

如果你愿意,可以告诉我:

  • ✅ CentOS 版本(6 / 7 / 8 / Stream)
  • ✅ Redis 安装方式(yum / 源码 / docker)
  • ✅ 你想查 哪一项配置

我可以给你更精确的命令。

0