Redis cluster
In the entire redis cluster environment, there are two roles, master and slave, and the data of the master and slave are synchronized.
The master has read and write permissions, and the slave only has read permissions.
Construction of Redis cluster environment
1. Make sure that every server has been configured with redis
2. Modify the slave node redis.windows.conf file
slaveof field
slaveof master node ip address master node port number
masterauth field
masterauth master node password
3. Restart the redis service after configuration
4. From the node src there is a file dump.rqb
This file is the synchronization information generated by the master-slave synchronization slave node. After deleting, the slave node information will all disappear.
Sentinel mechanism
When the host of the redis cluster hangs up, participate in the election from the opportunity and re-elect the host
Sentinel can monitor, remind, and automatically fail migration
Sentinel configuration
1. A single server is generally used as a sentry
2. Configure and start the redis service on the sentinel server
3. Modify the configuration file sentinel.conf in the redis directory (windows version of redis does not include this configuration file)
sentinel monitor mymast 192.168.110.133 6379 1 master node name IP port number election times
sentinel down-after-milliseconds mymaster 5000 heartbeat detection 5000 ms
sentinel parallel-syncs mymaster 2 This field means that after the new election, how many servers in the cluster are synchronized with the new host (if the current server is already a slave of a master server, then execute SLAVEOF The host port will stop the current server from synchronizing with the old master server, discard the old data set, and start synchronizing with the new master server. So the synchronized slave server will become unavailable during this time), adjust according to actual needs Quantity
sentinel auth-pass mymaster 1234 Set the password to connect the master and slave, because only one can be set, so the master and slave password should be the same
4. Start the sentry service
When the redis service has been started
redis directory ... / sentinel.conf --sentinel &
A great redis usage document
http://doc.redisfans.com/index.html