Linux under Redis master-slave Replication (master-slave) configuration __linux

Source: Internet
Author: User
Tags redis
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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.