温馨提示×

centos redis如何查看配置

小樊
42
2026-09-30 00:42:05
栏目: 云计算

在 CentOS 上查看 Redis 配置,常见有 命令行查看 和 配置文件查看 两种方式。


一、通过 redis-cli 查看(推荐)

1. 查看所有配置

redis-cli CONFIG GET *

2. 查看指定配置(如端口、持久化、最大内存)

redis-cli CONFIG GET port
redis-cli CONFIG GET dir
redis-cli CONFIG GET maxmemory
redis-cli CONFIG GET save

3. 查看 Redis 运行参数(更详细信息)

redis-cli INFO
redis-cli INFO server
redis-cli INFO memory
redis-cli INFO persistence

二、查看 Redis 配置文件

1. 查找配置文件位置

redis-cli CONFIG GET dir

或

ps -ef | grep redis

常见路径:

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

2. 查看配置文件内容

cat /etc/redis.conf

或

grep -v '^#' /etc/redis.conf | grep -v '^$'

(去掉注释和空行,更清晰)


三、查看 Redis 是否使用某个配置

redis-cli CONFIG REWRITE

注意:该命令会把当前运行配置写回配置文件(慎用)


四、验证 Redis 是否启动及使用配置

systemctl status redis
systemctl status redis-server

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

  • Redis 是 yum 安装还是编译安装
  • 想查 哪一类配置(如主从、持久化、内存、安全)

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

0 踩