您当前的位置: 首页 > 慢生活 > 程序人生 网站首页程序人生
Redis Config rewrite 命令
发布时间:2021-11-11 22:14:21编辑:雪饮阅读()
Redis Config rewrite 命令对启动 Redis 服务器时所指定的 redis.conf 配置文件进行改写。
CONFIG SET 命令可以对服务器的当前配置进行修改, 而修改后的配置可能和 redis.conf 文件中所描述的配置不一样, CONFIG REWRITE 的作用就是通过尽可能少的修改,
将服务器当前所使用的配置记录到 redis.conf 文件中。
返回值
一个状态值:如果配置重写成功则返回 OK ,失败则返回一个错误。
实例:
改之前:
C:\Users\Administrator>type C:\phpstudy_pro\Extensions\redis3.0.504\redis.conf
bind 127.0.0.1
port 6379
timeout 65
maxclients 10000
databases 16
maxmemory 1048576000
requirepass xy220807
127.0.0.1:6379> config get appendonly
1) "appendonly"
2) "no"
127.0.0.1:6379> config set appendonly yes
OK
修改后:
C:\Users\Administrator>type C:\phpstudy_pro\Extensions\redis3.0.504\redis.conf
bind 127.0.0.1
port 6379
timeout 65
maxclients 10000
databases 16
maxmemory 1048576000
requirepass xy220807
看来不生效,再次修改密码
127.0.0.1:6379> config get requirepass
1) "requirepass"
2) "xy220807"
127.0.0.1:6379> config set requirepass dmj220807
OK
还是不生效;
C:\Users\Administrator>type C:\phpstudy_pro\Extensions\redis3.0.504\redis.conf
bind 127.0.0.1
port 6379
timeout 65
maxclients 10000
databases 16
maxmemory 1048576000
requirepass xy220807
只有rewrite之后才能生效覆盖配置文件上对应配置;
127.0.0.1:6379> config rewrite
OK
C:\Users\Administrator>type C:\phpstudy_pro\Extensions\redis3.0.504\redis.conf
bind 127.0.0.1
port 6379
timeout 65
maxclients 10000
databases 16
maxmemory 1000mb
requirepass "dmj220807"
# Generated by CONFIG REWRITE
dir "C:\\phpstudy_pro\\Extensions\\redis3.0.504"
appendonly yes
如果不进行rewrite,则不覆盖配置文件,那么我的理解是仅对当前client生效。
关键字词:Redis,Config,rewrite