Redis 的 master/slave 数据复制方式可以是一主一从或者是一主多从的方式,Redis 在 master 是非阻塞模式,也就是说在 slave 执行数据同步的时候,master 是可以接受客户端的 请求的,并不影响同步数据的一致性,然而在 slave 端是阻塞模式的,slave 在同步 master 数据时,并不能够响应客户端的查询 Redis 的 master/slave 模式下,master 提供数据读写服务,而 slave 只提供读服务 Redis 的 master/slave 的配置方式是在 slave 主机的 Redis 目录下的 redis.conf 配置文件中 添加: slaveof master_ip master_port 例如: 我们配置我们的 slave 为:redis-slave.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 /home/falcon/redis-2.0.0/ slaveof 127.0.0.1 6379 appendonly no appendfsync everysec vm-enabled no vm-swap-file logs/redis-slave.swap vm-max-memory 0 vm-page-size 32 IT 运维专家网 http://www.LinuxTone.Org vm-pages 134217728 vm-max-threads 4 glueoutputbuf yes hash-max-zipmap-entries 64 hash-max-zipmap-value 512 activerehashing yes 启动 slave: [falcon@www.fwphp.cn ~/redis-2.0.0]$ ./redis-server redis-slave.conf 查看状态信息: [falcon@www.fwphp.cn ~/redis-2.0.0]$ ./redis-cli -p 6380 info redis_version:1.3.17 redis_git_sha1:00000000 redis_git_dirty:0 arch_bits:32 multiplexing_api:epoll process_id:10772 uptime_in_seconds:249 uptime_in_days:0 connected_clients:2 connected_slaves:0 blocked_clients:0 used_memory:1756868 used_memory_human:1.68M changes_since_last_save:0 bgsave_in_progress:0 last_save_time:1281654285 bgrewriteaof_in_progress:0 total_connections_received:13 total_commands_processed:9 expired_keys:0 hash_max_zipmap_entries:64 hash_max_zipmap_value:512 pubsub_channels:0 pubsub_patterns:0 vm_enabled:0 role:slave master_host:127.0.0.1 master_port:6379 master_link_status:up master_last_io_seconds_ago:248 db0:keys=23,expires=0 [falcon@www.fwphp.cn ~/redis-2.0.0]$ ./redis-cli -p 6379 info IT 运维专家网http://www.LinuxTone.Org redis_version:1.3.17 redis_git_sha1:00000000 redis_git_dirty:0 arch_bits:32 multiplexing_api:epoll process_id:7663 uptime_in_seconds:16787 uptime_in_days:0 connected_clients:1 connected_slaves:1 blocked_clients:0 used_memory:1757232 used_memory_human:1.68M changes_since_last_save:0 bgsave_in_progress:0 last_save_time:1281654286 bgrewriteaof_in_progress:0 total_connections_received:835 total_commands_processed:55953 expired_keys:1 hash_max_zipmap_entries:64 hash_max_zipmap_value:512 pubsub_channels:0 pubsub_patterns:0 vm_enabled:0 role:master db0:keys=23,expires=0 更多精彩内容请关注:http://bbs.superwu.cn 关注超人学院微信二维码: |
原文地址:http://blog.csdn.net/crxy2014/article/details/45970697