Redis database Master-slave replication configuration

Source: Internet
Author: User

Note: Make sure that Redis is installed before you make the following configuration. This tutorial requires two Redis servers: one when the primary database (master), one when from the database (slave).

1, configure the master-slave structure

For Redis master-slave configuration, only the configuration files from the node need to be modified.

  • Primary Database 192.168.20.111:6379
  • From the database 192.168.20.112:6379
1.1. Log in to Redis from the database, open the configuration file:


Add a bit of content:


Note: Make sure that port 6379 of the primary database is open.
Open 6379 Port command:

#/sbin/iptables-i input-p TCP--dport 6379-j ACCEPT
2. Start Database 2.1 and start the primary database:
#./redis6379 Start

2.2, start from the database:
#./redis6379 Start

2.3. Use REDIS-CLI to connect to the master database and enter a password to log in:
[Email protected] bin]#. /src/redis-cli-p 6379127.0.0.1:6379> Auth 123456OK

2.4. View the main database info property:
127.0.0.1:6379> Info

There is an item in the property # Replication

2.5. Use REDIS-CLI to connect from the database and enter the password:
[Email protected] etc]#. /src/redis-cli-p 6379127.0.0.1:6379> Auth 123456OK

2.6. View the From Database Info property:
127.0.0.1:6379> Info


There is an item in the property # Replication

3, test 3.1, enter a data in the main database
127.0.0.1:6379> Set num 13

3.2, go to query input data from the database
127.0.0.1:6379> Get num

Sync succeeded!

Redis database Master-slave replication configuration

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.