3

我已经为我的 nodeJS 应用程序安装了 Redis,并将其配置为在不同服务器上运行的另一个 Redis DB 实例的从属。我可以让 Redis 的相同实例(不同的 DB)(作为从属运行)充当本地安装应用程序的主控吗?

提前致谢

4

1 回答 1

4

是的,你可以,但有一个很大的警告

任何从属实例都可以是一个或多个其他实例的主实例。因此,您可以想象菊花链式从属服务器并构建分层复制系统。

现在,我的理解是您不需要您的从属服务器来提供另一个 Redis 实例,而只需允许应用程序在从属实例的另一个数据库中执行读/写操作。

要允许它,您需要在从属配置中将 slave-read-only 参数的值设置为“no”:

# 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

现在,您将在此实例上运行的所有写入操作都将是短暂的。如果 master 和 slave 之间的链接丢失,slave 将再次完全同步到 master。您在从站上设置的所有数据都将丢失。如果您停止并重新启动从站,您还将丢失所有临时数据。

它可能适合也可能不适合您的需求。

无法在数据库级别参数化同步(或持久性选项)。你不能告诉 Redis 同步一个给定的数据库,而不是另一个。配置始终适用于实例级别。

于 2013-04-20T11:03:49.313 回答