# If you run Redis from upstart or systemd, Redis can interact with your
# supervision tree. Options:
# supervised no - no supervision interaction
# supervised upstart - signal upstart by putting Redis into SIGSTOP mode
# supervised systemd - signal systemd by writing READY=1 to $NOTIFY_SOCKET
# supervised auto - detect upstart or systemd method based on
# UPSTART_JOB or NOTIFY_SOCKET environment variables
# Note: these supervision methods only signal "process is ready."
# They do not enable continuous liveness pings back to your supervisor.
supervised systemd
# Warning: since Redis is pretty fast an outside user can try up to
# 150k passwords per second against a good box. This means that you should
# use a very strong password otherwise it will be very easy to break.
#
. . . # It is also possible to completely kill a command by renaming it into # an empty string: # rename-command FLUSHDB "" rename-command FLUSHALL "" rename-command DEBUG "" . . .
假设您像前面的示例一样将`CONFIG`命令重命名`ASC12_CONFIG`为。首先,尝试使用原始`CONFIG`命令。它应该失败,因为您已将其重命名:
config get requirepass
(error) ERR unknown command 'config'
但是,调用重命名的命令将成功。它不区分大小写:
asc12_config get requirepass
1) "requirepass"
2) "your_redis_password"
最后,您可以从退出`redis-cli`:
exit
请注意,如果您已经在使用Redis命令行,然后重新启动Redis,则需要重新进行身份验证。否则,如果键入命令,则会出现此错误:
NOAUTH Authentication required.
关于重命名命令的做法,本`SECURITY`节末尾有一条警告性声明`/etc/redis/redis.conf`,内容为:
> `Please note that changing the name of commands that are logged into the AOF file or transmitted to slaves may cause problems.`
**_注意:_** _Redis项目选择使用术语“主”和“从”,而DigitalOcean通常更喜欢使用“主要”和“次要”替代方案。为了避免混淆,我们选择在此处使用Redis文档中使用的术语。_
这意味着,如果重命名的命令不在AOF文件中,或者如果该重命名的命令尚未将AOF文件传输到从属设备,则应该没有问题。
因此,在尝试重命名命令时,请记住这一点。重命名命令的最佳时间是在不使用AOF持久性时,或者在安装后即刚部署使用Redis的应用程序之前。
当您使用AOF并处理主从安装时,请[从项目的GitHub问题页面中](https://github.com/antirez/redis/issues/2783)考虑[此答案](https://github.com/antirez/redis/issues/2783)。以下是对作者问题的答复:
> 命令将以发送命令的相同方式记录到AOF并复制到从属设备,因此,如果您尝试在没有相同重命名的实例上重播AOF,则可能会遇到不一致的情况,因为命令无法执行(奴隶也一样)
因此,在这种情况下处理重命名的最佳方法是确保将重命名的命令应用于主从安装中的所有实例。
结论
--
在本教程中,您已安装和配置Redis,验证您的Redis安装是否正常运行,并使用其内置的安全功能使其较不容易受到恶意行为者的攻击。