温馨提示×

centos redis配置在哪

小樊
35
2026-09-24 03:25:08
栏目: 云计算

在 CentOS 上,Redis 的配置文件位置取决于你是通过什么方式安装的。

1. 通过 yum / dnf 安装(最常见)

如果你是用:

yum install redis
# 或
dnf install redis

那么配置文件通常在:

/etc/redis.conf

如果是多实例,可能是:

/etc/redis/redis.conf

2. 通过源码编译安装

如果你是从官网下载源码编译安装的,常见位置是:

/usr/local/redis/redis.conf

或者你当时指定的路径。

3. 查看当前 Redis 实际使用的配置文件

如果你不确定,可以用下面方法查:

方法一:通过进程查看

ps -ef | grep redis

你会看到类似:

redis-server /etc/redis.conf

/etc/redis.conf 就是配置文件路径。

方法二:进入 Redis 客户端查看

redis-cli
CONFIG GET dir
CONFIG GET save

虽然不能直接看到配置文件路径,但可以确认运行参数。


常见 Redis 配置项(在 redis.conf 中)

bind 127.0.0.1
port 6379
daemonize yes
requirepass yourpassword

修改配置后重启

systemctl restart redis
# 或
systemctl restart redis-server

如果你告诉我 CentOS 版本 + 安装方式,我可以给你更精确的路径。

0 踩