# You can configure a slave instance to accept writes or not. Writing against
# a slave instance may be useful to store some ephemeral data (because data
# written on a slave will be easily deleted after resync with the master) but
# may also cause problems if clients are writing to it because of a
# misconfiguration.
#
# Since Redis 2.6 by default slaves are read-only.
#
# Note: read only slaves are not designed to be exposed to untrusted clients
# on the internet. It's just a protection layer against misuse of the instance.
# Still a read only slave exports by default all the administrative commands
# such as CONFIG, DEBUG, and so forth. To a limited extend you can improve
# security of read only slaves using 'rename-command' to shadow all the
# administrative / dangerous commands.
slave-read-only no
1条答案
按热度按时间tag5nh1u1#
是的,你可以,但有一个很大的警告。
任何从示例都可以是一个或多个其他示例的主示例。因此,您可以想象菊花链从示例,并建立一个分层复制系统。
现在,我的理解是你不需要你的slave来提供给另一个Redis示例,而只需要允许应用程序在slave示例的另一个数据库中执行读/写操作。
要允许此操作,您需要在slave配置中将slave-read-only参数的值设置为“no”:
现在,您将在此示例上运行的所有写入操作都将是临时的。如果主服务器和从属服务器之间的链接丢失,从属服务器将再次与主服务器完全同步。您在从属服务器上设置的所有数据都将丢失。如果停止并重新启动从属服务器,也将丢失所有临时数据。
它可能适合也可能不适合你的需要。
在数据库级别无法设置同步(或者持久化选项)参数,你不能让Redis同步一个给定的数据库,而不同步另一个数据库。配置总是在示例级别应用。