Home > Database > Mysql Tutorial > redis学习及实践2---Redis的master/slave复制

redis学习及实践2---Redis的master/slave复制

WBOY
Release: 2016-06-07 17:36:36
Original
1297 people have browsed it

一、介绍Redis的master/slave数据复制方式可以是一主一从或者是一主多从的方式,Redis在master是非阻塞模式,也就是说在slave执行数据同步的时候,master是可以

,也就是说在,,。
服务,而

daemonize yes pidfile redis-slave.pid port 6380 timeout 300 loglevel verbose logfile stdout databases 16 save 900 1 save 300 10 save 60 10000 rdbcompression yes dbfilename dump-slave.rdb dir /usr/local/redis/var/ slaveof 127.0.0.1 6379 appendonly no appendfsync everysec

   启动slave:

   ./redis-server redis-slave.conf

三、配置实例:

   笔者有两台机器,一台linux机器A(ip:172.16.205.186),一台windows机器B(ip:192.168.30.86)。A机器上配置一个6379端口的master,6380端口的slave1;B机器上配置分别为6380和6381的slave2和slave3。

   A的Linux机器的配置如下:

[root@DEV etc]# ls redis.conf redis-slave1.conf [root@DEV etc]# cat redis.conf daemonize yes pidfile /usr/local/redis/var/redis.pid port 6379 timeout 300 loglevel debug logfile /usr/local/redis/var/redis.log databases 16 save 900 1 save 300 10 save 60 10000 rdbcompression yes dbfilename dump.rdb dir /usr/local/redis/var/ appendonly no appendfsync always [root@DEV etc]# cat redis-slave1.conf daemonize yes pidfile redis-slave.pid port 6380 timeout 300 loglevel verbose logfile stdout databases 16 save 900 1 save 300 10 save 60 10000 rdbcompression yes dbfilename dump-slave.rdb dir /usr/local/redis/var/ slaveof 127.0.0.1 6379 appendonly no appendfsync everysec

   B的Windows机器的配置如下:

slave2:

daemonize yes pidfile redis-slave2.pid port 6380 timeout 300 loglevel verbose logfile stdout2 databases 16 save 900 1 save 300 10 save 60 10000 rdbcompression yes dbfilename dump-slave2.rdb dir ./ slaveof 172.16.205.186 6379 appendonly no

slave3:

daemonize yes pidfile redis-slave3.pid port 6381 timeout 300 loglevel verbose logfile stdout3 databases 16 save 900 1 save 300 10 save 60 10000 rdbcompression yes dbfilename dump-slave3.rdb dir ./ slaveof 172.16.205.186 6379 appendonly no

这样就实现了linux一个master一个slave,windows两个slave,且三个slave都连同一个master。当然也可以某个slave作为另一个slave的master,只需要在conf文件里把“slaveof ”修改为相应slave的信息就行了。

本文出自 “会飞的蜗牛” 博客,请务必保留此出处

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template