single-Machine multi-instance Redis master-slave replication configuration
Redis principal and subordinate copy principle look here.
Master Redis's main configuration file is as follows:
/etc/init.d/redis_6379 boot
/etc/redis/redis_6379.conf configuration
/var/lib/redis/data/ data storage directory
/var/ Log/redis_6379.log Log
/var/run/redis_6379.pid process ID
The above files are generated by running the./install_server.sh of the compressed package.
/etc/redis/redis_6379.conf files are provided by the official ZIP package.
The configuration files for Slave Redis are as follows (copy Master counterpart):
/etc/init.d/redis_6380 boot
/etc/redis/redis_6380.conf configuration
/var/lib/redis/data_6380/ data storage Directory
/var/log/redis_6380.log Log
/var/run/redis_6380.pid process ID
Disabling data persistence in master only requires commenting out all save configurations in the master configuration file and then configuring data persistence only on slave.
Comment out all save in the/etc/redis/redis_6379.conf file in master Redis.
Set AppendOnly to Yes.
Requirepass password is optional.
Then, add something similar to the following line in the slave configuration file:
slaveof localhost 6379
localhost represents this machine, and 6379 represents the master Redis instance.
If Master Redis has a password configured, add the following:
Masterauth 123456
123456 represents the password for master Redis.
Finally, set AppendOnly to Yes and enable all save.
Start the slave Redis instance (master Redis has started) by following the command:
Redis-server /etc/redis/redis_6380.conf
Then check to see if the success was started by using the following command:
PS Aux|grep Redis
You can also view the slave log:
Finally, the REDIS-CLI client is connected to the master-slave Redis instance to see if the data is synchronized.
If you want to configure multiple slave, you can continue to configure multiple slave instances by following the steps of configuring slave above.
PS
Redis Master-slave replication configuration for multiple servers It's easy to read this article directly.