有没有一种方法,不允许任何人在redis中进行flushAll?

时间:2019-11-28 02:29:23

标签: redis

我正在寻找一个可以实时保存数据的项目,并且正在考虑Redis。 我看到的问题是,任何人都可以发出命令立即删除所有数据

如何在成功持久保存所有内容之前不允许用户发出这样的命令。

2 个答案:

答案 0 :(得分:3)

您可以在配置中使用重命名命令。根据{{​​3}}的安全性部分:

# Command renaming.
#
# It is possible to change the name of dangerous commands in a shared
# environment. For instance the CONFIG command may be renamed into something
# hard to guess so that it will still be available for internal-use tools
# but not available for general clients.
#
# Example:
#
# rename-command CONFIG b840fc02d524045429941cc15f59e41cb7be6c52
#
# It is also possible to completely kill a command by renaming it into
# an empty string:
#
# rename-command CONFIG ""
#
# Please note that changing the name of commands that are logged into the
# AOF file or transmitted to replicas may cause problems.

答案 1 :(得分:2)

@Leisen Chang 的答案所述,在重命名命令的顶部,即将发布的Redis版本6 ACL(Access的缩写)控制列表)。

ACL允许您创建用户并为他们分配调用命令和/或访问键模式的权限。例如,这是创建用户的方式,该用户可以执行除FLUSHALL以外的所有操作:

redis> ACL SETUSER myuser on >mypass +@all -flushall