Redis Master-Slave configuration

Source: Internet
Author: User

First, the preparatory work

Two machine operating systems are centos6.7, the IP card eth0 are:

Master 192.168.1.180
Slave 192.168.1.181

Second, the basic operation (all the following steps are to operate on two machines)

1, set hostname, respectively, master and slave

Lord set hostname

# hostname master//temporary effective

Or

# Vim/etc/sysconfig/network//Permanent effect
Hostname=Master

Set hostname from above

# hostname Slave//Temporary entry into force

Or

# Vim/etc/sysconfig/network//Permanent effect
Hostname=Slave

2. Turn off the firewall

The Lord and the slave are emptying iptables



The master and slave both turn off SELinux

# Setenforce 0

Redis Installation Steps

3. Configuration

Since I did not set the password for Redis prior to configuring the master, I can directly configure the connection without giving the master configuration. (If you want to set up is also possible)

Master configuration

[Email protected] etc]# vim redis.confdaemonize yespidfile/usr/local/redis/var/redis.pidport 6379timeout 300loglevel Debuglogfile/usr/local/redis/var/redis.logdatabases 16save 1save 10save 10000rdbcompression yesdbfilename Dump.rdbdir/usr/local/redis/var/appendonly noappendfsync alwaysrequirepass 123456 Set Password

From configuration: Also add the master's password on the slave

[[Email protected] etc]# vim redis.confdaemonize yespidfile /usr/local/redis/var /redis.pidport 6379timeout 300loglevel debuglogfile /usr/local/redis/var/ redis.logdatabases 16save 900 1save 300 10save 60 10000rdbcompression  Yesdbfilename dump.rdbdir /usr/local/redis/var/appendonly noappendfsync alwaysslaveof  192.168.1.180 7596    Add the ipmasterauth 123456      of the master    Add master's password [[Email protected] etc]# /etc/init.d/redis restart stop  redis-server:                                           [OK] Start  :                                                      [OK] View Log [email  protected] etc]# tail /usr/local/redis/var/redis.log[7584] 26 Mar  13:25:42.383 * connecting to master 192.168.1.180:6379[7584] 26 mar  13:25:42.384 * master <-> slave sync started[7584] 26 mar  13:25:42.384 * non blocking connect for sync fired the event. [7584] 26 mar 13:25:42.385 * master replied to ping, replication  can continue ... [7584] 26 mar 13:25:42.386 * partial resynchronization not possible   (No cached master) [7584] 26 mar 13:25:42.387 * full resync  From master: 47526b26d1963f0682d843591154525b5d6cb6a3:1[7584] 26 mar 13:25:42.460 *  MASTER&NBSP;&LT;-&GT;&NBSP;SLAVE&NBSP;SYNC:&NBSP;RECEIVING&NBSP;236&NBSP;BYTES&NBSP;FROM&NBSP;MASTER[7584]  26 mar 13:25:42.460 * master <-> slave sync: flushing  old data[7584] 26 mar 13:25:42.461 * master <-> slave  sync: Loading DB in memory[7584] 26 Mar 13:25:42.461 *  Master <-> slave sync: finished with success


See if it's successful

In the main

[[email protected] etc]#/usr/local/redis/bin/redis-cli-a 123456127.0.0.1:6379> keys * View all 1) "Set1" 2) "Set2" 3) "Key1 "4)" Key2 "5)" HASH1 "6)" List1 "7)" Key3 "127.0.0.1:6379> set Key6 guozhen Create a ok127.0.0.1:6379> keys *)" Set1 "2)" set 2 "3)" Key6 "4)" Key1 "5)" Key2 "6)" HASH1 "7)" List1 "8)" Key3 "127.0.0.1:6379> get key6 View content" Guozhen "

Look from

[[email protected] etc]#/usr/local/redis/bin/redis-cli127.0.0.1:6379> keys *] "Key1" 2) "Key2" 3) "HASH1" 4) "Key6" 5) "List1" 6) "Set1" 7) "Set2" 8) "Key3" 127.0.0.1:6379> get Key6 "Guozhen"

It's already there. Description we have successfully configured.























This article is from "Linux rookie" blog, please be sure to keep this source http://490617581.blog.51cto.com/11186315/1762061

Redis Master-Slave 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.