Redis Master-Slave configuration

Source: Internet
Author: User
Tags install redis

12. Redis Master-slave configuration

  • Install Redis and start with the steps described earlier

  • Master config file does not move

  • Add a line to the slave configuration file: slaveof 192.168.1.200 6379

  • Masterauth Szk #如果主上设置了密码, add this line.

  • Start master and slave, respectively


Tail/usr/local/redis/var/redis.log


3966] 15:02:58.330 * Master <-> SLAVE sync:receiving 192 bytes from MASTER
[3966] Feb 15:02:58.330 * MASTER <-> SLAVE sync:flushing old data
[3966] Feb 15:02:58.330 * MASTER <-> SLAVE sync:loading DB in memory
[3966] Feb 15:02:58.330 * MASTER <-> SLAVE sync:finished with success
[3966] 15:03:03.344-db 0:7 keys (0 volatile) in 8 slots HT.
[3966] Feb 15:03:03.344-1 clients connected (0 slaves), 466840 bytes in use
[3966] 15:03:08.396-db 0:7 keys (0 volatile) in 8 slots HT.
[3966] Feb 15:03:08.397-1 clients connected (0 slaves), 466848 bytes in use


Test:
/usr/local/redis/bin/redis-cli-a SZK Master

127.0.0.1:6379> Set Key1 Szk
Ok
127.0.0.1:6379> Get Key1
"Szk"


/usr/local/redis/bin/redis-cli from
127.0.0.1:6379> Get Key1
"Szk"


OK

13, Redis master-slave Other related configuration

  • Slave-read-only Yes #让从只读

  • Repl-ping-slave-period #设置slave向master发起ping的频率, launched every 10s

  • Repl-timeout #设置slave Ping Different master How many s after timeout

  • Repl-disable-tcp-nodelay no #是否开启tcp_nodeay, will use less bandwidth when turned on, but there will be a delay, so it is recommended to close

  • Repl-backlog-size 1MB #同步队列的长度, Backuplog is a buffer of master, master will write the data to the buffer, and slave will synchronize the data from the buffer after the master disconnects.

  • Repl-backlog-ttl 3600 #主从断开后, buffer expiration, default 1 hours

  • Slave-priority #多个slave是可以设置优先级的, the lower the value of the higher priority, applied to the cluster, support slave switch to mster, the highest priority will be switched

  • Min-slave-to-write 3 #和下面的一起使用, which means that master has found that more than 3 slave have a delay of more than 10s, then master will temporarily stop the write operation. If either of these values is 0, the function is turned off, and the default first value is 0

  • Min-slaves-max-log 10


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.