Database Reference
In-Depth Information
example of this is given in Chapter 7, “Delivering Streaming Metrics,” which
uses this facility to implement a basic real-time dashboard.
Events in Redis are simple text values that are published to a channel using
the PUBLISH command:
PUBLISH achannel "some message"
These PUBLISH commands are delivered to clients who have subscribed
to one or more channels using the SUBSCRIBE command. Conveniently,
thesecommandsarereplicatedjustlikeanyothercommandinRedissothey
will be delivered to clients who have subscribed to a slave of the master.
However, all publish commands must be issued on the master.
Replication
Redis supports basic master-slave replication. It generally works fairly well,
but as of the 2.6 series, a loss of synchronization between the master and
slaves requires a full replication. For large installs, this can take a long
time, and if it fails, must begin again. This is usually a larger problem when
attempting to replicate Redis databases across datacenters.
ThecurrentbetaversionofRedis,whichwillbethe2.8serieswhenreleased,
supports partial resynchronization. This alleviates many of the difficulties
that arise with unreliable network links and Redis where the cluster
becomes unavailable because the slave is unable to complete an initial
synchronization in a reasonable time.
Setting up a Redis master-slave replication environment is very simple.
The master usually does not require any changes, and slaves simply add a
slaveof directive to their configuration file:
slaveof <master ip address> <port>
This can even be applied from the Redis command-line client without
restarting the server application using the CONFIG SET command.
However, you should take care to ensure that the directive has been added
to the server's configuration, otherwise the change will be lost if the server
restarts for any reason. Because a Redis master requires no special
configuration, it is actually possible to slave a Redis server to another slave.
The applications for this are very limited, and you should not use it in a
Search WWH ::




Custom Search