在 CentOS 上查看 Redis 配置项 一般有几种常用方式,下面按使用场景给你总结一下。
redis-cli CONFIG GET *
例如查看 maxmemory:
redis-cli CONFIG GET maxmemory
常见示例:
redis-cli CONFIG GET port
redis-cli CONFIG GET bind
redis-cli CONFIG GET requirepass
redis-cli CONFIG GET maxmemory-policy
⚠️ 如果 Redis 有密码:
redis-cli -a yourpassword CONFIG GET *
/etc/redis.conf
# 或
/etc/redis/redis.conf
查看配置:
cat /etc/redis.conf
搜索某项配置:
grep maxmemory /etc/redis.conf
grep bind /etc/redis.conf
ps -ef | grep redis
示例输出:
redis 1234 1 0 10:00 ? 00:00:01 /usr/bin/redis-server /etc/redis.conf
说明当前使用的是 /etc/redis.conf
redis-cli CONFIG SET maxmemory 2gb
redis-cli CONFIG GET maxmemory
⚠️ 这种修改 重启后失效
systemctl status redis
systemctl status redis-server
| 配置项 | 说明 |
|---|---|
| port | 端口 |
| bind | 绑定 IP |
| requirepass | 密码 |
| maxmemory | 最大内存 |
| maxmemory-policy | 内存淘汰策略 |
| appendonly | 是否 AOF |
| save | RDB 快照 |
| daemonize | 是否后台运行 |
如果你愿意,可以告诉我:
我可以直接给你对应命令。