您好,我想请问下,当redis开启rdb持久化并主动退出时,在退出之前会主动bgsave一次来防止数据丢失,那么我将redis.conf中的save配置修改成一个不可能实现的频率,比如 save “1 10000000000” 来达到我既不想让它平时进行持久化操作,又防止意外退出时的数据丢失,我能不能这个样来配置并应用与生产环境呢?以此来避免Master空库启动清空数据的场景,以及这样做会对redis性能方面会有什么影响吗?
Comment From: itamarhaber
Ni hao @135zyf - this repo uses English for communication purposes - please edit the issue (add a title and body in English) so those of us who don't speak your language can assist.
Comment From: enjoy-binbin
A google translation:
Hello, I would like to ask, when redis enables rdb persistence and exits actively, it will actively bgsave once before exiting to prevent data loss, then I will modify the save configuration in redis.conf to an impossible frequency, For example, save "1 10000000000" to achieve that I do not want it to perform persistent operations at ordinary times, but also prevent data loss when it exits unexpectedly. Can I configure and apply it to the production environment in this way? This is to avoid the scenario where the Master empty library starts to clear the data, and will this have any impact on the performance of redis?
Theoretically as far as I know, the answer is (i think): yes, it can work, and don't have the impact on performance. Also if you are using 7.0, you can try this config, see more in redis.conf:
# When Redis receives a SIGINT or SIGTERM, shutdown is initiated and by default
# an RDB snapshot is written to disk in a blocking operation if save points are configured.
# The options used on signaled shutdown can include the following values:
# default: Saves RDB snapshot only if save points are configured.
# Waits for lagging replicas to catch up.
# save: Forces a DB saving operation even if no save points are configured.
# nosave: Prevents DB saving operation even if one or more save points are configured.
# now: Skips waiting for lagging replicas.
# force: Ignores any errors that would normally prevent the server from exiting.
#
# Any combination of values is allowed as long as "save" and "nosave" are not set simultaneously.
# Example: "nosave force now"
#
# shutdown-on-sigint default
# shutdown-on-sigterm default
Comment From: oranagra
configuring save to a very high number has a few other minor implications.
for example on FLUSHALL it'll persist an empty rdb file).
the alternative is to keep save empty, and use SHUTDOWN SAVE to terminate the server.
or use the above mentioned redis 7 configs.