redis master-slave replication and sentinel mechanism

In order to ensure high availability, redis also has a cluster mechanism.

1. Master-slave replication operation

The role of replication is to replicate multiple copies of the redis database and deploy them on different servers. If one of the servers fails, it can also be quickly migrated to other servers to provide services. The replication function can realize that when the data of a redis server is updated, the new data will be automatically synchronized to other servers

Master-slave replication is our common master/slave mode. The master database can perform read and write operations. When the write operation causes data changes, it will automatically synchronize the data to the slave database . In general, the slave database is read-only and receives data synchronized from the master database. A master database can have multiple slave databases.

Prepare two servers, install redis respectively, server1 server2

\1. Add slaveof server1-ip 6379 in the redis.conf file of server2, and comment out bindip at the same time, allowing all ip access; the actual configuration is very simple, add a line like this:

\2. Start server2

\3. Access the redis client of server2, input INFO replication

\4. By entering commands on the master machine, such as set foo bar, you can see that the value has been synchronized on the slave server

Guess you like

Origin blog.csdn.net/qq_22059611/article/details/104141841