Redis Config rewrite command
The Redis Config rewrite command rewrites the redis.conf configuration file specified when starting the Redis server.
CONFIG SETThe CONFIG command can modify the current configuration of the server, and the modified configuration may be different from that described in the redis.conf file. The purpose of CONFIG REWRITE is to record the configuration currently used by the server into the redis.conf file with as few changes as possible.
Syntax
The basic syntax of the Redis Config rewrite command is as follows:
redis 127.0.0.1:6379> CONFIG REWRITE parameter
Available versions
>= 2.8.0
Return value
A status value: returns OK if the configuration rewrite succeeds, or an error if it fails.
Example
The following is the setting for the appendonly option in the redis.conf file loaded into the Redis server before executing CONFIG REWRITE:
# ... 其他选项 appendonly no # ... 其他选项
After executing the following command:
127.0.0.1:6379> CONFIG GET appendonly # appendonly 处于关闭状态 1) "appendonly" 2) "no" 127.0.0.1:6379> CONFIG SET appendonly yes # 打开 appendonly OK 127.0.0.1:6379> CONFIG GET appendonly 1) "appendonly" 2) "yes" 127.0.0.1:6379> CONFIG REWRITE # 将 appendonly 的修改写入到 redis.conf 中 OK
The appendonly option in the rewritten redis.conf file will be changed:
# ... 其他选项 appendonly yes # ... 其他选项
Other extensions