Redis Config rewrite 命令

Redis 教程 · 2019-03-08 16:42:08

Redis Config rewrite 命令对启动 Redis 服务器时所指定的 redis.conf 配置文件进行改写。

CONFIG SET 命令可以对服务器的当前配置进行修改, 而修改后的配置可能和 redis.conf 文件中所描述的配置不一样, CONFIG REWRITE 的作用就是通过尽可能少的修改, 将服务器当前所使用的配置记录到 redis.conf 文件中。

语法

redis Config rewrite 命令基本语法如下:

redis 127.0.0.1:6379> CONFIG REWRITE parameter

可用版本

>= 2.8.0

返回值

一个状态值:如果配置重写成功则返回 OK ,失败则返回一个错误。

实例

以下是执行 CONFIG REWRITE 前, 被载入到 Redis 服务器的 redis.conf 文件中关于 appendonly 选项的设置:

# ... 其他选项

appendonly no

# ... 其他选项

在执行以下命令之后:

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

重写后的 redis.conf 文件中的 appendonly 选项将被改写:

# ... 其他选项

appendonly yes

# ... 其他选项

点击查看所有 Redis 教程 文章: https://codercto.com/courses/l/33.html

查看所有标签

Software Engineering for Internet Applications

Software Engineering for Internet Applications

Eve Andersson、Philip Greenspun、Andrew Grumet / The MIT Press / 2006-03-06 / USD 35.00

After completing this self-contained course on server-based Internet applications software, students who start with only the knowledge of how to write and debug a computer program will have learned ho......一起来看看 《Software Engineering for Internet Applications》 这本书的介绍吧!

HTML 压缩/解压工具
HTML 压缩/解压工具

在线压缩/解压 HTML 代码

URL 编码/解码
URL 编码/解码

URL 编码/解码

HEX CMYK 转换工具
HEX CMYK 转换工具

HEX CMYK 互转工具