Redis configuration master-slave replication (data synchronization)

  Recently, I have been working on some things that are convenient for the server. Let’s strengthen it. Last time I spent 1 or 2 weeks installing and deploying centos and installing php+mysql+nginx services on it; I recently watched a dozen small videos of the redis database, and practiced by myself. Practice, redis commands are basically familiar and used, and I want to play a little more advanced (I used mysql more before), such as master-slave replication and sentinel mode

1. The configuration of redis master-slave replication (in fact, it is not very complicated) One master master server and two slave servers, I am here to configure multi-port implementation, similar to the following (1. Modify the slave server configuration file, 2. Restart the slave server, 3. Start the service, 4. Check the result)


 1.1 Redis has a very powerful master-slave replication function, and also supports that a master can have multiple slaves, thus forming a powerful multi-server cluster architecture. Install three redis instances under the same window, where the main service port is 6379, the slave service slave1 is 6380, and the slave service slave2 is 6381

The main server is currently installed and started, and the decompression directories for copying the two main services are named Redis-salve1 and Redis-salve2. The following figure:



 1.2. Configure the slave server: configure two configuration files respectively (the two files need to be configured with the same content, take redis.windows.conf as an example):



Modify two places: port 6380 and slaveof 127.0.0.1 6379

 

Both slave servers need to be configured

1.3. Start two slave services

cmd switch to the respective directory, enter the command: redis-server --service-install redis.windows.conf --loglevel verbose --service-name redismaster (here is the name displayed in the windows service) This is the master 6379

redis-server --service-install redis.windows.conf --loglevel verbose --service-name redislave1 (here is the name displayed in the windows service) This is the main 6380


 1.4 Open the service, start two slave services and set them to start automatically



 1.5 Test data

Under the main service, use server-cli to enter set a test and press Enter.

Use the RedisDesktopManager visualization tool to view the results and verify that the three servers are successfully synchronized.

Add point data on the master server


View slave server


  

//To be continued -------------------------------- Sentinel mode from the server------- ---------------------------------

 

 

 

 

 

 

 

 

 

 

 

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326017812&siteId=291194637